Fix type annotations

Fix obtaining events for tasks moved from private to public
Fix assert_exists() to return company_origin if requested
This commit is contained in:
allegroai
2021-01-05 16:27:38 +02:00
parent c67a56eb8d
commit 22e9c2b7eb
6 changed files with 59 additions and 46 deletions

View File

@@ -217,3 +217,13 @@ class Task(AttributedDocument):
hyperparams = SafeMapField(field=SafeMapField(EmbeddedDocumentField(ParamsItem)))
configuration = SafeMapField(field=EmbeddedDocumentField(ConfigurationItem))
runtime = SafeDictField(default=dict)
def get_index_company(self) -> str:
"""
Returns the company ID used for locating indices containing task data.
In case the task has a valid company, this is the company ID.
Otherwise, if the task has a company_origin, this is a task that has been made public and the
origin company should be used.
Otherwise, an empty company is used.
"""
return self.company or self.company_origin or ""