Skip to content

Commit 00f050e

Browse files
authored
Merge 065fb19 into 560f993
2 parents 560f993 + 065fb19 commit 00f050e

27 files changed

+1576
-1390
lines changed

.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style = "blue"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags: '*'
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
permissions:
13+
contents: write
14+
pull-requests: read
15+
statuses: write
16+
actions: write
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: julia-actions/setup-julia@v2
21+
with:
22+
version: '1'
23+
arch: x64
24+
include-all-prereleases: false
25+
- name: Install dependencies
26+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.update(); Pkg.instantiate()'
27+
- name: Build and deploy
28+
env:
29+
GKSwstype: nul # turn off GR's interactive plotting for notebooks
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
31+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
32+
run: julia --project=docs/ docs/make.jl

.github/workflows/Testing.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ jobs:
1111
strategy:
1212
matrix:
1313
version:
14-
- '1.7'
1514
- '1.10'
1615
- '1'
1716
- 'nightly'
@@ -26,12 +25,12 @@ jobs:
2625
- os: macOS-latest
2726
arch: x86
2827
steps:
29-
- uses: actions/checkout@v2
30-
- uses: julia-actions/setup-julia@v1
28+
- uses: actions/checkout@v4
29+
- uses: julia-actions/setup-julia@v2
3130
with:
3231
version: ${{ matrix.version }}
3332
arch: ${{ matrix.arch }}
34-
- uses: actions/cache@v1
33+
- uses: actions/cache@v4
3534
env:
3635
cache-name: cache-artifacts
3736
with:

.gitignore

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,4 @@
1-
# Prerequisites
2-
*.d
3-
4-
# Object files
5-
*.o
6-
*.ko
7-
*.obj
8-
*.elf
9-
10-
# Linker output
11-
*.ilk
12-
*.map
13-
*.exp
14-
15-
# Precompiled Headers
16-
*.gch
17-
*.pch
18-
19-
# Libraries
20-
*.lib
21-
*.a
22-
*.la
23-
*.lo
24-
25-
# Shared objects (inc. Windows DLLs)
26-
*.dll
27-
*.so
28-
*.so.*
29-
*.dylib
30-
31-
# Executables
32-
*.exe
33-
*.out
34-
*.app
35-
*.i*86
36-
*.x86_64
37-
*.hex
38-
39-
# Debug files
40-
*.dSYM/
41-
*.su
42-
*.idb
43-
*.pdb
44-
45-
# Kernel Module Compile Results
46-
*.mod*
47-
*.cmd
48-
.tmp_versions/
49-
modules.order
50-
Module.symvers
51-
Mkfile.old
52-
dkms.conf
53-
541
# Projects files
55-
Manifest.toml
56-
deps/build.log
57-
deps/deps.jl
58-
deps/usr/
59-
deps/tmp-build.jl
2+
Manifest*
603
*.cov
4+
docs/build

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- From v0.6.0, Libtask is implemented by recording all the computing
2+
to a tape and copying that tape. Before that version, it is based on
3+
a tricky hack on the Julia internals. You can check the commit
4+
history of this repo to see the details.
5+
6+
- From version 0.9.0, the old `TArray` and `TRef` types are completely removed, where
7+
previously they were only deprecated. Additionally, the internals have been completely
8+
overhauled, and the public interface more precisely defined. See the docs for more info.

Project.toml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,24 @@ repo = "https://github.com/TuringLang/Libtask.jl.git"
66
version = "0.8.8"
77

88
[deps]
9-
FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e"
10-
LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"
11-
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
12-
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
9+
MistyClosures = "dbe65cb8-6be2-42dd-bbc5-4196aaced4f4"
10+
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
11+
ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63"
12+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1313

1414
[compat]
15-
FunctionWrappers = "1.1"
16-
LRUCache = "1.3"
17-
julia = "1.7"
15+
Aqua = "0.8.11"
16+
JuliaFormatter = "1.0.62"
17+
MistyClosures = "2.0.0"
18+
Mooncake = "0.4.99"
19+
ScopedValues = "1.3.0"
20+
Test = "1"
21+
julia = "1.10.8"
1822

1923
[extras]
20-
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
24+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
25+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
2126
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2227

2328
[targets]
24-
test = ["Test", "BenchmarkTools"]
29+
test = ["Aqua", "JuliaFormatter", "Test"]

README.md

Lines changed: 3 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,8 @@
22

