Skip to content

Commit ff55fe6

Browse files
authored
Merge pull request #17 from JuliaParallel/revise
Revise support and worker state callbacks
2 parents 8d30b83 + 07bda63 commit ff55fe6

13 files changed

Lines changed: 665 additions & 63 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ updates:
55
directory: "/" # Location of package manifests
66
schedule:
77
interval: "monthly"
8+
- package-ecosystem: "julia"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/ci.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,7 @@ jobs:
6767
# GitHub will automatically expand to the correct value (`x86_64` or `aarch64`)
6868
# based on the architecture of the underlying GitHub Runner (virtual machine).
6969
arch: ${{ github.ref == '32' && 'x86' || runner.arch }}
70-
- uses: actions/cache@v5
71-
env:
72-
cache-name: cache-artifacts
73-
with:
74-
path: ~/.julia/artifacts
75-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
76-
restore-keys: |
77-
${{ runner.os }}-test-${{ env.cache-name }}-
78-
${{ runner.os }}-test-${{ matrix.os }}
79-
${{ runner.os }}-
80-
- uses: julia-actions/julia-buildpkg@v1
70+
- uses: julia-actions/cache@v3
8171
- name: Decide what the value of JULIA_NUM_THREADS should be
8272
id: decide-numthreads-str
8373
run: |
@@ -115,6 +105,7 @@ jobs:
115105
- uses: julia-actions/setup-julia@latest
116106
with:
117107
version: '1'
108+
- uses: julia-actions/cache@v3
118109
- name: Install dependencies
119110
run: julia --project=docs/ -e 'using Pkg; Pkg.instantiate()'
120111
- name: Build and deploy
@@ -130,8 +121,9 @@ jobs:
130121
persist-credentials: false
131122
- uses: julia-actions/setup-julia@latest
132123
with:
133-
version: '1.12'
124+
version: '1'
134125
# version: 'nightly'
126+
- uses: julia-actions/cache@v3
135127
- run: julia --color=yes --project=ci/jet -e 'import Pkg; Pkg.instantiate()'
136128
- name: Run the JET tests
137129
run: julia --color=yes --project=ci/jet ci/jet/check.jl

.github/workflows/tagbot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: TagBot
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
7+
inputs:
8+
lookback:
9+
description: "[DEPRECATED] No longer has any effect"
10+
default: "3"
11+
jobs:
12+
TagBot:
13+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: JuliaRegistries/TagBot@v1
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}

Project.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,28 @@ version = "1.1.1"
44

55
[deps]
66
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
7+
ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63"
78
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
89
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
910

11+
[weakdeps]
12+
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
13+
14+
[extensions]
15+
ReviseExt = "Revise"
16+
1017
[compat]
1118
Aqua = "0.8"
1219
Distributed = "1"
1320
LibSSH = "0.7"
1421
LinearAlgebra = "1"
1522
Random = "1"
23+
Revise = "3.7.0"
24+
ScopedValues = "1.6.0"
1625
Serialization = "1"
1726
Sockets = "1"
1827
Test = "1"
19-
julia = "1.9"
28+
julia = "1.10"
2029

2130
[extras]
2231
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
@@ -26,4 +35,4 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2635
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2736

2837
[targets]
29-
test = ["Aqua", "Distributed", "LibSSH", "LinearAlgebra", "Test"]
38+
test = ["Aqua", "Distributed", "LibSSH", "LinearAlgebra", "Revise", "Test"]

docs/src/_changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ This documents notable changes in DistributedNext.jl. The format is based on
99

1010
## Unreleased
1111

12+
### Added
13+
- Implemented callback support for workers being added/removed etc ([#17]).
14+
- Added a package extension to support Revise.jl ([#17]).
15+
- Added support for setting worker statuses with [`setstatus`](@ref) and
16+
[`getstatus`](@ref) ([#17]).
17+
1218
### Fixed
1319
- Modified the default implementations of methods like `take!` and `wait` on
1420
[`AbstractWorkerPool`](@ref) to be threadsafe and behave more consistently

docs/src/index.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ DistributedNext.rmprocs
1414
DistributedNext.interrupt
1515
DistributedNext.myid
1616
DistributedNext.pmap
17+
DistributedNext.getstatus
18+
DistributedNext.@getstatus
19+
DistributedNext.setstatus!
20+
DistributedNext.@setstatus!
1721
DistributedNext.RemoteException
1822
DistributedNext.ProcessExitedException
1923
DistributedNext.Future
@@ -53,6 +57,19 @@ DistributedNext.cluster_cookie()
5357
DistributedNext.cluster_cookie(::Any)
5458
```
5559

60+
## Callbacks
61+
62+
```@docs
63+
DistributedNext.add_worker_starting_callback
64+
DistributedNext.remove_worker_starting_callback
65+
DistributedNext.add_worker_started_callback
66+
DistributedNext.remove_worker_started_callback
67+
DistributedNext.add_worker_exiting_callback
68+
DistributedNext.remove_worker_exiting_callback
69+
DistributedNext.add_worker_exited_callback
70+
DistributedNext.remove_worker_exited_callback
71+
```
72+
5673
## Cluster Manager Interface
5774

5875
This interface provides a mechanism to launch and manage Julia workers on different cluster environments.

ext/ReviseExt.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module ReviseExt
2+
3+
import DistributedNext
4+
import DistributedNext: myid, workers, remotecall
5+
6+
import Revise
7+
8+
9+
struct DistributedNextWorker <: Revise.AbstractWorker
10+
id::Int
11+
end
12+
13+
function get_workers()
14+
map(DistributedNextWorker, workers())
15+
end
16+
17+
function Revise.remotecall_impl(f, worker::DistributedNextWorker, args...; kwargs...)
18+
remotecall(f, worker.id, args...; kwargs...)
19+
end
20+
21+
Revise.is_master_worker(::typeof(get_workers)) = myid() == 1
22+
Revise.is_master_worker(worker::DistributedNextWorker) = worker.id == 1
23+
24+
function __init__()
25+
Revise.register_workers_function(get_workers)
26+
DistributedNext.add_worker_started_callback(pid -> Revise.init_worker(DistributedNextWorker(pid));
27+
key="DistributedNext-integration")
28+
end
29+
30+
end

src/DistributedNext.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ using Serialization, Sockets
2323
import Serialization: serialize, deserialize
2424
import Sockets: connect, wait_connected
2525

26+
@static if VERSION < v"1.11"
27+
using ScopedValues: ScopedValue, @with
28+
else
29+
using Base.ScopedValues: ScopedValue, @with
30+
end
31+
2632
# NOTE: clusterserialize.jl imports additional symbols from Serialization for use
2733

2834
export

0 commit comments

Comments
 (0)