nomad-coe / nomad

NOMAD lets you manage and share your materials science data in a way that makes it truly useful to you, your group, and the community.
https://nomad-lab.eu
Apache License 2.0
64 stars 14 forks source link

nomad dev search-quantities fails with "TypeError: _evaluate() missing 1 required positional argument: 'recursive_guard'" #9

Closed ondracka closed 3 years ago

ondracka commented 3 years ago

Some quick googling suggests this is a python 3.9 compatibility issue?

nomad dev search-quantities > gui/src/searchQuantities.json
Traceback (most recent call last):
  File "/home/ondracka/software/nomad/nomad/cli/lazy_import.py", line 107, in _actually_import
    importlib.reload(module)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 613, in _exec
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/ondracka/software/nomad/nomad/search.py", line 34, in <module>
    from nomad.app.v1 import models as api_models
  File "/home/ondracka/software/nomad/nomad/app/v1/models.py", line 146, in <module>
    And.update_forward_refs()
  File "/home/ondracka/software/.pyenv/lib/python3.9/site-packages/pydantic/main.py", line 677, in update_forward_refs
    update_field_forward_refs(f, globalns=globalns, localns=localns)
  File "/home/ondracka/software/.pyenv/lib/python3.9/site-packages/pydantic/typing.py", line 233, in update_field_forward_refs
    field.type_ = evaluate_forwardref(field.type_, globalns, localns or None)
  File "/home/ondracka/software/.pyenv/lib/python3.9/site-packages/pydantic/typing.py", line 50, in evaluate_forwardref
    return type_._evaluate(globalns, localns)
TypeError: _evaluate() missing 1 required positional argument: 'recursive_guard'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ondracka/software/.pyenv/bin/nomad", line 12, in <module>
    sys.exit(run_cli())
  File "/home/ondracka/software/nomad/nomad/cli/cli.py", line 115, in run_cli
    return cli()  # pylint: disable=E1120,E1123
  File "/home/ondracka/software/.pyenv/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/ondracka/software/.pyenv/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/ondracka/software/nomad/nomad/cli/cli.py", line 69, in invoke
    return super().invoke(ctx)
  File "/home/ondracka/software/.pyenv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ondracka/software/nomad/nomad/cli/cli.py", line 69, in invoke
    return super().invoke(ctx)
  File "/home/ondracka/software/.pyenv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ondracka/software/nomad/nomad/cli/cli.py", line 39, in invoke
    return super().invoke(ctx)
  File "/home/ondracka/software/.pyenv/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ondracka/software/.pyenv/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/ondracka/software/nomad/nomad/cli/cli.py", line 35, in lazy_callback
    return self.orig_callback(*args, **kwargs)
  File "/home/ondracka/software/nomad/nomad/cli/dev.py", line 128, in search_quantities
    for search_quantity in search.search_quantities.values()
  File "/home/ondracka/software/nomad/nomad/cli/lazy_import.py", line 68, in __getattribute__
    _actually_import(self.__name__)
  File "/home/ondracka/software/nomad/nomad/cli/lazy_import.py", line 111, in _actually_import
    raise LazyImportError(err_msg)
nomad.cli.lazy_import.LazyImportError: Error occured during loading of lazy module nomad.search: _evaluate() missing 1 required positional argument: 'recursive_guard'
markus1978 commented 3 years ago

Thanks for the report. We have not yet looked at 3.9. Our official support is for 3.7. We have good experiences with 3.8 as well.

We will look into this. In the mean time, we recommend using pyenv to use 3.7.

ondracka commented 3 years ago

Right, how about some improvements to the howto than (how to force a specific python version with the virtualenv), because I did the pyenv setup as suggested at: https://nomad-lab.eu/prod/rae/docs/developers.html#

pip install virtualenv
virtualenv -p `which python3` .pyenv
source .pyenv/bin/activate

and still somehow ended with the python 3.9?

markus1978 commented 3 years ago

I feel you. I get confused using pyenv myself. The bottom line is that -p needs to get the path to the python binary you actually want to use. We can try to add a command sequence for pyenv users to the documentation.

markus1978 commented 3 years ago

We resolved the mentioned python 3.9 issue. It was caused by an outdated dependency forcing installation of an outdated pydantic version. The fix will be part of the next NOMAD patch release (0.10.3).