33
[![Libtask Testing](https://github.com/TuringLang/Libtask.jl/workflows/Libtask%20Testing/badge.svg)](https://github.com/TuringLang/Libtask.jl/actions?branch=main)
44

5-
Tape based task copying in Turing
65

7-
## Getting Started
6+
Resumable and copyable functions in Julia, with optional dynamic scope.
7+
See the docs for example usage.
88

9-
Stack allocated objects are always deep copied:
10-
11-
```julia
12-
using Libtask
13-
14-
function f()
15-
t = 0
16-
for _ in 1:10
17-
produce(t)
18-
t = 1 + t
19-
end
20-
end
21-
22-
ttask = TapedTask(f)
23-
24-
@show consume(ttask) # 0
25-
@show consume(ttask) # 1
26-
27-
a = copy(ttask)
28-
@show consume(a) # 2
29-
@show consume(a) # 3
30-
31-
@show consume(ttask) # 2
32-
@show consume(ttask) # 3
33-
```
34-
35-
Heap-allocated Array and Ref objects are deep copied by default:
36-
37-
```julia
38-
using Libtask
39-
40-
function f()
41-
t = [0 1 2]
42-
for _ in 1:10
43-
produce(t[1])
44-
t[1] = 1 + t[1]
45-
end
46-
end
47-
48-
ttask = TapedTask(f)
49-
50-
@show consume(ttask) # 0
51-
@show consume(ttask) # 1
52-
53-
a = copy(ttask)
54-
@show consume(a) # 2
55-
@show consume(a) # 3
56-
57-
@show consume(ttask) # 2
58-
@show consume(ttask) # 3
59-
```
60-
61-
Other heap-allocated objects (e.g., `Dict`) are shallow copied, by default:
62-
63-
```julia
64-
using Libtask
65-
66-
function f()
67-
t = Dict(1=>10, 2=>20)
68-
while true
69-
produce(t[1])
70-
t[1] = 1 + t[1]
71-
end
72-
end
73-
74-
ttask = TapedTask(f)
75-
76-
@show consume(ttask) # 10
77-
@show consume(ttask) # 11
78-
79-
a = copy(ttask)
80-
@show consume(a) # 12
81-
@show consume(a) # 13
82-
83-
@show consume(ttask) # 14
84-
@show consume(ttask) # 15
85-
```
86-
87-
Notes:
88-
89-
- The [Turing](https://github.com/TuringLang/Turing.jl) probabilistic
90-
programming language uses this task copying feature in an efficient
91-
implementation of the [particle
92-
filtering](https://en.wikipedia.org/wiki/Particle_filter) sampling
93-
algorithm for arbitrary order [Markov
94-
processes](https://en.wikipedia.org/wiki/Markov_model#Hidden_Markov_model).
95-
96-
- From v0.6.0, Libtask is implemented by recording all the computing
97-
to a tape and copying that tape. Before that version, it is based on
98-
a tricky hack on the Julia internals. You can check the commit
99-
history of this repo to see the details.
9+
Used in the [Turing](https://github.com/TuringLang/Turing.jl) probabilistic programming language to implement various particle-based inference methods, for example those in [AdvancedPS.jl](https://github.com/TuringLang/AdvancedPS.jl/).

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
Libtask = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f"

docs/make.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Documenter, Libtask
2+
3+
DocMeta.setdocmeta!(Libtask, :DocTestSetup, :(using Libtask); recursive=true)
4+
5+
makedocs(;
6+
sitename="Libtask", doctest=true, pages=["index.md", "internals.md"], modules=[Libtask]
7+
)
8+
9+
deploydocs(; repo="github.com/TuringLang/Libtask.jl.git", push_preview=true)

docs/src/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Libtask
2+
3+
Libtask is best explained by the docstring for [`TapedTask`](@ref):
4+
```@docs; canonical=true
5+
Libtask.TapedTask
6+
```
7+
8+
The functions discussed the above docstring (in addition to [`TapedTask`](@ref) itself) form the
9+
public interface of Libtask.jl.
10+
They divide neatly into two kinds of functions: those which are used to manipulate
11+
[`TapedTask`](@ref)s, and those which are intended to be used _inside_ a
12+
[`TapedTask`](@ref).
13+
First, manipulation of [`TapedTask`](@ref)s:
14+
```@docs; canonical=true
15+
Libtask.consume
16+
Base.copy(::Libtask.TapedTask)
17+
Libtask.set_dynamic_scope!
18+
```
19+
20+
Functions for use inside a [`TapedTask`](@ref)s are:
21+
```@docs; canonical=true
22+
Libtask.produce
23+
Libtask.get_dynamic_scope
24+
```

0 commit comments

Comments
 (0)