Skip to content

Commit 34bcb04

Browse files
authored
Deprecation leading into v0.8 (#4)
* deprecate exports * deprecate showprogress * fix docstrings, deprecate nelements(ps, dim)
1 parent e396948 commit 34bcb04

File tree

8 files changed

+914
-825
lines changed

8 files changed

+914
-825
lines changed

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ CurrentModule = ParallelUtilities
55
# ParallelUtilities.jl
66

77
```@autodocs
8-
Modules = [ParallelUtilities]
8+
Modules = [ParallelUtilities, ParallelUtilities.ClusterQueryUtils]
99
```

src/ParallelUtilities.jl

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
module ParallelUtilities
22
using ProgressMeter
3-
using DataStructures
43
using Reexport
54
using OffsetArrays
5+
66
@reexport using Distributed
77

8-
export ProductSplit,
9-
ntasks,
10-
whichproc,
11-
procrange_recast,
12-
localindex,
13-
whichproc_localindex,
14-
extremadims,
15-
extrema_commonlastdim,
16-
nodenames,
17-
gethostnames,
18-
nprocs_node,
19-
pmapbatch,
20-
pmapbatch_elementwise,
21-
pmapsum,
22-
pmapsum_elementwise,
23-
pmapreduce,
24-
pmapreduce_commutative,
25-
pmapreduce_commutative_elementwise
8+
export ProductSplit,
9+
ntasks,
10+
whichproc,
11+
procrange_recast,
12+
localindex,
13+
whichproc_localindex,
14+
extremadims,
15+
extrema_commonlastdim,
16+
pmapbatch,
17+
pmapbatch_elementwise,
18+
pmapsum,
19+
pmapsum_elementwise,
20+
pmapreduce,
21+
pmapreduce_commutative,
22+
pmapreduce_commutative_elementwise
2623

2724
include("errors.jl")
2825
include("productsplit.jl")
26+
27+
include("clusterquery.jl")
28+
@reexport using .ClusterQueryUtils
29+
2930
include("utils.jl")
3031
include("trees.jl")
3132
include("mapreduce.jl")

src/clusterquery.jl

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
module ClusterQueryUtils
2+
3+
using Distributed
4+
using DataStructures
5+
6+
@deprecate gethostnames hostnames
7+
export hostnames
8+
export nodenames
9+
export procs_node
10+
export nprocs_node
11+
12+
"""
13+
gethostnames(procs = workers())
14+
15+
Return the hostname of each worker in `procs`. This is obtained by evaluating
16+
`Libc.gethostname()` on each worker asynchronously.
17+
18+
!!! warn
19+
`gethostnames` is deprecated in favor of `hostnames`
20+
"""
21+
gethostnames
22+
23+
"""
24+
hostnames(procs = workers())
25+
26+
Return the hostname of each worker in `procs`. This is obtained by evaluating
27+
`Libc.gethostname()` on each worker asynchronously.
28+
"""
29+
function hostnames(procs = workers())
30+
Base.depwarn("hostnames will not be exported in a future release. "*
31+
"It may be imported from the module ClusterQueryUtils", :hostnames)
32+
33+
hostnames = Vector{String}(undef, length(procs))
34+
35+
@sync for (ind,p) in enumerate(procs)
36+
@async hostnames[ind] = @fetchfrom p Libc.gethostname()
37+
end
38+
return hostnames
39+
end
40+
41+
42+
"""
43+
nodenames(procs = workers())
44+
45+
Return the unique hostnames that the workers in `procs` lie on.
46+
On an HPC system these are usually the hostnames of the nodes involved.
47+
"""
48+
nodenames(procs = workers()) = nodenames(hostnames(procs))
49+
50+
function nodenames(hostnames::AbstractVector{String})
51+
Base.depwarn("nodenames will not be exported in a future release. "*
52+
"It may be imported from the module ClusterQueryUtils", :nodenames)
53+
54+
unique(hostnames)
55+
end
56+
57+
"""
58+
procs_node(procs = workers())
59+
60+
Return the worker ids on each host of the cluster.
61+
On an HPC system this would return the workers on each node.
62+
"""
63+
function procs_node(procs = workers())
64+
hosts = hostnames(procs)
65+
nodes = nodenames(hosts)
66+
procs_node(procs, hosts, nodes)
67+
end
68+
69+
function procs_node(procs, hosts, nodes)
70+
Base.depwarn("procs_node will not be exported in a future release. "*
71+
"It may be imported from the module ClusterQueryUtils", :procs_node)
72+
73+
OrderedDict(node => procs[findall(isequal(node),hosts)] for node in nodes)
74+
end
75+
76+
"""
77+
nprocs_node(procs = workers())
78+
79+
Return the number of workers on each host.
80+
On an HPC system this would return the number of workers on each node.
81+
"""
82+
function nprocs_node(procs = workers())
83+
nprocs_node(hostnames(procs))
84+
end
85+
86+
function nprocs_node(hostnames::AbstractVector{String})
87+
nodes = nodenames(hostnames)
88+
nprocs_node(hostnames, nodes)
89+
end
90+
91+
function nprocs_node(hostnames::AbstractVector, nodes::AbstractVector)
92+
Base.depwarn("nprocs_node will not be exported in a future release. "*
93+
"It may be imported from the module ClusterQueryUtils", :nprocs_node)
94+
95+
OrderedDict(node => count(isequal(node), hostnames) for node in nodes)
96+
end
97+
98+
function nprocs_node(d::AbstractDict)
99+
Base.depwarn("nprocs_node will not be exported in a future release. "*
100+
"It may be imported from the module ClusterQueryUtils", :nprocs_node)
101+
102+
OrderedDict(node => length(procs) for (node, procs) in d)
103+
end
104+
105+
end

0 commit comments

Comments
 (0)