-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbdffd5
commit 78c6af9
Showing
16 changed files
with
202 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This workflow builds and checks the package for release | ||
name: Build | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- run: pip install tox | ||
|
||
- name: Test build integrity | ||
run: tox -e build | ||
env: | ||
# Use the CPU only version of torch when building/running the code | ||
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Lint | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- run: pip install tox | ||
|
||
- name: Lint the code | ||
run: tox -e lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.0.0-dev" | ||
__version__ = "2023.11.29" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"""The main entry point for the metatensor model interface.""" | ||
import argparse | ||
import sys | ||
|
||
from . import __version__ | ||
from .scripts import evaluate, export, train | ||
|
||
|
||
def main(): | ||
ap = argparse.ArgumentParser( | ||
description=__doc__, | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
|
||
ap.add_argument( | ||
"--version", | ||
action="version", | ||
version=f"metatensor_models {__version__}", | ||
) | ||
|
||
ap.add_argument( | ||
"--debug", | ||
action="store_true", | ||
help="Run with debug options.", | ||
) | ||
|
||
ap.add_argument( | ||
"--logfile", dest="logfile", action="store", help="Logfile (optional)" | ||
) | ||
|
||
subparser = ap.add_subparsers(help="sub-command help") | ||
evaluate_parser = subparser.add_parser( | ||
"evaluate", | ||
help=evaluate.__doc__, | ||
description="evaluate", | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
evaluate_parser.set_defaults(callable="evaluate") | ||
|
||
export_parser = subparser.add_parser( | ||
"export", | ||
help=export.__doc__, | ||
description="export", | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
export_parser.set_defaults(callable="export") | ||
train_parser = subparser.add_parser( | ||
"train", | ||
help=train.__doc__, | ||
description="train", | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
train_parser.set_defaults(callable="train") | ||
|
||
if len(sys.argv) < 2: | ||
ap.error("A subcommand is required.") | ||
|
||
# Be case insensitive for the subcommand | ||
sys.argv[1] = sys.argv[1].lower() | ||
|
||
args = ap.parse_args(sys.argv[1:]) | ||
|
||
if args.callable == "evaluate": | ||
evaluate() | ||
elif args.callable == "export": | ||
export() | ||
elif args.callable == "train": | ||
train() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .evaluate import evaluate | ||
from .export import export | ||
from .train import train | ||
|
||
__all__ = ["evaluate", "export", "train"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def evaluate(): | ||
"""evaluate a model""" | ||
print("Run evaluate...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def export(): | ||
"""export a model""" | ||
print("Run exort...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def train(): | ||
"""train a model""" | ||
print("Run train...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import subprocess | ||
import sys | ||
|
||
import pytest | ||
|
||
from metatensor_models.scripts import __all__ as available_scripts | ||
|
||
|
||
class Test_parse_args(object): | ||
"""Tests for argument parsing.""" | ||
|
||
def test_required_args(self): | ||
"""Test required arguments.""" | ||
with pytest.raises(subprocess.CalledProcessError): | ||
subprocess.check_call(["metatensor_models"]) | ||
|
||
def test_wrong_module(self): | ||
"""Test wrong module.""" | ||
with pytest.raises(subprocess.CalledProcessError): | ||
subprocess.check_call(["metatensor_models", "foo"]) | ||
|
||
@pytest.mark.parametrize("module", tuple(available_scripts)) | ||
def test_available_modules(self, module): | ||
"""Test available modules.""" | ||
subprocess.check_call(["metatensor_models", module, "--help"]) | ||
|
||
@pytest.mark.parametrize("args", ("version", "help")) | ||
def test_extra_options(self, args): | ||
"""Test extra options.""" | ||
subprocess.check_call(["metatensor_models", "--" + args]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters