Skip to content

Commit

Permalink
Updated error msg, added compute_type to update model
Browse files Browse the repository at this point in the history
  • Loading branch information
3coins committed Oct 12, 2022
1 parent c611a16 commit 64ff6ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion jupyter_scheduler/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ async def patch(self, job_id):
status = Status(status) if status else None

if status and status != Status.STOPPED:
raise tornado.web.HTTPError(500, "Value of 'STOPPED' only allowed for field 'status'")
raise tornado.web.HTTPError(
500,
"Invalid value for field 'status'. Jobs can only be updated to status 'STOPPED' after creation.",
)

if status:
await ensure_async(self.scheduler.stop_job(job_id))
Expand Down
3 changes: 2 additions & 1 deletion jupyter_scheduler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ class UpdateJobDefinition(BaseModel):
name: Optional[str] = None
url: Optional[str] = None
schedule: Optional[str] = None
timezone: Optional[str] = None # Should be a timezone e.g., US/Eastern, Asia/Kolkata
timezone: Optional[str] = None
output_filename_template: Optional[str] = OUTPUT_FILENAME_TEMPLATE
active: Optional[bool] = None
compute_type: Optional[str] = None


class ListJobDefinitionsQuery(BaseModel):
Expand Down
6 changes: 5 additions & 1 deletion jupyter_scheduler/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ async def test_patch_jobs_for_invalid_status(jp_fetch):
job_id = "542e0fac-1274-4a78-8340-a850bdb559c8"
body = {"status": "IN_PROGRESS"}
await jp_fetch("scheduler", "jobs", job_id, method="PATCH", body=json.dumps(body))
assert expected_http_error(e, 500, "Value of 'STOPPED' only allowed for field 'status'")
assert expected_http_error(
e,
500,
"Invalid value for field 'status'. Jobs can only be updated to status 'STOPPED' after creation.",
)


async def test_patch_jobs(jp_fetch):
Expand Down

0 comments on commit 64ff6ad

Please sign in to comment.