mirror of
https://github.com/clearml/clearml-server
synced 2025-06-26 23:15:47 +00:00
Allow updating tags on published reports
This commit is contained in:
parent
f09ac672d2
commit
ab798e4170
@ -73,10 +73,6 @@ def update_report(call: APICall, company_id: str, request: UpdateReportRequest):
|
|||||||
task = _assert_report(
|
task = _assert_report(
|
||||||
task_id=request.task, company_id=company_id, only_fields=("status",),
|
task_id=request.task, company_id=company_id, only_fields=("status",),
|
||||||
)
|
)
|
||||||
if task.status != TaskStatus.created:
|
|
||||||
raise errors.bad_request.InvalidTaskStatus(
|
|
||||||
expected=TaskStatus.created, status=task.status
|
|
||||||
)
|
|
||||||
|
|
||||||
partial_update_dict = {
|
partial_update_dict = {
|
||||||
field: value for field, value in call.data.items() if field in update_fields
|
field: value for field, value in call.data.items() if field in update_fields
|
||||||
@ -84,14 +80,20 @@ def update_report(call: APICall, company_id: str, request: UpdateReportRequest):
|
|||||||
if not partial_update_dict:
|
if not partial_update_dict:
|
||||||
return UpdateResponse(updated=0)
|
return UpdateResponse(updated=0)
|
||||||
|
|
||||||
now = datetime.utcnow()
|
tags_only = list(partial_update_dict.keys()) == ["tags"]
|
||||||
updated = task.update(
|
if task.status != TaskStatus.created and not tags_only:
|
||||||
upsert=False,
|
raise errors.bad_request.InvalidTaskStatus(
|
||||||
**partial_update_dict,
|
expected=TaskStatus.created, status=task.status
|
||||||
last_change=now,
|
)
|
||||||
last_update=now,
|
|
||||||
last_changed_by=call.identity.user,
|
more_updates = {}
|
||||||
)
|
if not tags_only:
|
||||||
|
now = datetime.utcnow()
|
||||||
|
more_updates.update(
|
||||||
|
last_change=now, last_update=now, last_changed_by=call.identity.user
|
||||||
|
)
|
||||||
|
|
||||||
|
updated = task.update(upsert=False, **partial_update_dict, **more_updates)
|
||||||
if not updated:
|
if not updated:
|
||||||
return UpdateResponse(updated=0)
|
return UpdateResponse(updated=0)
|
||||||
|
|
||||||
|
@ -58,6 +58,11 @@ class TestReports(TestService):
|
|||||||
with self.api.raises(errors.bad_request.InvalidTaskStatus):
|
with self.api.raises(errors.bad_request.InvalidTaskStatus):
|
||||||
self.api.reports.update(task=task_id, comment=comment)
|
self.api.reports.update(task=task_id, comment=comment)
|
||||||
|
|
||||||
|
# update on tags can be done for published report too
|
||||||
|
self.api.reports.update(task=task_id, tags=["test"])
|
||||||
|
task = self.api.tasks.get_all_ex(id=[task_id]).tasks[0]
|
||||||
|
self.assertEqual(task.tags, ["test"])
|
||||||
|
|
||||||
# move under another project autodeletes the empty project
|
# move under another project autodeletes the empty project
|
||||||
new_project_name = "Reports Test"
|
new_project_name = "Reports Test"
|
||||||
self._delete_project(new_project_name)
|
self._delete_project(new_project_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user