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

ORM: Remove pymatgen version check in StructureData.set_pymatgen_structure #5777

Merged
merged 3 commits into from
Nov 17, 2022

Conversation

unkcpz
Copy link
Member

@unkcpz unkcpz commented Nov 17, 2022

Don't know what happened exactly, but if I don't do this, I'll get the exception:

...
 File "/home/jovyan/aiida-core/aiida/orm/nodes/data/cif.py", line 764, in get_structure
    result = convert_function(cif=self, parameters=parameters, metadata={'store_provenance': store})
  File "/home/jovyan/aiida-core/aiida/engine/processes/functions.py", line 179, in decorated_function
    result, _ = run_get_node(*args, **kwargs)
  File "/home/jovyan/aiida-core/aiida/engine/processes/functions.py", line 152, in run_get_node
    result = process.execute()
  File "/home/jovyan/aiida-core/aiida/engine/processes/functions.py", line 366, in execute
    result = super().execute()
  File "/opt/conda/lib/python3.9/site-packages/plumpy/processes.py", line 86, in func_wrapper
    return func(self, *args, **kwargs)
  File "/opt/conda/lib/python3.9/site-packages/plumpy/processes.py", line 1172, in execute
    return self.future().result()
  File "/opt/conda/lib/python3.9/site-packages/plumpy/process_states.py", line 228, in execute
    result = self.run_fn(*self.args, **self.kwargs)
  File "/home/jovyan/aiida-core/aiida/engine/processes/functions.py", line 410, in run
    result = self._func(*args, **kwargs)
  File "/home/jovyan/aiida-core/aiida/tools/data/cif.py", line 152, in _get_aiida_structure_pymatgen_inline
    return {'structure': StructureData(pymatgen_structure=structures[0])}
  File "/home/jovyan/aiida-core/aiida/orm/nodes/data/structure.py", line 742, in __init__
    self.set_pymatgen_structure(pymatgen_structure)
  File "/home/jovyan/aiida-core/aiida/orm/nodes/data/structure.py", line 827, in set_pymatgen_structure
    from pkg_resources import parse_version
  File "/opt/conda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3268, in <module>
    def _initialize_master_working_set():
  File "/opt/conda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3251, in _call_aside
    f(*args, **kwargs)
  File "/opt/conda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3293, in _initialize_master_working_set
    tuple(
  File "/opt/conda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3294, in <genexpr>
    dist.activate(replace=False)
  File "/opt/conda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2805, in activate
    declare_namespace(pkg)
  File "/opt/conda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2304, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/opt/conda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2221, in _handle_ns
    loader = importer.find_module(packageName)
  File "<frozen importlib._bootstrap_external>", line 493, in _find_module_shim
  File "<frozen importlib._bootstrap_external>", line 1428, in find_loader
  File "<frozen importlib._bootstrap_external>", line 1473, in find_spec
  File "<frozen importlib._bootstrap_external>", line 64, in _path_join
  File "<frozen importlib._bootstrap_external>", line 64, in <listcomp>
AttributeError: 'PosixPath' object has no attribute 'rstrip'

@sphuber
Copy link
Contributor

sphuber commented Nov 17, 2022

I think we can just remove the version check, since we require pymatgen>=2019.7.2 in the pyproject.toml. So just always use the case with the new feature, and then you can get rid of the version check entirely.

@unkcpz
Copy link
Member Author

unkcpz commented Nov 17, 2022

@sphuber thanks! I'll update this PR for it.

@unkcpz unkcpz requested a review from sphuber November 17, 2022 13:24
@sphuber sphuber changed the title Move pkg_resources to head of import ORM: Remove pymatgen version check in StructureData.set_pymatgen_structure Nov 17, 2022
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @unkcpz

@sphuber sphuber merged commit 6071d32 into aiidateam:main Nov 17, 2022
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

Successfully merging this pull request may close these issues.

2 participants