From ba03924cb4a8652b7659da0644aa38da150a18e6 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Tue, 5 Jan 2021 18:51:54 +0200 Subject: [PATCH] Fix archived and development system tags should not be cleaned up --- apiserver/bll/task/task_bll.py | 13 ++++++++++++- apiserver/tests/automated/test_tasks_edit.py | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apiserver/bll/task/task_bll.py b/apiserver/bll/task/task_bll.py index ab1a766..aa42a1d 100644 --- a/apiserver/bll/task/task_bll.py +++ b/apiserver/bll/task/task_bll.py @@ -26,6 +26,7 @@ from apiserver.database.model.task.task import ( ArtifactModes, external_task_types, ) +from apiserver.database.model import EntityVisibility from apiserver.database.utils import get_company_or_none_constraint, id as create_id from apiserver.es_factory import es_factory from apiserver.service_repo import APICall @@ -231,6 +232,16 @@ class TaskBLL: now = datetime.utcnow() + def clean_system_tags(input_tags: Sequence[str]) -> Sequence[str]: + if not input_tags: + return input_tags + + return [ + tag + for tag in input_tags + if tag not in [TaskSystemTags.development, EntityVisibility.archived.value] + ] + with TimingContext("mongo", "clone task"): new_task = Task( id=create_id(), @@ -244,7 +255,7 @@ class TaskBLL: parent=parent or task.parent, project=project or task.project, tags=tags or task.tags, - system_tags=system_tags or [], + system_tags=system_tags or clean_system_tags(task.system_tags), type=task.type, script=task.script, output=Output(destination=task.output.destination) diff --git a/apiserver/tests/automated/test_tasks_edit.py b/apiserver/tests/automated/test_tasks_edit.py index 59b5eb5..9f2d490 100644 --- a/apiserver/tests/automated/test_tasks_edit.py +++ b/apiserver/tests/automated/test_tasks_edit.py @@ -120,7 +120,7 @@ class TestTasksEdit(TestService): self.assertEqual(new_task.parent, task) # self.assertEqual(new_task.execution.parameters, execution["parameters"]) self.assertEqual(new_task.execution.framework, execution_overrides["framework"]) - self.assertEqual(new_task.system_tags, []) + self.assertEqual(new_task.system_tags, ["test"]) def test_model_check_in_clone(self): model = self.new_model()