Skip to content

Commit

Permalink
Update MACE (#352)
Browse files Browse the repository at this point in the history
* Update MACE

* Fix tests

* Fix log for non-strings

* Update gitignore

* Fix log test when message is None

---------

Co-authored-by: ElliottKasoar <[email protected]>
  • Loading branch information
ElliottKasoar and ElliottKasoar authored Nov 18, 2024
1 parent 563742a commit 2f5976c
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*.png
*.svg
*.xz
*.txt
~*
*~
.project
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Tools for machine learnt interatomic potentials

- Python >= 3.9
- ASE >= 3.23
- mace-torch = 0.3.6
- mace-torch = 0.3.8
- chgnet = 0.3.8 (optional)
- matgl = 1.1.3 (optional)
- sevenn = 0.10.0 (optional)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Dependencies

- Python >= 3.9
- ASE >= 3.23
- mace-torch = 0.3.6
- mace-torch = 0.3.8
- chgnet = 0.3.8 (optional)
- matgl = 1.1.3 (optional)
- sevenn = 0.10.0 (optional)
Expand Down
1 change: 1 addition & 0 deletions janus_core/helpers/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def format(self, record: logging.LogRecord) -> str:
Formatted log message.
"""
# Parse JSON dump from codecarbon
record.msg = str(record.msg)
if len(record.msg) > 1 and (record.msg[0] == "{" and record.msg[-1] == "}"):
msg_dict = json.loads(record.msg)
record.msg = ""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ janus = "janus_core.cli.janus:app"
[tool.poetry.dependencies]
ase = "^3.23"
codecarbon = "^2.5.0"
mace-torch = "0.3.6"
mace-torch = "0.3.8"
numpy = "^1.26.4"
phonopy = "^2.23.1"
python = "^3.9"
Expand Down
Binary file added tests/models/MACE-OFF23_small.model
Binary file not shown.
4 changes: 3 additions & 1 deletion tests/test_single_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def test_single_point_molecule(tmp_path):
assert atoms.info["mace_energy"] == pytest.approx(-14.035236305927514)
assert "mace_forces" in atoms.arrays
assert "mace_stress" in atoms.info
assert atoms.info["mace_stress"] == pytest.approx([0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
assert atoms.info["mace_stress"] == pytest.approx(
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], abs=1e-5
)


def test_invalid_prop():
Expand Down
4 changes: 3 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def assert_log_contains(
with open(log_path, encoding="utf8") as log_file:
logs = yaml.safe_load(log_file)
# Nested join as log["message"] may be a list
messages = "".join("".join(log["message"]) for log in logs)
messages = "".join(
"".join(log["message"]) if log["message"] else "" for log in logs
)

assert all(inc in messages for inc in includes)
assert all(exc not in messages for exc in excludes)
Expand Down

0 comments on commit 2f5976c

Please sign in to comment.