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

remove global multiprocessing.set_start_method #8343

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

braingram
Copy link
Collaborator

@braingram braingram commented Mar 11, 2024

Fixes: #8306

Without setting a multiprocessing start method (using the default) on linux with python 3.12 results in a DeprecationWarning.

Warnings for python 3.12:

  jwst/jump/tests/test_detect_jumps.py: 9 warnings
  jwst/jump/tests/test_jump_step.py: 24 warnings
    /opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=2483) is multi-threaded, use of fork() may lead to deadlocks in the child.
      self.pid = os.fork()
  
  jwst/ramp_fitting/tests/test_ramp_fit.py::test_multiprocessing
  jwst/ramp_fitting/tests/test_ramp_fit.py::test_multiprocessing2
  jwst/ramp_fitting/tests/test_ramp_fit_step.py::test_ramp_fit_step[2]
  jwst/ramp_fitting/tests/test_ramp_fit_step.py::test_ramp_fit_step[2]
  jwst/ramp_fitting/tests/test_ramp_fit_step.py::test_ramp_fit_step[half]
  jwst/ramp_fitting/tests/test_ramp_fit_step.py::test_ramp_fit_step[half]
  jwst/ramp_fitting/tests/test_ramp_fit_step.py::test_ramp_fit_step[all]
  jwst/ramp_fitting/tests/test_ramp_fit_step.py::test_ramp_fit_step[all]
    /opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=2486) is multi-threaded, use of fork() may lead to deadlocks in the child.
      self.pid = os.fork()

This is due to fork being unsafe for applications that use threads. This warning was previously silenced using a global set_start_method which can cause issues for other packages (see #8306).

stcal (which is the primary user of multiprocessing in the pipeline) was updated:
spacetelescope/stcal#249

This PR temporarily uses stcal main (that can be removed prior to merge or after a stcal release is made) to pick up the changes in the above PR and updates the remaining multiprocessing usage in wfss_contam to only set forkserver in a context (to not impact other packages). EDIT: stcal 1.7.0 (now the required version) contains the required changes

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 75.77%. Comparing base (2fb073e) to head (18344af).
Report is 27 commits behind head on master.

Files Patch % Lines
jwst/wfss_contam/observations.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8343      +/-   ##
==========================================
+ Coverage   75.31%   75.77%   +0.46%     
==========================================
  Files         474      476       +2     
  Lines       38965    39448     +483     
==========================================
+ Hits        29345    29891     +546     
+ Misses       9620     9557      -63     
Flag Coverage Δ *Carryforward flag
nightly 77.66% <ø> (+0.32%) ⬆️ Carriedforward from 2fb073e

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@braingram braingram changed the title TEST: remove global multiprocessing.set_start_method remove global multiprocessing.set_start_method Mar 12, 2024
@braingram braingram force-pushed the no_forkserver branch 2 times, most recently from e6944ee to a443917 Compare March 13, 2024 20:40
@braingram braingram marked this pull request as ready for review March 13, 2024 21:23
@braingram braingram requested a review from a team as a code owner March 13, 2024 21:23
@braingram
Copy link
Collaborator Author

braingram commented Mar 13, 2024

Regtests run at: https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1310/
26 failures which appear to match the 26 on main:
https://plwishmaster.stsci.edu:8081/blue/organizations/jenkins/RT%2FJWST/detail/JWST/2808/tests
and match up with the description of the crds update today.

@braingram
Copy link
Collaborator Author

Note: prior to merge the dev dependency on stcal should be removed.

@braingram
Copy link
Collaborator Author

The 3.9 and oldestdeps failures look like they'd be addressed in:
#8365

@braingram
Copy link
Collaborator Author

@emolter this PR has some minor overlap with #8417 I gave #8417 a skim and it looks like it would make the wfss changes in this PR unecessary. However this PR has additional related changes in jump and ramp_fitting. What would you recommend for sequencing these? As the changes in this PR are minor compared to #8417 can we get this one merged first? I'll rebase and let me know if you'd like to see a newer regtest run.

Copy link
Collaborator

@emolter emolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes look good to me. Are there any regtests that test the multiprocessing modes for these steps? Not sure what that would even look like...

RE my PR for the wfss_contam step, I think it's completely fine to merge this right away. It will be a while before that PR gets merged as there are lots of outstanding issues.

@braingram
Copy link
Collaborator Author

braingram commented Apr 11, 2024

Thanks for taking a look!

The code changes look good to me. Are there any regtests that test the multiprocessing modes for these steps? Not sure what that would even look like...

Not that I'm aware of. The main motivation for adding the set_start_method in #8093 is the DeprecationWarnings that will be seen if using fork (the default on linux) and python 3.12. I'm happy to go into more details but the tldr is that we need to set a non-fork method to avoid these warnings.

RE my PR for the wfss_contam step, I think it's completely fine to merge this right away. It will be a while before that PR gets merged as there are lots of outstanding issues.

Good to know. Let me if there's anything I can do to help.

Copy link
Collaborator

@hbushouse hbushouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Is everyone else happy?

@hbushouse hbushouse merged commit fb8605c into spacetelescope:master Apr 11, 2024
27 of 28 checks passed
@braingram braingram deleted the no_forkserver branch April 11, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiprocessing Start Method Forced to Forkserver
3 participants