Skip to content

Ci release allencell migration#506

Draft
fatwir wants to merge 17 commits into
mainfrom
ci-release-allencell-migration
Draft

Ci release allencell migration#506
fatwir wants to merge 17 commits into
mainfrom
ci-release-allencell-migration

Conversation

@fatwir

@fatwir fatwir commented May 4, 2026

Copy link
Copy Markdown
Contributor

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-update work to a releasable state under the new AllenCell GitHub org and tags it as 0.6.3. The branch is 12 commits ahead of main and bundles three concerns that ship together because they unblock the same downstream consumers (cellsmap):

  1. Runtime modernization — Python 3.10–3.12 + CUDA 12.4/13.0 + PyTorch ≥ 2.5; numpy capped <2.0 for downstream pandas/scikit-image stacks.
  2. bioio 3.x compatibilitybioio.writers.OmeTiffWriter calls in diffusion_autoencoder.py swapped for tifffile.imwrite (bioio 3.x removed the writer plugins we relied on); new cached_loader.py and load_timelapse.py for the timelapse pipeline.
  3. CI / packaging migration to AllenCell org — workflows ported to uv, codecov-action v5, peaceiris/actions-gh-pages v4; documentation URLs updated; mlflow capped <3 to avoid an import-time hang in mlflow.genai.scorers.builtin_scorers that blocks monai (and therefore every cyto-dl model).

Commit list (main..HEAD)

SHA Subject
10d13ff1 Update lockfile and requirements files
570661d5 Modernize CI workflows, complete AllenCell migration, bump 0.6.3
dab95f8e Replace OmeTiffWriter with tifffile.imwrite for bioio 3.x compat
fcc03677 Cap numpy <2.0 for compatibility with downstream pipelines
20a054af Remove context information from MAE
ddcb6c30 Merge python312-cuda13-update
bd7a0cdc AWS training requirements
7fab474e Add multi-timepoint eval script
0ee94341 Fix Python 3.12 + PyTorch 2.6+ test compatibility
ecc31cd1 Update dependencies for Python 3.12 and CUDA 12.4/13.0 support
9541a15c Merge PR #505 (workflow-release)
6286746c Bump 0.6.1 → 0.6.2

Verification

Synced fresh into cellsmap sandbox via uv sync --extra ml_workflows:

Package Resolved
cyto-dl 0.6.3 (this branch)
mlflow 2.22.4
bioio / bioio-base 3.3.0
bioio-ome-tiff 1.4.0
bioio-ome-zarr 3.4.0
bioio-tifffile 1.3.0
torch 2.6.0
numpy 1.26.4
tifffile 2026.3.3 (floats — no pin needed)

24 / 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:

  • PyPI Trusted Publisher: re-register the trusted publisher entry under the AllenCell org so publish.yml can mint a token (the inline note in .github/workflows/publish.yml documents this).
  • CODECOV_TOKEN repository secret: set under AllenCell/cyto-dl settings.
  • GitHub Pages must be enabled (Settings → Pages → "GitHub Actions") for build-docs.yml to publish.
  • After 0.6.3 is on PyPI, downstream cellsmap can drop its temporary git pin (cyto-dl @ git+…@570661d5) and revert to cyto-dl>=0.6.3.

Out of scope

  • 637 Dependabot vulnerabilities flagged on default branch — separate hardening pass.
  • lie_learn / equiv extra still needs the ugly_install.sh C-source patch on Python ≥ 3.12; the extra is excluded from the test matrix until upstream ships a 3.12 wheel.

smishra3 and others added 16 commits November 30, 2025 21:47
  - 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.
@fatwir
fatwir requested review from jessicasyu, smishra3 and vianamp May 12, 2026 03:36
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)
@jessicasyu

Copy link
Copy Markdown

@fatwir Some quick comments:

  • a PR with this many lines/files changed is very hard to review. Please break this down into smaller, well-scoped PRs. It is not blocking endo, so we can take our time with these changes
  • we are working on a new set of recommendations/templates/reusable GitHub Actions workflows for versioning and publishing to PyPI, so I might pause on those changes (or, keep them in a draft PR we can iterate on)
  • we probably want to drop Codecov entirely

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.

3 participants