Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise support and worker state callbacks #17

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
21 changes: 4 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
version:
- 'nightly'
- '1'
- '1.9'
- '1.10'
os:
- ubuntu-latest
- macOS-latest
Expand All @@ -36,26 +36,14 @@ jobs:
exclude:
- os: macOS-latest
arch: x86
- os: windows-latest # Killing workers doesn't work on windows in 1.9
version: '1.9'

steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-${{ matrix.os }}
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-runtest@v1
env:
JULIA_NUM_THREADS: 4
Expand All @@ -70,8 +58,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
with:
version: '1'
- uses: julia-actions/cache@v2
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.instantiate()'
- name: Build and deploy
Expand Down
11 changes: 9 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"

[weakdeps]
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"

[extensions]
ReviseExt = "Revise"

[compat]
Distributed = "1"
Random = "1"
Revise = "3.7.0"
Serialization = "1"
Sockets = "1"
julia = "1.9"
julia = "1.10"

[extras]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand All @@ -21,4 +28,4 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["LinearAlgebra", "Test", "LibSSH", "Distributed"]
test = ["LinearAlgebra", "Test", "LibSSH", "Distributed", "Revise"]
4 changes: 4 additions & 0 deletions docs/src/_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ This documents notable changes in DistributedNext.jl. The format is based on
incompatibilities from both libraries being used simultaneously ([#10]).
- [`other_workers()`](@ref) and [`other_procs()`](@ref) were implemented and
exported ([#18]).
- Implemented callback support for workers being added/removed etc ([#17]).
- Added a package extension to support Revise.jl ([#17]).
- Added support for setting worker statuses with [`setstatus`](@ref) and
[`getstatus`](@ref) ([#17]).

## [v1.0.0] - 2024-12-02

Expand Down
15 changes: 15 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ DistributedNext.rmprocs
DistributedNext.interrupt
DistributedNext.myid
DistributedNext.pmap
DistributedNext.getstatus
DistributedNext.setstatus
DistributedNext.RemoteException
DistributedNext.ProcessExitedException
DistributedNext.Future
Expand Down Expand Up @@ -52,6 +54,19 @@ DistributedNext.cluster_cookie()
DistributedNext.cluster_cookie(::Any)
```

## Callbacks

```@docs
DistributedNext.add_worker_starting_callback
DistributedNext.remove_worker_starting_callback
DistributedNext.add_worker_started_callback
DistributedNext.remove_worker_started_callback
DistributedNext.add_worker_exiting_callback
DistributedNext.remove_worker_exiting_callback
DistributedNext.add_worker_exited_callback
DistributedNext.remove_worker_exited_callback
```

## Cluster Manager Interface

This interface provides a mechanism to launch and manage Julia workers on different cluster environments.
Expand Down
30 changes: 30 additions & 0 deletions ext/ReviseExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module ReviseExt

import DistributedNext
import DistributedNext: myid, workers, remotecall

import Revise


struct DistributedNextWorker <: Revise.AbstractWorker
id::Int
end

function get_workers()
map(DistributedNextWorker, workers())
end

function Revise.remotecall_impl(f, worker::DistributedNextWorker, args...; kwargs...)
remotecall(f, worker.id, args...; kwargs...)
end

Revise.is_master_worker(::typeof(get_workers)) = myid() == 1
Revise.is_master_worker(worker::DistributedNextWorker) = worker.id == 1

function __init__()
Revise.register_workers_function(get_workers)
DistributedNext.add_worker_started_callback(pid -> Revise.init_worker(DistributedNextWorker(pid));
key="DistributedNext-integration")
end

end
Loading
Loading