Skip to content

Test that vector of enums works as input#1904

Open
sebproell wants to merge 1 commit into4C-multiphysics:mainfrom
sebproell:enum-vector-input
Open

Test that vector of enums works as input#1904
sebproell wants to merge 1 commit into4C-multiphysics:mainfrom
sebproell:enum-vector-input

Conversation

@sebproell
Copy link
Copy Markdown
Member

@sebproell sebproell self-assigned this Mar 27, 2026
@sebproell sebproell enabled auto-merge March 27, 2026 21:22
Copy link
Copy Markdown
Member

@ppraegla ppraegla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that this works. But when I try it in the code, I get the following error. So, maybe the schema generation needs to be adapted for this case

[build]   File "/home/user/4C/build/release/python_venv_build_test/bin/create-schema-files", line 8, in <module>
[build]     sys.exit(cli())
[build]              ^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/json_schema.py", line 400, in cli
[build]     main(**vars(args))
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/json_schema.py", line 318, in main
[build]     metadata_object = All_Of.from_4C_metadata(metadata["sections"], context)
[build]                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/metadata.py", line 190, in from_4C_metadata
[build]     specs = [metadata_from_dict(spec, context) for spec in specs]
[build]              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/metadata.py", line 891, in metadata_from_dict
[build]     return metadata_class.from_4C_metadata(data_dict, context)
[build]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/metadata.py", line 772, in from_4C_metadata
[build]     metadata_from_dict(spec, context) for spec in data_dict.pop("specs", [])
[build]     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/metadata.py", line 891, in metadata_from_dict
[build]     return metadata_class.from_4C_metadata(data_dict, context)
[build]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/metadata.py", line 190, in from_4C_metadata
[build]     specs = [metadata_from_dict(spec, context) for spec in specs]
[build]              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/metadata.py", line 891, in metadata_from_dict
[build]     return metadata_class.from_4C_metadata(data_dict, context)
[build]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/metadata.py", line 500, in from_4C_metadata
[build]     value_type: NATIVE_CPP_ALIAS = metadata_from_dict(
[build]                                    ^^^^^^^^^^^^^^^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/metadata.py", line 891, in metadata_from_dict
[build]     return metadata_class.from_4C_metadata(data_dict, context)
[build]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[build]   File "/home/user/4C/utilities/four_c_python/src/four_c_metadata/metadata.py", line 440, in from_4C_metadata
[build]     choices = [c["name"] for c in data_dict.pop("choices")]
[build]                                   ^^^^^^^^^^^^^^^^^^^^^^^^
[build] KeyError: 'choices'

@ppraegla
Copy link
Copy Markdown
Member

Looking further into this, the 4C_metadata.yaml contains

- name: TEST
              type: vector
              value_type:
                type: enum

Which indeed misses the choices keyword normally present for enum types

@sebproell
Copy link
Copy Markdown
Member Author

@ppraegla Thanks for checking. I will add the choices here, this was indeed never used so far.

@sebproell
Copy link
Copy Markdown
Member Author

Ah this is once more related to #1708. Added it to the list there. I will see if I find the time soon to cross a few things of this list.

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 this pull request may close these issues.

3 participants