Skip to content

Migrating the extension dependencies to pip-tools #24

Description

@Thibault-Pelletier

Following recent PRs in the repo and the recent addition to Slicer packaging, the dependency handling for SlicerNUNet should be moved to pip-tools.

Overview

Pip tools migration implies:

  • A requirements.in / pyproject.toml file compiling the bare requirements necessary for the extension including Python and platform specific requirements
  • A constraints.txt file listing requirements that shouldn't be touched in Slicer environment (in the long run the contraints.txt file would be handled by Slicer)

Pip tools would then make it possible to generate requirements lock file per supported python version and supported OS.
This way of specifying the requirements should be compatible with the new Slicer packaging infrastructure.

Example of content

Example requirements.in content:

nnunetv2>=2.7.0; platform_system == "Darwin"
nnunetv2>=2.3.0; platform_system != "Darwin"
acvl-utils==0.2.0; python_version < "3.12"
dynamic_network_architectures!=0.4

Example constraints.txt content:

SimpleITK==9999
torch==9999
requests==9999
dynamic_network_architectures!=0.4

Lock generation

Lock generation per platform would imply generating the locks on the CI when generating a new version.

The lock generation can be done / tested on the Github CI first. In the future, lock generation may make more sense on Kitware's CI when packaging the wheel and after running the unit tests to make sure the locked versions are actually working in Slicer's environment.

On Github lock generation can be done in a job that will:

  • Checkout the latest stable Slicer version
  • Run pip-compile for the given Slicer to generate the lock file
  • Install the extension
  • Run the self tests of the extension
  • Commit the updated lock file provided the self tests are working

As Slicer ships with given python versions, requirements locks should probably mapped to requirements-py<version>-<os>.lock tags.

Enforcing version

Pip tools comes with the pip-sync method followed by args that force the environment to be synced to the required package version.
Running pip-sync requirements-py<version>-<os>.lock --pip-args "--no-deps" would force the environment to be updated to locked versions.

This differs from pip_ensure which does a soft check based on the requirements.in only. For the NNUNet package, it may be necessary to use a hard sync as compared to the soft pip_ensure given the package's compatibility flakiness.

@lassoan @ebrahimebrahim @pieper happy to get your thoughts on this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions