Skip to content

Commit f84c0a7

Browse files
authored
Merge pull request #192 from eth-cscs/Post-job-hot-fix
Post job hot fix
2 parents 460e282 + ab6147a commit f84c0a7

File tree

9 files changed

+26
-28
lines changed

9 files changed

+26
-28
lines changed

src/firecrest/compute/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class GetJobMetadataResponse(CamelModel):
6565

6666

6767
class PostJobSubmissionResponse(CamelModel):
68-
job_id: Optional[int] = Field(None, nullable=True)
68+
job_id: Optional[str] = Field(None, nullable=True)
6969

7070

7171
class PostJobAttachRequest(CamelModel):

src/firecrest/filesystem/transfer/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class TransferJobLogs(CamelModel):
8181

8282

8383
class TransferJob(CamelModel):
84-
job_id: int
84+
job_id: str
8585
system: str
8686
working_directory: str
8787
logs: TransferJobLogs

src/lib/datatransfers/datatransfer_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TransferJobLogs(CamelModel):
1818

1919

2020
class TransferJob(CamelModel):
21-
job_id: int
21+
job_id: str
2222
system: str
2323
working_directory: str
2424
logs: TransferJobLogs

src/lib/scheduler_clients/scheduler_base_client.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def submit_job(
2525
job_description: JobDescriptionModel,
2626
username: str,
2727
jwt_token: str,
28-
) -> int | None:
28+
) -> str | None:
2929
pass
3030

3131
@abstractmethod
@@ -35,17 +35,13 @@ async def attach_command(
3535
job_id: str,
3636
username: str,
3737
jwt_token: str,
38-
) -> int | None:
38+
) -> None:
3939
pass
4040

4141
@abstractmethod
4242
# Note: returns multiple jobs to deal with job_id duplicates (see Slurm doc)
4343
async def get_job(
44-
self,
45-
job_id: str,
46-
username: str,
47-
jwt_token: str,
48-
allusers: bool = True
44+
self, job_id: str, username: str, jwt_token: str, allusers: bool = True
4945
) -> List[JobModel]:
5046
pass
5147

@@ -58,10 +54,7 @@ async def get_job_metadata(
5854

5955
@abstractmethod
6056
async def get_jobs(
61-
self,
62-
username: str,
63-
jwt_token: str,
64-
allusers: bool = False
57+
self, username: str, jwt_token: str, allusers: bool = False
6558
) -> List[JobModel] | None:
6659
pass
6760

src/lib/scheduler_clients/slurm/slurm_base_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def submit_job(
2525
job_description: SlurmJobDescription,
2626
username: str,
2727
jwt_token: str,
28-
) -> int | None:
28+
) -> str | None:
2929
pass
3030

3131
@abstractmethod
@@ -35,7 +35,7 @@ async def attach_command(
3535
job_id: str,
3636
username: str,
3737
jwt_token: str,
38-
) -> int | None:
38+
) -> str | None:
3939
pass
4040

4141
@abstractmethod

src/lib/scheduler_clients/slurm/slurm_cli_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def submit_job(
6666
job_description: SlurmJobDescription,
6767
username: str,
6868
jwt_token: str,
69-
) -> int | None:
69+
) -> str | None:
7070
sbatch = SbatchCommand(job_description=job_description)
7171
return await self.__executed_ssh_cmd(
7272
username, jwt_token, sbatch, job_description.script
@@ -78,7 +78,7 @@ async def attach_command(
7878
job_id: str,
7979
username: str,
8080
jwt_token: str,
81-
) -> int | None:
81+
) -> None:
8282
srun = SrunCommand(command=command, job_id=job_id, overlap=True)
8383
return await self.__executed_ssh_cmd(username, jwt_token, srun)
8484

src/lib/scheduler_clients/slurm/slurm_client.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def submit_job(
5555
job_description: SlurmJobDescription,
5656
username: str,
5757
jwt_token: str,
58-
) -> int | None:
58+
) -> str | None:
5959

6060
if job_description.script_path:
6161
if self.slurm_cli_client:
@@ -74,7 +74,7 @@ async def submit_job(
7474

7575
async def attach_command(
7676
self, command: str, job_id: str, username: str, jwt_token: str
77-
) -> int | None:
77+
) -> None:
7878
return await self.slurm_default_client.attach_command(
7979
command, job_id, username, jwt_token
8080
)
@@ -97,12 +97,14 @@ async def get_job_metadata(
9797
self, job_id: str, username: str, jwt_token: str
9898
) -> List[SlurmJobMetadata]:
9999
if self.slurm_cli_client:
100-
return await self.slurm_cli_client.get_job_metadata(job_id, username, jwt_token)
100+
return await self.slurm_cli_client.get_job_metadata(
101+
job_id, username, jwt_token
102+
)
101103
else:
102104
raise HTTPException(
103-
status_code=501,
104-
detail="Scheduler can't handle this request when configured to use rest connection mode",
105-
)
105+
status_code=501,
106+
detail="Scheduler can't handle this request when configured to use rest connection mode",
107+
)
106108

107109
async def get_nodes(self, username: str, jwt_token: str) -> List[SlurmNode] | None:
108110
return await self.slurm_default_client.get_nodes(username, jwt_token)

src/lib/scheduler_clients/slurm/slurm_rest_client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async def submit_job(
9292
job_description: SlurmJobDescription,
9393
username: str,
9494
jwt_token: str,
95-
) -> int | None:
95+
) -> str | None:
9696

9797
client = await self.get_aiohttp_client()
9898
timeout = aiohttp.ClientTimeout(total=self.timeout)
@@ -132,15 +132,18 @@ async def submit_job(
132132
if response.status != status.HTTP_200_OK:
133133
await _slurm_unexpected_response(response)
134134
job_submit_result = await response.json()
135-
return job_submit_result["job_id"]
135+
job_id = job_submit_result.get("job_id")
136+
if job_id is None:
137+
return None
138+
return str(job_id)
136139

137140
async def attach_command(
138141
self,
139142
command: str,
140143
job_id: str,
141144
username: str,
142145
jwt_token: str,
143-
) -> int | None:
146+
) -> None:
144147
pass
145148

146149
async def get_job(

tests/mocked_api_responses/slurm_submit_job.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
},
1616
"errors": [],
17-
"job_id": 42,
17+
"job_id": "42",
1818
"step_id": "BATCH",
1919
"job_submit_user_msg": ""
2020
}

0 commit comments

Comments
 (0)