-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make sure code runs with python 3.9
To make the installation easier, drop clapper dependency and test against python 3.9 Also point to stable docs.
- Loading branch information
Showing
9 changed files
with
168 additions
and
154 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 |
---|---|---|
|
@@ -18,5 +18,5 @@ jobs: | |
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
python-version: "3.9" | ||
- uses: pre-commit/[email protected] |
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ SPDX-FileContributor: Amir Mohammadi <[email protected]> | |
SPDX-License-Identifier: GPL-3.0-or-later | ||
--> | ||
|
||
[![latest-docs](https://img.shields.io/badge/docs-latest-orange.svg)](https://gridtk.readthedocs.io/en/latest/) | ||
[![docs](https://img.shields.io/badge/docs-stable-orange.svg)](https://gridtk.readthedocs.io/en/stable/) | ||
[![build](https://github.com/idiap/gridtk/actions/workflows/build.yml/badge.svg)](https://github.com/idiap/gridtk/actions/workflows/build.yml) | ||
[![coverage](https://raw.githubusercontent.com/idiap/gridtk/python-coverage-comment-action-data/badge.svg)](https://htmlpreview.github.io/?https://github.com/idiap/gridtk/blob/python-coverage-comment-action-data/htmlcov/index.html) | ||
[![repository](https://img.shields.io/badge/github-project-0000c0.svg)](https://github.com/idiap/gridtk) | ||
|
@@ -26,22 +26,20 @@ installation, submission, monitoring, and various commands provided by GridTK. | |
Before diving into GridTK, ensure you have the following prerequisites: | ||
|
||
1. A working SLURM setup. | ||
2. [Pixi](https://pixi.sh) installed. | ||
2. [pipx](https://pipx.pypa.io/stable/) installed. | ||
3. GridTK installed (instructions provided below). | ||
|
||
## Installation | ||
|
||
To install GridTK, open your terminal and run the following command: | ||
|
||
```bash | ||
$ pixi global install pipx | ||
$ pixi global install python=3.12 | ||
$ pipx install --force --python python3.12 'git+https://github.com/idiap/gridtk.git' | ||
$ pipx install gridtk | ||
``` | ||
It is **not recommennded** to install GridTK using `pip install gridtk` in the | ||
same environment as your expeirments. GirdTK does not need to be installed in | ||
the same environment as your experiments and its depencencies may conflict with | ||
your experiments. | ||
your experiments' dependencies. | ||
|
||
## Basic Usage | ||
|
||
|
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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# SPDX-FileContributor: Amir Mohammadi <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
"""Implements a Slurm job manager. Jobs are kept track of in an SQL database | ||
and logs are written to a default logs folder. | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# SPDX-FileContributor: Amir Mohammadi <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import json | ||
import re | ||
import shlex | ||
|
@@ -11,6 +12,7 @@ | |
|
||
from pathlib import Path | ||
from sqlite3 import Connection as SQLite3Connection | ||
from typing import Optional | ||
|
||
from sqlalchemy import Column, ForeignKey, Integer, String, Table, event | ||
from sqlalchemy.engine import Engine | ||
|
@@ -80,7 +82,7 @@ class ObjectValue(TypeDecorator): | |
|
||
def process_bind_param(self, value, dialect): | ||
if value is not None: | ||
if isinstance(value, dict | list | tuple): | ||
if isinstance(value, (dict, list, tuple)): | ||
value = json.dumps(value) | ||
elif isinstance(value, Path): | ||
value = str(value.absolute()) | ||
|
@@ -141,12 +143,12 @@ class Job(Base): | |
command: Mapped[list] = mapped_column(ObjectValue) | ||
logs_dir: Mapped[Path] = mapped_column(ObjectValue) | ||
is_array_job: Mapped[bool] | ||
dependencies_str: Mapped[str | None] = mapped_column(String(2048)) | ||
grid_id: Mapped[int | None] | ||
state: Mapped[str | None] = mapped_column(String(30), default="UNKNOWN") | ||
exit_code: Mapped[str | None] | ||
nodes: Mapped[str | None] # list of node names | ||
array_task_ids: Mapped[list[int] | None] = mapped_column(ObjectValue) | ||
dependencies_str: Mapped[Optional[str]] = mapped_column(String(2048)) | ||
grid_id: Mapped[Optional[int]] | ||
state: Mapped[Optional[str]] = mapped_column(String(30), default="UNKNOWN") | ||
exit_code: Mapped[Optional[str]] | ||
nodes: Mapped[Optional[str]] # list of node names | ||
array_task_ids: Mapped[Optional[list[int]]] = mapped_column(ObjectValue) | ||
dependencies_jobdependency: Mapped[list[JobDependency]] = relationship( | ||
JobDependency, | ||
primaryjoin=id == JobDependency.job_id, # type: ignore[attr-defined] | ||
|
@@ -237,14 +239,17 @@ def submitted_command(self, fh, session): | |
] + command | ||
|
||
def submit(self, session: Session = None): | ||
with tempfile.NamedTemporaryFile( | ||
mode="w+t", suffix=".sh", delete_on_close=False | ||
) as fh: | ||
command = self.submitted_command(fh=fh, session=session) | ||
output = subprocess.check_output( | ||
command, | ||
text=True, | ||
) | ||
with tempfile.NamedTemporaryFile(mode="w+t", suffix=".sh", delete=False) as fh: | ||
try: | ||
command = self.submitted_command(fh=fh, session=session) | ||
output = subprocess.check_output( | ||
command, | ||
text=True, | ||
) | ||
finally: | ||
# remove the temporary file here because we don't want it | ||
# deleted after fh.close() is called | ||
Path(fh.name).unlink(missing_ok=True) | ||
# find job ID from output | ||
# output is like b'Submitted batch job 123456789\n' | ||
self.grid_id = int(re.search("[0-9]+", output).group()) | ||
|
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 |
---|---|---|
|
@@ -2,8 +2,11 @@ | |
# SPDX-FileContributor: Amir Mohammadi <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import re | ||
|
||
from typing import Optional | ||
|
||
|
||
def parse_array_indexes(indexes_str: str) -> list[int]: | ||
"""Pares a string of array indexes to a list of integers.""" | ||
|
@@ -36,7 +39,7 @@ def parse_segment(segment): | |
return result | ||
|
||
|
||
def job_ids_from_dep_str(dependency_string: str | None) -> list[int]: | ||
def job_ids_from_dep_str(dependency_string: Optional[str]) -> list[int]: | ||
"""Extract job IDs from a dependency string.""" | ||
if not dependency_string: | ||
return [] | ||
|