mirror of
https://github.com/clearml/clearml-server
synced 2025-03-03 10:43:10 +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_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 = {
|
||||
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:
|
||||
return UpdateResponse(updated=0)
|
||||
|
||||
now = datetime.utcnow()
|
||||
updated = task.update(
|
||||
upsert=False,
|
||||
**partial_update_dict,
|
||||
last_change=now,
|
||||
last_update=now,
|
||||
last_changed_by=call.identity.user,
|
||||
)
|
||||
tags_only = list(partial_update_dict.keys()) == ["tags"]
|
||||
if task.status != TaskStatus.created and not tags_only:
|
||||
raise errors.bad_request.InvalidTaskStatus(
|
||||
expected=TaskStatus.created, status=task.status
|
||||
)
|
||||
|
||||
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:
|
||||
return UpdateResponse(updated=0)
|
||||
|
||||
|
@ -58,6 +58,11 @@ class TestReports(TestService):
|
||||
with self.api.raises(errors.bad_request.InvalidTaskStatus):
|
||||
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
|
||||
new_project_name = "Reports Test"
|
||||
self._delete_project(new_project_name)
|
||||
|
Loading…
Reference in New Issue
Block a user