-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a class to represent job resources required/requested for a batch job. Includes documentation and some unit tests, but not enough. Incorporated into `_click_batch`.
- Loading branch information
1 parent
c8c0723
commit 42a9d78
Showing
2 changed files
with
122 additions
and
12 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
31 changes: 31 additions & 0 deletions
31
flepimop/gempyor_pkg/tests/batch/test_job_resources_class.py
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Literal | ||
|
||
import pytest | ||
|
||
from gempyor.batch import JobResources | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"kwargs", | ||
( | ||
{"nodes": 0, "cpus": 1, "memory": 1}, | ||
{"nodes": 1, "cpus": 0, "memory": 1}, | ||
{"nodes": 1, "cpus": 1, "memory": 0}, | ||
{"nodes": 0, "cpus": 0, "memory": 1}, | ||
{"nodes": 1, "cpus": 0, "memory": 0}, | ||
{"nodes": 0, "cpus": 1, "memory": 0}, | ||
{"nodes": 0, "cpus": 0, "memory": 0}, | ||
), | ||
) | ||
def test_less_than_one_value_error( | ||
kwargs: dict[Literal["nodes", "cpus", "memory"], int] | ||
) -> None: | ||
param = next(k for k, v in kwargs.items() if v < 1) | ||
with pytest.raises( | ||
ValueError, | ||
match=( | ||
f"^The '{param}' attribute must be greater than 0, " | ||
f"but instead was given '{kwargs.get(param)}'.$" | ||
), | ||
): | ||
JobResources(**kwargs) |