mirror of
https://github.com/clearml/clearml-server
synced 2025-06-26 23:15:47 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1a50c1370 | ||
|
|
22a2a02760 | ||
|
|
ab798e4170 | ||
|
|
f09ac672d2 | ||
|
|
2149b76f63 |
@@ -60,6 +60,7 @@ def start_pipeline(call: APICall, company_id: str, request: StartPipelineRequest
|
||||
queued, res = enqueue_task(
|
||||
task_id=task.id,
|
||||
company_id=company_id,
|
||||
user_id=call.identity.user,
|
||||
queue_id=request.queue,
|
||||
status_message="Starting pipeline",
|
||||
status_reason="",
|
||||
|
||||
@@ -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,18 @@ def update_report(call: APICall, company_id: str, request: UpdateReportRequest):
|
||||
if not partial_update_dict:
|
||||
return UpdateResponse(updated=0)
|
||||
|
||||
allowed_for_published = set(partial_update_dict.keys()).issubset({"tags", "name"})
|
||||
if task.status != TaskStatus.created and not allowed_for_published:
|
||||
raise errors.bad_request.InvalidTaskStatus(
|
||||
expected=TaskStatus.created, status=task.status
|
||||
)
|
||||
|
||||
now = datetime.utcnow()
|
||||
updated = task.update(
|
||||
upsert=False,
|
||||
**partial_update_dict,
|
||||
last_change=now,
|
||||
last_update=now,
|
||||
last_changed_by=call.identity.user,
|
||||
)
|
||||
more_updates = {"last_change": now, "last_changed_by": call.identity.user}
|
||||
if not allowed_for_published:
|
||||
more_updates["last_update"] = now
|
||||
|
||||
updated = task.update(upsert=False, **partial_update_dict, **more_updates)
|
||||
if not updated:
|
||||
return UpdateResponse(updated=0)
|
||||
|
||||
|
||||
50
apiserver/tests/automated/test_pipelines.py
Normal file
50
apiserver/tests/automated/test_pipelines.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from typing import Tuple
|
||||
|
||||
from apiserver.tests.automated import TestService
|
||||
|
||||
|
||||
class TestPipelines(TestService):
|
||||
def test_start_pipeline(self):
|
||||
queue = self.api.queues.get_default().id
|
||||
task_name = "pipelines test"
|
||||
project, task = self._temp_project_and_task(name=task_name)
|
||||
args = [{"name": "hello", "value": "test"}]
|
||||
|
||||
res = self.api.pipelines.start_pipeline(task=task, queue=queue, args=args)
|
||||
pipeline_task = res.pipeline
|
||||
try:
|
||||
self.assertTrue(res.enqueued)
|
||||
pipeline = self.api.tasks.get_all_ex(id=[pipeline_task]).tasks[0]
|
||||
self.assertTrue(pipeline.name.startswith(task_name))
|
||||
self.assertEqual(pipeline.status, "queued")
|
||||
self.assertEqual(pipeline.project.id, project)
|
||||
self.assertEqual(
|
||||
pipeline.hyperparams.Args,
|
||||
{
|
||||
a["name"]: {
|
||||
"section": "Args",
|
||||
"name": a["name"],
|
||||
"value": a["value"],
|
||||
}
|
||||
for a in args
|
||||
},
|
||||
)
|
||||
finally:
|
||||
self.api.tasks.delete(task=pipeline_task, force=True)
|
||||
|
||||
def _temp_project_and_task(self, name) -> Tuple[str, str]:
|
||||
project = self.create_temp(
|
||||
"projects", name=name, description="test", delete_params=dict(force=True),
|
||||
)
|
||||
|
||||
return (
|
||||
project,
|
||||
self.create_temp(
|
||||
"tasks",
|
||||
name=name,
|
||||
type="testing",
|
||||
input=dict(view=dict()),
|
||||
project=project,
|
||||
system_tags=["pipeline"],
|
||||
),
|
||||
)
|
||||
@@ -58,6 +58,12 @@ class TestReports(TestService):
|
||||
with self.api.raises(errors.bad_request.InvalidTaskStatus):
|
||||
self.api.reports.update(task=task_id, comment=comment)
|
||||
|
||||
# update on tags or rename can be done for published report too
|
||||
self.api.reports.update(task=task_id, name="new name", tags=["test"])
|
||||
task = self.api.tasks.get_all_ex(id=[task_id]).tasks[0]
|
||||
self.assertEqual(task.tags, ["test"])
|
||||
self.assertEqual(task.name, "new name")
|
||||
|
||||
# move under another project autodeletes the empty project
|
||||
new_project_name = "Reports Test"
|
||||
self._delete_project(new_project_name)
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "1.9.0"
|
||||
__version__ = "1.9.1"
|
||||
|
||||
Reference in New Issue
Block a user