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

Use multiprocessing get_context and python 3.12 #249

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
- linux: py39-oldestdeps-cov-xdist
- linux: py39-xdist
- linux: py310-xdist
- linux: py311-cov-xdist
- linux: py311-xdist
- linux: py312-cov-xdist
coverage: codecov
- macos: py311-xdist
test_downstream:
Expand Down
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
Changes to API
--------------

jump
~~~~

- Switch multiprocessing method to ``fork_server``. [#249]

ramp_fitting
~~~~~~~~~~~~

- Switch multiprocessing method to ``fork_server``. [#249]

Bug Fixes
---------

Expand Down
7 changes: 4 additions & 3 deletions src/stcal/jump/jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,10 @@ def detect_jumps(
),
)
log.info("Creating %d processes for jump detection ", n_slices)
pool = multiprocessing.Pool(processes=n_slices)
######### JUST FOR DEBUGGING #########################
# pool = multiprocessing.Pool(processes=1)
ctx = multiprocessing.get_context("forkserver")
pool = ctx.Pool(processes=n_slices)
######### JUST FOR DEBUGGING #########################
# pool = ctx.Pool(processes=1)
# Starts each slice in its own process. Starmap allows more than one
# parameter to be passed.
real_result = pool.starmap(twopt.find_crs, slices)
Expand Down
5 changes: 3 additions & 2 deletions src/stcal/ramp_fitting/ols_fit.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#! /usr/bin/env python

import logging
import multiprocessing
import time
import warnings
from multiprocessing import cpu_count
from multiprocessing.pool import Pool

import numpy as np

Expand Down Expand Up @@ -160,7 +160,8 @@ def ols_ramp_fit_multiprocessing(
ramp_data, buffsize, save_opt, readnoise_2d, gain_2d, weighting, number_slices
)

pool = Pool(processes=number_slices)
ctx = multiprocessing.get_context("forkserver")
pool = ctx.Pool(processes=number_slices)
pool_results = pool.starmap(ols_ramp_fit_single, slices)
pool.close()
pool.join()
Expand Down
Loading