Skip to content

Commit 4f8908c

Browse files
committed
Start working on processor pattern
1 parent 54051f1 commit 4f8908c

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

exca/processors.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import contextlib
2+
import typing as tp
3+
from pathlib import Path
4+
5+
from .helpers import DiscriminatedModel
6+
7+
8+
class ClusterConfig(DiscriminatedModel, discriminated_key="processor"):
9+
"""Base class for cluster configurations"""
10+
11+
# workdir: None | WorkDir = None
12+
13+
def submit(
14+
self, func: tp.Callable[..., tp.Any], *args: tp.Any, **kwargs: tp.Any
15+
) -> Any:
16+
"""Submit a job and return job object"""
17+
...
18+
19+
@contextlib.contextmanager
20+
def submission_context(self) -> tp.Iterator[None]:
21+
yield None
22+
23+
24+
class _SubmititConfig(ClusterConfig):
25+
job_name: str | None = None
26+
timeout_min: int | None = None
27+
conda_env: Path | str | None = None
28+
_excecutor: tp.Any = None
29+
30+
@contextlib.contextmanager
31+
def submission_context(self) -> tp.Iterator[None]:
32+
yield None
33+
34+
35+
class Slurm(_SubmititConfig):
36+
nodes: int = 1
37+
tasks_per_node: int = 1
38+
cpus_per_task: int | None = None
39+
gpus_per_node: int | None = None
40+
mem_gb: float | None = None
41+
partition: str | None = None
42+
account: str | None = None

exca/test_processors.py

Whitespace-only changes.

0 commit comments

Comments
 (0)