Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update conda to include nc-time-axis #763

Closed
jwarner8 opened this issue Jul 30, 2024 · 6 comments
Closed

Update conda to include nc-time-axis #763

jwarner8 opened this issue Jul 30, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@jwarner8
Copy link
Contributor

Something else

When plotting ML data, iris crashes as it needs to import nc-time-axis which isn't included as standard. This library increases the range of calendars we support (https://pypi.org/project/nc-time-axis/).

Workaround so far is manually installing package into local conda environment. Lock files will need updating.

@jwarner8 jwarner8 added the enhancement New feature or request label Jul 30, 2024
@jfrost-mo
Copy link
Member

nc-time-axis is a SciTools project, so should be sufficiently maintained for our needs.

I'm happy for it to be added to the environment. Go ahead and create a patch adding it to the pyproject.toml and requirements/environment.yaml.

CSET/pyproject.toml

Lines 24 to 32 in ce10907

dependencies = [
"numpy",
"scitools-iris >= 3.6",
"ruamel.yaml >= 0.17",
"pygraphviz >= 1.11",
"mo_pack >= 0.3.0",
"isodate",
"markdown-it-py >= 3.0",
]

# Runtime dependencies
- numpy
- iris >= 3.5
- ruamel.yaml >= 0.17
- mo_pack # For handling pp files.
- pygraphviz
- isodate
- markdown-it-py >= 3.0

After updating those two files and making a pull request, you'll need to rerun the conda lockfile generation action. In Actions > Update conda lock files > Run workflow select your branch, then run the workflow.

A new PR will be created to update the lockfiles. Make sure to change the base branch of this PR to your branch by clicking the "Edit" button next to the PR title.

@jwarner8 jwarner8 self-assigned this Jul 30, 2024
@jwarner8
Copy link
Contributor Author

jwarner8 commented Aug 1, 2024

Thanks, these instructions were really helpful and clear. Have now done this.

@jfrost-mo
Copy link
Member

To update the conda-forge package

Conda packages are built from "feedstocks", which are repositories that contain the list of steps to build, package, and test the package, as well as the required metadata, such as the package name, and needed dependencies.

The CSET feedstock is at github.com/conda-forge/cset-feedstock. The only user editable file in this repository is recipe/meta.yaml. All of the other files are either automatically generated from the recipe file, or inert things like the README that don't affect the feedstock.

In this case we care about the runtime dependencies at

cset-feedstock/recipe/meta.yaml
Lines 22 to 30 in abb107d:

  run:
    - python >=3.10
    - numpy
    - iris >=3.6
    - ruamel.yaml >=0.17
    - pygraphviz >=1.11
    - mo_pack >=0.3
    - isodate >=0.6
    - markdown-it-py >=3.0

Because this repository is not within the MetOffice GitHub organisation, we cannot directly change it. We have to make a fork of the repository to make changes.

Once you have created a fork, you can edit the feedstock recipe and make the needed changes. In this case we need two changes.

  1. Add the new dependency under the runtime requirements section. Remember to use the conda-forge package name!
    requirements:
      run:
        - my_dependency
  2. Increase the build number. This is used when the package version does not increase, so conda knows which version is more up-to-date.

Finally make your pull request, the feedstock maintainer (me) will review and merge it, and then your updated package will be on conda-forge soon after.

Once the updated package is on conda-forge, you will then need to rerun the conda-lock workflow to regenerate the lockfiles once again, so we are actually using it.

@jwarner8
Copy link
Contributor Author

jwarner8 commented Aug 1, 2024

To update the conda-forge package

Conda packages are built from "feedstocks", which are repositories that contain the list of steps to build, package, and test the package, as well as the required metadata, such as the package name, and needed dependencies.

The CSET feedstock is at github.com/conda-forge/cset-feedstock. The only user editable file in this repository is recipe/meta.yaml. All of the other files are either automatically generated from the recipe file, or inert things like the README that don't affect the feedstock.

In this case we care about the runtime dependencies at

cset-feedstock/recipe/meta.yaml
Lines 22 to 30 in abb107d:

  run:
    - python >=3.10
    - numpy
    - iris >=3.6
    - ruamel.yaml >=0.17
    - pygraphviz >=1.11
    - mo_pack >=0.3
    - isodate >=0.6
    - markdown-it-py >=3.0

Because this repository is not within the MetOffice GitHub organisation, we cannot directly change it. We have to make a fork of the repository to make changes.

Once you have created a fork, you can edit the feedstock recipe and make the needed changes. In this case we need two changes.

  1. Add the new dependency under the runtime requirements section. Remember to use the conda-forge package name!
    requirements:
      run:
        - my_dependency
  2. Increase the build number. This is used when the package version does not increase, so conda knows which version is more up-to-date.

Finally make your pull request, the feedstock maintainer (me) will review and merge it, and then your updated package will be on conda-forge soon after.

Once the updated package is on conda-forge, you will then need to rerun the conda-lock workflow to regenerate the lockfiles once again, so we are actually using it.

Thanks, this is great. I will progress this tomorrow morning and report back.

@jwarner8
Copy link
Contributor Author

jwarner8 commented Aug 5, 2024

Issue now closed, but valuable documentation needs to be captured for reproducing in future.

@jfrost-mo
Copy link
Member

I've opened #776 for adding this documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants