Ci release allencell migration#506
Draft
fatwir wants to merge 17 commits into
Draft
Conversation
- Update pyproject.toml with newer package versions - Add Python 3.10-3.12 support, drop Python 3.9 - Update torch>=2.5.0, numpy>=1.26, anndata>=0.11, zarr>=2.18, etc. - Add Windows platform support alongside Linux - Regenerate requirements/*.txt lock files - Add CUDA installation instructions to README - Add Windows installation guide (conda workaround for edt) - Add corporate proxy/PyPI mirror troubleshooting
Replace deprecated pkg_resources with importlib.metadata and allowlist monai.utils.enums.TraceKeys for torch.load weights_only=True default. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…l/cyto-dl into python312-cuda13-update merging hpc branch with local
CI / Actions - test.yml: switch from conda+pip to uv; matrix py3.10-3.12 (drop 3.9, add 3.12); bump checkout v3->v4; codecov-action v3->v5 with token. - build-docs.yml: fix broken requirements path (used non-existent requirements/linux/docs-requirements.txt); switch to uv sync --extra docs; replace JamesIves gh-pages action (per-repo ACCESS_TOKEN) with peaceiris/actions-gh-pages@v4 using GITHUB_TOKEN; modernize action versions; add contents:write permission. - publish.yml: replace pdm with uv build; bump checkout to v4; add inline note that the PyPI Trusted Publisher must be re-registered for AllenCell/cyto-dl post-migration. - make-requirements.yml: bump setup-uv to v5 and uv 0.6.14 -> 0.10.2; bump checkout/git-auto-commit-action; add contents:write permission. Dependencies - Cap mlflow at <3 to avoid mlflow.genai.scorers.builtin_scorers triggering an infinite loop in pydantic field collection on import, which cascades through monai.handlers and blocks any cyto-dl model import. Resolves transitive resolution back to mlflow 2.x. AllenCell migration - pyproject.toml Homepage, README.md (4 URLs), docs/installation.rst, docs/overview.md (3 URLs incl. cyto-ml typo fix) updated from AllenCellModeling/cyto-dl -> AllenCell/cyto-dl. Left AllenCellModeling/aicsimageio reference in docs/using_examples.rst intact (separate legacy repo, still under AllenCellModeling). Release - Bump 0.6.2 -> 0.6.3 in version.toml, pyproject.toml (project.version + bumpver.current_version), cyto_dl/__init__.py. uv.lock regenerated. This release is what unblocks endo's transitive tifffile pin: by pulling cyto-dl 0.6.3 (which carries bioio 3.0.0 + bioio-tifffile 1.3.0), endo can let tifffile float to current versions instead of being held at 2025.1.10 by the old bioio 1.5.x stack.
Commit dab95f8 ported diffusion_autoencoder.py only; the same call pattern lived in 4 other modules and continued to break test collection in CI under Python 3.10, where the bioio-ome-tiff plugin is not auto-discoverable on the bioio.writers namespace. Migrated: - cyto_dl/image/transforms/save.py (Save class) - cyto_dl/callbacks/image_saver.py (ImageSaver callback) - cyto_dl/callbacks/latent_walk_diffae.py (LatentWalkDiffAE callback) - cyto_dl/models/classification/classification.py (Classification model) Each site used the trivial OmeTiffWriter.save(uri=path, data=array) shape, mapped 1:1 to tifffile.imwrite(path, array).
- bandit B324 (cached_loader.py): pass usedforsecurity=False to the md5 call. The hash is used solely as a short cache-key digest; not security-relevant. Inline comment documents intent. - bandit B110 (worker_init.py x2): replace silent except/pass with a logger.debug call so failures during fsspec/cache reset are at least observable, and add nosec annotations explaining the intentional best-effort behavior. - prettier (publish.yml): single-space comment alignment per project prettier config. - mdformat (README.md): blank line required after #### headings before fenced code blocks.
Refurb v2.0.0 sets Options.allow_redefinition, which mypy 1.18 removed (it became read-only / dropped from public API). The hook crashes on startup with AttributeError before any code is scanned. Pinning mypy<1.18 in additional_dependencies keeps the existing refurb rev pin intact while restoring functionality. Once refurb ships a release that targets mypy >=1.18, this can be relaxed by removing the additional_dependencies entry and bumping the rev.
Second-round CI cleanup after refurb hook unblocked by mypy<1.18 pin: - chmod -x cyto_dl/image/transforms/load_timelapse.py (was 100755 with no shebang; flagged by check-executables-have-shebangs) - black: rewrap long save_path line and self.save() call in image_saver.py; collapse single-arg multi-line calls in cached_loader.py - isort: alphabetize load_timelapse import in transforms/__init__.py; reorder tifffile in diffusion_autoencoder.py; move importlib.metadata import in tests/helpers/run_if.py - docformatter: reflow docstrings in worker_init.py and load_timelapse.py - refurb FURB109: list -> tuple in 'in' membership checks (image_saver.py) - refurb FURB184: chain BioImage(...).get_image_dask_data().compute() (cached_loader.py) - refurb FURB107: replace try/except OSError: pass with contextlib.suppress(OSError) (cached_loader.py)
PyTorch >= 2.6 changed torch.load's default weights_only from False to
True. Lightning checkpoints saved by cyto-dl embed Hydra/OmegaConf
hparams (DictConfig, ListConfig, ContainerMetadata, AnyNode, ...), so
'Trainer.fit(ckpt_path=...)', 'Trainer.test(ckpt_path=...)', and
'LightningModule.load_from_checkpoint(...)' fail with:
UnpicklingError: Weights only load failed. ... Unsupported global:
GLOBAL omegaconf.listconfig.ListConfig was not an allowed global.
Lightning calls torch.load internally without exposing weights_only, so
register the OmegaConf containers via torch.serialization.add_safe_globals
at cyto_dl import time. OmegaConf containers are pure config holders, so
allowlisting them is safe.
Fixes test_train.py::test_train_resume[gan-*] and
test_eval.py::test_train_eval[gan-gan-*] under torch >= 2.6.
PyTorch >= 2.6 flipped torch.load's default weights_only from False to True. The previous attempt at allowlisting OmegaConf classes via torch.serialization.add_safe_globals turned out to be whack-a-mole: after registering DictConfig/ListConfig/Metadata/AnyNode/... the next unpickler error is on typing.Any, then potentially on any Hydra-instantiable user class embedded in checkpoint hparams. Cyto-dl checkpoints save Hydra-instantiable hparams which can reference arbitrary user code, so 'safe' weights-only loading is fundamentally incompatible with the package's checkpoint shape. Cyto-dl users load their own checkpoints, so honor the pre-2.6 default by wrapping torch.load to inject weights_only=False when the caller didn't pass it explicitly. Pass weights_only=True at the call site to opt back in. Also: - refurb FURB107: use contextlib.suppress instead of try/except/pass (folded away by replacing the try-block with the monkey-patch). - docformatter: re-flow worker_init.py and load_timelapse.py docstrings with the project hook args (no --pre-summary-newline) to match CI. Fixes test_train.py::test_train_resume[gan-*] and test_eval.py::test_train_eval[gan-gan-*] under torch >= 2.6.
The previous setdefault-based patch was a no-op against Lightning, which
explicitly passes weights_only=weights_only with a default of None in
lightning.fabric.utilities.cloud_io._load (cloud_io.py L37, L56, L76).
Under torch >= 2.6, weights_only=None is treated as True by torch.load,
so the safe-unpickler still rejected omegaconf.ListConfig.
Detect both 'arg omitted' and 'arg explicitly None' by checking
kwargs.get('weights_only') is None, and force False in both cases. An
explicit True from the caller is still honored.
Verified with a roundtrip of {'cfg': ListConfig([1,2,3])}:
torch.load(buf) -> succeeds (no kwarg)
torch.load(buf, weights_only=None) -> succeeds (Lightning path)
torch.load(buf, weights_only=True) -> correctly rejects (opt-in)
|
@fatwir Some quick comments:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Python 3.12 / CUDA 13 / bioio 3.x / AllenCell migration → 0.6.3
Compare URL: https://github.com/AllenCell/cyto-dl/compare/main...ci-release-allencell-migration?expand=1
Summary
Brings the
python312-cuda13-updatework to a releasable state under the newAllenCellGitHub org and tags it as 0.6.3. The branch is 12 commits ahead ofmainand bundles three concerns that ship together because they unblock the same downstream consumers (cellsmap):<2.0for downstream pandas/scikit-image stacks.bioio.writers.OmeTiffWritercalls indiffusion_autoencoder.pyswapped fortifffile.imwrite(bioio 3.x removed the writer plugins we relied on); newcached_loader.pyandload_timelapse.pyfor the timelapse pipeline.AllenCellorg — workflows ported touv, codecov-action v5, peaceiris/actions-gh-pages v4; documentation URLs updated;mlflowcapped<3to avoid an import-time hang inmlflow.genai.scorers.builtin_scorersthat blocksmonai(and therefore every cyto-dl model).Commit list (
main..HEAD)10d13ff1570661d5dab95f8efcc0367720a054afddcb6c30python312-cuda13-updatebd7a0cdc7fab474e0ee94341ecc31cd19541a15c6286746cVerification
Synced fresh into
cellsmapsandbox viauv sync --extra ml_workflows:cyto-dlmlflowbioio/bioio-basebioio-ome-tiffbioio-ome-zarrbioio-tifffiletorchnumpytifffile24 / 26 cellsmap import smoke tests pass against this build. The 2 failing modules (
write_zarr.py,make_mp4.py) are unrelated (cellsmap-side migration, tracked separately) and not on the model-qc inference path.Manual follow-ups required after merge
These cannot be automated in the PR:
AllenCellorg sopublish.ymlcan mint a token (the inline note in.github/workflows/publish.ymldocuments this).CODECOV_TOKENrepository secret: set underAllenCell/cyto-dlsettings.build-docs.ymlto publish.cellsmapcan drop its temporary git pin (cyto-dl @ git+…@570661d5) and revert tocyto-dl>=0.6.3.Out of scope
lie_learn/equivextra still needs theugly_install.shC-source patch on Python ≥ 3.12; the extra is excluded from the test matrix until upstream ships a 3.12 wheel.