Skip to content

Commit

Permalink
Handle import errors from MACE
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed May 3, 2024
1 parent 1c36d1c commit 754fc8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions janus_core/cli/janus.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
from janus_core.cli.geomopt import geomopt
from janus_core.cli.md import md
from janus_core.cli.singlepoint import singlepoint
from janus_core.cli.train import train

app = Typer(name="janus", no_args_is_help=True)
app.command()(singlepoint)
app.command()(geomopt)
app.command()(md)
app.command()(train)
# Train not imlpemented in older versions of MACE
try:
from janus_core.cli.train import train

app.command()(train)
except NotImplementedError:
pass


@app.callback(invoke_without_command=True, help="")
Expand Down
5 changes: 4 additions & 1 deletion janus_core/helpers/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from pathlib import Path
from typing import Optional

from mace.cli.run_train import run as run_train
try:
from mace.cli.run_train import run as run_train
except ImportError as e:
raise NotImplementedError("Please update MACE to use this module.") from e
from mace.tools import build_default_arg_parser as mace_parser
import yaml

Expand Down

0 comments on commit 754fc8f

Please sign in to comment.