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

pydantic validation failure #101

Open
grg2rsr opened this issue Dec 11, 2024 · 2 comments
Open

pydantic validation failure #101

grg2rsr opened this issue Dec 11, 2024 · 2 comments
Assignees

Comments

@grg2rsr
Copy link
Collaborator

grg2rsr commented Dec 11, 2024

seeing this currently when trying to run the conversion for processed only
@h-mayorquin

(nwb) georg@georg-laptop:~/code/IBL-to-nwb$ /home/georg/.python_envs/nwb/bin/python /home/georg/code/IBL-to-nwb/src/ibl_to_nwb/_scripts/convert_brainwide_map_processed_only.py
/home/georg/.python_envs/nwb/lib/python3.12/site-packages/one/alf/files.py:10: FutureWarning: `one.alf.files` will be removed in version 3.0. Use `one.alf.path` instead.
  warnings.warn(
Traceback (most recent call last):
  File "/home/georg/code/IBL-to-nwb/src/ibl_to_nwb/_scripts/convert_brainwide_map_processed_only.py", line 43, in <module>
    data_interfaces.append(IblSortingInterface(session=session_id, cache_folder=one_cache_folder_path / "sorting"))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/code/neuroconv/src/neuroconv/datainterfaces/ecephys/basesortingextractorinterface.py", line 22, in __init__
    super().__init__(**source_data)
  File "/home/georg/code/neuroconv/src/neuroconv/baseextractorinterface.py", line 34, in __init__
    super().__init__(**source_data)
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/_internal/_validate_call.py", line 38, in wrapper_function
    return wrapper(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/_internal/_validate_call.py", line 111, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/code/neuroconv/src/neuroconv/basedatainterface.py", line 65, in __init__
    self._validate_source_data(source_data=source_data, verbose=verbose)
  File "/home/georg/code/neuroconv/src/neuroconv/basedatainterface.py", line 55, in _validate_source_data
    source_schema = self.get_source_schema()
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/code/neuroconv/src/neuroconv/basedatainterface.py", line 41, in get_source_schema
    return get_json_schema_from_method_signature(cls, exclude=["source_data"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/code/neuroconv/src/neuroconv/utils/json_schema.py", line 167, in get_json_schema_from_method_signature
    temp_json_schema = model.model_json_schema()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/main.py", line 512, in model_json_schema
    return model_json_schema(
           ^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 2374, in model_json_schema
    return schema_generator_instance.generate(cls.__pydantic_core_schema__, mode=mode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 397, in generate
    json_schema: JsonSchemaValue = self.generate_inner(schema)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 565, in generate_inner
    json_schema = current_handler(schema)
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/_internal/_schema_generation_shared.py", line 38, in __call__
    return self.handler(core_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 540, in new_handler_func
    json_schema = js_modify_function(schema_or_field, current_handler)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/main.py", line 728, in __get_pydantic_json_schema__
    return handler(core_schema)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/_internal/_schema_generation_shared.py", line 38, in __call__
    return self.handler(core_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 493, in handler_func
    json_schema = generate_for_schema_type(schema_or_field)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 1489, in model_schema
    json_schema = self.generate_inner(schema['schema'])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 565, in generate_inner
    json_schema = current_handler(schema)
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/_internal/_schema_generation_shared.py", line 38, in __call__
    return self.handler(core_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 493, in handler_func
    json_schema = generate_for_schema_type(schema_or_field)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 1603, in model_fields_schema
    json_schema = self._named_required_fields_schema(named_required_fields)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 1393, in _named_required_fields_schema
    field_json_schema = self.generate_inner(field).copy()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 565, in generate_inner
    json_schema = current_handler(schema)
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/_internal/_schema_generation_shared.py", line 38, in __call__
    return self.handler(core_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 493, in handler_func
    json_schema = generate_for_schema_type(schema_or_field)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 1461, in model_field_schema
    return self.generate_inner(schema['schema'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 565, in generate_inner
    json_schema = current_handler(schema)
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/_internal/_schema_generation_shared.py", line 38, in __call__
    return self.handler(core_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 493, in handler_func
    json_schema = generate_for_schema_type(schema_or_field)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 1117, in default_schema
    json_schema = self.generate_inner(schema['schema'])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 565, in generate_inner
    json_schema = current_handler(schema)
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/_internal/_schema_generation_shared.py", line 38, in __call__
    return self.handler(core_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 493, in handler_func
    json_schema = generate_for_schema_type(schema_or_field)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 859, in is_instance_schema
    return self.handle_invalid_for_json_schema(schema, f'core_schema.IsInstanceSchema ({schema["cls"]})')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/georg/.python_envs/nwb/lib/python3.12/site-packages/pydantic/json_schema.py", line 2279, in handle_invalid_for_json_schema
    raise PydanticInvalidForJsonSchema(f'Cannot generate a JsonSchema for {error_info}')
pydantic.errors.PydanticInvalidForJsonSchema: Cannot generate a JsonSchema for core_schema.IsInstanceSchema (<class 'inspect._empty'>)

For further information visit https://errors.pydantic.dev/2.10/u/invalid-for-json-schema
@h-mayorquin h-mayorquin self-assigned this Dec 11, 2024
@h-mayorquin
Copy link
Contributor

Hi, @grg2rsr.

I just pushed a fix to your branch here:

https://github.com/catalystneuro/IBL-to-nwb/pull/102/files#r1884077875

So this should be close when we merge #102

Moreover, this is a neuroconv issue that I will address over there but the fixes in #102 should be enough for you to avoid that error.

@h-mayorquin
Copy link
Contributor

I added now a PR in neuroconv:

catalystneuro/neuroconv#1157

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

2 participants