Closed ericpre closed 1 year ago
I just tried it myself and could reproduce it. You can quickly fix it with
pip install pydantic==1.10.9
Ignore the dependency error.
I will try to look into this in more detail. We are planning a new release for the nomad-lab package soon and a proper fix will be included.
Thanks, it helps to get one step further but I am hitting another issue with magic
library being missing - the python wrapper is installed but not the C library. As this is no build for windows on conda-forge, it will most likely not be easy to install on windows.
==================================================================================== test session starts =====================================================================================
platform win32 -- Python 3.9.16, pytest-7.4.0, pluggy-1.2.0 -- C:\Users\M0041User\mambaforge\envs\nomad\python.exe
cachedir: .pytest_cache
rootdir: nomad-schema-plugin-example
plugins: anyio-3.7.1
collected 1 item
tests/test_schema.py::test_schema FAILED
========================================================================================== FAILURES ==========================================================================================
________________________________________________________________________________________ test_schema _________________________________________________________________________________________
def test_schema():
test_file = os.path.join(os.path.dirname(__file__), 'data', 'test.archive.yaml')
> entry_archive = parse(test_file)[0]
tests\test_schema.py:6:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\..\mambaforge\envs\nomad\lib\site-packages\nomad\client\processing.py:50: in parse
parser, mainfile_keys = parsers.match_parser(mainfile_path, strict=strict, parser_name=parser_name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
mainfile_path = 'C:\\Users\\M0041User\\OneDrive - UK Atomic Energy Authority\\MBU Corrosion database\\NOMAD_plugin\\nomad-schema-plugin-example\\tests\\data\\test.archive.yaml', strict = True
parser_name = None
def match_parser(mainfile_path: str, strict=True, parser_name: str = None) -> Tuple[Parser, List[str]]:
'''
Performs parser matching. This means it take the given mainfile and potentially
opens it with the given callback and tries to identify a parser that can parse
the file.
This is determined by filename (e.g. *.out), mime type (e.g. text/*, application/xml),
and beginning file contents.
Arguments:
mainfile_path: Path to the mainfile
strict: Only match strict parsers, e.g. no artificial parsers for missing or empty entries.
parser_name: Optional, to force the matching to test only a specific parser
Returns:
A tuple (`parser`, `mainfile_keys`). The `parser` is the matched parser, and
`mainfile_keys` defines the keys to use for child entries, if any. If there are
no child entries, `mainfile_keys` will be None. If no parser matches, we return
(None, None).
'''
mainfile = os.path.basename(mainfile_path)
if mainfile.startswith('.') or mainfile.startswith('~'):
return None, None
with open(mainfile_path, 'rb') as f:
> compression, open_compressed = _compressions.get(f.read(3), (None, open))
E NameError: name '_compressions' is not defined
..\..\..\..\mambaforge\envs\nomad\lib\site-packages\nomad\parsing\parsers.py:77: NameError
====================================================================================== warnings summary ======================================================================================
..\..\..\..\mambaforge\envs\nomad\lib\site-packages\nomad\config\models.py:26
C:\Users\M0041User\mambaforge\envs\nomad\lib\site-packages\nomad\config\models.py:26: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import get_distribution, DistributionNotFound
..\..\..\..\mambaforge\envs\nomad\lib\site-packages\pkg_resources\__init__.py:2871
C:\Users\M0041User\mambaforge\envs\nomad\lib\site-packages\pkg_resources\__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ===================================================================================
FAILED tests/test_schema.py::test_schema - NameError: name '_compressions' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================================== 1 failed, 2 warnings in 5.51s ================================================================================
There is this extra package with the needed .dll that is described in the python-magic docs. https://pypi.org/project/python-magic/
I can't test it though. The only experience I have is with people using WSL and here libmagic seemed to be present.
Sorry, I missed the relevant part of the installation of python-magic
for windows! :man_facepalming: It is possible to install the binaries using pip install python-magic-bin
and it works fine! I tend to be bit suspicious when installing binaries from pypi but it seems works fine.
I can run the tests now! :)
I have installed this example and tried to run the tests but I have the following error:
pip list:
Any idea what causes the issue? Thanks!