Skip to content

Update Cellpose for reproducibility#1593

Merged
bgruening merged 5 commits intobgruening:masterfrom
kostrykin:dev/cellpose
Mar 15, 2025
Merged

Update Cellpose for reproducibility#1593
bgruening merged 5 commits intobgruening:masterfrom
kostrykin:dev/cellpose

Conversation

@kostrykin
Copy link
Copy Markdown
Collaborator

This PR (hopefully) solves the reproducibility issues with Cellpose.

Main changes:

  • MKL_NUM_THREADS is set to 1 (see this for details, much thanks to @bgruening for helping to figure this out)
  • PyTorch reproducibility guidelines are applied
  • Linting issues are fixed (including a wrong test parameter)

Can't test the tool locally due to weird planemo error (probably unrelated to the tool itself).

Job in error state.. tool_id: cellpose, exit_code: 2, stderr: /bin/sh: 0: cannot open /tmp/tmpuytylmul/job_working_directory/000/2/tool_script.sh: No such file

@kostrykin
Copy link
Copy Markdown
Collaborator Author

kostrykin commented Mar 14, 2025

Tests have passed, looking good.
https://github.com/bgruening/galaxytools/actions/runs/13866572460?pr=1593#summary-38807044580

Just some file sizes are too large (I guess they have been before too).


# Make sure, that MKL_NUM_THREADS is set to 1, to ensure reproducibility:
# https://forum.image.sc/t/reproducibility-how-we-spent-years-building-containers-and-then-mkl-decided-to-screw-our-results/109599
assert str(os.environ['MKL_NUM_THREADS']) == '1'
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

instead of asserting, could we also set this variable here again?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The question is, at what point MKL is loaded. My guess is that this happens when NumPy is loaded. I have made some adjustments based on your suggestion accordingly in 66fb725.

@bgruening bgruening merged commit 5846f23 into bgruening:master Mar 15, 2025
9 of 11 checks passed
@bgruening
Copy link
Copy Markdown
Owner

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants