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

[BUG] add-packages to dependencies: section, if present. #337

Open
mforbes opened this issue Sep 8, 2021 · 5 comments
Open

[BUG] add-packages to dependencies: section, if present. #337

mforbes opened this issue Sep 8, 2021 · 5 comments
Labels
TRIAGE Uncategorized issue

Comments

@mforbes
Copy link

mforbes commented Sep 8, 2021

When an anaconda-project.yml file has a dependencies: section rather than a packages: section as allowed by the alias implemented in PR #200 and requested in issue #194 so that anaconda-project.yml files can act as environment.yml files, new packages should be added to the existing section.

What happens instead is that anaconda-project add-packages inserts and additional packages: section with the new package rather than reusing the existing dependencies: section. Thus, anaconda-project add-packages pandas migh produce something like this:

#anaconda-project.yaml
...
dependencies:
- numpy
- matplotlib

packages:
- pandas

when it should produce something like:

#anaconda-project.yaml
...
dependencies:
- numpy
- matplotlib
- pandas
@mforbes mforbes added the TRIAGE Uncategorized issue label Sep 8, 2021
@mforbes mforbes changed the title [BUG] add-packages to dependencies: section. [BUG] add-packages to dependencies: section, if present. Sep 8, 2021
@AlbertDeFusco
Copy link
Collaborator

ah! thanks for that.

@mforbes
Copy link
Author

mforbes commented Jan 29, 2022

I will try to take a stab at fixing this.

As per @jbednar's request in #194, can we replace packages with dependencies as the recommended approach going forward once this is resolved? I don't see any good reason for recommending packages except for this issue.

@AlbertDeFusco
Copy link
Collaborator

I agree. I've been looking at the code and I see that packages is somewhat hardcoded. I'm trying to come up with searches to help understand

❯ grep "\['packages'\]" -r .
./anaconda_project/env_spec.py:        template_json['something']['packages'] = packages
./anaconda_project/test/test_project_ops.py:            assert spec in env_commented_map['packages'], env_commented_map['packages']
./anaconda_project/project_file.py:                move_list_elements(spec_json['packages'], as_json['packages'])
./anaconda_project/conda_manager.py:        yaml_dict['packages'] = packages_dict
./anaconda_project/project_ops.py:        env_dict['packages'] = old_packages
./anaconda_project/project_ops.py:                        env_dict['packages'].append({'pip': []})
./anaconda_project/project_ops.py:                        env_dict['packages'] = [{'pip': []}]
./anaconda_project/project_ops.py:                    env_dict['packages'].append({'pip': pip_packages})
./anaconda_project/project_ops.py:                env_dict['packages'] = old_packages
./anaconda_project/project_ops.py:            env_dict['packages'] = old_packages
./anaconda_project/requirements_registry/providers/test/test_conda_env.py:        project.project_file.set_value(['packages', deps + ['boguspackage'])
❯ grep -E "get\('packages'.*\)" -r .
./anaconda_project/env_spec.py:        raw_dependencies = yaml.get('packages', [])
./anaconda_project/project_ops.py:        old_packages = env_dict.get('packages', [])
./anaconda_project/project_ops.py:            _pkgs = env_dict.get('packages', [])
./anaconda_project/project_ops.py:            old_packages = env_dict.get('packages', [])
./anaconda_project/project_ops.py:            old_packages = env_dict.get('packages', [])
./anaconda_project/project.py:            packages_by_platform = lock_set.get('packages', {})
./anaconda_project/project.py:                    packages = env_dict.get('packages', [])

This seems like a good opportunity to adopt black (or some other linter/formatter) to swap all singe to double quotes to help my grepping

@mforbes
Copy link
Author

mforbes commented Jan 31, 2022

@AlbertDeFusco I will push some code later today, but I have made a test fixture that should run all tests with 'dependencies' and 'packages'. I will try to fix some of the resulting errors, but will probably need your guidance tomorrow (did you get my meeting request?).

@AlbertDeFusco
Copy link
Collaborator

Great! Looking forward to meeting tomorrow

mforbes pushed a commit to mforbes/anaconda-project that referenced this issue Feb 1, 2022
mforbes pushed a commit to mforbes/anaconda-project that referenced this issue Feb 6, 2022
AlbertDeFusco pushed a commit to AlbertDeFusco/anaconda-project that referenced this issue Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TRIAGE Uncategorized issue
Projects
None yet
Development

No branches or pull requests

2 participants