Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ jobs:
name: Check coding style
runs-on: ubuntu-latest
steps:
# clone repo and check out
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Check that all Python code is linted with black
run: pip install black && black . --check
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install the project
run: uv sync --all-extras --dev

- name: Lint the project
run: uv run ruff check && uv run ruff format --check
28 changes: 13 additions & 15 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", 3.11]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install . --upgrade
- name: Test with pytest
run: |
pytest
- uses: actions/checkout@v4

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install the project
run: uv sync --all-extras --dev

- name: Test with pytest
run: uv run pytest
17 changes: 0 additions & 17 deletions Pipfile

This file was deleted.

924 changes: 0 additions & 924 deletions Pipfile.lock

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ Tools to easly schedule atomistic simulation workflow. Docs available at [readth

## Installation

The package can be installed with [uv](https://docs.astral.sh/uv/):

```sh
git clone https://github.com/SINGROUP/Runner.git
cd Runner
pip install . --upgrade
uv sync
```
12 changes: 6 additions & 6 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Installation
Requirements
====================

* Python_ 3.6 or newer
* ASE_ 3.19 or newer
* Python_ 3.10 or newer
* ASE_ 3.22.1 or older

.. _Python: https://www.python.org/
.. _ASE: https://wiki.fysik.dtu.dk/ase/index.html
Expand All @@ -23,15 +23,15 @@ installed during setup.
:git:

The source is available on `github <https://github.com/SINGROUP/Runner>`_,
which can be installed as::
which can be installed using `uv <https://docs.astral.sh/uv/>`_ as::

$ git clone https://github.com/SINGROUP/Runner.git
$ cd Runner
$ pip install . --upgrade
$ uv sync


To update the installation::
To use familiar `pip` workflow::

$ cd Runner
$ git pull
$ pip install . --upgrade
$ uv pip install . --upgrade
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[project]
name = "Runner"
version = "0.1.0"
description = "Tools to easly schedule atomistic simulation workflow"
readme = "README.md"
authors = [
{ name = "Yashasvi S. Ranawat", email = "yashasvi.ranawat@gmail.com" }
]
requires-python = ">=3.10"
dependencies = [
"ase==3.22.1",
"docutils>=0.3",
"numpy>=2.2.3",
"psutil>=7.0.0",
]

[project.scripts]
runner = "runner.cli:main"

[dependency-groups]
dev = [
"pytest>=8.3.4",
"ruff>=0.9.9",
"sphinx>=8.1.3",
"sphinx-rtd-theme>=3.0.2",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.ruff]
line-length = 88

[tool.ruff.lint]
select = ["F", "I", "E"]
8 changes: 3 additions & 5 deletions runner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""__init__ for runner"""
from runner.runners import SlurmRunner
from runner.runners import TerminalRunner
from runner.relay import Relay

from runner import utils
from runner.relay import Relay
from runner.runners import SlurmRunner, TerminalRunner
from runner.utils.runnerdata import RunnerData


__all__ = ["SlurmRunner", "TerminalRunner", "RunnerData", "utils", "Relay"]
__version__ = "0.1"
24 changes: 9 additions & 15 deletions runner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
"""

import argparse
import textwrap

from ase.db import connect
from ase.io.formats import string2index

from runner.runners.__init__ import runner_type2func
from runner.utils import (
submit,
cancel,
get_status,
get_graphical_status,
get_runner_list,
get_status,
remove_runner,
stop_runner,
submit,
)


Expand Down Expand Up @@ -100,7 +103,7 @@ def add_arguments(parser):

# stop runner
desc = "Stop a runner from metadata."
add = "Runner isn't stopped immediately, but after completing spool" "process."
add = "Runner isn't stopped immediately, but after completing spool process."
subparser = subparsers.add_parser(
"stop",
formatter_class=Formatter,
Expand All @@ -113,10 +116,7 @@ def add_arguments(parser):

# submit a row
desc = "Submit row(s) for run."
add = (
"Row ids can be int or python like"
" slice, eg. '1:4' gives ids 1, 2, and 3"
)
add = "Row ids can be int or python like slice, eg. '1:4' gives ids 1, 2, and 3"
subparser = subparsers.add_parser(
"submit",
formatter_class=Formatter,
Expand All @@ -140,10 +140,7 @@ def add_arguments(parser):

# cancel a submitted row
desc = "Cancel row(s) for run."
add = (
"Row ids can be int or python like"
" slice, eg. '1:4' gives ids 1, 2, and 3"
)
add = "Row ids can be int or python like slice, eg. '1:4' gives ids 1, 2, and 3"
subparser = subparsers.add_parser(
"cancel",
formatter_class=Formatter,
Expand All @@ -170,10 +167,7 @@ def add_arguments(parser):

# check status of a row
desc = "Check running status of row(s)"
add = (
"Row ids can be int or python like"
" slice, eg. '1:4' gives ids 1, 2, and 3"
)
add = "Row ids can be int or python like slice, eg. '1:4' gives ids 1, 2, and 3"
subparser = subparsers.add_parser(
"status",
formatter_class=Formatter,
Expand Down
33 changes: 15 additions & 18 deletions runner/relay.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
"""
Relay to form complex workflows
"""
import time

import json
import time
from copy import deepcopy

import numpy as np
from ase import Atoms
from ase import db
from runner.utils import submit, cancel, get_graphical_status
from runner.utils.runnerdata import RunnerData
from ase import Atoms, db

from runner.runners import runner_types
from runner.utils import cancel, get_graphical_status, submit
from runner.utils.runnerdata import RunnerData


class Relay:
Expand Down Expand Up @@ -125,17 +127,15 @@ def commit(self, database=None):
if database is None:
if self._database is None:
raise RuntimeError(
f"{self.__str__()} needs a"
f" database for commit. No previous"
f" database commits."
f"{self.__str__()} needs a database for commit. "
f"No previous database commits."
)
database = self._database
elif self._database is not None:
if self._database != database:
raise RuntimeError(
f"{self.__str__()} already commited with"
f" {self._database}, cannot commit with"
f" {database}"
f"{self.__str__()} already commited with {self._database}, "
f"cannot commit with {database}"
)

# recursively commit parents
Expand All @@ -153,9 +153,8 @@ def commit(self, database=None):

if status in ["submit", "running", "cancel"]:
raise RuntimeError(
f"cannot commit {self.__str__()}. It is "
f"either submitted, running, or being"
f" cancelled."
f"cannot commit {self.__str__()}. It is either submitted, "
f"running, or being cancelled."
)

with db.connect(database) as fdb:
Expand Down Expand Up @@ -400,7 +399,7 @@ def get_row(self, cycle_time=10, wait=True):

row = property(
get_row,
doc=("Atoms row attached with the relay, awaits " "for the run to finish"),
doc=("Atoms row attached with the relay, awaits for the run to finish"),
)

def _to_dict(self):
Expand Down Expand Up @@ -586,9 +585,7 @@ def _spider(self, dict_=None, parent_call=None):
if isinstance(parent, Relay):
if parent.id_ not in dict_:
if parent.id_ in parent_call:
raise RuntimeError(
"Cyclic connection detected." " Abandon ship!"
)
raise RuntimeError("Cyclic connection detected. Abandon ship!")
dict_[parent.id_] = parent

dict_ = parent._spider(dict_, parent_call)
Expand Down
Loading