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

Clashes between definition names #25

Open
gilesknap opened this issue Jan 21, 2024 · 0 comments
Open

Clashes between definition names #25

gilesknap opened this issue Jan 21, 2024 · 0 comments

Comments

@gilesknap
Copy link
Member

We can't build a global schema of all support yaml if two support yaml share a definition name. That is even though the module name is different.

This is perhaps not a real problem, except that we do this in the CI tests to make sure all submitted yaml is good.

This limitation makes the module a little brittle.

e.g.

generating all support schema
+ ibek ioc generate-schema /home/runner/work/ibek-support/ibek-support/tests/../ADAravis/ADAravis.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../ADCore-slim/ADCore.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../ADCore/ADCore.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../ADSample/ADSimDetector.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../ADSimDetector/ADSimDetector.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../_global/epics.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../asyn/asyn.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../autosave/autosave.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../iocStats/iocStats.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../modbus/modbus.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../motor/motor.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../motorMotorSim/motorMotorSim.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../pmac/pmac.ibek.support.yaml /home/runner/work/ibek-support/ibek-support/tests/../zebra/zebra.ibek.support.yaml --no-ibek-defs --output /tmp/all.ibek.ioc.schema.json
Traceback (most recent call last):

  File "/home/runner/.local/bin/ibek", line 8, in <module>
    sys.exit(cli())

  File "/home/runner/.local/lib/python3.10/site-packages/ibek/ioc_cmds/commands.py", line 72, in generate_schema
    ioc_model = ioc_create_model(definitions)

  File "/home/runner/.local/lib/python3.10/site-packages/ibek/gen_scripts.py", line 45, in ioc_create_model
    model = make_ioc_model(entity_models)

  File "/home/runner/.local/lib/python3.10/site-packages/ibek/ioc.py", line 178, in make_ioc_model
    class NewIOC(IOC):

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 182, in __new__
    complete_model_class(

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 501, in complete_model_class
    schema = gen_schema.clean_schema(schema)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 405, in clean_schema
    schema = _discriminated_union.apply_discriminators(schema)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 60, in apply_discriminators
    return simplify_schema_references(_core_utils.walk_core_schema(schema, inner))

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 431, in walk_core_schema
    return f(schema.copy(), _dispatch)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 48, in inner
    s = recurse(s, inner)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 207, in walk
    return f(schema, self._walk)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 48, in inner
    s = recurse(s, inner)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 210, in _walk
    schema = self._schema_type_to_method[schema['type']](schema.copy(), f)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 240, in handle_definitions_schema
    new_inner_schema = self.walk(schema['schema'], f)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 207, in walk
    return f(schema, self._walk)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 48, in inner
    s = recurse(s, inner)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 210, in _walk
    schema = self._schema_type_to_method[schema['type']](schema.copy(), f)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 219, in _handle_other_schemas
    schema['schema'] = self.walk(sub_schema, f)  # type: ignore

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 207, in walk
    return f(schema, self._walk)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 48, in inner
    s = recurse(s, inner)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 210, in _walk
    schema = self._schema_type_to_method[schema['type']](schema.copy(), f)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 354, in handle_model_fields_schema
    replaced_field['schema'] = self.walk(v['schema'], f)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 207, in walk
    return f(schema, self._walk)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 48, in inner
    s = recurse(s, inner)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 210, in _walk
    schema = self._schema_type_to_method[schema['type']](schema.copy(), f)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 336, in handle_json_or_python_schema
    schema['json_schema'] = self.walk(schema['json_schema'], f)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 207, in walk
    return f(schema, self._walk)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 48, in inner
    s = recurse(s, inner)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 210, in _walk
    schema = self._schema_type_to_method[schema['type']](schema.copy(), f)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 254, in handle_list_schema
    schema['items_schema'] = self.walk(items_schema, f)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py", line 207, in walk
    return f(schema, self._walk)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 57, in inner
    s = apply_discriminator(s, discriminator, definitions)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 99, in apply_discriminator
    return _ApplyInferredDiscriminator(discriminator, definitions or {}).apply(schema)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 194, in apply
    schema = self._apply_to_root(schema)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 234, in _apply_to_root
    self._handle_choice(choice)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 285, in _handle_choice
    self._handle_choice(self.definitions[choice['schema_ref']])

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 309, in _handle_choice
    self._set_unique_choice_for_values(choice, inferred_discriminator_values)

  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_discriminated_union.py", line 504, in _set_unique_choice_for_values
    raise TypeError(

TypeError: Value 'ADSimDetector.simDetector' for discriminator 'type' mapped to multiple choices

Error: Process completed with exit code 1.
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

No branches or pull requests

1 participant