Skip to content

Commit 5a73d7c

Browse files
committed
Update SLURM client and job scheduler to v0.0.44 of REST api
Generate new slurm reset v0.0.44 models from OpenAPI data. Factor out common models from slurmdb models. Rename two fields called list to list_1 that confuses type annotation, alias CurrentEnum as JobStateEnum, and drop root field reference in job_state. Update workflow to use Python 3.11
1 parent e7de9b0 commit 5a73d7c

9 files changed

Lines changed: 2115 additions & 6678 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.10"]
18+
python-version: ["3.11"]
1919

2020
steps:
2121
- uses: actions/checkout@v4

ParProcCo/job_scheduler.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
from .job_scheduling_information import JobSchedulingInformation
1616
from .slurm.slurm_client import SlurmClient
1717
from .slurm.slurm_rest import (
18+
CurrentEnum as JobStateEnum,
1819
JobDescMsg,
1920
JobInfo,
2021
JobSubmitReq,
21-
JobStateEnum,
2222
StringArray,
2323
Uint32NoValStruct,
2424
Uint64NoValStruct,
@@ -38,13 +38,6 @@
3838
],
3939
)
4040

41-
# class NewJobStateEnum(Enum):
42-
# CANCELLED = "CANCELLED" #
43-
# LAUNCH_FAILED = "LAUNCH_FAILED" #
44-
# UPDATE_DB = "UPDATE_DB" #
45-
# RECONFIG_FAIL = "RECONFIG_FAIL" #
46-
# POWER_UP_NODE = "POWER_UP_NODE" #
47-
4841

4942
class STATEGROUP(tuple[SLURMSTATE], Enum): # type: ignore
5043
OUTOFTIME = (SLURMSTATE.TIMEOUT, SLURMSTATE.DEADLINE)
@@ -151,7 +144,7 @@ def fetch_and_update_state(
151144
job_id = job_info.job_id
152145
if job_id is None or job_id < 0:
153146
raise ValueError(f"Job info has invalid job id: {job_info}")
154-
state = job_info.job_state.root
147+
state = job_info.job_state
155148
slurm_state = SLURMSTATE[state[0].value] if state else None
156149

157150
start_time = (
@@ -532,13 +525,14 @@ def handle_timeouts(
532525
if deadline is not None
533526
]
534527
)
528+
logging.debug("Next deadline: %s", next_deadline)
535529
check_time = min(
536530
((next_deadline - datetime.now()) / 2), timedelta(minutes=1)
537531
)
538532

539533
if not_started:
540534
not_started = handle_not_started(not_started, check_time=check_time)
541-
logging.info("Not started: %i", len(not_started))
535+
logging.info("Not started: %i (%s)", len(not_started), check_time)
542536

543537
for jsi in wait_for_ended(
544538
[v for k, v in running_jobs.items() if k not in not_started],

ParProcCo/slurm/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Get OpenAPI schema from endpoint:
22
```
3-
$ curl -H X-SLURM-USER-NAME:${USER} -H X-SLURM-USER-TOKEN:${SLURM_TOKEN) "${SLURM_REST_URL}/openapi" -o slurm-rest.json
3+
$ curl -H X-SLURM-USER-NAME:${USER} -H X-SLURM-USER-TOKEN:${SLURM_TOKEN} "${SLURM_REST_URL}/openapi" -o slurm-rest.json
44
```
55
Filter and rename schema and refs to remove version
66
```
@@ -9,7 +9,7 @@ $ python generate_models.py -d slurm-rest.json slurmdb-rest.yaml
99
```
1010
Run datamodel generating script
1111
```
12-
$ datamodel-codegen --input slurm-rest.yaml --target-python-version 3.11 --use-schema-description --use-field-description --output-model-type pydantic_v2.BaseModel --use-union-operator --use-standard-collections --field-constraints --use-double-quotes --output slurm_rest.py
13-
$ datamodel-codegen --input slurmdb-rest.yaml --target-python-version 3.11 --use-schema-description --use-field-description --output-model-type pydantic_v2.BaseModel --use-union-operator --use-standard-collections --field-constraints --use-double-quotes --output slurmdb_rest.py
12+
$ datamodel-codegen --input slurm-rest.yaml --target-python-version 3.12 --use-schema-description --use-field-description --output-model-type pydantic_v2.BaseModel --use-union-operator --use-standard-collections --field-constraints --use-double-quotes --output slurm_rest.py
13+
$ datamodel-codegen --input slurmdb-rest.yaml --target-python-version 3.12 --use-schema-description --use-field-description --output-model-type pydantic_v2.BaseModel --use-union-operator --use-standard-collections --field-constraints --use-double-quotes --output slurmdb_rest.py
1414
```
1515

ParProcCo/slurm/generate_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def create_argparser():
8181
default=False,
8282
)
8383
ap.add_argument(
84-
"--version", "-v", help="str: slurm OpenAPI version string", default="v0.0.38"
84+
"--version", "-v", help="str: slurm OpenAPI version string", default="v0.0.44"
8585
)
8686
ap.add_argument(
8787
"input_file",

ParProcCo/slurm/slurm_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
OpenapiKillJobResp,
1717
)
1818

19-
_SLURM_VERSION = "v0.0.42"
19+
_SLURM_VERSION = "v0.0.44"
2020

2121

2222
def get_slurm_token() -> str:

0 commit comments

Comments
 (0)