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

Fix logic for running without --file sources #231

Open
riccardoporreca opened this issue Aug 10, 2022 · 1 comment · May be fixed by #232
Open

Fix logic for running without --file sources #231

riccardoporreca opened this issue Aug 10, 2022 · 1 comment · May be fixed by #232

Comments

@riccardoporreca
Copy link
Contributor

riccardoporreca commented Aug 10, 2022

Running w/o sources for dependencies is allowed by design (and would use the sources from the lockfile).

However, the CLI interface checks the existence of an environment.y(a)ml file for such cases, as this is the default:

https://github.com/conda-incubator/conda-lock/blob/7d9bd6d67d59fdd30d92a2ace3ee344aafa6a2b1/conda_lock/conda_lock.py#L1134-L1143

How to reproduce

# environment-foo.yml
channels:
- conda-forge
dependencies:
- python=3.8.12
- numpy=1.22.3
platforms:
- win-64
conda-lock -f environment-foo.yml --lockfile conda-lock.yml
# Locking dependencies for ['win-64']...
# INFO:conda_lock.conda_solver:win-64 using specs ['python 3.8.12.*', 'numpy 1.22.3.*']

Running with lock-file only shows the help because no environment.y(a)ml exists:

conda-lock --lockfile conda-lock.yml
# Usage: conda-lock lock [OPTIONS]
# [...]

If we just create an empty environment.yml, the CLI gets past the check above and the rest behaves as expected

conda-lock --lockfile conda-lock.yml
# Locking dependencies for ['win-64']...
# INFO:conda_lock.conda_solver:win-64 using specs ['python 3.8.12.*', 'numpy 1.22.3.*']
@riccardoporreca riccardoporreca changed the title Fix logic for running with out --file sources Fix logic for running without --file sources Aug 10, 2022
@riccardoporreca
Copy link
Contributor Author

riccardoporreca commented Aug 10, 2022

Actually, a similar logic is implemented in run_lock() (introduced in df566dc), which however accounts for the presence of the lock-file:

https://github.com/conda-incubator/conda-lock/blob/7d9bd6d67d59fdd30d92a2ace3ee344aafa6a2b1/conda_lock/conda_lock.py#L920-L944

This should make the logic in the CLI unnecessary (although we might want to rely on DEFAULT_FILES instead of allowing only for environment.yaml)

riccardoporreca added a commit to riccardoporreca/conda-lock that referenced this issue Aug 10, 2022
* Resolves conda#231, reviewing and extending the logic for supporting .yaml extension (conda#99).
riccardoporreca added a commit to riccardoporreca/conda-lock that referenced this issue Aug 10, 2022
from the case of files specified and same as default, while keeping the CLI default to have it in the `--help` (conda#231).
riccardoporreca added a commit to riccardoporreca/conda-lock that referenced this issue Aug 10, 2022
even when falling back from the source files in the lockfile (conda#231).
@riccardoporreca riccardoporreca linked a pull request Aug 10, 2022 that will close this issue
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 a pull request may close this issue.

1 participant