Skip to content

Commit 49f9581

Browse files
Remove circular dependence from MP software stack (#532)
* remove circular software dependence (robocrys depends on mp_api, mp_api on emmet-core, emmet-core on robocrys through extras) added by switching from pymatgen to mp_api * organize tests / test data outside package / change formula_db.json.gz format to save disk space * update / run precommit * disable progress bar in matminer json loading
1 parent d51b9d1 commit 49f9581

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+163
-82
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
run: |
1919
conda install --quiet --yes -c conda-forge openbabel pip ruamel.yaml
2020
pip install -r requirements.txt
21-
pip install -e .[tests]
21+
pip install -e .[tests,cli]
2222
2323
- name: Test
24-
run: pytest --cov=robocrys --cov-report=xml --cov-config=.coveragerc
24+
run: pytest --cov=robocrys --cov-report=xml --cov-config=.coveragerc tests/
2525

2626
docs:
2727
runs-on: ubuntu-latest
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
python -m pip install --upgrade pip
3939
pip install -r requirements.txt
40-
pip install -e .[docs]
40+
pip install -e .[docs,cli]
4141
4242
- name: Build
4343
run: sphinx-build docs/src docs_build

.pre-commit-config.yaml

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,49 @@
1+
exclude: ^(docs|tests|dev_scripts|.github)
2+
3+
default_language_version:
4+
python: python3.11
5+
6+
ci:
7+
autoupdate_schedule: yearly
8+
skip: [flake8, autoflake, mypy]
9+
110
repos:
2-
- repo: https://github.com/myint/autoflake
3-
rev: v1.4
11+
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.4.3
414
hooks:
5-
- id: autoflake
6-
args: [--in-place, --remove-all-unused-imports, --remove-unused-variable, --ignore-init-module-imports]
15+
- id: ruff
16+
args: [--fix, --unsafe-fixes]
17+
718
- repo: https://github.com/psf/black
8-
rev: 21.4b2
19+
rev: 24.2.0
920
hooks:
10-
- id: black
11-
- repo: https://gitlab.com/pycqa/flake8
12-
rev: 3.9.1
13-
hooks:
14-
- id: flake8
15-
args: [--max-line-length=125, "--extend-ignore=E203,W503"]
16-
language_version: python3
21+
- id: black
22+
1723
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v3.4.0
24+
rev: v4.5.0
1925
hooks:
2026
- id: check-yaml
2127
- id: end-of-file-fixer
2228
- id: trailing-whitespace
23-
- repo: https://github.com/pycqa/isort
24-
rev: 5.8.0
29+
30+
- repo: https://github.com/PyCQA/autoflake
31+
rev: v2.3.0
32+
hooks:
33+
- id: autoflake
34+
args:
35+
- --in-place
36+
- --remove-unused-variables
37+
- --remove-all-unused-imports
38+
- --expand-star-imports
39+
- --ignore-init-module-imports
40+
41+
- repo: https://github.com/pre-commit/mirrors-mypy
42+
rev: v1.8.0
2543
hooks:
26-
- id: isort
27-
name: isort (python)
28-
args: [--profile=black]
44+
- id: mypy
45+
files: ^pymatgen/
46+
args:
47+
- --namespace-packages
48+
- --explicit-package-bases
49+
additional_dependencies: ['types-requests']

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ matminer==0.9.2
88
monty==2024.7.30
99
pubchempy==1.0.4
1010
pybtex==0.24.0
11-
mp-api==0.42.2
12-
boto3

robocrys/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
isort:skip_file
44
"""
5+
56
from __future__ import annotations
67

78
from robocrys._version import __version__

robocrys/adapter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""This module implements a class to resolve the symbolic references in condensed
22
structure data.
33
"""
4+
45
from __future__ import annotations
56

67
from typing import Any

robocrys/cli.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
"""This module contains a script for using robocrys from the command line."""
2+
23
from __future__ import annotations
34

45
import argparse
56
import sys
67
import warnings
78

89
from pymatgen.core.structure import Structure
9-
from mp_api.client import MPRestError
10+
11+
try:
12+
from mp_api.client import MPRestError
13+
except ImportError:
14+
MPRestError = None
1015

1116
from robocrys import StructureCondenser, StructureDescriber, __version__
1217

@@ -210,6 +215,13 @@ def main():
210215

211216
except FileNotFoundError:
212217
if args.filename[:3] in ["mp-", "mvc"]:
218+
219+
if MPRestError is None:
220+
raise ImportError(
221+
"Please install the Materials Project API using"
222+
"`pip install mp_api`"
223+
)
224+
213225
from mp_api.client import MPRester
214226

215227
mpr = MPRester(args.api_key)

robocrys/condense/component.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module implements functions for handling structure components."""
2+
23
from __future__ import annotations
34

45
from copy import deepcopy

robocrys/condense/condenser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module defines a class for condensing structures into dict representations."""
2+
23
from __future__ import annotations
34

45
from typing import TYPE_CHECKING, Any
-174 KB
Binary file not shown.

robocrys/condense/mineral.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
):
6363
self.mineral_db = mineral_db if mineral_db is not None else _mineral_db_file
6464
if isinstance(self.mineral_db, (str, Path)):
65-
self.mineral_db = load_dataframe_from_json(self.mineral_db)
65+
self.mineral_db = load_dataframe_from_json(self.mineral_db, pbar=False)
6666

6767
self.initial_ltol = initial_ltol
6868
self.initial_stol = initial_stol

0 commit comments

Comments
 (0)