Skip to content

Commit

Permalink
Merge pull request #302 from hatemhelal/checks
Browse files Browse the repository at this point in the history
Adding pre-commit checks and github action runners
  • Loading branch information
ilyes319 authored Mar 27, 2024
2 parents 969081a + 52abffe commit f690a7f
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflow/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on: []
# branches: []
# pull_request:
# branches: []


jobs:
build-linux:
Expand Down Expand Up @@ -43,4 +43,4 @@ jobs:
# run: mypy --config-file=.mypy.ini .

- name: Test with pytest
run: python -m pytest tests
run: python -m pytest tests
14 changes: 14 additions & 0 deletions .github/workflow/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Pre-Commit Checks

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
29 changes: 29 additions & 0 deletions .github/workflow/unittest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: unit tests
on:
pull_request:
push:
branches: [main]

jobs:
pytest-container:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"

- name: Install requirements
run: |
pip install -U pip
pip install .[dev]
- name: Log installed environment
run: |
python3 -m pip freeze
- name: Run unit tests
run: |
pytest tests
50 changes: 50 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
hooks:
- id: black
name: Black Formating

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: Sort imports

# Failing - to be investigated separately
# - repo: local
# hooks:
# - id: pylint
# name: Pylint Checks
# entry: pylint
# language: system
# types: [python]
# args:
# [
# "--rcfile=pyproject.toml",
# "mace",
# "tests",
# "scripts"
# ]

# - repo: local
# hooks:
# - id: mypy
# name: mypy type checks
# entry: mypy
# language: system
# types: [python]
# args:
# [
# --config-file=.mypy.ini,
# mace,
# tests,
# scripts
# ]

18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ mace_eval_configs \

## Tutorial

You can run our [Colab tutorial](https://colab.research.google.com/drive/1D6EtMUjQPey_GkuxUAbPgld6_9ibIa-V?authuser=1#scrollTo=Z10787RE1N8T) to quickly get started with MACE.
You can run our [Colab tutorial](https://colab.research.google.com/drive/1D6EtMUjQPey_GkuxUAbPgld6_9ibIa-V?authuser=1#scrollTo=Z10787RE1N8T) to quickly get started with MACE.

We also have a more detailed user and developer tutorial at https://github.com/ilyes319/mace-tutorials

Expand Down Expand Up @@ -203,7 +203,7 @@ print(atoms.get_potential_energy())

### MACE-OFF: Transferable Organic Force Fields

There is a series (small, medium, large) transferable organic force fields. These can be used for the simulation of organic molecules, crystals and molecular liquids, or as a starting point for fine-tuning on a new dataset. The models are released under the [ASL license](https://github.com/gabor1/ASL).
There is a series (small, medium, large) transferable organic force fields. These can be used for the simulation of organic molecules, crystals and molecular liquids, or as a starting point for fine-tuning on a new dataset. The models are released under the [ASL license](https://github.com/gabor1/ASL).
The models are releaed on GitHub at https://github.com/ACEsuit/mace-off.
If you use them please cite [our paper](https://arxiv.org/abs/2312.15211) which also contains detailed benchmarks and example applications.

Expand All @@ -220,13 +220,15 @@ print(atoms.get_potential_energy())

## Development

We use `black`, `isort`, `pylint`, and `mypy`.
Run the following to format and check your code:

```sh
bash ./scripts/run_checks.sh
This project uses [pre-commit](https://pre-commit.com/) to execute code formatting and linting on commit.
We also use `black`, `isort`, `pylint`, and `mypy`.
We recommend setting up your development environment by installing the `dev` packages
into your python environment:
```bash
pip install -e ".[dev]"
pre-commit install
```

The second line will initialise `pre-commit` to automaticaly run code checks on commit.
We have CI set up to check this, but we _highly_ recommend that you run those commands
before you commit (and push) to avoid accidentally committing bad code.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ disable = [
ignore-paths = [
"^mace/tools/torch_geometric/.*$",
"^mace/tools/scatter.py$",
]
]
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ console_scripts =

[options.extras_require]
wandb = wandb
dev =
black
isort
mypy
pre-commit
pytest
pylint
2 changes: 1 addition & 1 deletion tests/test_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import ase.io
import numpy as np
import pytest
from ase import build
from ase.atoms import Atoms
from ase.calculators.test import gradient_test
from ase.constraints import ExpCellFilter
from ase import build

from mace.calculators import mace_mp, mace_off
from mace.calculators.foundations_models import local_model_path
Expand Down

0 comments on commit f690a7f

Please sign in to comment.