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

Signature TypeError when zen wrapping function that accepts Pydantic BaseModel #723

Open
siboles opened this issue Aug 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@siboles
Copy link

siboles commented Aug 27, 2024

I'm very new to hydra and hydra-zen, so this could very much be a user issue, but I am experiencing the following.

Code Snippet

from pydantic import BaseModel
from hydra_zen import store, zen
from hydra_zen.third_party.pydantic import pydantic_parser

class Input(BaseModel):
    x: int = 1

def task(input: Input):
    print(input)


if __name__ == "__main__":
    store(task, hydra_defaults=["_self_", {"input": "base"}])
    store(Input, group="input", name="base")
    store.add_to_hydra_store()

    zen(task, instantiation_wrapper=pydantic_parser).hydra_main(
        config_name="task", config_path=None, version_base="1.3"
    )

Expected Behavior

print the instantiated Input model.

Observed Behavior

Full Error Trace
Error executing job with overrides: []
Traceback (most recent call last):
  File "/home/scotts/svnrepos/repo3/MCLS_008/src/scripts/simple_hydra.py", line 19, in <module>
    zen(task, instantiation_wrapper=pydantic_parser).hydra_main(
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra_zen/wrapper/_implementations.py", line 532, in hydra_main
    return hydra.main(**kw)(target)()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/main.py", line 94, in decorated_main
    _run_hydra(
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra
    _run_app(
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/_internal/utils.py", line 457, in _run_app
    run_and_report(
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
    raise ex
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/_internal/utils.py", line 220, in run_and_report
    return func()
           ^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/_internal/utils.py", line 458, in <lambda>
    lambda: hydra.run(
            ^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
        ^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra_zen/wrapper/_implementations.py", line 451, in __call__
    name: self.instantiate(val) if is_instantiable(val) else val
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra_zen/wrapper/_implementations.py", line 375, in instantiate
    __c = instantiate(__c, _target_wrapper_=self._instantiation_wrapper)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra_zen/_hydra_overloads.py", line 341, in instantiate
    return hydra_instantiate(config, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 226, in instantiate
    return instantiate_node(
           ^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 347, in instantiate_node
    return _call_target(_target_, partial, args, kwargs, full_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra_zen/_hydra_overloads.py", line 105, in _call_target
    _target_ = target_wrapper(_target_)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/hydra_zen/third_party/pydantic.py", line 117, in pydantic_parser
    return cast(_T, parser(_constructor_as_fn(target)))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/pydantic/validate_call_decorator.py", line 56, in validate
    validate_call_wrapper = _validate_call.ValidateCallWrapper(function, config, validate_return, local_ns)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/pydantic/_internal/_validate_call.py", line 57, in __init__
    schema = gen_schema.clean_schema(gen_schema.generate_schema(function))
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 512, in generate_schema
    schema = self._generate_schema_inner(obj)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 789, in _generate_schema_inner
    return self.match_type(obj)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 856, in match_type
    return self._callable_schema(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 1670, in _callable_schema
    sig = signature(function)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/inspect.py", line 3310, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/inspect.py", line 3054, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scotts/miniforge3/envs/bkrsim/lib/python3.12/inspect.py", line 2530, in _signature_from_callable
    raise TypeError(
TypeError: unexpected object <pydantic._internal._utils.ClassAttribute object at 0x7c78bdca8b50> in __signature__ attribute
config.yaml
_target_: __main__.task
input:
  _target_: __main__.Input
  x: 1
hydra.yaml
hydra:
  run:
    dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S}
  sweep:
    dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S}
    subdir: ${hydra.job.num}
  launcher:
    _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher
  sweeper:
    _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper
    max_batch_size: null
    params: null
  help:
    app_name: ${hydra.job.name}
    header: '${hydra.help.app_name} is powered by Hydra.

      '
    footer: 'Powered by Hydra (https://hydra.cc)

      Use --hydra-help to view Hydra specific help

      '
    template: '${hydra.help.header}

      == Configuration groups ==

      Compose your configuration from those groups (group=option)


      $APP_CONFIG_GROUPS


      == Config ==

      Override anything in the config (foo.bar=value)


      $CONFIG


      ${hydra.help.footer}

      '
  hydra_help:
    template: 'Hydra (${hydra.runtime.version})

      See https://hydra.cc for more info.


      == Flags ==

      $FLAGS_HELP


      == Configuration groups ==

      Compose your configuration from those groups (For example, append hydra/job_logging=disabled
      to command line)


      $HYDRA_CONFIG_GROUPS


      Use ''--cfg hydra'' to Show the Hydra config.

      '
    hydra_help: ???
  hydra_logging:
    version: 1
    formatters:
      simple:
        format: '[%(asctime)s][HYDRA] %(message)s'
    handlers:
      console:
        class: logging.StreamHandler
        formatter: simple
        stream: ext://sys.stdout
    root:
      level: INFO
      handlers:
      - console
    loggers:
      logging_example:
        level: DEBUG
    disable_existing_loggers: false
  job_logging:
    version: 1
    formatters:
      simple:
        format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s'
    handlers:
      console:
        class: logging.StreamHandler
        formatter: simple
        stream: ext://sys.stdout
      file:
        class: logging.FileHandler
        formatter: simple
        filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log
    root:
      level: INFO
      handlers:
      - console
      - file
    disable_existing_loggers: false
  env: {}
  mode: RUN
  searchpath: []
  callbacks: {}
  output_subdir: .hydra
  overrides:
    hydra:
    - hydra.mode=RUN
    task: []
  job:
    name: _implementations
    chdir: null
    override_dirname: ''
    id: ???
    num: ???
    config_name: task
    env_set: {}
    env_copy: []
    config:
      override_dirname:
        kv_sep: '='
        item_sep: ','
        exclude_keys: []
  runtime:
    version: 1.3.2
    version_base: '1.3'
    cwd: /home/scotts/svnrepos/repo3/MCLS_008/src/scripts
    config_sources:
    - path: hydra.conf
      schema: pkg
      provider: hydra
    - path: hydra_zen.wrapper
      schema: pkg
      provider: main
    - path: ''
      schema: structured
      provider: schema
    output_dir: /home/scotts/svnrepos/repo3/MCLS_008/src/scripts/outputs/2024-08-26/16-49-28
    choices:
      input: base
      hydra/env: default
      hydra/callbacks: null
      hydra/job_logging: default
      hydra/hydra_logging: default
      hydra/hydra_help: default
      hydra/help: default
      hydra/sweeper: basic
      hydra/launcher: basic
      hydra/output: default
  verbose: false

Environment

Conda Environment
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
aiohttp                   3.9.5           py312h98912ed_0    conda-forge
aiosignal                 1.3.1              pyhd8ed1ab_0    conda-forge
alsa-lib                  1.2.12               h4ab18f5_0    conda-forge
annotated-types           0.7.0              pyhd8ed1ab_0    conda-forge
antlr-python-runtime      4.9.3              pyhd8ed1ab_1    conda-forge
aom                       3.9.1                hac33072_0    conda-forge
attr                      2.5.1                h166bdaf_1    conda-forge
attrs                     23.2.0             pyh71513ae_0    conda-forge
bkrsim                    0.0                      pypi_0    pypi
blosc                     1.21.5               hc2324a3_1    conda-forge
bzip2                     1.0.8                hd590300_5    conda-forge
c-ares                    1.28.1               hd590300_0    conda-forge
ca-certificates           2024.7.4             hbcca054_0    conda-forge
cairo                     1.18.0               h3faef2a_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
coverage                  7.5.4           py312h9a8786e_0    conda-forge
dav1d                     1.2.1                hd590300_0    conda-forge
dbus                      1.13.6               h5008d03_3    conda-forge
double-conversion         3.3.0                h59595ed_0    conda-forge
eigen                     3.4.0                h00ab1b0_0    conda-forge
enum-tools                0.12.0                   pypi_0    pypi
exceptiongroup            1.2.0              pyhd8ed1ab_2    conda-forge
expat                     2.6.2                h59595ed_0    conda-forge
ffmpeg                    6.1.1           gpl_he44c6f3_112    conda-forge
fltk                      1.3.9                hea138e6_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 h77eed37_2    conda-forge
fontconfig                2.14.2               h14ed4e7_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freeimage                 3.18.0              h4b96d29_20    conda-forge
freetype                  2.12.1               h267a509_2    conda-forge
fribidi                   1.0.10               h36c2ea0_0    conda-forge
frozenlist                1.4.1           py312h98912ed_0    conda-forge
gettext                   0.22.5               h59595ed_2    conda-forge
gettext-tools             0.22.5               h59595ed_2    conda-forge
gl2ps                     1.4.2                h0708190_0    conda-forge
glew                      2.1.0                h9c3ff4c_2    conda-forge
glib                      2.80.2               hf974151_0    conda-forge
glib-tools                2.80.2               hb6ce0ca_0    conda-forge
gmp                       6.3.0                hac33072_2    conda-forge
gmsh                      4.12.2               h6b98cf8_0    conda-forge
gnutls                    3.7.9                hb077bed_0    conda-forge
graphite2                 1.3.13            h59595ed_1003    conda-forge
gst-plugins-base          1.24.4               h9ad1361_0    conda-forge
gstreamer                 1.24.4               haf2f30d_0    conda-forge
harfbuzz                  8.5.0                hfac3d4d_0    conda-forge
hdf4                      4.2.15               h2a13503_7    conda-forge
hdf5                      1.14.3          nompi_hdf9ad27_105    conda-forge
hydra-core                1.3.2              pyhd8ed1ab_0    conda-forge
hydra-zen                 0.13.0             pyhd8ed1ab_0    conda-forge
icu                       73.2                 h59595ed_0    conda-forge
idna                      3.7                pyhd8ed1ab_0    conda-forge
imath                     3.1.11               hfc55251_0    conda-forge
importlib_resources       6.4.0              pyhd8ed1ab_0    conda-forge
iniconfig                 2.0.0              pyhd8ed1ab_0    conda-forge
jsoncpp                   1.9.5                h4bd325d_1    conda-forge
jxrlib                    1.1                  hd590300_3    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
krb5                      1.21.3               h659f571_0    conda-forge
lame                      3.100             h166bdaf_1003    conda-forge
lcms2                     2.16                 hb7c19ff_0    conda-forge
ld_impl_linux-64          2.40                 hf3520f5_7    conda-forge
lerc                      4.0.0                h27087fc_0    conda-forge
libabseil                 20240116.2      cxx17_h59595ed_0    conda-forge
libaec                    1.1.3                h59595ed_0    conda-forge
libasprintf               0.22.5               h661eb56_2    conda-forge
libasprintf-devel         0.22.5               h661eb56_2    conda-forge
libass                    0.17.1               h8fe9dca_1    conda-forge
libblas                   3.9.0           22_linux64_openblas    conda-forge
libcap                    2.69                 h0f662aa_0    conda-forge
libcblas                  3.9.0           22_linux64_openblas    conda-forge
libclang-cpp18.1          18.1.7          default_h9bb3924_0    conda-forge
libclang13                18.1.7          default_h087397f_0    conda-forge
libcups                   2.3.3                h4637d8d_4    conda-forge
libcurl                   8.8.0                hca28451_1    conda-forge
libdeflate                1.20                 hd590300_0    conda-forge
libdrm                    2.4.122              h4ab18f5_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 hd590300_2    conda-forge
libexpat                  2.6.2                h59595ed_0    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libflac                   1.4.3                h59595ed_0    conda-forge
libgcc-ng                 14.1.0               h77fa898_0    conda-forge
libgcrypt                 1.11.0               h4ab18f5_1    conda-forge
libgettextpo              0.22.5               h59595ed_2    conda-forge
libgettextpo-devel        0.22.5               h59595ed_2    conda-forge
libgfortran-ng            14.1.0               h69a702a_0    conda-forge
libgfortran5              14.1.0               hc5f4f2c_0    conda-forge
libglib                   2.80.2               hf974151_0    conda-forge
libglu                    9.0.0             hac7e632_1003    conda-forge
libgomp                   14.1.0               h77fa898_0    conda-forge
libgpg-error              1.50                 h4f305b6_0    conda-forge
libhwloc                  2.10.0          default_h5622ce7_1001    conda-forge
libiconv                  1.17                 hd590300_2    conda-forge
libidn2                   2.3.7                hd590300_0    conda-forge
libjpeg-turbo             3.0.0                hd590300_1    conda-forge
liblapack                 3.9.0           22_linux64_openblas    conda-forge
libllvm18                 18.1.7               hb77312f_0    conda-forge
libnetcdf                 4.9.2           nompi_h135f659_114    conda-forge
libnghttp2                1.58.0               h47da74e_1    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libogg                    1.3.5                h4ab18f5_0    conda-forge
libopenblas               0.3.27          pthreads_h413a1c8_0    conda-forge
libopenvino               2024.1.0             h2da1b83_7    conda-forge
libopenvino-auto-batch-plugin 2024.1.0             hb045406_7    conda-forge
libopenvino-auto-plugin   2024.1.0             hb045406_7    conda-forge
libopenvino-hetero-plugin 2024.1.0             h5c03a75_7    conda-forge
libopenvino-intel-cpu-plugin 2024.1.0             h2da1b83_7    conda-forge
libopenvino-intel-gpu-plugin 2024.1.0             h2da1b83_7    conda-forge
libopenvino-intel-npu-plugin 2024.1.0             he02047a_7    conda-forge
libopenvino-ir-frontend   2024.1.0             h5c03a75_7    conda-forge
libopenvino-onnx-frontend 2024.1.0             h07e8aee_7    conda-forge
libopenvino-paddle-frontend 2024.1.0             h07e8aee_7    conda-forge
libopenvino-pytorch-frontend 2024.1.0             he02047a_7    conda-forge
libopenvino-tensorflow-frontend 2024.1.0             h39126c6_7    conda-forge
libopenvino-tensorflow-lite-frontend 2024.1.0             he02047a_7    conda-forge
libopus                   1.3.1                h7f98852_1    conda-forge
libpciaccess              0.18                 hd590300_0    conda-forge
libpng                    1.6.43               h2797004_0    conda-forge
libpq                     16.3                 ha72fbe1_0    conda-forge
libprotobuf               4.25.3               h08a7969_0    conda-forge
libraw                    0.21.1               h2a13503_2    conda-forge
libsndfile                1.2.2                hc60ed4a_1    conda-forge
libsqlite                 3.46.0               hde9e2c9_0    conda-forge
libssh2                   1.11.0               h0841786_0    conda-forge
libstdcxx-ng              14.1.0               hc0a3c3a_0    conda-forge
libsystemd0               255                  h3516f8a_1    conda-forge
libtasn1                  4.19.0               h166bdaf_0    conda-forge
libtheora                 1.1.1             h4ab18f5_1006    conda-forge
libtiff                   4.6.0                h1dd3fc0_3    conda-forge
libunistring              0.9.10               h7f98852_0    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libva                     2.21.0               h4ab18f5_2    conda-forge
libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
libvpx                    1.14.1               hac33072_0    conda-forge
libwebp-base              1.4.0                hd590300_0    conda-forge
libxcb                    1.15                 h0b41bf4_0    conda-forge
libxcrypt                 4.4.36               hd590300_1    conda-forge
libxkbcommon              1.7.0                h662e7e4_0    conda-forge
libxml2                   2.12.7               hc051c1a_1    conda-forge
libxslt                   1.1.39               h76b75d6_0    conda-forge
libzip                    1.10.1               h2629f0a_3    conda-forge
libzlib                   1.2.13               h4ab18f5_6    conda-forge
loguru                    0.7.2           py312h7900ff3_1    conda-forge
lxml                      5.2.2           py312hb90d8a5_0    conda-forge
lz4-c                     1.9.4                hcb278e6_0    conda-forge
mpg123                    1.32.6               h59595ed_0    conda-forge
msgpack-python            1.0.8           py312h2492b07_0    conda-forge
multidict                 6.0.5           py312h98912ed_0    conda-forge
mysql-common              8.3.0                hf1915f5_4    conda-forge
mysql-libs                8.3.0                hca2cd23_4    conda-forge
ncurses                   6.5                  h59595ed_0    conda-forge
nettle                    3.9.1                h7ab15ed_0    conda-forge
nlohmann_json             3.11.3               h59595ed_0    conda-forge
numpy                     2.0.0           py312h22e1c76_0    conda-forge
occt                      7.7.2           novtk_h130ccc2_101    conda-forge
ocl-icd                   2.3.2                hd590300_1    conda-forge
omegaconf                 2.3.0              pyhd8ed1ab_0    conda-forge
openexr                   3.2.2                haf962dd_1    conda-forge
openh264                  2.4.1                h59595ed_0    conda-forge
openjpeg                  2.5.2                h488ebb8_0    conda-forge
openssl                   3.3.1                hb9d3cd8_3    conda-forge
p11-kit                   0.24.1               hc5aa10d_0    conda-forge
packaging                 24.1               pyhd8ed1ab_0    conda-forge
pcre2                     10.43                hcad00b1_0    conda-forge
pip                       24.0               pyhd8ed1ab_0    conda-forge
pixman                    0.43.2               h59595ed_0    conda-forge
pluggy                    1.5.0              pyhd8ed1ab_0    conda-forge
proj                      9.3.1                h1d62c97_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pugixml                   1.14                 h59595ed_0    conda-forge
pulseaudio-client         17.0                 hb77b528_0    conda-forge
pydantic                  2.8.2              pyhd8ed1ab_0    conda-forge
pydantic-core             2.20.1          py312hf008fa9_0    conda-forge
pydantic-xml              2.11.0                   pypi_0    pypi
pygments                  2.18.0                   pypi_0    pypi
pytest                    8.2.2              pyhd8ed1ab_0    conda-forge
pytest-cov                5.0.0              pyhd8ed1ab_0    conda-forge
python                    3.12.3          hab00c5b_0_cpython    conda-forge
python-gmsh               4.12.2               h57928b3_0    conda-forge
python_abi                3.12                    4_cp312    conda-forge
pyyaml                    6.0.1           py312h98912ed_1    conda-forge
qt6-main                  6.7.1                h2471661_2    conda-forge
rapidjson                 1.1.0.post20240409      hac33072_1    conda-forge
readline                  8.2                  h8228510_1    conda-forge
scipy                     1.14.0          py312hc2bc53b_0    conda-forge
setuptools                70.1.1             pyhd8ed1ab_0    conda-forge
snappy                    1.2.1                ha2e4443_0    conda-forge
sqlite                    3.46.0               h6d4b2fc_0    conda-forge
svt-av1                   2.1.0                hac33072_0    conda-forge
tbb                       2021.12.0            h297d8ca_1    conda-forge
tbb-devel                 2021.12.0            h7c56ddd_1    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tqdm                      4.66.4             pyhd8ed1ab_0    conda-forge
typing-extensions         4.12.2               hd8ed1ab_0    conda-forge
typing_extensions         4.12.2             pyha770c72_0    conda-forge
tzdata                    2024a                h0c530f3_0    conda-forge
utfcpp                    4.0.5                ha770c72_0    conda-forge
vtk                       9.3.0           qt_py312h1234567_200    conda-forge
vtk-base                  9.3.0           qt_py312h1234567_200    conda-forge
vtk-io-ffmpeg             9.3.0           qt_py312h1234567_200    conda-forge
wayland                   1.23.0               h5291e77_0    conda-forge
wheel                     0.43.0             pyhd8ed1ab_1    conda-forge
wslink                    2.1.1              pyhd8ed1ab_0    conda-forge
x264                      1!164.3095           h166bdaf_2    conda-forge
x265                      3.5                  h924138e_3    conda-forge
xcb-util                  0.4.0                hd590300_1    conda-forge
xcb-util-cursor           0.1.4                hd590300_1    conda-forge
xcb-util-image            0.4.0                h8ee46fc_1    conda-forge
xcb-util-keysyms          0.4.0                h8ee46fc_1    conda-forge
xcb-util-renderutil       0.3.9                hd590300_1    conda-forge
xcb-util-wm               0.4.1                h8ee46fc_1    conda-forge
xkeyboard-config          2.42                 h4ab18f5_0    conda-forge
xorg-fixesproto           5.0               h7f98852_1002    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.1.1                hd590300_0    conda-forge
xorg-libsm                1.2.4                h7391055_0    conda-forge
xorg-libx11               1.8.9                h8ee46fc_0    conda-forge
xorg-libxau               1.0.11               hd590300_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h0b41bf4_2    conda-forge
xorg-libxfixes            5.0.3             h7f98852_1004    conda-forge
xorg-libxmu               1.1.3                h4ab18f5_1    conda-forge
xorg-libxrender           0.9.11               hd590300_0    conda-forge
xorg-libxt                1.3.0                hd590300_1    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-xextproto            7.3.0             h0b41bf4_1003    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
yaml                      0.2.5                h7f98852_2    conda-forge
yarl                      1.9.4           py312h98912ed_0    conda-forge
zipp                      3.19.2             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               h4ab18f5_6    conda-forge
zstd                      1.5.6                ha6fb4c9_0    conda-forge
System Information
OS: Pop!_OS 22.04 LTS x86_64
Kernel: 6.9.3-76060903-generic
@rsokl
Copy link
Contributor

rsokl commented Aug 28, 2024

Thanks for the great bug report. Super easy for me to dig into 👍

Minimal repro of the bug:

from pydantic import BaseModel
from hydra_zen import instantiate, store, builds
from hydra_zen.third_party.pydantic import pydantic_parser

class Input(BaseModel):
    x: int = 1

instantiate(builds(Input, x=1), _target_wrapper_=pydantic_parser)
# raises same error as OP

(Ironic that pydantic's validator can't handle its own types :P)

Here is a temporary workaround:

def my_parser(x):
    if isinstance(target, type) and issubclass(target, BaseModel):
        # this already applies pydantic parsing
        return x
    return pydantic_parser(x)

instantiate(builds(Input, x=1), _target_wrapper_=my_parser)

I will fix pydantic_parser in the next release of hydra-zen

@rsokl rsokl added the bug Something isn't working label Aug 28, 2024
@github-staff github-staff deleted a comment from mayank785 Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants
@siboles @rsokl and others