1

Here's an excerpt from my environment.yml:

name: my-project
channels:
  - pytorch-nightly
  - defaults
dependencies:
  - pytorch=1.13.0.*
  - pip:
    - https://github.com/explosion/spacy-models/releases/download/nb_core_news_md-3.3.0/nb_core_news_md-3.3.0-py3-none-any.whl
prefix: ~/opt/miniconda3/envs/my-project

When I create my environment (conda env create -f environment.yml) and re-export it to environment.yml (conda env export > environment.yml), the file gets changed:

name: my-project
channels:
  - pytorch-nightly
  - defaults
dependencies:
  - pytorch=1.13.0.dev20220614=py3.9_0
  - pip:
    - nb-core-news-md==3.3.0
prefix: ~/opt/miniconda3/envs/my-project

Then, when I re-create my environment the next day, Conda complains that pytorch=1.13.0.dev20220614=py3.9_0 does not exist because it was replaced by a new PyTorch Preview (Nightly) build. dev20220614=py3.9_0 is no longer available.

Conda also complains that nb-core-news-md==3.3.0 does not exist. It was installed via a URL directly to the whl. That URL was removed from the environment.yml.

How can I prevent conda env export from changing these two dependencies? I still want Conda to lock down the specifics for all other dependencies, just not for these two.

leifericf
  • 2,324
  • 3
  • 26
  • 37
  • 1
    Try using the `--no-build` flag when exporting: https://stackoverflow.com/a/69011426/14536215 – Tzane Jun 15 '22 at 10:29
  • Ah! The `--no-builds` flag worked well for `pytorch` (yay!) but not for `nb-core-news-md`. For the latter package, the URL was still removed. – leifericf Jun 15 '22 at 12:35
  • Correction to my previous comment: It did not work for `pytorch` either, actually, because `dev20220614` is apparently part of the _package_ version and not the _build_ version. For `pytorch`, only `=py3.9_0` was removed when using the `--no-builds` flag. My apologies for the misunderstanding. – leifericf Jun 15 '22 at 12:42
  • I think PyTorch is not following the build versioning conventions that work with Conda. I have opened an issue for this on GitHub: https://github.com/pytorch/pytorch/issues/79606 – leifericf Jun 15 '22 at 13:31

1 Answers1

0

I get why PyTorch is deleting daily builds, but it's kind of disruptive for the workflow you have. What you're asking for cannot be expressed with Conda CLI commands. Instead, consider exporting the regular YAML, but then run some sed commands to replace the particular requirements prior to recreating the environment.

merv
  • 67,214
  • 13
  • 180
  • 245