Skip to content

Commit

Permalink
Rename num_jobs to max_processes
Browse files Browse the repository at this point in the history
  • Loading branch information
spenczar committed Jul 15, 2023
1 parent e69c95f commit 2b38635
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ propagated_orbits = propagator.propagate_orbits(
orbits,
times,
chunk_size=100,
num_jobs=1,
max_processes=1,
)
```

Expand Down
24 changes: 12 additions & 12 deletions adam_core/propagator/propagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def propagate_orbits(
orbits: Orbits,
times: Time,
chunk_size: int = 100,
num_jobs: Optional[int] = 1,
max_processes: Optional[int] = 1,
) -> Orbits:
"""
Propagate each orbit in orbits to each time in times.
Expand All @@ -62,18 +62,18 @@ def propagate_orbits(
Times to which to propagate orbits.
chunk_size : int, optional
Number of orbits to send to each job.
num_jobs : int or None, optional
Number of jobs to launch. If None then the number of
jobs will be equal to the number of cores on the machine. If 1
max_processes : int or None, optional
Maximum number of processes to launch. If None then the number of
processes will be equal to the number of cores on the machine. If 1
then no multiprocessing will be used.
Returns
-------
propagated : `~adam_core.orbits.orbits.Orbits`
Propagated orbits.
"""
if num_jobs is None or num_jobs > 1:
with concurrent.futures.ProcessPoolExecutor(max_workers=num_jobs) as executor:
if max_processes is None or max_processes > 1:
with concurrent.futures.ProcessPoolExecutor(max_workers=max_processes) as executor:
futures = []
for orbit_chunk in _iterate_chunks(orbits, chunk_size):
futures.append(executor.submit(propagation_worker, orbit_chunk, times, self))
Expand Down Expand Up @@ -105,7 +105,7 @@ def generate_ephemeris(
orbits: Orbits,
observers,
chunk_size: int = 100,
num_jobs: Optional[int] = 1,
max_processes: Optional[int] = 1,
):
"""
Generate ephemerides for each orbit in orbits as observed by each observer
Expand All @@ -120,9 +120,9 @@ def generate_ephemeris(
orbit.
chunk_size : int, optional
Number of orbits to send to each job.
num_jobs : int or None, optional
Number of jobs to launch. If None then the number of
jobs will be equal to the number of cores on the machine. If 1
max_processes : int or None, optional
Number of processes to launch. If None then the number of
processes will be equal to the number of cores on the machine. If 1
then no multiprocessing will be used.
Returns
Expand All @@ -134,8 +134,8 @@ def generate_ephemeris(
TODO: Add ephemeris class
TODO: Add an observers class
"""
if num_jobs is None or num_jobs > 1:
with concurrent.futures.ProcessPoolExecutor(max_workers=num_jobs) as executor:
if max_processes is None or max_processes > 1:
with concurrent.futures.ProcessPoolExecutor(max_workers=max_processes) as executor:
futures = []
for orbit_chunk in _iterate_chunks(orbits, chunk_size):
futures.append(executor.submit(ephemeris_worker, orbit_chunk, observers, self))
Expand Down
4 changes: 2 additions & 2 deletions adam_core/propagator/tests/test_propagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_propagator_single_worker():
times = Time(["2020-01-01T00:00:00", "2020-01-01T00:00:01"])

prop = MockPropagator()
have = prop.propagate_orbits(orbits, times, num_jobs=1)
have = prop.propagate_orbits(orbits, times, max_processes=1)

assert len(have) == len(orbits) * len(times)

Expand All @@ -40,6 +40,6 @@ def test_propagator_multiple_workers():
times = Time(["2020-01-01T00:00:00", "2020-01-01T00:00:01"])

prop = MockPropagator()
have = prop.propagate_orbits(orbits, times, num_jobs=4)
have = prop.propagate_orbits(orbits, times, max_processes=4)

assert len(have) == len(orbits) * len(times)

0 comments on commit 2b38635

Please sign in to comment.