Fix deleting model events

Add delete_external_artifacts parameter to projects.delete endpoint
This commit is contained in:
allegroai 2023-07-26 18:49:54 +03:00
parent 5950b81f0b
commit f7dcbd96ec
5 changed files with 17 additions and 1 deletions

View File

@ -23,6 +23,7 @@ class MoveRequest(ProjectRequest):
class DeleteRequest(ProjectRequest):
force = fields.BoolField(default=False)
delete_contents = fields.BoolField(default=False)
delete_external_artifacts = fields.BoolField(default=True)
class ProjectOrNoneRequest(models.Base):

View File

@ -14,6 +14,8 @@ from .metadata import Metadata
class ModelBLL:
event_bll = None
@classmethod
def get_company_model_by_id(
cls, company_id: str, model_id: str, only_fields=None
@ -156,6 +158,11 @@ class ModelBLL:
can_delete_folders=False,
)
if not cls.event_bll:
from apiserver.bll.event import EventBLL
cls.event_bll = EventBLL()
cls.event_bll.delete_task_events(company_id, model_id, allow_locked=True, model=True)
del_count = Model.objects(id=model_id, company=company_id).delete()
return del_count, model

View File

@ -128,7 +128,7 @@ def delete_project(
project_id: str,
force: bool,
delete_contents: bool,
delete_external_artifacts=True,
delete_external_artifacts: bool,
) -> Tuple[DeleteProjectResult, Set[str]]:
project = Project.get_for_writing(
company=company, id=project_id, _only=("id", "path", "system_tags")

View File

@ -888,6 +888,13 @@ delete {
}
}
}
"2.26": ${delete."2.13"} {
request.properties.delete_external_artifacts {
description: "If set to 'true' then BE will try to delete the extenal artifacts associated with the project tasks and models from the fileserver (if configured to do so)"
type: boolean
default: true
}
}
}
get_unique_metric_variants {
"2.1" {

View File

@ -356,6 +356,7 @@ def delete(call: APICall, company_id: str, request: DeleteRequest):
project_id=request.project,
force=request.force,
delete_contents=request.delete_contents,
delete_external_artifacts=request.delete_external_artifacts,
)
_reset_cached_tags(company_id, projects=list(affected_projects))
call.result.data = {**attr.asdict(res)}