diff --git a/exca/processors.py b/exca/processors.py new file mode 100644 index 00000000..6d868087 --- /dev/null +++ b/exca/processors.py @@ -0,0 +1,42 @@ +import contextlib +import typing as tp +from pathlib import Path + +from .helpers import DiscriminatedModel + + +class ClusterConfig(DiscriminatedModel, discriminated_key="processor"): + """Base class for cluster configurations""" + + # workdir: None | WorkDir = None + + def submit( + self, func: tp.Callable[..., tp.Any], *args: tp.Any, **kwargs: tp.Any + ) -> Any: + """Submit a job and return job object""" + ... + + @contextlib.contextmanager + def submission_context(self) -> tp.Iterator[None]: + yield None + + +class _SubmititConfig(ClusterConfig): + job_name: str | None = None + timeout_min: int | None = None + conda_env: Path | str | None = None + _excecutor: tp.Any = None + + @contextlib.contextmanager + def submission_context(self) -> tp.Iterator[None]: + yield None + + +class Slurm(_SubmititConfig): + nodes: int = 1 + tasks_per_node: int = 1 + cpus_per_task: int | None = None + gpus_per_node: int | None = None + mem_gb: float | None = None + partition: str | None = None + account: str | None = None diff --git a/exca/test_processors.py b/exca/test_processors.py new file mode 100644 index 00000000..e69de29b