Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions app/s3df/compute_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from slurmrestd_client.models.slurm_v0041_post_job_submit_request_jobs_inner_memory_per_cpu import (
SlurmV0041PostJobSubmitRequestJobsInnerMemoryPerCpu,
)
from fastapi import HTTPException, Response
from fastapi import HTTPException
from pydantic import ConfigDict, ValidationError

from ..routers.compute import models as compute_models
Expand Down Expand Up @@ -495,19 +495,14 @@ async def get_job(
if resp and resp.jobs:
return _job_from_slurm_info(resp.jobs[0], include_spec)
except ApiException as exc:
if exc.status != 414:
raise RuntimeError(f"Slurm get_job failed: {exc}") from exc
if exc.status != 404:
logger.exception("Slurm get_job failed for job %s", job_id)
raise HTTPException(status_code=500, detail="Slurm get_job failed") from exc

if historical:
# Fall back to job history endpoint
try:
resp = api.slurm_v0041_get_job_history(job_id, _headers=headers)
if resp and resp.jobs:
return _job_from_slurm_info(resp.jobs[0], include_spec)
except ApiException as exc:
raise RuntimeError(f"Slurm job history failed: {exc}") from exc
raise HTTPException(status_code=501, detail="Historical job lookup is not implemented yet")

raise RuntimeError(f"Job {job_id} not found")
raise HTTPException(status_code=404, detail=f"Job {job_id} not found")

# -- get_jobs -----------------------------------------------------------

Expand All @@ -524,15 +519,14 @@ async def get_jobs(
"""POST /compute/status/{resource_id}"""
api, headers = self._get_slurm_context(user)

if historical:
raise HTTPException(status_code=501, detail="Historical job listing is not implemented yet")

try:
if historical:
# resp = api.slurm_v0041_get_jobs_history(_headers=headers)
# return a 501 not implemented as we don't want to hit the slurmdb
return Response(status_code=501, content="Historical job listing is not implemented yet")
else:
resp = api.slurm_v0041_get_jobs(_headers=headers)
resp = api.slurm_v0041_get_jobs(_headers=headers)
except ApiException as exc:
raise RuntimeError(f"Slurm get_jobs failed: {exc}") from exc
logger.exception("Slurm get_jobs failed")
raise HTTPException(status_code=500, detail="Slurm get_jobs failed") from exc


jobs = resp.jobs or []
Expand Down
Loading