Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add CAREamics version to BMZ (#395)
## Description <!-- This section provides the necessary background and information for reviewers to understand the code and have the correct mindset when examining changes. --> > [!NOTE] > **tldr**: Make BMZ use the latest PyPI version of CAREamics. Following #385, this PR adds utilities to extract the version of CAREamics and modifies the BMZ environment yaml to fetch this version from PyPI. ### Background - why do we need this PR? <!-- What problem are you solving? Describe in a few sentences the state before this PR. Use code examples if useful. --> The BMZ env yaml was fetching and installing CAREamics via the main branch in Github, this can cause errors as the main branch might have breaking changes compared to the latest PyPI or even older versions users might have installed. ### Overview - what changed? <!-- What aspects and mechanisms of the code base changed? Describe only the general idea and overarching features. --> This PR introduces a new utils function to get the `Major.minor.patch` version of CAREamics, and builds the BMZ env yaml such that `torch`, `torchvision`, and `CAREamics` are fetched from PyPI according to their know versions. ### Implementation - how did you implement the changes? <!-- How did you solve the issue technically? Explain why you chose this approach and provide code examples if applicable (e.g. change in the API for users). --> Locally (e.g. when installed via `pip install -e .`) the CAREamics `__version__` is returned as a dev versions: e.g. `0.0.7.dev10a43fe0b087f`. The new `get_clean_version` utility only keeps the `Major.minor.patch` version. Finally, the function building up the BMZ env yaml now calls this utility and fetches `torch`, `torchvision` and `CAREamics` from PyPI. Note that the choice of moving `torch` and `torchvision` to PyPI is motivated by [PyTorch's conda package discontinuation](pytorch/pytorch#138506). ## Changes Made <!-- This section highlights the important features and files that reviewers should pay attention to when reviewing. Only list important features or files, this is useful for reviewers to correctly assess how deeply the modifications impact the code base. For instance: ### New features or files - `NewClass` added to `new_file.py` - `new_function` added to `existing_file.py` ... --> ### New features or files <!-- List new features or files added. --> - `careamics.utils.version.get_clean_version` to get the CAREamics version, and corresponding test. ### Modified features or files <!-- List important modified features or files. --> - `careamics.model_io.bioimage.bioimage_utils.create_env_text` now includes CAREamics version and installs `torch` and `torchvision` from pip. ## How has this been tested? <!-- Describe the tests that you ran to verify your changes. This can be a short description of the tests added to the PR or code snippet to reproduce the change in behaviour. --> Only via `pytest`. > [!WARNING] > This should be tested with an install from PyPI (or with a tagged commit) and with upload to the BMZ to verify that the env is valid. ## Related Issues <!-- Link to any related issues or discussions. Use keywords like "Fixes", "Resolves", or "Closes" to link to issues automatically. --> - Resolves #385 ## Additional Notes and Examples <!-- Provide any additional information that will help reviewers understand the changes. This can be links to documentations, forum posts, past discussions etc. --> > [!WARNING] > If working on a local editable install, `pip` automatically increases the patch version from the latest **known**. If you `pip install -e .` again, this might increase the latest known version. BMZ models should therefore preferentially be uploaded from an env installed from PyPI. --- **Please ensure your PR meets the following requirements:** - [x] Code builds and passes tests locally, including doctests - [x] New tests have been added (for bug fixes/features) - [x] Pre-commit passes - [ ] PR to the documentation exists (for bug fixes / features)
- Loading branch information