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

Convert complains of duplicate keys in some recipes #385

Open
bamarco opened this issue Nov 19, 2023 · 3 comments · May be fixed by #386
Open

Convert complains of duplicate keys in some recipes #385

bamarco opened this issue Nov 19, 2023 · 3 comments · May be fixed by #386

Comments

@bamarco
Copy link
Contributor

bamarco commented Nov 19, 2023

Traceback (most recent call last):
  File "/home/monkey/micromamba/envs/boa-dev/bin/boa", line 33, in <module>
    sys.exit(load_entry_point('boa', 'console_scripts', 'boa')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/monkey/proj/lib/boa/boa/cli/boa.py", line 223, in main
    convert.main(args.target)
  File "/home/monkey/proj/lib/boa/boa/cli/convert.py", line 132, in main
    yaml.load("".join(rest_lines))
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/main.py", line 451, in load
    return constructor.get_single_data()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/constructor.py", line 114, in get_single_data
    return self.construct_document(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/constructor.py", line 123, in construct_document
    for _dummy in generator:
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/constructor.py", line 1470, in construct_yaml_map
    self.construct_mapping(node, data, deep=True)
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/constructor.py", line 1359, in construct_mapping
    value = self.construct_object(value_node, deep=deep)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/constructor.py", line 145, in construct_object
    data = self.construct_non_recursive_object(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/constructor.py", line 186, in construct_non_recursive_object
    for _dummy in generator:
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/constructor.py", line 1470, in construct_yaml_map
    self.construct_mapping(node, data, deep=True)
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/constructor.py", line 1360, in construct_mapping
    if self.check_mapping_key(node, key_node, maptyp, key, value):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/monkey/micromamba/envs/boa-dev/lib/python3.11/site-packages/ruamel/yaml/constructor.py", line 276, in check_mapping_key
    raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
  in "<unicode string>", line 7, column 3:
      url: 'https://github.com/stan-de ... 
      ^ (line: 7)
found duplicate key "url" with value "https://github.com/stan-dev/{{ name }}/releases/download/v{{ version }}/{{ name }}-{{ version }}-linux-arm64.tar.gz  # [aarch64]" (original value: "https://github.com/stan-dev/{{ name }}/releases/download/v{{ version }}/{{ name }}-{{ version }}.tar.gz  # [x86 or arm64]")
  in "<unicode string>", line 9, column 3:
      url: 'https://github.com/stan-de ... 
      ^ (line: 9)

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
@bamarco
Copy link
Contributor Author

bamarco commented Nov 19, 2023

I can work on fixing this, I'm just unsure of the desired behaviour. Does conda-forge do something to deduplicate these keys before yaml processing? What does boa need for a well-formed recipe?

The use case is when there are multiple architecture urls with sha256 hashes.

@bamarco
Copy link
Contributor Author

bamarco commented Nov 20, 2023

Found the desired result in the boa spec:

  source:
    - url: https://package1.com/a.tar.bz2
      folder: stuff
    - url: https://package1.com/b.tar.bz2
      folder: stuff
    - git_url: https://github.com/mamba-org/boa
      folder: boa

@bamarco
Copy link
Contributor Author

bamarco commented Nov 20, 2023

actually in this case it would be

source:
  - sel(not win):
      url: http://path/to/unix/source
  - sel(win):
      url: http://path/to/windows/source

@bamarco bamarco linked a pull request Nov 20, 2023 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