diff --git a/clearml/automation/controller.py b/clearml/automation/controller.py index cb860bc7..0efdfce0 100644 --- a/clearml/automation/controller.py +++ b/clearml/automation/controller.py @@ -3589,8 +3589,9 @@ class PipelineDecorator(PipelineController): break if kwargs: leaves = cls._singleton._find_executed_node_leaves() - _node.parents = (_node.parents or []) + \ - [x for x in cls._evaluated_return_values.get(tid, []) if x in leaves] + _node.parents = (_node.parents or []) + [ + x for x in cls._evaluated_return_values.get(tid, []) if x in leaves + ] for k, v in kwargs.items(): if v is None or isinstance(v, (bool, int, float, str)): _node.parameters["{}/{}".format(CreateFromFunction.kwargs_section, k)] = v diff --git a/clearml/backend_api/api_proxy.py b/clearml/backend_api/api_proxy.py index 22281cfd..eedcde61 100644 --- a/clearml/backend_api/api_proxy.py +++ b/clearml/backend_api/api_proxy.py @@ -47,7 +47,7 @@ class ApiServiceProxy(object): # noinspection PyBroadException try: return importlib.import_module(name, package=package) - except Exception: + except Exception as ex: return None diff --git a/clearml/backend_api/services/v2_20/__init__.py b/clearml/backend_api/services/v2_20/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/clearml/backend_api/services/v2_20/auth.py b/clearml/backend_api/services/v2_20/auth.py new file mode 100644 index 00000000..4566ca17 --- /dev/null +++ b/clearml/backend_api/services/v2_20/auth.py @@ -0,0 +1,793 @@ +""" +auth service + +This service provides authentication management and authorization + +validation for the entire system. +""" +import six +from datetime import datetime + +from dateutil.parser import parse as parse_datetime + +from clearml.backend_api.session import ( + Request, + Response, + NonStrictDataModel, + schema_property, +) + + +class Credentials(NonStrictDataModel): + """ + :param access_key: Credentials access key + :type access_key: str + :param secret_key: Credentials secret key + :type secret_key: str + :param label: Optional credentials label + :type label: str + """ + + _schema = { + "properties": { + "access_key": { + "description": "Credentials access key", + "type": ["string", "null"], + }, + "label": { + "description": "Optional credentials label", + "type": ["string", "null"], + }, + "secret_key": { + "description": "Credentials secret key", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, access_key=None, secret_key=None, label=None, **kwargs): + super(Credentials, self).__init__(**kwargs) + self.access_key = access_key + self.secret_key = secret_key + self.label = label + + @schema_property("access_key") + def access_key(self): + return self._property_access_key + + @access_key.setter + def access_key(self, value): + if value is None: + self._property_access_key = None + return + + self.assert_isinstance(value, "access_key", six.string_types) + self._property_access_key = value + + @schema_property("secret_key") + def secret_key(self): + return self._property_secret_key + + @secret_key.setter + def secret_key(self, value): + if value is None: + self._property_secret_key = None + return + + self.assert_isinstance(value, "secret_key", six.string_types) + self._property_secret_key = value + + @schema_property("label") + def label(self): + return self._property_label + + @label.setter + def label(self, value): + if value is None: + self._property_label = None + return + + self.assert_isinstance(value, "label", six.string_types) + self._property_label = value + + +class CredentialKey(NonStrictDataModel): + """ + :param access_key: + :type access_key: str + :param label: Optional credentials label + :type label: str + :param last_used: + :type last_used: datetime.datetime + :param last_used_from: + :type last_used_from: str + """ + + _schema = { + "properties": { + "access_key": {"description": "", "type": ["string", "null"]}, + "label": { + "description": "Optional credentials label", + "type": ["string", "null"], + }, + "last_used": { + "description": "", + "format": "date-time", + "type": ["string", "null"], + }, + "last_used_from": {"description": "", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__( + self, access_key=None, label=None, last_used=None, last_used_from=None, **kwargs + ): + super(CredentialKey, self).__init__(**kwargs) + self.access_key = access_key + self.label = label + self.last_used = last_used + self.last_used_from = last_used_from + + @schema_property("access_key") + def access_key(self): + return self._property_access_key + + @access_key.setter + def access_key(self, value): + if value is None: + self._property_access_key = None + return + + self.assert_isinstance(value, "access_key", six.string_types) + self._property_access_key = value + + @schema_property("label") + def label(self): + return self._property_label + + @label.setter + def label(self, value): + if value is None: + self._property_label = None + return + + self.assert_isinstance(value, "label", six.string_types) + self._property_label = value + + @schema_property("last_used") + def last_used(self): + return self._property_last_used + + @last_used.setter + def last_used(self, value): + if value is None: + self._property_last_used = None + return + + self.assert_isinstance(value, "last_used", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_last_used = value + + @schema_property("last_used_from") + def last_used_from(self): + return self._property_last_used_from + + @last_used_from.setter + def last_used_from(self, value): + if value is None: + self._property_last_used_from = None + return + + self.assert_isinstance(value, "last_used_from", six.string_types) + self._property_last_used_from = value + + +class CreateCredentialsRequest(Request): + """ + Creates a new set of credentials for the authenticated user. + New key/secret is returned. + Note: Secret will never be returned in any other API call. + If a secret is lost or compromised, the key should be revoked + and a new set of credentials can be created. + + :param label: Optional credentials label + :type label: str + """ + + _service = "auth" + _action = "create_credentials" + _version = "2.20" + _schema = { + "additionalProperties": False, + "definitions": {}, + "properties": { + "label": { + "description": "Optional credentials label", + "type": ["string", "null"], + } + }, + "type": "object", + } + + def __init__(self, label=None, **kwargs): + super(CreateCredentialsRequest, self).__init__(**kwargs) + self.label = label + + @schema_property("label") + def label(self): + return self._property_label + + @label.setter + def label(self, value): + if value is None: + self._property_label = None + return + + self.assert_isinstance(value, "label", six.string_types) + self._property_label = value + + +class CreateCredentialsResponse(Response): + """ + Response of auth.create_credentials endpoint. + + :param credentials: Created credentials + :type credentials: Credentials + """ + + _service = "auth" + _action = "create_credentials" + _version = "2.20" + + _schema = { + "definitions": { + "credentials": { + "properties": { + "access_key": { + "description": "Credentials " "access " "key", + "type": ["string", "null"], + }, + "label": { + "description": "Optional " "credentials " "label", + "type": ["string", "null"], + }, + "secret_key": { + "description": "Credentials " "secret " "key", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "credentials": { + "description": "Created credentials", + "oneOf": [{"$ref": "#/definitions/credentials"}, {"type": "null"}], + } + }, + "type": "object", + } + + def __init__(self, credentials=None, **kwargs): + super(CreateCredentialsResponse, self).__init__(**kwargs) + self.credentials = credentials + + @schema_property("credentials") + def credentials(self): + return self._property_credentials + + @credentials.setter + def credentials(self, value): + if value is None: + self._property_credentials = None + return + if isinstance(value, dict): + value = Credentials.from_dict(value) + else: + self.assert_isinstance(value, "credentials", Credentials) + self._property_credentials = value + + +class EditCredentialsRequest(Request): + """ + Updates the label of the existing credentials for the authenticated user. + + :param access_key: Existing credentials key + :type access_key: str + :param label: New credentials label + :type label: str + """ + + _service = "auth" + _action = "edit_credentials" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "access_key": {"description": "Existing credentials key", "type": "string"}, + "label": {"description": "New credentials label", "type": "string"}, + }, + "required": ["access_key"], + "type": "object", + } + + def __init__(self, access_key, label=None, **kwargs): + super(EditCredentialsRequest, self).__init__(**kwargs) + self.access_key = access_key + self.label = label + + @schema_property("access_key") + def access_key(self): + return self._property_access_key + + @access_key.setter + def access_key(self, value): + if value is None: + self._property_access_key = None + return + + self.assert_isinstance(value, "access_key", six.string_types) + self._property_access_key = value + + @schema_property("label") + def label(self): + return self._property_label + + @label.setter + def label(self, value): + if value is None: + self._property_label = None + return + + self.assert_isinstance(value, "label", six.string_types) + self._property_label = value + + +class EditCredentialsResponse(Response): + """ + Response of auth.edit_credentials endpoint. + + :param updated: Number of credentials updated + :type updated: int + """ + + _service = "auth" + _action = "edit_credentials" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of credentials updated", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(EditCredentialsResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class EditUserRequest(Request): + """ + Edit a users' auth data properties + + :param user: User ID + :type user: str + :param role: The new user's role within the company + :type role: str + """ + + _service = "auth" + _action = "edit_user" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "role": { + "description": "The new user's role within the company", + "enum": ["admin", "superuser", "user", "annotator"], + "type": ["string", "null"], + }, + "user": {"description": "User ID", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, user=None, role=None, **kwargs): + super(EditUserRequest, self).__init__(**kwargs) + self.user = user + self.role = role + + @schema_property("user") + def user(self): + return self._property_user + + @user.setter + def user(self, value): + if value is None: + self._property_user = None + return + + self.assert_isinstance(value, "user", six.string_types) + self._property_user = value + + @schema_property("role") + def role(self): + return self._property_role + + @role.setter + def role(self, value): + if value is None: + self._property_role = None + return + + self.assert_isinstance(value, "role", six.string_types) + self._property_role = value + + +class EditUserResponse(Response): + """ + Response of auth.edit_user endpoint. + + :param updated: Number of users updated (0 or 1) + :type updated: float + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "auth" + _action = "edit_user" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of users updated (0 or 1)", + "enum": [0, 1], + "type": ["number", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(EditUserResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + + self.assert_isinstance(value, "updated", six.integer_types + (float,)) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class GetCredentialsRequest(Request): + """ + Returns all existing credential keys for the authenticated user. + Note: Only credential keys are returned. + + """ + + _service = "auth" + _action = "get_credentials" + _version = "2.20" + _schema = { + "additionalProperties": False, + "definitions": {}, + "properties": {}, + "type": "object", + } + + +class GetCredentialsResponse(Response): + """ + Response of auth.get_credentials endpoint. + + :param credentials: List of credentials, each with an empty secret field. + :type credentials: Sequence[CredentialKey] + :param additional_credentials: The user credentials for the user tenant + companies, each with an empty secret field. + :type additional_credentials: dict + """ + + _service = "auth" + _action = "get_credentials" + _version = "2.20" + + _schema = { + "definitions": { + "credential_key": { + "properties": { + "access_key": {"description": "", "type": ["string", "null"]}, + "label": { + "description": "Optional " "credentials " "label", + "type": ["string", "null"], + }, + "last_used": { + "description": "", + "format": "date-time", + "type": ["string", "null"], + }, + "last_used_from": {"description": "", "type": ["string", "null"]}, + }, + "type": "object", + } + }, + "properties": { + "additional_credentials": { + "additionalProperties": True, + "description": "The user credentials for the user tenant companies, each with an empty secret field.", + "type": ["object", "null"], + }, + "credentials": { + "description": "List of credentials, each with an empty secret field.", + "items": {"$ref": "#/definitions/credential_key"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, credentials=None, additional_credentials=None, **kwargs): + super(GetCredentialsResponse, self).__init__(**kwargs) + self.credentials = credentials + self.additional_credentials = additional_credentials + + @schema_property("credentials") + def credentials(self): + return self._property_credentials + + @credentials.setter + def credentials(self, value): + if value is None: + self._property_credentials = None + return + + self.assert_isinstance(value, "credentials", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + CredentialKey.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "credentials", CredentialKey, is_array=True) + self._property_credentials = value + + @schema_property("additional_credentials") + def additional_credentials(self): + return self._property_additional_credentials + + @additional_credentials.setter + def additional_credentials(self, value): + if value is None: + self._property_additional_credentials = None + return + + self.assert_isinstance(value, "additional_credentials", (dict,)) + self._property_additional_credentials = value + + +class LoginRequest(Request): + """ + Get a token based on supplied credentials (key/secret). + Intended for use by users with key/secret credentials that wish to obtain a token + for use with other services. + + :param expiration_sec: Requested token expiration time in seconds. Not + guaranteed, might be overridden by the service + :type expiration_sec: int + """ + + _service = "auth" + _action = "login" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "expiration_sec": { + "description": "Requested token expiration time in seconds. Not guaranteed, " + "might be overridden by the service", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, expiration_sec=None, **kwargs): + super(LoginRequest, self).__init__(**kwargs) + self.expiration_sec = expiration_sec + + @schema_property("expiration_sec") + def expiration_sec(self): + return self._property_expiration_sec + + @expiration_sec.setter + def expiration_sec(self, value): + if value is None: + self._property_expiration_sec = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "expiration_sec", six.integer_types) + self._property_expiration_sec = value + + +class LoginResponse(Response): + """ + Response of auth.login endpoint. + + :param token: Token string + :type token: str + """ + + _service = "auth" + _action = "login" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "token": {"description": "Token string", "type": ["string", "null"]} + }, + "type": "object", + } + + def __init__(self, token=None, **kwargs): + super(LoginResponse, self).__init__(**kwargs) + self.token = token + + @schema_property("token") + def token(self): + return self._property_token + + @token.setter + def token(self, value): + if value is None: + self._property_token = None + return + + self.assert_isinstance(value, "token", six.string_types) + self._property_token = value + + +class RevokeCredentialsRequest(Request): + """ + Revokes (and deletes) a set (key, secret) of credentials for + the authenticated user. + + :param access_key: Credentials key + :type access_key: str + """ + + _service = "auth" + _action = "revoke_credentials" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "access_key": {"description": "Credentials key", "type": ["string", "null"]} + }, + "required": ["key_id"], + "type": "object", + } + + def __init__(self, access_key=None, **kwargs): + super(RevokeCredentialsRequest, self).__init__(**kwargs) + self.access_key = access_key + + @schema_property("access_key") + def access_key(self): + return self._property_access_key + + @access_key.setter + def access_key(self, value): + if value is None: + self._property_access_key = None + return + + self.assert_isinstance(value, "access_key", six.string_types) + self._property_access_key = value + + +class RevokeCredentialsResponse(Response): + """ + Response of auth.revoke_credentials endpoint. + + :param revoked: Number of credentials revoked + :type revoked: int + """ + + _service = "auth" + _action = "revoke_credentials" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "revoked": { + "description": "Number of credentials revoked", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, revoked=None, **kwargs): + super(RevokeCredentialsResponse, self).__init__(**kwargs) + self.revoked = revoked + + @schema_property("revoked") + def revoked(self): + return self._property_revoked + + @revoked.setter + def revoked(self, value): + if value is None: + self._property_revoked = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "revoked", six.integer_types) + self._property_revoked = value + + +response_mapping = { + LoginRequest: LoginResponse, + CreateCredentialsRequest: CreateCredentialsResponse, + GetCredentialsRequest: GetCredentialsResponse, + EditCredentialsRequest: EditCredentialsResponse, + RevokeCredentialsRequest: RevokeCredentialsResponse, + EditUserRequest: EditUserResponse, +} diff --git a/clearml/backend_api/services/v2_20/events.py b/clearml/backend_api/services/v2_20/events.py new file mode 100644 index 00000000..b6a2a264 --- /dev/null +++ b/clearml/backend_api/services/v2_20/events.py @@ -0,0 +1,5362 @@ +""" +events service + +Provides an API for running tasks to report events collected by the system. +""" +import six +import enum + +from clearml.backend_api.session import ( + Request, + BatchRequest, + Response, + NonStrictDataModel, + CompoundRequest, + schema_property, + StringEnum, +) + + +class MetricVariants(NonStrictDataModel): + """ """ + + _schema = { + "metric": {"description": "The metric name", "type": "string"}, + "type": "object", + "variants": { + "description": "The names of the metric variants", + "items": {"type": "string"}, + "type": "array", + }, + } + + +class MetricsScalarEvent(NonStrictDataModel): + """ + Used for reporting scalar metrics during training task + + :param timestamp: Epoch milliseconds UTC, will be set by the server if not set. + :type timestamp: float + :param task: Task ID (required) + :type task: str + :param iter: Iteration + :type iter: int + :param metric: Metric name, e.g. 'count', 'loss', 'accuracy' + :type metric: str + :param variant: E.g. 'class_1', 'total', 'average + :type variant: str + :param value: + :type value: float + """ + + _schema = { + "description": "Used for reporting scalar metrics during training task", + "properties": { + "iter": {"description": "Iteration", "type": "integer"}, + "metric": { + "description": "Metric name, e.g. 'count', 'loss', 'accuracy'", + "type": "string", + }, + "task": {"description": "Task ID (required)", "type": "string"}, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": { + "const": "training_stats_scalar", + "description": "training_stats_vector", + }, + "value": {"description": "", "type": "number"}, + "variant": { + "description": "E.g. 'class_1', 'total', 'average", + "type": "string", + }, + }, + "required": ["task", "type"], + "type": "object", + } + + def __init__( + self, + task, + timestamp=None, + iter=None, + metric=None, + variant=None, + value=None, + **kwargs + ): + super(MetricsScalarEvent, self).__init__(**kwargs) + self.timestamp = timestamp + self.task = task + self.iter = iter + self.metric = metric + self.variant = variant + self.value = value + + @schema_property("timestamp") + def timestamp(self): + return self._property_timestamp + + @timestamp.setter + def timestamp(self, value): + if value is None: + self._property_timestamp = None + return + + self.assert_isinstance(value, "timestamp", six.integer_types + (float,)) + self._property_timestamp = value + + @schema_property("type") + def type(self): + return "training_stats_scalar" + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("iter") + def iter(self): + return self._property_iter + + @iter.setter + def iter(self, value): + if value is None: + self._property_iter = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iter", six.integer_types) + self._property_iter = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + @schema_property("value") + def value(self): + return self._property_value + + @value.setter + def value(self, value): + if value is None: + self._property_value = None + return + + self.assert_isinstance(value, "value", six.integer_types + (float,)) + self._property_value = value + + +class MetricsVectorEvent(NonStrictDataModel): + """ + Used for reporting vector metrics during training task + + :param timestamp: Epoch milliseconds UTC, will be set by the server if not set. + :type timestamp: float + :param task: Task ID (required) + :type task: str + :param iter: Iteration + :type iter: int + :param metric: Metric name, e.g. 'count', 'loss', 'accuracy' + :type metric: str + :param variant: E.g. 'class_1', 'total', 'average + :type variant: str + :param values: vector of float values + :type values: Sequence[float] + """ + + _schema = { + "description": "Used for reporting vector metrics during training task", + "properties": { + "iter": {"description": "Iteration", "type": "integer"}, + "metric": { + "description": "Metric name, e.g. 'count', 'loss', 'accuracy'", + "type": "string", + }, + "task": {"description": "Task ID (required)", "type": "string"}, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": { + "const": "training_stats_vector", + "description": "training_stats_vector", + }, + "values": { + "description": "vector of float values", + "items": {"type": "number"}, + "type": "array", + }, + "variant": { + "description": "E.g. 'class_1', 'total', 'average", + "type": "string", + }, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + timestamp=None, + iter=None, + metric=None, + variant=None, + values=None, + **kwargs + ): + super(MetricsVectorEvent, self).__init__(**kwargs) + self.timestamp = timestamp + self.task = task + self.iter = iter + self.metric = metric + self.variant = variant + self.values = values + + @schema_property("timestamp") + def timestamp(self): + return self._property_timestamp + + @timestamp.setter + def timestamp(self, value): + if value is None: + self._property_timestamp = None + return + + self.assert_isinstance(value, "timestamp", six.integer_types + (float,)) + self._property_timestamp = value + + @schema_property("type") + def type(self): + return "training_stats_vector" + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("iter") + def iter(self): + return self._property_iter + + @iter.setter + def iter(self, value): + if value is None: + self._property_iter = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iter", six.integer_types) + self._property_iter = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + @schema_property("values") + def values(self): + return self._property_values + + @values.setter + def values(self, value): + if value is None: + self._property_values = None + return + + self.assert_isinstance(value, "values", (list, tuple)) + + self.assert_isinstance( + value, "values", six.integer_types + (float,), is_array=True + ) + self._property_values = value + + +class MetricsImageEvent(NonStrictDataModel): + """ + An image or video was dumped to storage for debugging + + :param timestamp: Epoch milliseconds UTC, will be set by the server if not set. + :type timestamp: float + :param task: Task ID (required) + :type task: str + :param iter: Iteration + :type iter: int + :param metric: Metric name, e.g. 'count', 'loss', 'accuracy' + :type metric: str + :param variant: E.g. 'class_1', 'total', 'average + :type variant: str + :param key: File key + :type key: str + :param url: File URL + :type url: str + """ + + _schema = { + "description": "An image or video was dumped to storage for debugging", + "properties": { + "iter": {"description": "Iteration", "type": "integer"}, + "key": {"description": "File key", "type": "string"}, + "metric": { + "description": "Metric name, e.g. 'count', 'loss', 'accuracy'", + "type": "string", + }, + "task": {"description": "Task ID (required)", "type": "string"}, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": {"const": "training_debug_image", "description": ""}, + "url": {"description": "File URL", "type": "string"}, + "variant": { + "description": "E.g. 'class_1', 'total', 'average", + "type": "string", + }, + }, + "required": ["task", "type"], + "type": "object", + } + + def __init__( + self, + task, + timestamp=None, + iter=None, + metric=None, + variant=None, + key=None, + url=None, + **kwargs + ): + super(MetricsImageEvent, self).__init__(**kwargs) + self.timestamp = timestamp + self.task = task + self.iter = iter + self.metric = metric + self.variant = variant + self.key = key + self.url = url + + @schema_property("timestamp") + def timestamp(self): + return self._property_timestamp + + @timestamp.setter + def timestamp(self, value): + if value is None: + self._property_timestamp = None + return + + self.assert_isinstance(value, "timestamp", six.integer_types + (float,)) + self._property_timestamp = value + + @schema_property("type") + def type(self): + return "training_debug_image" + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("iter") + def iter(self): + return self._property_iter + + @iter.setter + def iter(self, value): + if value is None: + self._property_iter = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iter", six.integer_types) + self._property_iter = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + + self.assert_isinstance(value, "key", six.string_types) + self._property_key = value + + @schema_property("url") + def url(self): + return self._property_url + + @url.setter + def url(self, value): + if value is None: + self._property_url = None + return + + self.assert_isinstance(value, "url", six.string_types) + self._property_url = value + + +class MetricsPlotEvent(NonStrictDataModel): + """ + An entire plot (not single datapoint) and it's layout. + Used for plotting ROC curves, confidence matrices, etc. when evaluating the net. + + :param timestamp: Epoch milliseconds UTC, will be set by the server if not set. + :type timestamp: float + :param task: Task ID (required) + :type task: str + :param iter: Iteration + :type iter: int + :param metric: Metric name, e.g. 'count', 'loss', 'accuracy' + :type metric: str + :param variant: E.g. 'class_1', 'total', 'average + :type variant: str + :param plot_str: An entire plot (not single datapoint) and it's layout. Used + for plotting ROC curves, confidence matrices, etc. when evaluating the net. + :type plot_str: str + :param skip_validation: If set then plot_str is not checked for a valid json. + The default is False + :type skip_validation: bool + """ + + _schema = { + "description": " An entire plot (not single datapoint) and it's layout. " + " Used for plotting ROC curves, confidence matrices, etc. when evaluating the net.", + "properties": { + "iter": {"description": "Iteration", "type": "integer"}, + "metric": { + "description": "Metric name, e.g. 'count', 'loss', 'accuracy'", + "type": "string", + }, + "plot_str": { + "description": "An entire plot (not single datapoint) and it's layout." + " Used for plotting ROC curves, confidence matrices, etc. when evaluating the net.", + "type": "string", + }, + "skip_validation": { + "description": "If set then plot_str is not checked for a valid json. The default is False", + "type": "boolean", + }, + "task": {"description": "Task ID (required)", "type": "string"}, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": {"const": "plot", "description": "'plot'"}, + "variant": { + "description": "E.g. 'class_1', 'total', 'average", + "type": "string", + }, + }, + "required": ["task", "type"], + "type": "object", + } + + def __init__( + self, + task, + timestamp=None, + iter=None, + metric=None, + variant=None, + plot_str=None, + skip_validation=None, + **kwargs + ): + super(MetricsPlotEvent, self).__init__(**kwargs) + self.timestamp = timestamp + self.task = task + self.iter = iter + self.metric = metric + self.variant = variant + self.plot_str = plot_str + self.skip_validation = skip_validation + + @schema_property("timestamp") + def timestamp(self): + return self._property_timestamp + + @timestamp.setter + def timestamp(self, value): + if value is None: + self._property_timestamp = None + return + + self.assert_isinstance(value, "timestamp", six.integer_types + (float,)) + self._property_timestamp = value + + @schema_property("type") + def type(self): + return "plot" + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("iter") + def iter(self): + return self._property_iter + + @iter.setter + def iter(self, value): + if value is None: + self._property_iter = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iter", six.integer_types) + self._property_iter = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + @schema_property("plot_str") + def plot_str(self): + return self._property_plot_str + + @plot_str.setter + def plot_str(self, value): + if value is None: + self._property_plot_str = None + return + + self.assert_isinstance(value, "plot_str", six.string_types) + self._property_plot_str = value + + @schema_property("skip_validation") + def skip_validation(self): + return self._property_skip_validation + + @skip_validation.setter + def skip_validation(self, value): + if value is None: + self._property_skip_validation = None + return + + self.assert_isinstance(value, "skip_validation", (bool,)) + self._property_skip_validation = value + + +class ScalarKeyEnum(StringEnum): + iter = "iter" + timestamp = "timestamp" + iso_time = "iso_time" + + +class LogLevelEnum(StringEnum): + notset = "notset" + debug = "debug" + verbose = "verbose" + info = "info" + warn = "warn" + warning = "warning" + error = "error" + fatal = "fatal" + critical = "critical" + + +class EventTypeEnum(StringEnum): + training_stats_scalar = "training_stats_scalar" + training_stats_vector = "training_stats_vector" + training_debug_image = "training_debug_image" + plot = "plot" + log = "log" + + +class TaskMetricVariants(NonStrictDataModel): + """ + :param task: Task ID + :type task: str + :param metric: Metric name + :type metric: str + :param variants: Metric variant names + :type variants: Sequence[str] + """ + + _schema = { + "properties": { + "metric": {"description": "Metric name", "type": "string"}, + "task": {"description": "Task ID", "type": "string"}, + "variants": { + "description": "Metric variant names", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, metric=None, variants=None, **kwargs): + super(TaskMetricVariants, self).__init__(**kwargs) + self.task = task + self.metric = metric + self.variants = variants + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variants") + def variants(self): + return self._property_variants + + @variants.setter + def variants(self, value): + if value is None: + self._property_variants = None + return + + self.assert_isinstance(value, "variants", (list, tuple)) + + self.assert_isinstance(value, "variants", six.string_types, is_array=True) + self._property_variants = value + + +class TaskLogEvent(NonStrictDataModel): + """ + A log event associated with a task. + + :param timestamp: Epoch milliseconds UTC, will be set by the server if not set. + :type timestamp: float + :param task: Task ID (required) + :type task: str + :param level: Log level. + :type level: LogLevelEnum + :param worker: Name of machine running the task. + :type worker: str + :param msg: Log message. + :type msg: str + """ + + _schema = { + "description": "A log event associated with a task.", + "properties": { + "level": { + "$ref": "#/definitions/log_level_enum", + "description": "Log level.", + }, + "msg": {"description": "Log message.", "type": "string"}, + "task": {"description": "Task ID (required)", "type": "string"}, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": {"const": "log", "description": "'log'"}, + "worker": { + "description": "Name of machine running the task.", + "type": "string", + }, + }, + "required": ["task", "type"], + "type": "object", + } + + def __init__( + self, task, timestamp=None, level=None, worker=None, msg=None, **kwargs + ): + super(TaskLogEvent, self).__init__(**kwargs) + self.timestamp = timestamp + self.task = task + self.level = level + self.worker = worker + self.msg = msg + + @schema_property("timestamp") + def timestamp(self): + return self._property_timestamp + + @timestamp.setter + def timestamp(self, value): + if value is None: + self._property_timestamp = None + return + + self.assert_isinstance(value, "timestamp", six.integer_types + (float,)) + self._property_timestamp = value + + @schema_property("type") + def type(self): + return "log" + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("level") + def level(self): + return self._property_level + + @level.setter + def level(self, value): + if value is None: + self._property_level = None + return + if isinstance(value, six.string_types): + try: + value = LogLevelEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "level", enum.Enum) + self._property_level = value + + @schema_property("worker") + def worker(self): + return self._property_worker + + @worker.setter + def worker(self, value): + if value is None: + self._property_worker = None + return + + self.assert_isinstance(value, "worker", six.string_types) + self._property_worker = value + + @schema_property("msg") + def msg(self): + return self._property_msg + + @msg.setter + def msg(self, value): + if value is None: + self._property_msg = None + return + + self.assert_isinstance(value, "msg", six.string_types) + self._property_msg = value + + +class DebugImagesResponseTaskMetrics(NonStrictDataModel): + """ + :param task: Task ID + :type task: str + :param iterations: + :type iterations: Sequence[dict] + """ + + _schema = { + "properties": { + "iterations": { + "items": { + "properties": { + "events": { + "items": { + "description": "Debug " "image " "event", + "type": "object", + }, + "type": "array", + }, + "iter": { + "description": "Iteration " "number", + "type": "integer", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "task": {"description": "Task ID", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, task=None, iterations=None, **kwargs): + super(DebugImagesResponseTaskMetrics, self).__init__(**kwargs) + self.task = task + self.iterations = iterations + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("iterations") + def iterations(self): + return self._property_iterations + + @iterations.setter + def iterations(self, value): + if value is None: + self._property_iterations = None + return + + self.assert_isinstance(value, "iterations", (list, tuple)) + + self.assert_isinstance(value, "iterations", (dict,), is_array=True) + self._property_iterations = value + + +class DebugImagesResponse(NonStrictDataModel): + """ + :param scroll_id: Scroll ID for getting more results + :type scroll_id: str + :param metrics: Debug image events grouped by tasks and iterations + :type metrics: Sequence[DebugImagesResponseTaskMetrics] + """ + + _schema = { + "properties": { + "metrics": { + "description": "Debug image events grouped by " "tasks and iterations", + "items": {"$ref": "#/definitions/debug_images_response_task_metrics"}, + "type": ["array", "null"], + }, + "scroll_id": { + "description": "Scroll ID for getting more " "results", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, scroll_id=None, metrics=None, **kwargs): + super(DebugImagesResponse, self).__init__(**kwargs) + self.scroll_id = scroll_id + self.metrics = metrics + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + DebugImagesResponseTaskMetrics.from_dict(v) + if isinstance(v, dict) + else v + for v in value + ] + else: + self.assert_isinstance( + value, "metrics", DebugImagesResponseTaskMetrics, is_array=True + ) + self._property_metrics = value + + +class PlotsResponseTaskMetrics(NonStrictDataModel): + """ + :param task: Task ID + :type task: str + :param iterations: + :type iterations: Sequence[dict] + """ + + _schema = { + "properties": { + "iterations": { + "items": { + "properties": { + "events": { + "items": {"description": "Plot " "event", "type": "object"}, + "type": "array", + }, + "iter": { + "description": "Iteration " "number", + "type": "integer", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "task": {"description": "Task ID", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, task=None, iterations=None, **kwargs): + super(PlotsResponseTaskMetrics, self).__init__(**kwargs) + self.task = task + self.iterations = iterations + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("iterations") + def iterations(self): + return self._property_iterations + + @iterations.setter + def iterations(self, value): + if value is None: + self._property_iterations = None + return + + self.assert_isinstance(value, "iterations", (list, tuple)) + + self.assert_isinstance(value, "iterations", (dict,), is_array=True) + self._property_iterations = value + + +class PlotsResponse(NonStrictDataModel): + """ + :param scroll_id: Scroll ID for getting more results + :type scroll_id: str + :param metrics: Plot events grouped by tasks and iterations + :type metrics: Sequence[PlotsResponseTaskMetrics] + """ + + _schema = { + "properties": { + "metrics": { + "description": "Plot events grouped by tasks and " "iterations", + "items": {"$ref": "#/definitions/plots_response_task_metrics"}, + "type": ["array", "null"], + }, + "scroll_id": { + "description": "Scroll ID for getting more " "results", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, scroll_id=None, metrics=None, **kwargs): + super(PlotsResponse, self).__init__(**kwargs) + self.scroll_id = scroll_id + self.metrics = metrics + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + PlotsResponseTaskMetrics.from_dict(v) if isinstance(v, dict) else v + for v in value + ] + else: + self.assert_isinstance( + value, "metrics", PlotsResponseTaskMetrics, is_array=True + ) + self._property_metrics = value + + +class DebugImageSampleResponse(NonStrictDataModel): + """ + :param scroll_id: Scroll ID to pass to the next calls to get_debug_image_sample + or next_debug_image_sample + :type scroll_id: str + :param event: Debug image event + :type event: dict + :param min_iteration: minimal valid iteration for the variant + :type min_iteration: int + :param max_iteration: maximal valid iteration for the variant + :type max_iteration: int + """ + + _schema = { + "properties": { + "event": {"description": "Debug image event", "type": ["object", "null"]}, + "max_iteration": { + "description": "maximal valid iteration for " "the variant", + "type": ["integer", "null"], + }, + "min_iteration": { + "description": "minimal valid iteration for " "the variant", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID to pass to the next " + "calls to get_debug_image_sample " + "or next_debug_image_sample", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + scroll_id=None, + event=None, + min_iteration=None, + max_iteration=None, + **kwargs + ): + super(DebugImageSampleResponse, self).__init__(**kwargs) + self.scroll_id = scroll_id + self.event = event + self.min_iteration = min_iteration + self.max_iteration = max_iteration + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("event") + def event(self): + return self._property_event + + @event.setter + def event(self, value): + if value is None: + self._property_event = None + return + + self.assert_isinstance(value, "event", (dict,)) + self._property_event = value + + @schema_property("min_iteration") + def min_iteration(self): + return self._property_min_iteration + + @min_iteration.setter + def min_iteration(self, value): + if value is None: + self._property_min_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "min_iteration", six.integer_types) + self._property_min_iteration = value + + @schema_property("max_iteration") + def max_iteration(self): + return self._property_max_iteration + + @max_iteration.setter + def max_iteration(self, value): + if value is None: + self._property_max_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "max_iteration", six.integer_types) + self._property_max_iteration = value + + +class PlotSampleResponse(NonStrictDataModel): + """ + :param scroll_id: Scroll ID to pass to the next calls to get_plot_sample or + next_plot_sample + :type scroll_id: str + :param event: Plot event + :type event: dict + :param min_iteration: minimal valid iteration for the variant + :type min_iteration: int + :param max_iteration: maximal valid iteration for the variant + :type max_iteration: int + """ + + _schema = { + "properties": { + "event": {"description": "Plot event", "type": ["object", "null"]}, + "max_iteration": { + "description": "maximal valid iteration for " "the variant", + "type": ["integer", "null"], + }, + "min_iteration": { + "description": "minimal valid iteration for " "the variant", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID to pass to the next " + "calls to get_plot_sample or " + "next_plot_sample", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + scroll_id=None, + event=None, + min_iteration=None, + max_iteration=None, + **kwargs + ): + super(PlotSampleResponse, self).__init__(**kwargs) + self.scroll_id = scroll_id + self.event = event + self.min_iteration = min_iteration + self.max_iteration = max_iteration + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("event") + def event(self): + return self._property_event + + @event.setter + def event(self, value): + if value is None: + self._property_event = None + return + + self.assert_isinstance(value, "event", (dict,)) + self._property_event = value + + @schema_property("min_iteration") + def min_iteration(self): + return self._property_min_iteration + + @min_iteration.setter + def min_iteration(self, value): + if value is None: + self._property_min_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "min_iteration", six.integer_types) + self._property_min_iteration = value + + @schema_property("max_iteration") + def max_iteration(self): + return self._property_max_iteration + + @max_iteration.setter + def max_iteration(self, value): + if value is None: + self._property_max_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "max_iteration", six.integer_types) + self._property_max_iteration = value + + +class AddRequest(CompoundRequest): + """ + Adds a single event + + """ + + _service = "events" + _action = "add" + _version = "2.20" + _item_prop_name = "event" + _schema = { + "anyOf": [ + {"$ref": "#/definitions/metrics_scalar_event"}, + {"$ref": "#/definitions/metrics_vector_event"}, + {"$ref": "#/definitions/metrics_image_event"}, + {"$ref": "#/definitions/metrics_plot_event"}, + {"$ref": "#/definitions/task_log_event"}, + ], + "definitions": { + "log_level_enum": { + "enum": [ + "notset", + "debug", + "verbose", + "info", + "warn", + "warning", + "error", + "fatal", + "critical", + ], + "type": "string", + }, + "metrics_image_event": { + "description": "An image or video was dumped to storage for debugging", + "properties": { + "iter": {"description": "Iteration", "type": "integer"}, + "key": {"description": "File key", "type": "string"}, + "metric": { + "description": "Metric name, e.g. 'count', 'loss', 'accuracy'", + "type": "string", + }, + "task": { + "description": "Task ID (required)", + "type": "string", + }, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": {"const": "training_debug_image", "description": ""}, + "url": {"description": "File URL", "type": "string"}, + "variant": { + "description": "E.g. 'class_1', 'total', 'average", + "type": "string", + }, + }, + "required": ["task", "type"], + "type": "object", + }, + "metrics_plot_event": { + "description": " An entire plot (not single datapoint) and it's layout. " + "Used for plotting ROC curves, confidence matrices, " + "etc. when evaluating the net.", + "properties": { + "iter": {"description": "Iteration", "type": "integer"}, + "metric": { + "description": "Metric name, e.g. 'count', 'loss', 'accuracy'", + "type": "string", + }, + "plot_str": { + "description": "An entire plot (not single datapoint) and it's layout. " + "Used for plotting ROC curves, confidence matrices, etc. when evaluating the net.", + "type": "string", + }, + "skip_validation": { + "description": "If set then plot_str is not checked for a valid json. The default is False", + "type": "boolean", + }, + "task": { + "description": "Task ID (required)", + "type": "string", + }, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": {"const": "plot", "description": "'plot'"}, + "variant": { + "description": "E.g. 'class_1', 'total', 'average", + "type": "string", + }, + }, + "required": ["task", "type"], + "type": "object", + }, + "metrics_scalar_event": { + "description": "Used for reporting scalar metrics during training task", + "properties": { + "iter": {"description": "Iteration", "type": "integer"}, + "metric": { + "description": "Metric name, e.g. 'count', 'loss', 'accuracy'", + "type": "string", + }, + "task": { + "description": "Task ID (required)", + "type": "string", + }, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": { + "const": "training_stats_scalar", + "description": "training_stats_vector", + }, + "value": {"description": "", "type": "number"}, + "variant": { + "description": "E.g. 'class_1', 'total', 'average", + "type": "string", + }, + }, + "required": ["task", "type"], + "type": "object", + }, + "metrics_vector_event": { + "description": "Used for reporting vector metrics during training task", + "properties": { + "iter": {"description": "Iteration", "type": "integer"}, + "metric": { + "description": "Metric name, e.g. 'count', 'loss', 'accuracy'", + "type": "string", + }, + "task": { + "description": "Task ID (required)", + "type": "string", + }, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": { + "const": "training_stats_vector", + "description": "training_stats_vector", + }, + "values": { + "description": "vector of float values", + "items": {"type": "number"}, + "type": "array", + }, + "variant": { + "description": "E.g. 'class_1', 'total', 'average", + "type": "string", + }, + }, + "required": ["task"], + "type": "object", + }, + "task_log_event": { + "description": "A log event associated with a task.", + "properties": { + "level": { + "$ref": "#/definitions/log_level_enum", + "description": "Log level.", + }, + "msg": {"description": "Log message.", "type": "string"}, + "task": { + "description": "Task ID (required)", + "type": "string", + }, + "timestamp": { + "description": "Epoch milliseconds UTC, will be set by the server if not set.", + "type": ["number", "null"], + }, + "type": {"const": "log", "description": "'log'"}, + "worker": { + "description": "Name of machine running the task.", + "type": "string", + }, + }, + "required": ["task", "type"], + "type": "object", + }, + }, + "type": "object", + } + + def __init__(self, event): + super(AddRequest, self).__init__() + self.event = event + + @property + def event(self): + return self._property_event + + @event.setter + def event(self, value): + self.assert_isinstance( + value, + "event", + ( + MetricsScalarEvent, + MetricsVectorEvent, + MetricsImageEvent, + MetricsPlotEvent, + TaskLogEvent, + ), + ) + self._property_event = value + + +class AddResponse(Response): + """ + Response of events.add endpoint. + + """ + + _service = "events" + _action = "add" + _version = "2.20" + + _schema = {"additionalProperties": True, "definitions": {}, "type": "object"} + + +class AddBatchRequest(BatchRequest): + """ + Adds a batch of events in a single call (json-lines format, stream-friendly) + + """ + + _service = "events" + _action = "add_batch" + _version = "2.20" + _batched_request_cls = AddRequest + + +class AddBatchResponse(Response): + """ + Response of events.add_batch endpoint. + + :param added: + :type added: int + :param errors: + :type errors: int + :param errors_info: + :type errors_info: dict + """ + + _service = "events" + _action = "add_batch" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "added": {"type": ["integer", "null"]}, + "errors": {"type": ["integer", "null"]}, + "errors_info": {"type": ["object", "null"]}, + }, + "type": "object", + } + + def __init__(self, added=None, errors=None, errors_info=None, **kwargs): + super(AddBatchResponse, self).__init__(**kwargs) + self.added = added + self.errors = errors + self.errors_info = errors_info + + @schema_property("added") + def added(self): + return self._property_added + + @added.setter + def added(self, value): + if value is None: + self._property_added = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "added", six.integer_types) + self._property_added = value + + @schema_property("errors") + def errors(self): + return self._property_errors + + @errors.setter + def errors(self, value): + if value is None: + self._property_errors = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "errors", six.integer_types) + self._property_errors = value + + @schema_property("errors_info") + def errors_info(self): + return self._property_errors_info + + @errors_info.setter + def errors_info(self, value): + if value is None: + self._property_errors_info = None + return + + self.assert_isinstance(value, "errors_info", (dict,)) + self._property_errors_info = value + + +class ClearScrollRequest(Request): + """ + Clear an open Scroll ID + + :param scroll_id: Scroll ID as returned by previous events service calls + :type scroll_id: str + """ + + _service = "events" + _action = "clear_scroll" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "scroll_id": { + "description": "Scroll ID as returned by previous events service calls", + "type": "string", + } + }, + "required": ["scroll_id"], + "type": "object", + } + + def __init__(self, scroll_id, **kwargs): + super(ClearScrollRequest, self).__init__(**kwargs) + self.scroll_id = scroll_id + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class ClearScrollResponse(Response): + """ + Response of events.clear_scroll endpoint. + + """ + + _service = "events" + _action = "clear_scroll" + _version = "2.20" + + _schema = {"additionalProperties": False, "definitions": {}, "type": "object"} + + +class ClearTaskLogRequest(Request): + """ + Remove old logs from task + + :param task: Task ID + :type task: str + :param allow_locked: Allow deleting events even if the task is locked + :type allow_locked: bool + :param threshold_sec: The amount of seconds ago to retain the log records. The + older log records will be deleted. If not passed or 0 then all the log records + for the task will be deleted + :type threshold_sec: int + """ + + _service = "events" + _action = "clear_task_log" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "allow_locked": { + "default": False, + "description": "Allow deleting events even if the task is locked", + "type": "boolean", + }, + "task": {"description": "Task ID", "type": "string"}, + "threshold_sec": { + "description": "The amount of seconds ago to retain the log records. " + "The older log records will be deleted. If not passed or 0 " + "then all the log records for the task will be deleted", + "type": "integer", + }, + }, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, allow_locked=False, threshold_sec=None, **kwargs): + super(ClearTaskLogRequest, self).__init__(**kwargs) + self.task = task + self.allow_locked = allow_locked + self.threshold_sec = threshold_sec + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("allow_locked") + def allow_locked(self): + return self._property_allow_locked + + @allow_locked.setter + def allow_locked(self, value): + if value is None: + self._property_allow_locked = None + return + + self.assert_isinstance(value, "allow_locked", (bool,)) + self._property_allow_locked = value + + @schema_property("threshold_sec") + def threshold_sec(self): + return self._property_threshold_sec + + @threshold_sec.setter + def threshold_sec(self, value): + if value is None: + self._property_threshold_sec = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "threshold_sec", six.integer_types) + self._property_threshold_sec = value + + +class ClearTaskLogResponse(Response): + """ + Response of events.clear_task_log endpoint. + + :param deleted: The number of deleted log records + :type deleted: int + """ + + _service = "events" + _action = "clear_task_log" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "deleted": { + "description": "The number of deleted log records", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, deleted=None, **kwargs): + super(ClearTaskLogResponse, self).__init__(**kwargs) + self.deleted = deleted + + @schema_property("deleted") + def deleted(self): + return self._property_deleted + + @deleted.setter + def deleted(self, value): + if value is None: + self._property_deleted = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "deleted", six.integer_types) + self._property_deleted = value + + +class DebugImagesRequest(Request): + """ + Get the debug image events for the requested amount of iterations per each task + + :param metrics: List of metrics and variants + :type metrics: Sequence[TaskMetricVariants] + :param iters: Max number of latest iterations for which to return debug images + :type iters: int + :param navigate_earlier: If set then events are retreived from latest + iterations to earliest ones. Otherwise from earliest iterations to the latest. + The default is True + :type navigate_earlier: bool + :param refresh: If set then scroll will be moved to the latest iterations. The + default is False + :type refresh: bool + :param scroll_id: Scroll ID of previous call (used for getting more results) + :type scroll_id: str + """ + + _service = "events" + _action = "debug_images" + _version = "2.20" + _schema = { + "definitions": { + "task_metric_variants": { + "properties": { + "metric": {"description": "Metric " "name", "type": "string"}, + "task": {"description": "Task " "ID", "type": "string"}, + "variants": { + "description": "Metric variant names", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["task"], + "type": "object", + } + }, + "properties": { + "iters": { + "description": "Max number of latest iterations for which to return debug images", + "type": "integer", + }, + "metrics": { + "description": "List of metrics and variants", + "items": {"$ref": "#/definitions/task_metric_variants"}, + "type": "array", + }, + "navigate_earlier": { + "description": "If set then events are retreived from latest " + "iterations to earliest ones. Otherwise from " + "earliest iterations to the latest. The default is True", + "type": "boolean", + }, + "refresh": { + "description": "If set then scroll will be moved to the latest iterations. " + "The default is False", + "type": "boolean", + }, + "scroll_id": { + "description": "Scroll ID of previous call (used for getting more results)", + "type": "string", + }, + }, + "required": ["metrics"], + "type": "object", + } + + def __init__( + self, + metrics, + iters=None, + navigate_earlier=None, + refresh=None, + scroll_id=None, + **kwargs + ): + super(DebugImagesRequest, self).__init__(**kwargs) + self.metrics = metrics + self.iters = iters + self.navigate_earlier = navigate_earlier + self.refresh = refresh + self.scroll_id = scroll_id + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + TaskMetricVariants.from_dict(v) if isinstance(v, dict) else v + for v in value + ] + else: + self.assert_isinstance(value, "metrics", TaskMetricVariants, is_array=True) + self._property_metrics = value + + @schema_property("iters") + def iters(self): + return self._property_iters + + @iters.setter + def iters(self, value): + if value is None: + self._property_iters = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iters", six.integer_types) + self._property_iters = value + + @schema_property("navigate_earlier") + def navigate_earlier(self): + return self._property_navigate_earlier + + @navigate_earlier.setter + def navigate_earlier(self, value): + if value is None: + self._property_navigate_earlier = None + return + + self.assert_isinstance(value, "navigate_earlier", (bool,)) + self._property_navigate_earlier = value + + @schema_property("refresh") + def refresh(self): + return self._property_refresh + + @refresh.setter + def refresh(self, value): + if value is None: + self._property_refresh = None + return + + self.assert_isinstance(value, "refresh", (bool,)) + self._property_refresh = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class DeleteForTaskRequest(Request): + """ + Delete all task event. *This cannot be undone!* + + :param task: Task ID + :type task: str + :param allow_locked: Allow deleting events even if the task is locked + :type allow_locked: bool + """ + + _service = "events" + _action = "delete_for_task" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "allow_locked": { + "default": False, + "description": "Allow deleting events even if the task is locked", + "type": "boolean", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, allow_locked=False, **kwargs): + super(DeleteForTaskRequest, self).__init__(**kwargs) + self.task = task + self.allow_locked = allow_locked + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("allow_locked") + def allow_locked(self): + return self._property_allow_locked + + @allow_locked.setter + def allow_locked(self, value): + if value is None: + self._property_allow_locked = None + return + + self.assert_isinstance(value, "allow_locked", (bool,)) + self._property_allow_locked = value + + +class DeleteForTaskResponse(Response): + """ + Response of events.delete_for_task endpoint. + + :param deleted: Number of deleted events + :type deleted: bool + """ + + _service = "events" + _action = "delete_for_task" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "deleted": { + "description": "Number of deleted events", + "type": ["boolean", "null"], + } + }, + "type": "object", + } + + def __init__(self, deleted=None, **kwargs): + super(DeleteForTaskResponse, self).__init__(**kwargs) + self.deleted = deleted + + @schema_property("deleted") + def deleted(self): + return self._property_deleted + + @deleted.setter + def deleted(self, value): + if value is None: + self._property_deleted = None + return + + self.assert_isinstance(value, "deleted", (bool,)) + self._property_deleted = value + + +class DownloadTaskLogRequest(Request): + """ + Get an attachment containing the task's log + + :param task: Task ID + :type task: str + :param line_type: Line format type + :type line_type: str + :param line_format: Line string format. Used if the line type is 'text' + :type line_format: str + """ + + _service = "events" + _action = "download_task_log" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "line_format": { + "default": "{asctime} {worker} {level} {msg}", + "description": "Line string format. Used if the line type is 'text'", + "type": "string", + }, + "line_type": { + "description": "Line format type", + "enum": ["json", "text"], + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + line_type=None, + line_format="{asctime} {worker} {level} {msg}", + **kwargs + ): + super(DownloadTaskLogRequest, self).__init__(**kwargs) + self.task = task + self.line_type = line_type + self.line_format = line_format + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("line_type") + def line_type(self): + return self._property_line_type + + @line_type.setter + def line_type(self, value): + if value is None: + self._property_line_type = None + return + + self.assert_isinstance(value, "line_type", six.string_types) + self._property_line_type = value + + @schema_property("line_format") + def line_format(self): + return self._property_line_format + + @line_format.setter + def line_format(self, value): + if value is None: + self._property_line_format = None + return + + self.assert_isinstance(value, "line_format", six.string_types) + self._property_line_format = value + + +class DownloadTaskLogResponse(Response): + """ + Response of events.download_task_log endpoint. + + """ + + _service = "events" + _action = "download_task_log" + _version = "2.20" + + _schema = {"definitions": {}, "type": "string"} + + +class GetDebugImageSampleRequest(Request): + """ + Return the debug image per metric and variant for the provided iteration + + :param task: Task ID + :type task: str + :param metric: Metric name + :type metric: str + :param variant: Metric variant + :type variant: str + :param iteration: The iteration to bring debug image from. If not specified + then the latest reported image is retrieved + :type iteration: int + :param refresh: If set then scroll state will be refreshed to reflect the + latest changes in the debug images + :type refresh: bool + :param scroll_id: Scroll ID from the previous call to get_debug_image_sample or + empty + :type scroll_id: str + :param navigate_current_metric: If set then subsequent navigation with + next_debug_image_sample is done on the debug images for the passed metric only. + Otherwise for all the metrics + :type navigate_current_metric: bool + """ + + _service = "events" + _action = "get_debug_image_sample" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "iteration": { + "description": "The iteration to bring debug image from. If not specified " + "then the latest reported image is retrieved", + "type": "integer", + }, + "metric": {"description": "Metric name", "type": "string"}, + "navigate_current_metric": { + "default": True, + "description": "If set then subsequent navigation with " + "next_debug_image_sample is done on the debug images for " + "the passed metric only. Otherwise for all the metrics", + "type": "boolean", + }, + "refresh": { + "description": "If set then scroll state will be " + "refreshed to reflect the latest changes in the debug images", + "type": "boolean", + }, + "scroll_id": { + "description": "Scroll ID from the previous call " + "to get_debug_image_sample or empty", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + "variant": {"description": "Metric variant", "type": "string"}, + }, + "required": ["task", "metric", "variant"], + "type": "object", + } + + def __init__( + self, + task, + metric, + variant, + iteration=None, + refresh=None, + scroll_id=None, + navigate_current_metric=True, + **kwargs + ): + super(GetDebugImageSampleRequest, self).__init__(**kwargs) + self.task = task + self.metric = metric + self.variant = variant + self.iteration = iteration + self.refresh = refresh + self.scroll_id = scroll_id + self.navigate_current_metric = navigate_current_metric + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + @schema_property("iteration") + def iteration(self): + return self._property_iteration + + @iteration.setter + def iteration(self, value): + if value is None: + self._property_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iteration", six.integer_types) + self._property_iteration = value + + @schema_property("refresh") + def refresh(self): + return self._property_refresh + + @refresh.setter + def refresh(self, value): + if value is None: + self._property_refresh = None + return + + self.assert_isinstance(value, "refresh", (bool,)) + self._property_refresh = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("navigate_current_metric") + def navigate_current_metric(self): + return self._property_navigate_current_metric + + @navigate_current_metric.setter + def navigate_current_metric(self, value): + if value is None: + self._property_navigate_current_metric = None + return + + self.assert_isinstance(value, "navigate_current_metric", (bool,)) + self._property_navigate_current_metric = value + + +class GetDebugImageSampleResponse(Response): + """ + Response of events.get_debug_image_sample endpoint. + + """ + + _service = "events" + _action = "get_debug_image_sample" + _version = "2.20" + + _schema = { + "$ref": "#/definitions/debug_image_sample_response", + "definitions": { + "debug_image_sample_response": { + "properties": { + "event": { + "description": "Debug " "image " "event", + "type": ["object", "null"], + }, + "max_iteration": { + "description": "maximal valid iteration for the variant", + "type": ["integer", "null"], + }, + "min_iteration": { + "description": "minimal valid iteration for the variant", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID to pass to the next calls to get_debug_image_sample " + "or next_debug_image_sample", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + } + + +class GetMultiTaskPlotsRequest(Request): + """ + Get 'plot' events for the given tasks + + :param tasks: List of task IDs + :type tasks: Sequence[str] + :param iters: Max number of latest iterations for which to return debug images + :type iters: int + :param scroll_id: Scroll ID of previous call (used for getting more results) + :type scroll_id: str + :param no_scroll: If Truethen no scroll is created. Suitable for one time calls + :type no_scroll: bool + """ + + _service = "events" + _action = "get_multi_task_plots" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "iters": { + "description": "Max number of latest iterations for which to return debug images", + "type": "integer", + }, + "no_scroll": { + "default": False, + "description": "If Truethen no scroll is created. Suitable for one time calls", + "type": "boolean", + }, + "scroll_id": { + "description": "Scroll ID of previous call (used for getting more results)", + "type": "string", + }, + "tasks": { + "description": "List of task IDs", + "items": {"description": "Task ID", "type": "string"}, + "type": "array", + }, + }, + "required": ["tasks"], + "type": "object", + } + + def __init__(self, tasks, iters=None, scroll_id=None, no_scroll=False, **kwargs): + super(GetMultiTaskPlotsRequest, self).__init__(**kwargs) + self.tasks = tasks + self.iters = iters + self.scroll_id = scroll_id + self.no_scroll = no_scroll + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + + self.assert_isinstance(value, "tasks", six.string_types, is_array=True) + self._property_tasks = value + + @schema_property("iters") + def iters(self): + return self._property_iters + + @iters.setter + def iters(self, value): + if value is None: + self._property_iters = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iters", six.integer_types) + self._property_iters = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("no_scroll") + def no_scroll(self): + return self._property_no_scroll + + @no_scroll.setter + def no_scroll(self, value): + if value is None: + self._property_no_scroll = None + return + + self.assert_isinstance(value, "no_scroll", (bool,)) + self._property_no_scroll = value + + +class GetMultiTaskPlotsResponse(Response): + """ + Response of events.get_multi_task_plots endpoint. + + :param plots: Plots mapping (keyed by task name) + :type plots: dict + :param returned: Number of results returned + :type returned: int + :param total: Total number of results available for this query + :type total: float + :param scroll_id: Scroll ID for getting more results + :type scroll_id: str + """ + + _service = "events" + _action = "get_multi_task_plots" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "plots": { + "description": "Plots mapping (keyed by task name)", + "type": ["object", "null"], + }, + "returned": { + "description": "Number of results returned", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID for getting more results", + "type": ["string", "null"], + }, + "total": { + "description": "Total number of results available for this query", + "type": ["number", "null"], + }, + }, + "type": "object", + } + + def __init__(self, plots=None, returned=None, total=None, scroll_id=None, **kwargs): + super(GetMultiTaskPlotsResponse, self).__init__(**kwargs) + self.plots = plots + self.returned = returned + self.total = total + self.scroll_id = scroll_id + + @schema_property("plots") + def plots(self): + return self._property_plots + + @plots.setter + def plots(self, value): + if value is None: + self._property_plots = None + return + + self.assert_isinstance(value, "plots", (dict,)) + self._property_plots = value + + @schema_property("returned") + def returned(self): + return self._property_returned + + @returned.setter + def returned(self, value): + if value is None: + self._property_returned = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "returned", six.integer_types) + self._property_returned = value + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + + self.assert_isinstance(value, "total", six.integer_types + (float,)) + self._property_total = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class GetPlotSampleRequest(Request): + """ + Return the plot per metric and variant for the provided iteration + + :param task: Task ID + :type task: str + :param metric: Metric name + :type metric: str + :param variant: Metric variant + :type variant: str + :param iteration: The iteration to bring plot from. If not specified then the + latest reported plot is retrieved + :type iteration: int + :param refresh: If set then scroll state will be refreshed to reflect the + latest changes in the plots + :type refresh: bool + :param scroll_id: Scroll ID from the previous call to get_plot_sample or empty + :type scroll_id: str + :param navigate_current_metric: If set then subsequent navigation with + next_plot_sample is done on the plots for the passed metric only. Otherwise for + all the metrics + :type navigate_current_metric: bool + """ + + _service = "events" + _action = "get_plot_sample" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "iteration": { + "description": "The iteration to bring plot from. If not specified then the " + "latest reported plot is retrieved", + "type": "integer", + }, + "metric": {"description": "Metric name", "type": "string"}, + "navigate_current_metric": { + "default": True, + "description": "If set then subsequent navigation with next_plot_sample is done on the " + "plots for the passed metric only. Otherwise for all the metrics", + "type": "boolean", + }, + "refresh": { + "description": "If set then scroll state will be refreshed to reflect the latest " + "changes in the plots", + "type": "boolean", + }, + "scroll_id": { + "description": "Scroll ID from the previous call to get_plot_sample or empty", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + "variant": {"description": "Metric variant", "type": "string"}, + }, + "required": ["task", "metric", "variant"], + "type": "object", + } + + def __init__( + self, + task, + metric, + variant, + iteration=None, + refresh=None, + scroll_id=None, + navigate_current_metric=True, + **kwargs + ): + super(GetPlotSampleRequest, self).__init__(**kwargs) + self.task = task + self.metric = metric + self.variant = variant + self.iteration = iteration + self.refresh = refresh + self.scroll_id = scroll_id + self.navigate_current_metric = navigate_current_metric + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + @schema_property("iteration") + def iteration(self): + return self._property_iteration + + @iteration.setter + def iteration(self, value): + if value is None: + self._property_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iteration", six.integer_types) + self._property_iteration = value + + @schema_property("refresh") + def refresh(self): + return self._property_refresh + + @refresh.setter + def refresh(self, value): + if value is None: + self._property_refresh = None + return + + self.assert_isinstance(value, "refresh", (bool,)) + self._property_refresh = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("navigate_current_metric") + def navigate_current_metric(self): + return self._property_navigate_current_metric + + @navigate_current_metric.setter + def navigate_current_metric(self, value): + if value is None: + self._property_navigate_current_metric = None + return + + self.assert_isinstance(value, "navigate_current_metric", (bool,)) + self._property_navigate_current_metric = value + + +class GetPlotSampleResponse(Response): + """ + Response of events.get_plot_sample endpoint. + + """ + + _service = "events" + _action = "get_plot_sample" + _version = "2.20" + + _schema = { + "$ref": "#/definitions/plot_sample_response", + "definitions": { + "plot_sample_response": { + "properties": { + "event": { + "description": "Plot event", + "type": ["object", "null"], + }, + "max_iteration": { + "description": "maximal valid iteration for the variant", + "type": ["integer", "null"], + }, + "min_iteration": { + "description": "minimal valid iteration for the variant", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID to pass to the next calls to get_plot_sample " + "or next_plot_sample", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + } + + +class GetScalarMetricDataRequest(Request): + """ + get scalar metric data for task + + :param task: task ID + :type task: str + :param metric: type of metric + :type metric: str + :param no_scroll: If Truethen no scroll is created. Suitable for one time calls + :type no_scroll: bool + """ + + _service = "events" + _action = "get_scalar_metric_data" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "metric": {"description": "type of metric", "type": ["string", "null"]}, + "no_scroll": { + "default": False, + "description": "If Truethen no scroll is created. Suitable for one time calls", + "type": ["boolean", "null"], + }, + "task": {"description": "task ID", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, task=None, metric=None, no_scroll=False, **kwargs): + super(GetScalarMetricDataRequest, self).__init__(**kwargs) + self.task = task + self.metric = metric + self.no_scroll = no_scroll + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("no_scroll") + def no_scroll(self): + return self._property_no_scroll + + @no_scroll.setter + def no_scroll(self, value): + if value is None: + self._property_no_scroll = None + return + + self.assert_isinstance(value, "no_scroll", (bool,)) + self._property_no_scroll = value + + +class GetScalarMetricDataResponse(Response): + """ + Response of events.get_scalar_metric_data endpoint. + + :param events: task scalar metric events + :type events: Sequence[dict] + :param returned: amount of events returned + :type returned: int + :param total: amount of events in task + :type total: int + :param scroll_id: Scroll ID of previous call (used for getting more results) + :type scroll_id: str + """ + + _service = "events" + _action = "get_scalar_metric_data" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "events": { + "description": "task scalar metric events", + "items": {"type": "object"}, + "type": ["array", "null"], + }, + "returned": { + "description": "amount of events returned", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID of previous call (used for getting more results)", + "type": ["string", "null"], + }, + "total": { + "description": "amount of events in task", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, events=None, returned=None, total=None, scroll_id=None, **kwargs + ): + super(GetScalarMetricDataResponse, self).__init__(**kwargs) + self.events = events + self.returned = returned + self.total = total + self.scroll_id = scroll_id + + @schema_property("events") + def events(self): + return self._property_events + + @events.setter + def events(self, value): + if value is None: + self._property_events = None + return + + self.assert_isinstance(value, "events", (list, tuple)) + + self.assert_isinstance(value, "events", (dict,), is_array=True) + self._property_events = value + + @schema_property("returned") + def returned(self): + return self._property_returned + + @returned.setter + def returned(self, value): + if value is None: + self._property_returned = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "returned", six.integer_types) + self._property_returned = value + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "total", six.integer_types) + self._property_total = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class GetScalarMetricsAndVariantsRequest(Request): + """ + get task scalar metrics and variants + + :param task: task ID + :type task: str + """ + + _service = "events" + _action = "get_scalar_metrics_and_variants" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"task": {"description": "task ID", "type": "string"}}, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, **kwargs): + super(GetScalarMetricsAndVariantsRequest, self).__init__(**kwargs) + self.task = task + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class GetScalarMetricsAndVariantsResponse(Response): + """ + Response of events.get_scalar_metrics_and_variants endpoint. + + :param metrics: + :type metrics: dict + """ + + _service = "events" + _action = "get_scalar_metrics_and_variants" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "metrics": {"additionalProperties": True, "type": ["object", "null"]} + }, + "type": "object", + } + + def __init__(self, metrics=None, **kwargs): + super(GetScalarMetricsAndVariantsResponse, self).__init__(**kwargs) + self.metrics = metrics + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (dict,)) + self._property_metrics = value + + +class GetTaskEventsRequest(Request): + """ + Scroll through task events, sorted by timestamp + + :param task: Task ID + :type task: str + :param order: 'asc' (default) or 'desc'. + :type order: str + :param scroll_id: Pass this value on next call to get next page + :type scroll_id: str + :param batch_size: Number of events to return each time (default 500) + :type batch_size: int + :param event_type: Return only events of this type + :type event_type: str + """ + + _service = "events" + _action = "get_task_events" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "batch_size": { + "description": "Number of events to return each time (default 500)", + "type": "integer", + }, + "event_type": { + "description": "Return only events of this type", + "type": "string", + }, + "order": { + "description": "'asc' (default) or 'desc'.", + "enum": ["asc", "desc"], + "type": "string", + }, + "scroll_id": { + "description": "Pass this value on next call to get next page", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + order=None, + scroll_id=None, + batch_size=None, + event_type=None, + **kwargs + ): + super(GetTaskEventsRequest, self).__init__(**kwargs) + self.task = task + self.order = order + self.scroll_id = scroll_id + self.batch_size = batch_size + self.event_type = event_type + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("order") + def order(self): + return self._property_order + + @order.setter + def order(self, value): + if value is None: + self._property_order = None + return + + self.assert_isinstance(value, "order", six.string_types) + self._property_order = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("batch_size") + def batch_size(self): + return self._property_batch_size + + @batch_size.setter + def batch_size(self, value): + if value is None: + self._property_batch_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "batch_size", six.integer_types) + self._property_batch_size = value + + @schema_property("event_type") + def event_type(self): + return self._property_event_type + + @event_type.setter + def event_type(self, value): + if value is None: + self._property_event_type = None + return + + self.assert_isinstance(value, "event_type", six.string_types) + self._property_event_type = value + + +class GetTaskEventsResponse(Response): + """ + Response of events.get_task_events endpoint. + + :param events: Events list + :type events: Sequence[dict] + :param returned: Number of results returned + :type returned: int + :param total: Total number of results available for this query + :type total: float + :param scroll_id: Scroll ID for getting more results + :type scroll_id: str + """ + + _service = "events" + _action = "get_task_events" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "events": { + "description": "Events list", + "items": {"type": "object"}, + "type": ["array", "null"], + }, + "returned": { + "description": "Number of results returned", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID for getting more results", + "type": ["string", "null"], + }, + "total": { + "description": "Total number of results available for this query", + "type": ["number", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, events=None, returned=None, total=None, scroll_id=None, **kwargs + ): + super(GetTaskEventsResponse, self).__init__(**kwargs) + self.events = events + self.returned = returned + self.total = total + self.scroll_id = scroll_id + + @schema_property("events") + def events(self): + return self._property_events + + @events.setter + def events(self, value): + if value is None: + self._property_events = None + return + + self.assert_isinstance(value, "events", (list, tuple)) + + self.assert_isinstance(value, "events", (dict,), is_array=True) + self._property_events = value + + @schema_property("returned") + def returned(self): + return self._property_returned + + @returned.setter + def returned(self, value): + if value is None: + self._property_returned = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "returned", six.integer_types) + self._property_returned = value + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + + self.assert_isinstance(value, "total", six.integer_types + (float,)) + self._property_total = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class GetTaskLatestScalarValuesRequest(Request): + """ + Get the tasks's latest scalar values + + :param task: Task ID + :type task: str + """ + + _service = "events" + _action = "get_task_latest_scalar_values" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"task": {"description": "Task ID", "type": "string"}}, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, **kwargs): + super(GetTaskLatestScalarValuesRequest, self).__init__(**kwargs) + self.task = task + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class GetTaskLatestScalarValuesResponse(Response): + """ + Response of events.get_task_latest_scalar_values endpoint. + + :param metrics: + :type metrics: Sequence[dict] + """ + + _service = "events" + _action = "get_task_latest_scalar_values" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "metrics": { + "items": { + "properties": { + "name": {"description": "Metric name", "type": "string"}, + "variants": { + "items": { + "properties": { + "last_100_value": { + "description": "Average of 100 last reported values", + "type": "number", + }, + "last_value": { + "description": "Last reported value", + "type": "number", + }, + "name": { + "description": "Variant name", + "type": "string", + }, + }, + "type": "object", + }, + "type": "array", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, metrics=None, **kwargs): + super(GetTaskLatestScalarValuesResponse, self).__init__(**kwargs) + self.metrics = metrics + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + + self.assert_isinstance(value, "metrics", (dict,), is_array=True) + self._property_metrics = value + + +class GetTaskLogRequest(Request): + """ + Get 'log' events for this task + + :param task: Task ID + :type task: str + :param batch_size: The amount of log events to return + :type batch_size: int + :param navigate_earlier: If set then log events are retreived from the latest + to the earliest ones (in timestamp descending order, unless order='asc'). + Otherwise from the earliest to the latest ones (in timestamp ascending order, + unless order='desc'). The default is True + :type navigate_earlier: bool + :param from_timestamp: Epoch time in UTC ms to use as the navigation start. + Optional. If not provided, reference timestamp is determined by the + 'navigate_earlier' parameter (if true, reference timestamp is the last + timestamp and if false, reference timestamp is the first timestamp) + :type from_timestamp: float + :param order: If set, changes the order in which log events are returned based + on the value of 'navigate_earlier' + :type order: str + """ + + _service = "events" + _action = "get_task_log" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "batch_size": { + "description": "The amount of log events to return", + "type": "integer", + }, + "from_timestamp": { + "description": "Epoch time in UTC ms to use as the navigation start. Optional. If not provided, " + "reference timestamp is determined by the 'navigate_earlier' parameter (if true, reference " + " timestamp is the last timestamp and if false, reference timestamp is the first timestamp)", + "type": "number", + }, + "navigate_earlier": { + "description": "If set then log events are retreived from the latest to the earliest ones " + "(in timestamp descending order, unless order='asc'). Otherwise from the earliest to the " + "latest ones (in timestamp ascending order, unless order='desc'). The default is True", + "type": "boolean", + }, + "order": { + "description": "If set, changes the order in which log events are returned based on the value of " + "'navigate_earlier'", + "enum": ["asc", "desc"], + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + batch_size=None, + navigate_earlier=None, + from_timestamp=None, + order=None, + **kwargs + ): + super(GetTaskLogRequest, self).__init__(**kwargs) + self.task = task + self.batch_size = batch_size + self.navigate_earlier = navigate_earlier + self.from_timestamp = from_timestamp + self.order = order + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("batch_size") + def batch_size(self): + return self._property_batch_size + + @batch_size.setter + def batch_size(self, value): + if value is None: + self._property_batch_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "batch_size", six.integer_types) + self._property_batch_size = value + + @schema_property("navigate_earlier") + def navigate_earlier(self): + return self._property_navigate_earlier + + @navigate_earlier.setter + def navigate_earlier(self, value): + if value is None: + self._property_navigate_earlier = None + return + + self.assert_isinstance(value, "navigate_earlier", (bool,)) + self._property_navigate_earlier = value + + @schema_property("from_timestamp") + def from_timestamp(self): + return self._property_from_timestamp + + @from_timestamp.setter + def from_timestamp(self, value): + if value is None: + self._property_from_timestamp = None + return + + self.assert_isinstance(value, "from_timestamp", six.integer_types + (float,)) + self._property_from_timestamp = value + + @schema_property("order") + def order(self): + return self._property_order + + @order.setter + def order(self, value): + if value is None: + self._property_order = None + return + + self.assert_isinstance(value, "order", six.string_types) + self._property_order = value + + +class GetTaskLogResponse(Response): + """ + Response of events.get_task_log endpoint. + + :param events: Log items list + :type events: Sequence[dict] + :param returned: Number of log events returned + :type returned: int + :param total: Total number of log events available for this query + :type total: float + """ + + _service = "events" + _action = "get_task_log" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "events": { + "description": "Log items list", + "items": {"type": "object"}, + "type": ["array", "null"], + }, + "returned": { + "description": "Number of log events returned", + "type": ["integer", "null"], + }, + "total": { + "description": "Total number of log events available for this query", + "type": ["number", "null"], + }, + }, + "type": "object", + } + + def __init__(self, events=None, returned=None, total=None, **kwargs): + super(GetTaskLogResponse, self).__init__(**kwargs) + self.events = events + self.returned = returned + self.total = total + + @schema_property("events") + def events(self): + return self._property_events + + @events.setter + def events(self, value): + if value is None: + self._property_events = None + return + + self.assert_isinstance(value, "events", (list, tuple)) + + self.assert_isinstance(value, "events", (dict,), is_array=True) + self._property_events = value + + @schema_property("returned") + def returned(self): + return self._property_returned + + @returned.setter + def returned(self, value): + if value is None: + self._property_returned = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "returned", six.integer_types) + self._property_returned = value + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + + self.assert_isinstance(value, "total", six.integer_types + (float,)) + self._property_total = value + + +class GetTaskMetricsRequest(Request): + """ + For each task, get a list of metrics for which the requested event type was reported + + :param tasks: Task IDs + :type tasks: Sequence[str] + :param event_type: Event type + :type event_type: EventTypeEnum + """ + + _service = "events" + _action = "get_task_metrics" + _version = "2.20" + _schema = { + "definitions": { + "event_type_enum": { + "enum": [ + "training_stats_scalar", + "training_stats_vector", + "training_debug_image", + "plot", + "log", + ], + "type": "string", + } + }, + "properties": { + "event_type": { + "$ref": "#/definitions/event_type_enum", + "description": "Event type", + }, + "tasks": { + "description": "Task IDs", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["tasks"], + "type": "object", + } + + def __init__(self, tasks, event_type=None, **kwargs): + super(GetTaskMetricsRequest, self).__init__(**kwargs) + self.tasks = tasks + self.event_type = event_type + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + + self.assert_isinstance(value, "tasks", six.string_types, is_array=True) + self._property_tasks = value + + @schema_property("event_type") + def event_type(self): + return self._property_event_type + + @event_type.setter + def event_type(self, value): + if value is None: + self._property_event_type = None + return + if isinstance(value, six.string_types): + try: + value = EventTypeEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "event_type", enum.Enum) + self._property_event_type = value + + +class GetTaskMetricsResponse(Response): + """ + Response of events.get_task_metrics endpoint. + + :param metrics: List of task with their metrics + :type metrics: Sequence[dict] + """ + + _service = "events" + _action = "get_task_metrics" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "metrics": { + "description": "List of task with their metrics", + "items": {"type": "object"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, metrics=None, **kwargs): + super(GetTaskMetricsResponse, self).__init__(**kwargs) + self.metrics = metrics + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + + self.assert_isinstance(value, "metrics", (dict,), is_array=True) + self._property_metrics = value + + +class GetTaskPlotsRequest(Request): + """ + Get all 'plot' events for this task + + :param task: Task ID + :type task: str + :param iters: Max number of latest iterations for which to return debug images + :type iters: int + :param scroll_id: Scroll ID of previous call (used for getting more results) + :type scroll_id: str + :param metrics: List of metrics and variants + :type metrics: Sequence[MetricVariants] + :param no_scroll: If Truethen no scroll is created. Suitable for one time calls + :type no_scroll: bool + """ + + _service = "events" + _action = "get_task_plots" + _version = "2.20" + _schema = { + "definitions": { + "metric_variants": { + "metric": {"description": "The metric name", "type": "string"}, + "type": "object", + "variants": { + "description": "The names of the metric variants", + "items": {"type": "string"}, + "type": "array", + }, + } + }, + "properties": { + "iters": { + "description": "Max number of latest iterations for which to return debug images", + "type": "integer", + }, + "metrics": { + "description": "List of metrics and variants", + "items": {"$ref": "#/definitions/metric_variants"}, + "type": "array", + }, + "no_scroll": { + "default": False, + "description": "If Truethen no scroll is created. Suitable for one time calls", + "type": "boolean", + }, + "scroll_id": { + "description": "Scroll ID of previous call (used for getting more results)", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, task, iters=None, scroll_id=None, metrics=None, no_scroll=False, **kwargs + ): + super(GetTaskPlotsRequest, self).__init__(**kwargs) + self.task = task + self.iters = iters + self.scroll_id = scroll_id + self.metrics = metrics + self.no_scroll = no_scroll + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("iters") + def iters(self): + return self._property_iters + + @iters.setter + def iters(self, value): + if value is None: + self._property_iters = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iters", six.integer_types) + self._property_iters = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + MetricVariants.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "metrics", MetricVariants, is_array=True) + self._property_metrics = value + + @schema_property("no_scroll") + def no_scroll(self): + return self._property_no_scroll + + @no_scroll.setter + def no_scroll(self, value): + if value is None: + self._property_no_scroll = None + return + + self.assert_isinstance(value, "no_scroll", (bool,)) + self._property_no_scroll = value + + +class GetTaskPlotsResponse(Response): + """ + Response of events.get_task_plots endpoint. + + :param plots: Plots list + :type plots: Sequence[dict] + :param returned: Number of results returned + :type returned: int + :param total: Total number of results available for this query + :type total: float + :param scroll_id: Scroll ID for getting more results + :type scroll_id: str + """ + + _service = "events" + _action = "get_task_plots" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "plots": { + "description": "Plots list", + "items": {"type": "object"}, + "type": ["array", "null"], + }, + "returned": { + "description": "Number of results returned", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID for getting more results", + "type": ["string", "null"], + }, + "total": { + "description": "Total number of results available for this query", + "type": ["number", "null"], + }, + }, + "type": "object", + } + + def __init__(self, plots=None, returned=None, total=None, scroll_id=None, **kwargs): + super(GetTaskPlotsResponse, self).__init__(**kwargs) + self.plots = plots + self.returned = returned + self.total = total + self.scroll_id = scroll_id + + @schema_property("plots") + def plots(self): + return self._property_plots + + @plots.setter + def plots(self, value): + if value is None: + self._property_plots = None + return + + self.assert_isinstance(value, "plots", (list, tuple)) + + self.assert_isinstance(value, "plots", (dict,), is_array=True) + self._property_plots = value + + @schema_property("returned") + def returned(self): + return self._property_returned + + @returned.setter + def returned(self, value): + if value is None: + self._property_returned = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "returned", six.integer_types) + self._property_returned = value + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + + self.assert_isinstance(value, "total", six.integer_types + (float,)) + self._property_total = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class GetTaskSingleValueMetricsRequest(Request): + """ + Get single value metrics for the passed tasks + + :param tasks: List of task Task IDs + :type tasks: Sequence[str] + """ + + _service = "events" + _action = "get_task_single_value_metrics" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "tasks": { + "description": "List of task Task IDs", + "items": {"description": "Task ID", "type": "string"}, + "type": "array", + } + }, + "required": ["tasks"], + "type": "object", + } + + def __init__(self, tasks, **kwargs): + super(GetTaskSingleValueMetricsRequest, self).__init__(**kwargs) + self.tasks = tasks + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + + self.assert_isinstance(value, "tasks", six.string_types, is_array=True) + self._property_tasks = value + + +class GetTaskSingleValueMetricsResponse(Response): + """ + Response of events.get_task_single_value_metrics endpoint. + + :param tasks: Single value metrics grouped by task + :type tasks: Sequence[dict] + """ + + _service = "events" + _action = "get_task_single_value_metrics" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "tasks": { + "description": "Single value metrics grouped by task", + "items": { + "properties": { + "task": {"description": "Task ID", "type": "string"}, + "values": { + "items": { + "properties": { + "metric": {"type": "string"}, + "timestamp": {"type": "number"}, + "value": {"type": "number"}, + "variant": {"type": "string"}, + }, + "type": "object", + }, + "type": "array", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, tasks=None, **kwargs): + super(GetTaskSingleValueMetricsResponse, self).__init__(**kwargs) + self.tasks = tasks + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + + self.assert_isinstance(value, "tasks", (dict,), is_array=True) + self._property_tasks = value + + +class GetVectorMetricsAndVariantsRequest(Request): + """ + :param task: Task ID + :type task: str + """ + + _service = "events" + _action = "get_vector_metrics_and_variants" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"task": {"description": "Task ID", "type": "string"}}, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, **kwargs): + super(GetVectorMetricsAndVariantsRequest, self).__init__(**kwargs) + self.task = task + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class GetVectorMetricsAndVariantsResponse(Response): + """ + Response of events.get_vector_metrics_and_variants endpoint. + + :param metrics: + :type metrics: Sequence[dict] + """ + + _service = "events" + _action = "get_vector_metrics_and_variants" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "metrics": { + "description": "", + "items": {"type": "object"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, metrics=None, **kwargs): + super(GetVectorMetricsAndVariantsResponse, self).__init__(**kwargs) + self.metrics = metrics + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + + self.assert_isinstance(value, "metrics", (dict,), is_array=True) + self._property_metrics = value + + +class MultiTaskScalarMetricsIterHistogramRequest(Request): + """ + Used to compare scalar stats histogram of multiple tasks + + :param tasks: List of task Task IDs. Maximum amount of tasks is 10 + :type tasks: Sequence[str] + :param samples: The amount of histogram points to return. Optional, the default + value is 6000 + :type samples: int + :param key: Histogram x axis to use: iter - iteration number iso_time - event + time as ISO formatted string timestamp - event timestamp as milliseconds since + epoch + :type key: ScalarKeyEnum + """ + + _service = "events" + _action = "multi_task_scalar_metrics_iter_histogram" + _version = "2.20" + _schema = { + "definitions": { + "scalar_key_enum": { + "enum": ["iter", "timestamp", "iso_time"], + "type": "string", + } + }, + "properties": { + "key": { + "$ref": "#/definitions/scalar_key_enum", + "description": "\n Histogram x axis to use:\n iter - iteration number\n iso_time - event time as ISO formatted string\n timestamp - event timestamp as milliseconds since epoch\n ", + }, + "samples": { + "description": "The amount of histogram points to return. Optional, the default value is 6000", + "type": "integer", + }, + "tasks": { + "description": "List of task Task IDs. Maximum amount of tasks is 10", + "items": {"description": "List of task Task IDs", "type": "string"}, + "type": "array", + }, + }, + "required": ["tasks"], + "type": "object", + } + + def __init__(self, tasks, samples=None, key=None, **kwargs): + super(MultiTaskScalarMetricsIterHistogramRequest, self).__init__(**kwargs) + self.tasks = tasks + self.samples = samples + self.key = key + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + + self.assert_isinstance(value, "tasks", six.string_types, is_array=True) + self._property_tasks = value + + @schema_property("samples") + def samples(self): + return self._property_samples + + @samples.setter + def samples(self, value): + if value is None: + self._property_samples = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "samples", six.integer_types) + self._property_samples = value + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + if isinstance(value, six.string_types): + try: + value = ScalarKeyEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "key", enum.Enum) + self._property_key = value + + +class MultiTaskScalarMetricsIterHistogramResponse(Response): + """ + Response of events.multi_task_scalar_metrics_iter_histogram endpoint. + + """ + + _service = "events" + _action = "multi_task_scalar_metrics_iter_histogram" + _version = "2.20" + + _schema = {"additionalProperties": True, "definitions": {}, "type": "object"} + + +class NextDebugImageSampleRequest(Request): + """ + Get the image for the next variant for the same iteration or for the next iteration + + :param task: Task ID + :type task: str + :param scroll_id: Scroll ID from the previous call to get_debug_image_sample + :type scroll_id: str + :param navigate_earlier: If set then get the either previous variant event from + the current iteration or (if does not exist) the last variant event from the + previous iteration. Otherwise next variant event from the current iteration or + first variant event from the next iteration + :type navigate_earlier: bool + """ + + _service = "events" + _action = "next_debug_image_sample" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "navigate_earlier": { + "description": "If set then get the either previous variant event from the current " + "iteration or (if does not exist) the last variant event from the previous iteration. " + "Otherwise next variant event from the current iteration or first variant event from the next iteration", + "type": "boolean", + }, + "scroll_id": { + "description": "Scroll ID from the previous call to get_debug_image_sample", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "scroll_id"], + "type": "object", + } + + def __init__(self, task, scroll_id, navigate_earlier=None, **kwargs): + super(NextDebugImageSampleRequest, self).__init__(**kwargs) + self.task = task + self.scroll_id = scroll_id + self.navigate_earlier = navigate_earlier + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("navigate_earlier") + def navigate_earlier(self): + return self._property_navigate_earlier + + @navigate_earlier.setter + def navigate_earlier(self, value): + if value is None: + self._property_navigate_earlier = None + return + + self.assert_isinstance(value, "navigate_earlier", (bool,)) + self._property_navigate_earlier = value + + +class NextDebugImageSampleResponse(Response): + """ + Response of events.next_debug_image_sample endpoint. + + """ + + _service = "events" + _action = "next_debug_image_sample" + _version = "2.20" + + _schema = { + "$ref": "#/definitions/debug_image_sample_response", + "definitions": { + "debug_image_sample_response": { + "properties": { + "event": { + "description": "Debug image event", + "type": ["object", "null"], + }, + "max_iteration": { + "description": "maximal valid iteration for the variant", + "type": ["integer", "null"], + }, + "min_iteration": { + "description": "minimal valid iteration for the variant", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID to pass to the next calls to get_debug_image_sample or next_debug_image_sample", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + } + + +class NextPlotSampleRequest(Request): + """ + Get the plot for the next variant for the same iteration or for the next iteration + + :param task: Task ID + :type task: str + :param scroll_id: Scroll ID from the previous call to get_plot_sample + :type scroll_id: str + :param navigate_earlier: If set then get the either previous variant event from + the current iteration or (if does not exist) the last variant event from the + previous iteration. Otherwise next variant event from the current iteration or + first variant event from the next iteration + :type navigate_earlier: bool + """ + + _service = "events" + _action = "next_plot_sample" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "navigate_earlier": { + "description": "If set then get the either previous variant event from the current " + "iteration or (if does not exist) the last variant event from the previous iteration. " + "Otherwise next variant event from the current iteration or first variant event from the " + "next iteration", + "type": "boolean", + }, + "scroll_id": { + "description": "Scroll ID from the previous call to get_plot_sample", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "scroll_id"], + "type": "object", + } + + def __init__(self, task, scroll_id, navigate_earlier=None, **kwargs): + super(NextPlotSampleRequest, self).__init__(**kwargs) + self.task = task + self.scroll_id = scroll_id + self.navigate_earlier = navigate_earlier + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("navigate_earlier") + def navigate_earlier(self): + return self._property_navigate_earlier + + @navigate_earlier.setter + def navigate_earlier(self, value): + if value is None: + self._property_navigate_earlier = None + return + + self.assert_isinstance(value, "navigate_earlier", (bool,)) + self._property_navigate_earlier = value + + +class NextPlotSampleResponse(Response): + """ + Response of events.next_plot_sample endpoint. + + """ + + _service = "events" + _action = "next_plot_sample" + _version = "2.20" + + _schema = { + "$ref": "#/definitions/plot_sample_response", + "definitions": { + "plot_sample_response": { + "properties": { + "event": { + "description": "Plot event", + "type": ["object", "null"], + }, + "max_iteration": { + "description": "maximal valid iteration for the variant", + "type": ["integer", "null"], + }, + "min_iteration": { + "description": "minimal valid iteration for the variant", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID to pass to the next calls to get_plot_sample or next_plot_sample", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + } + + +class PlotsRequest(Request): + """ + Get plot events for the requested amount of iterations per each task + + :param metrics: List of metrics and variants + :type metrics: Sequence[TaskMetricVariants] + :param iters: Max number of latest iterations for which to return debug images + :type iters: int + :param navigate_earlier: If set then events are retreived from latest + iterations to earliest ones. Otherwise from earliest iterations to the latest. + The default is True + :type navigate_earlier: bool + :param refresh: If set then scroll will be moved to the latest iterations. The + default is False + :type refresh: bool + :param scroll_id: Scroll ID of previous call (used for getting more results) + :type scroll_id: str + """ + + _service = "events" + _action = "plots" + _version = "2.20" + _schema = { + "definitions": { + "task_metric_variants": { + "properties": { + "metric": {"description": "Metric name", "type": "string"}, + "task": {"description": "Task ID", "type": "string"}, + "variants": { + "description": "Metric variant names", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["task"], + "type": "object", + } + }, + "properties": { + "iters": { + "description": "Max number of latest iterations for which to return debug images", + "type": "integer", + }, + "metrics": { + "description": "List of metrics and variants", + "items": {"$ref": "#/definitions/task_metric_variants"}, + "type": "array", + }, + "navigate_earlier": { + "description": "If set then events are retreived from latest iterations to earliest ones. " + "Otherwise from earliest iterations to the latest. The default is True", + "type": "boolean", + }, + "refresh": { + "description": "If set then scroll will be moved to the latest iterations. The default is False", + "type": "boolean", + }, + "scroll_id": { + "description": "Scroll ID of previous call (used for getting more results)", + "type": "string", + }, + }, + "required": ["metrics"], + "type": "object", + } + + def __init__( + self, + metrics, + iters=None, + navigate_earlier=None, + refresh=None, + scroll_id=None, + **kwargs + ): + super(PlotsRequest, self).__init__(**kwargs) + self.metrics = metrics + self.iters = iters + self.navigate_earlier = navigate_earlier + self.refresh = refresh + self.scroll_id = scroll_id + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + TaskMetricVariants.from_dict(v) if isinstance(v, dict) else v + for v in value + ] + else: + self.assert_isinstance(value, "metrics", TaskMetricVariants, is_array=True) + self._property_metrics = value + + @schema_property("iters") + def iters(self): + return self._property_iters + + @iters.setter + def iters(self, value): + if value is None: + self._property_iters = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iters", six.integer_types) + self._property_iters = value + + @schema_property("navigate_earlier") + def navigate_earlier(self): + return self._property_navigate_earlier + + @navigate_earlier.setter + def navigate_earlier(self, value): + if value is None: + self._property_navigate_earlier = None + return + + self.assert_isinstance(value, "navigate_earlier", (bool,)) + self._property_navigate_earlier = value + + @schema_property("refresh") + def refresh(self): + return self._property_refresh + + @refresh.setter + def refresh(self, value): + if value is None: + self._property_refresh = None + return + + self.assert_isinstance(value, "refresh", (bool,)) + self._property_refresh = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class ScalarMetricsIterHistogramRequest(Request): + """ + Get histogram data of all the vector metrics and variants in the task + + :param task: Task ID + :type task: str + :param samples: The amount of histogram points to return (0 to return all the + points). Optional, the default value is 6000. + :type samples: int + :param key: Histogram x axis to use: iter - iteration number iso_time - event + time as ISO formatted string timestamp - event timestamp as milliseconds since + epoch + :type key: ScalarKeyEnum + :param metrics: List of metrics and variants + :type metrics: Sequence[MetricVariants] + """ + + _service = "events" + _action = "scalar_metrics_iter_histogram" + _version = "2.20" + _schema = { + "definitions": { + "metric_variants": { + "metric": {"description": "The metric name", "type": "string"}, + "type": "object", + "variants": { + "description": "The names of the metric " "variants", + "items": {"type": "string"}, + "type": "array", + }, + }, + "scalar_key_enum": { + "enum": ["iter", "timestamp", "iso_time"], + "type": "string", + }, + }, + "properties": { + "key": { + "$ref": "#/definitions/scalar_key_enum", + "description": "\n" + " Histogram x axis " + "to use:\n" + " iter - iteration " + "number\n" + " iso_time - event " + "time as ISO formatted string\n" + " timestamp - event " + "timestamp as milliseconds since " + "epoch\n", + }, + "metrics": { + "description": "List of metrics and variants", + "items": {"$ref": "#/definitions/metric_variants"}, + "type": "array", + }, + "samples": { + "description": "The amount of histogram points to return (0 to return all the points). Optional, the default value is 6000.", + "type": "integer", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, samples=None, key=None, metrics=None, **kwargs): + super(ScalarMetricsIterHistogramRequest, self).__init__(**kwargs) + self.task = task + self.samples = samples + self.key = key + self.metrics = metrics + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("samples") + def samples(self): + return self._property_samples + + @samples.setter + def samples(self, value): + if value is None: + self._property_samples = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "samples", six.integer_types) + self._property_samples = value + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + if isinstance(value, six.string_types): + try: + value = ScalarKeyEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "key", enum.Enum) + self._property_key = value + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + MetricVariants.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "metrics", MetricVariants, is_array=True) + self._property_metrics = value + + +class ScalarMetricsIterHistogramResponse(Response): + """ + Response of events.scalar_metrics_iter_histogram endpoint. + + :param images: + :type images: Sequence[dict] + """ + + _service = "events" + _action = "scalar_metrics_iter_histogram" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "images": {"items": {"type": "object"}, "type": ["array", "null"]} + }, + "type": "object", + } + + def __init__(self, images=None, **kwargs): + super(ScalarMetricsIterHistogramResponse, self).__init__(**kwargs) + self.images = images + + @schema_property("images") + def images(self): + return self._property_images + + @images.setter + def images(self, value): + if value is None: + self._property_images = None + return + + self.assert_isinstance(value, "images", (list, tuple)) + + self.assert_isinstance(value, "images", (dict,), is_array=True) + self._property_images = value + + +class ScalarMetricsIterRawRequest(Request): + """ + Get raw data for a specific metric variants in the task + + :param task: Task ID + :type task: str + :param metric: Metric and variants for which to return data points + :type metric: MetricVariants + :param key: Array of x axis to return. Supported values: iter - iteration + number timestamp - event timestamp as milliseconds since epoch + :type key: ScalarKeyEnum + :param batch_size: The number of data points to return for this call. Optional, + the default value is 10000. Maximum batch size is 200000 + :type batch_size: int + :param count_total: Count the total number of data points. If false, total + number of data points is not counted and null is returned + :type count_total: bool + :param scroll_id: Optional Scroll ID. Use to get more data points following a + previous call + :type scroll_id: str + """ + + _service = "events" + _action = "scalar_metrics_iter_raw" + _version = "2.20" + _schema = { + "definitions": { + "metric_variants": { + "metric": {"description": "The metric name", "type": "string"}, + "type": "object", + "variants": { + "description": "The names of the metric " "variants", + "items": {"type": "string"}, + "type": "array", + }, + }, + "scalar_key_enum": { + "enum": ["iter", "timestamp", "iso_time"], + "type": "string", + }, + }, + "properties": { + "batch_size": { + "default": 10000, + "description": "The number of data points to return for this call. Optional, the default value is 10000. " + " Maximum batch size is 200000", + "type": "integer", + }, + "count_total": { + "default": False, + "description": "Count the total number of data points. If false, total number of data points is not " + "counted and null is returned", + "type": "boolean", + }, + "key": { + "$ref": "#/definitions/scalar_key_enum", + "description": "Array of x axis to return. Supported " + "values:\n" + " iter - iteration " + "number\n" + " timestamp - event " + "timestamp as milliseconds since " + "epoch\n", + }, + "metric": { + "$ref": "#/definitions/metric_variants", + "description": "Metric and variants for which to return data points", + }, + "scroll_id": { + "description": "Optional Scroll ID. Use to get more data points following a previous call", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "metric"], + "type": "object", + } + + def __init__( + self, + task, + metric, + key=None, + batch_size=10000, + count_total=False, + scroll_id=None, + **kwargs + ): + super(ScalarMetricsIterRawRequest, self).__init__(**kwargs) + self.task = task + self.metric = metric + self.key = key + self.batch_size = batch_size + self.count_total = count_total + self.scroll_id = scroll_id + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + if isinstance(value, dict): + value = MetricVariants.from_dict(value) + else: + self.assert_isinstance(value, "metric", MetricVariants) + self._property_metric = value + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + if isinstance(value, six.string_types): + try: + value = ScalarKeyEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "key", enum.Enum) + self._property_key = value + + @schema_property("batch_size") + def batch_size(self): + return self._property_batch_size + + @batch_size.setter + def batch_size(self, value): + if value is None: + self._property_batch_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "batch_size", six.integer_types) + self._property_batch_size = value + + @schema_property("count_total") + def count_total(self): + return self._property_count_total + + @count_total.setter + def count_total(self, value): + if value is None: + self._property_count_total = None + return + + self.assert_isinstance(value, "count_total", (bool,)) + self._property_count_total = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class ScalarMetricsIterRawResponse(Response): + """ + Response of events.scalar_metrics_iter_raw endpoint. + + :param variants: Raw data points for each variant + :type variants: dict + :param total: Total data points count. If count_total is false, null is + returned + :type total: int + :param returned: Number of data points returned in this call. If 0 results were + returned, no more results are avilable + :type returned: int + :param scroll_id: Scroll ID. Use to get more data points when calling this + endpoint again + :type scroll_id: str + """ + + _service = "events" + _action = "scalar_metrics_iter_raw" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "returned": { + "description": "Number of data points returned in this call. If 0 results were " + "returned, no more results are avilable", + "type": ["integer", "null"], + }, + "scroll_id": { + "description": "Scroll ID. Use to get more data points when calling this endpoint again", + "type": ["string", "null"], + }, + "total": { + "description": "Total data points count. If count_total is false, null is returned", + "type": ["integer", "null"], + }, + "variants": { + "additionalProperties": True, + "description": "Raw data points for each variant", + "type": ["object", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, variants=None, total=None, returned=None, scroll_id=None, **kwargs + ): + super(ScalarMetricsIterRawResponse, self).__init__(**kwargs) + self.variants = variants + self.total = total + self.returned = returned + self.scroll_id = scroll_id + + @schema_property("variants") + def variants(self): + return self._property_variants + + @variants.setter + def variants(self, value): + if value is None: + self._property_variants = None + return + + self.assert_isinstance(value, "variants", (dict,)) + self._property_variants = value + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "total", six.integer_types) + self._property_total = value + + @schema_property("returned") + def returned(self): + return self._property_returned + + @returned.setter + def returned(self, value): + if value is None: + self._property_returned = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "returned", six.integer_types) + self._property_returned = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class VectorMetricsIterHistogramRequest(Request): + """ + Get histogram data of all the scalar metrics and variants in the task + + :param task: Task ID + :type task: str + :param metric: + :type metric: str + :param variant: + :type variant: str + """ + + _service = "events" + _action = "vector_metrics_iter_histogram" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "metric": {"description": "", "type": "string"}, + "task": {"description": "Task ID", "type": "string"}, + "variant": {"description": "", "type": "string"}, + }, + "required": ["task", "metric", "variant"], + "type": "object", + } + + def __init__(self, task, metric, variant, **kwargs): + super(VectorMetricsIterHistogramRequest, self).__init__(**kwargs) + self.task = task + self.metric = metric + self.variant = variant + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + +class VectorMetricsIterHistogramResponse(Response): + """ + Response of events.vector_metrics_iter_histogram endpoint. + + :param images: + :type images: Sequence[dict] + """ + + _service = "events" + _action = "vector_metrics_iter_histogram" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "images": {"items": {"type": "object"}, "type": ["array", "null"]} + }, + "type": "object", + } + + def __init__(self, images=None, **kwargs): + super(VectorMetricsIterHistogramResponse, self).__init__(**kwargs) + self.images = images + + @schema_property("images") + def images(self): + return self._property_images + + @images.setter + def images(self, value): + if value is None: + self._property_images = None + return + + self.assert_isinstance(value, "images", (list, tuple)) + + self.assert_isinstance(value, "images", (dict,), is_array=True) + self._property_images = value + + +response_mapping = { + AddRequest: AddResponse, + AddBatchRequest: AddBatchResponse, + DeleteForTaskRequest: DeleteForTaskResponse, + DebugImagesRequest: DebugImagesResponse, + PlotsRequest: PlotsResponse, + GetDebugImageSampleRequest: GetDebugImageSampleResponse, + NextDebugImageSampleRequest: NextDebugImageSampleResponse, + GetPlotSampleRequest: GetPlotSampleResponse, + NextPlotSampleRequest: NextPlotSampleResponse, + GetTaskMetricsRequest: GetTaskMetricsResponse, + GetTaskLogRequest: GetTaskLogResponse, + GetTaskEventsRequest: GetTaskEventsResponse, + DownloadTaskLogRequest: DownloadTaskLogResponse, + GetTaskPlotsRequest: GetTaskPlotsResponse, + GetMultiTaskPlotsRequest: GetMultiTaskPlotsResponse, + GetVectorMetricsAndVariantsRequest: GetVectorMetricsAndVariantsResponse, + VectorMetricsIterHistogramRequest: VectorMetricsIterHistogramResponse, + ScalarMetricsIterHistogramRequest: ScalarMetricsIterHistogramResponse, + MultiTaskScalarMetricsIterHistogramRequest: MultiTaskScalarMetricsIterHistogramResponse, + GetTaskSingleValueMetricsRequest: GetTaskSingleValueMetricsResponse, + GetTaskLatestScalarValuesRequest: GetTaskLatestScalarValuesResponse, + GetScalarMetricsAndVariantsRequest: GetScalarMetricsAndVariantsResponse, + GetScalarMetricDataRequest: GetScalarMetricDataResponse, + ScalarMetricsIterRawRequest: ScalarMetricsIterRawResponse, + ClearScrollRequest: ClearScrollResponse, + ClearTaskLogRequest: ClearTaskLogResponse, +} diff --git a/clearml/backend_api/services/v2_20/models.py b/clearml/backend_api/services/v2_20/models.py new file mode 100644 index 00000000..80841cdf --- /dev/null +++ b/clearml/backend_api/services/v2_20/models.py @@ -0,0 +1,4697 @@ +""" +models service + +This service provides a management interface for models (results of training tasks) stored in the system. +""" +import six +from datetime import datetime + +from dateutil.parser import parse as parse_datetime + +from clearml.backend_api.session import ( + Request, + Response, + NonStrictDataModel, + schema_property, +) + + +class MultiFieldPatternData(NonStrictDataModel): + """ + :param pattern: Pattern string (regex) + :type pattern: str + :param fields: List of field names + :type fields: Sequence[str] + """ + + _schema = { + "properties": { + "fields": { + "description": "List of field names", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "pattern": { + "description": "Pattern string (regex)", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, pattern=None, fields=None, **kwargs): + super(MultiFieldPatternData, self).__init__(**kwargs) + self.pattern = pattern + self.fields = fields + + @schema_property("pattern") + def pattern(self): + return self._property_pattern + + @pattern.setter + def pattern(self, value): + if value is None: + self._property_pattern = None + return + + self.assert_isinstance(value, "pattern", six.string_types) + self._property_pattern = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (list, tuple)) + + self.assert_isinstance(value, "fields", six.string_types, is_array=True) + self._property_fields = value + + +class MetadataItem(NonStrictDataModel): + """ + :param key: The key uniquely identifying the metadata item inside the given + entity + :type key: str + :param type: The type of the metadata item + :type type: str + :param value: The value stored in the metadata item + :type value: str + """ + + _schema = { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": ["string", "null"], + }, + "type": { + "description": "The type of the metadata item", + "type": ["string", "null"], + }, + "value": { + "description": "The value stored in the metadata item", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, key=None, type=None, value=None, **kwargs): + super(MetadataItem, self).__init__(**kwargs) + self.key = key + self.type = type + self.value = value + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + + self.assert_isinstance(value, "key", six.string_types) + self._property_key = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + + self.assert_isinstance(value, "type", six.string_types) + self._property_type = value + + @schema_property("value") + def value(self): + return self._property_value + + @value.setter + def value(self, value): + if value is None: + self._property_value = None + return + + self.assert_isinstance(value, "value", six.string_types) + self._property_value = value + + +class Model(NonStrictDataModel): + """ + :param id: Model id + :type id: str + :param name: Model name + :type name: str + :param user: Associated user id + :type user: str + :param company: Company id + :type company: str + :param created: Model creation time + :type created: datetime.datetime + :param last_update: Model last update time + :type last_update: datetime.datetime + :param task: Task ID of task in which the model was created + :type task: str + :param parent: Parent model ID + :type parent: str + :param project: Associated project ID + :type project: str + :param comment: Model comment + :type comment: str + :param tags: User-defined tags + :type tags: Sequence[str] + :param system_tags: System tags. This field is reserved for system use, please + don't use it. + :type system_tags: Sequence[str] + :param framework: Framework on which the model is based. Should be identical to + the framework of the task which created the model + :type framework: str + :param design: Json object representing the model design. Should be identical + to the network design of the task which created the model + :type design: dict + :param labels: Json object representing the ids of the labels in the model. The + keys are the layers' names and the values are the ids. + :type labels: dict + :param uri: URI for the model, pointing to the destination storage. + :type uri: str + :param ready: Indication if the model is final and can be used by other tasks + :type ready: bool + :param ui_cache: UI cache for this model + :type ui_cache: dict + :param metadata: Model metadata + :type metadata: dict + :param stats: Model statistics + :type stats: dict + """ + + _schema = { + "properties": { + "comment": {"description": "Model comment", "type": ["string", "null"]}, + "company": {"description": "Company id", "type": ["string", "null"]}, + "created": { + "description": "Model creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "design": { + "additionalProperties": True, + "description": "Json object representing the model design. Should be identical to the network design of the task which created the model", + "type": ["object", "null"], + }, + "framework": { + "description": "Framework on which the model is based. Should be identical to the framework of the task which created the model", + "type": ["string", "null"], + }, + "id": {"description": "Model id", "type": ["string", "null"]}, + "labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model. The keys are the layers' names and the values are the ids.", + "type": ["object", "null"], + }, + "last_update": { + "description": "Model last update time", + "format": "date-time", + "type": ["string", "null"], + }, + "metadata": { + "additionalProperties": {"$ref": "#/definitions/metadata_item"}, + "description": "Model metadata", + "type": ["object", "null"], + }, + "name": {"description": "Model name", "type": ["string", "null"]}, + "parent": {"description": "Parent model ID", "type": ["string", "null"]}, + "project": { + "description": "Associated project ID", + "type": ["string", "null"], + }, + "ready": { + "description": "Indication if the model is final and can be used by other tasks", + "type": ["boolean", "null"], + }, + "stats": { + "description": "Model statistics", + "properties": { + "labels_count": { + "description": "Number of the model labels", + "type": "integer", + } + }, + "type": ["object", "null"], + }, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "task": { + "description": "Task ID of task in which the model was created", + "type": ["string", "null"], + }, + "ui_cache": { + "additionalProperties": True, + "description": "UI cache for this model", + "type": ["object", "null"], + }, + "uri": { + "description": "URI for the model, pointing to the destination storage." + "destination storage.", + "type": ["string", "null"], + }, + "user": {"description": "Associated user id", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__( + self, + id=None, + name=None, + user=None, + company=None, + created=None, + last_update=None, + task=None, + parent=None, + project=None, + comment=None, + tags=None, + system_tags=None, + framework=None, + design=None, + labels=None, + uri=None, + ready=None, + ui_cache=None, + metadata=None, + stats=None, + **kwargs + ): + super(Model, self).__init__(**kwargs) + self.id = id + self.name = name + self.user = user + self.company = company + self.created = created + self.last_update = last_update + self.task = task + self.parent = parent + self.project = project + self.comment = comment + self.tags = tags + self.system_tags = system_tags + self.framework = framework + self.design = design + self.labels = labels + self.uri = uri + self.ready = ready + self.ui_cache = ui_cache + self.metadata = metadata + self.stats = stats + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("user") + def user(self): + return self._property_user + + @user.setter + def user(self, value): + if value is None: + self._property_user = None + return + + self.assert_isinstance(value, "user", six.string_types) + self._property_user = value + + @schema_property("company") + def company(self): + return self._property_company + + @company.setter + def company(self, value): + if value is None: + self._property_company = None + return + + self.assert_isinstance(value, "company", six.string_types) + self._property_company = value + + @schema_property("created") + def created(self): + return self._property_created + + @created.setter + def created(self, value): + if value is None: + self._property_created = None + return + + self.assert_isinstance(value, "created", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_created = value + + @schema_property("last_update") + def last_update(self): + return self._property_last_update + + @last_update.setter + def last_update(self, value): + if value is None: + self._property_last_update = None + return + + self.assert_isinstance(value, "last_update", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_last_update = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("parent") + def parent(self): + return self._property_parent + + @parent.setter + def parent(self, value): + if value is None: + self._property_parent = None + return + + self.assert_isinstance(value, "parent", six.string_types) + self._property_parent = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("framework") + def framework(self): + return self._property_framework + + @framework.setter + def framework(self, value): + if value is None: + self._property_framework = None + return + + self.assert_isinstance(value, "framework", six.string_types) + self._property_framework = value + + @schema_property("design") + def design(self): + return self._property_design + + @design.setter + def design(self, value): + if value is None: + self._property_design = None + return + + self.assert_isinstance(value, "design", (dict,)) + self._property_design = value + + @schema_property("labels") + def labels(self): + return self._property_labels + + @labels.setter + def labels(self, value): + if value is None: + self._property_labels = None + return + + self.assert_isinstance(value, "labels", (dict,)) + self._property_labels = value + + @schema_property("uri") + def uri(self): + return self._property_uri + + @uri.setter + def uri(self, value): + if value is None: + self._property_uri = None + return + + self.assert_isinstance(value, "uri", six.string_types) + self._property_uri = value + + @schema_property("ready") + def ready(self): + return self._property_ready + + @ready.setter + def ready(self, value): + if value is None: + self._property_ready = None + return + + self.assert_isinstance(value, "ready", (bool,)) + self._property_ready = value + + @schema_property("ui_cache") + def ui_cache(self): + return self._property_ui_cache + + @ui_cache.setter + def ui_cache(self, value): + if value is None: + self._property_ui_cache = None + return + + self.assert_isinstance(value, "ui_cache", (dict,)) + self._property_ui_cache = value + + @schema_property("metadata") + def metadata(self): + return self._property_metadata + + @metadata.setter + def metadata(self, value): + if value is None: + self._property_metadata = None + return + + self.assert_isinstance(value, "metadata", (dict,)) + self._property_metadata = value + + @schema_property("stats") + def stats(self): + return self._property_stats + + @stats.setter + def stats(self, value): + if value is None: + self._property_stats = None + return + + self.assert_isinstance(value, "stats", (dict,)) + self._property_stats = value + + +class AddOrUpdateMetadataRequest(Request): + """ + Add or update model metadata + + :param model: ID of the model + :type model: str + :param metadata: Metadata items to add or update + :type metadata: Sequence[MetadataItem] + :param replace_metadata: If set then the all the metadata items will be + replaced with the provided ones. Otherwise only the provided metadata items + will be updated or added + :type replace_metadata: bool + """ + + _service = "models" + _action = "add_or_update_metadata" + _version = "2.20" + _schema = { + "definitions": { + "metadata_item": { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": ["string", "null"], + }, + "type": { + "description": "The " "type " "of " "the " "metadata " "item", + "type": ["string", "null"], + }, + "value": { + "description": "The value stored in the metadata item", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "metadata": { + "description": "Metadata items to add or update", + "items": {"$ref": "#/definitions/metadata_item"}, + "type": "array", + }, + "model": {"description": "ID of the model", "type": "string"}, + "replace_metadata": { + "default": False, + "description": "If set then the all the metadata items will be replaced with the " + "provided ones. Otherwise only the provided metadata items will be updated or added", + "type": "boolean", + }, + }, + "required": ["model", "metadata"], + "type": "object", + } + + def __init__(self, model, metadata, replace_metadata=False, **kwargs): + super(AddOrUpdateMetadataRequest, self).__init__(**kwargs) + self.model = model + self.metadata = metadata + self.replace_metadata = replace_metadata + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + @schema_property("metadata") + def metadata(self): + return self._property_metadata + + @metadata.setter + def metadata(self, value): + if value is None: + self._property_metadata = None + return + + self.assert_isinstance(value, "metadata", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + MetadataItem.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "metadata", MetadataItem, is_array=True) + self._property_metadata = value + + @schema_property("replace_metadata") + def replace_metadata(self): + return self._property_replace_metadata + + @replace_metadata.setter + def replace_metadata(self, value): + if value is None: + self._property_replace_metadata = None + return + + self.assert_isinstance(value, "replace_metadata", (bool,)) + self._property_replace_metadata = value + + +class AddOrUpdateMetadataResponse(Response): + """ + Response of models.add_or_update_metadata endpoint. + + :param updated: Number of models updated (0 or 1) + :type updated: int + """ + + _service = "models" + _action = "add_or_update_metadata" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of models updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(AddOrUpdateMetadataResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class ArchiveManyRequest(Request): + """ + Archive models + + :param ids: IDs of the models to archive + :type ids: Sequence[str] + """ + + _service = "models" + _action = "archive_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "IDs of the models to archive", + "items": {"type": "string"}, + "type": "array", + } + }, + "required": ["ids"], + "type": "object", + } + + def __init__(self, ids, **kwargs): + super(ArchiveManyRequest, self).__init__(**kwargs) + self.ids = ids + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + +class ArchiveManyResponse(Response): + """ + Response of models.archive_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "models" + _action = "archive_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "archived": { + "description": "Indicates whether the model was archived", + "type": "boolean", + }, + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(ArchiveManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class CreateRequest(Request): + """ + Create a new model not associated with a task + + :param uri: URI for the model + :type uri: str + :param name: Model name Unique within the company. + :type name: str + :param comment: Model comment + :type comment: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param framework: Framework on which the model is based. Case insensitive. + Should be identical to the framework of the task which created the model. + :type framework: str + :param design: Json[d] object representing the model design. Should be + identical to the network design of the task which created the model + :type design: dict + :param labels: Json object + :type labels: dict + :param ready: Indication if the model is final and can be used by other tasks. + Default is false. + :type ready: bool + :param public: Create a public model Default is false. + :type public: bool + :param project: Project to which to model belongs + :type project: str + :param parent: Parent model + :type parent: str + :param task: Associated task ID + :type task: str + """ + + _service = "models" + _action = "create" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "comment": {"description": "Model comment", "type": "string"}, + "design": { + "additionalProperties": True, + "description": "Json[d] object representing the model design. Should be identical " + "to the network design of the task which created the model", + "type": "object", + }, + "framework": { + "description": "Framework on which the model is based. Case insensitive. Should " + "be identical to the framework of the task which created the model.", + "type": "string", + }, + "labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object", + "type": "object", + }, + "name": { + "description": "Model name Unique within the company.", + "type": "string", + }, + "parent": {"description": "Parent model", "type": "string"}, + "project": { + "description": "Project to which to model belongs", + "type": "string", + }, + "public": { + "default": False, + "description": "Create a public model Default is false.", + "type": "boolean", + }, + "ready": { + "default": False, + "description": "Indication if the model is final and can be used by other tasks. Default is false.", + "type": "boolean", + }, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + "task": {"description": "Associated task ID", "type": "string"}, + "uri": {"description": "URI for the model", "type": "string"}, + }, + "required": ["uri", "name"], + "type": "object", + } + + def __init__( + self, + uri, + name, + comment=None, + tags=None, + system_tags=None, + framework=None, + design=None, + labels=None, + ready=False, + public=False, + project=None, + parent=None, + task=None, + **kwargs + ): + super(CreateRequest, self).__init__(**kwargs) + self.uri = uri + self.name = name + self.comment = comment + self.tags = tags + self.system_tags = system_tags + self.framework = framework + self.design = design + self.labels = labels + self.ready = ready + self.public = public + self.project = project + self.parent = parent + self.task = task + + @schema_property("uri") + def uri(self): + return self._property_uri + + @uri.setter + def uri(self, value): + if value is None: + self._property_uri = None + return + + self.assert_isinstance(value, "uri", six.string_types) + self._property_uri = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("framework") + def framework(self): + return self._property_framework + + @framework.setter + def framework(self, value): + if value is None: + self._property_framework = None + return + + self.assert_isinstance(value, "framework", six.string_types) + self._property_framework = value + + @schema_property("design") + def design(self): + return self._property_design + + @design.setter + def design(self, value): + if value is None: + self._property_design = None + return + + self.assert_isinstance(value, "design", (dict,)) + self._property_design = value + + @schema_property("labels") + def labels(self): + return self._property_labels + + @labels.setter + def labels(self, value): + if value is None: + self._property_labels = None + return + + self.assert_isinstance(value, "labels", (dict,)) + self._property_labels = value + + @schema_property("ready") + def ready(self): + return self._property_ready + + @ready.setter + def ready(self, value): + if value is None: + self._property_ready = None + return + + self.assert_isinstance(value, "ready", (bool,)) + self._property_ready = value + + @schema_property("public") + def public(self): + return self._property_public + + @public.setter + def public(self, value): + if value is None: + self._property_public = None + return + + self.assert_isinstance(value, "public", (bool,)) + self._property_public = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("parent") + def parent(self): + return self._property_parent + + @parent.setter + def parent(self, value): + if value is None: + self._property_parent = None + return + + self.assert_isinstance(value, "parent", six.string_types) + self._property_parent = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class CreateResponse(Response): + """ + Response of models.create endpoint. + + :param id: ID of the model + :type id: str + :param created: Was the model created + :type created: bool + """ + + _service = "models" + _action = "create" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "created": { + "description": "Was the model created", + "type": ["boolean", "null"], + }, + "id": {"description": "ID of the model", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, id=None, created=None, **kwargs): + super(CreateResponse, self).__init__(**kwargs) + self.id = id + self.created = created + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("created") + def created(self): + return self._property_created + + @created.setter + def created(self, value): + if value is None: + self._property_created = None + return + + self.assert_isinstance(value, "created", (bool,)) + self._property_created = value + + +class DeleteRequest(Request): + """ + Delete a model. + + :param model: Model ID + :type model: str + :param force: Force. Required if there are tasks that use the model as an + execution model, or if the model's creating task is published. + :type force: bool + """ + + _service = "models" + _action = "delete" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "description": "Force. Required if there are tasks that use the model as an execution model, or if the model's creating task is published.", + "type": "boolean", + }, + "model": {"description": "Model ID", "type": "string"}, + }, + "required": ["model"], + "type": "object", + } + + def __init__(self, model, force=None, **kwargs): + super(DeleteRequest, self).__init__(**kwargs) + self.model = model + self.force = force + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class DeleteResponse(Response): + """ + Response of models.delete endpoint. + + :param deleted: Indicates whether the model was deleted + :type deleted: bool + :param url: The url of the model file + :type url: str + """ + + _service = "models" + _action = "delete" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "deleted": { + "description": "Indicates whether the model was deleted", + "type": ["boolean", "null"], + }, + "url": { + "description": "The url of the model file", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, deleted=None, url=None, **kwargs): + super(DeleteResponse, self).__init__(**kwargs) + self.deleted = deleted + self.url = url + + @schema_property("deleted") + def deleted(self): + return self._property_deleted + + @deleted.setter + def deleted(self, value): + if value is None: + self._property_deleted = None + return + + self.assert_isinstance(value, "deleted", (bool,)) + self._property_deleted = value + + @schema_property("url") + def url(self): + return self._property_url + + @url.setter + def url(self, value): + if value is None: + self._property_url = None + return + + self.assert_isinstance(value, "url", six.string_types) + self._property_url = value + + +class DeleteManyRequest(Request): + """ + Delete models + + :param ids: IDs of the models to delete + :type ids: Sequence[str] + :param force: Force. Required if there are tasks that use the model as an + execution model, or if the model's creating task is published. + :type force: bool + """ + + _service = "models" + _action = "delete_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "description": "Force. Required if there are tasks that use the model as an execution model, or if the model's creating task is published.", + "type": "boolean", + }, + "ids": { + "description": "IDs of the models to delete", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__(self, ids, force=None, **kwargs): + super(DeleteManyRequest, self).__init__(**kwargs) + self.ids = ids + self.force = force + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class DeleteManyResponse(Response): + """ + Response of models.delete_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "models" + _action = "delete_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "deleted": { + "description": "Indicates whether the model was deleted", + "type": "boolean", + }, + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "url": { + "description": "The url of the model file", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(DeleteManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class DeleteMetadataRequest(Request): + """ + Delete metadata from model + + :param model: ID of the model + :type model: str + :param keys: The list of metadata keys to delete + :type keys: Sequence[str] + """ + + _service = "models" + _action = "delete_metadata" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "keys": { + "description": "The list of metadata keys to delete", + "items": {"type": "string"}, + "type": "array", + }, + "model": {"description": "ID of the model", "type": "string"}, + }, + "required": ["model", "keys"], + "type": "object", + } + + def __init__(self, model, keys, **kwargs): + super(DeleteMetadataRequest, self).__init__(**kwargs) + self.model = model + self.keys = keys + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + @schema_property("keys") + def keys(self): + return self._property_keys + + @keys.setter + def keys(self, value): + if value is None: + self._property_keys = None + return + + self.assert_isinstance(value, "keys", (list, tuple)) + + self.assert_isinstance(value, "keys", six.string_types, is_array=True) + self._property_keys = value + + +class DeleteMetadataResponse(Response): + """ + Response of models.delete_metadata endpoint. + + :param updated: Number of models updated (0 or 1) + :type updated: int + """ + + _service = "models" + _action = "delete_metadata" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of models updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(DeleteMetadataResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class EditRequest(Request): + """ + Edit an existing model + + :param model: Model ID + :type model: str + :param uri: URI for the model + :type uri: str + :param name: Model name Unique within the company. + :type name: str + :param comment: Model comment + :type comment: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param framework: Framework on which the model is based. Case insensitive. + Should be identical to the framework of the task which created the model. + :type framework: str + :param design: Json[d] object representing the model design. Should be + identical to the network design of the task which created the model + :type design: dict + :param labels: Json object + :type labels: dict + :param ready: Indication if the model is final and can be used by other tasks + :type ready: bool + :param project: Project to which to model belongs + :type project: str + :param parent: Parent model + :type parent: str + :param task: Associated task ID + :type task: str + :param iteration: Iteration (used to update task statistics) + :type iteration: int + :param metadata: Model metadata + :type metadata: list + """ + + _service = "models" + _action = "edit" + _version = "2.20" + _schema = { + "definitions": { + "metadata_item": { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": "string", + }, + "type": { + "description": "The type of the metadata item", + "type": "string", + }, + "value": { + "description": "The value stored in the metadata item", + "type": "string", + }, + }, + "type": "object", + } + }, + "properties": { + "comment": {"description": "Model comment", "type": "string"}, + "design": { + "additionalProperties": True, + "description": "Json[d] object representing the model design. Should be identical to the network design of the task which created the model", + "type": "object", + }, + "framework": { + "description": "Framework on which the model is based. Case insensitive. Should be identical to the framework of the task which created the model.", + "type": "string", + }, + "iteration": { + "description": "Iteration (used to update task statistics)", + "type": "integer", + }, + "labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object", + "type": "object", + }, + "model": {"description": "Model ID", "type": "string"}, + "name": { + "description": "Model name Unique within the company.", + "type": "string", + }, + "parent": {"description": "Parent model", "type": "string"}, + "project": { + "description": "Project to which to model belongs", + "type": "string", + }, + "ready": { + "description": "Indication if the model is final and can be used by other tasks", + "type": "boolean", + }, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + "task": {"description": "Associated task ID", "type": "string"}, + "uri": {"description": "URI for the model", "type": "string"}, + "metadata": { + "type": "array", + "items": {"$ref": "#/definitions/metadata_item"}, + "description": "Model metadata", + }, + }, + "required": ["model"], + "type": "object", + } + + def __init__( + self, + model, + uri=None, + name=None, + comment=None, + tags=None, + system_tags=None, + framework=None, + design=None, + labels=None, + ready=None, + project=None, + parent=None, + task=None, + iteration=None, + metadata=None, + **kwargs + ): + super(EditRequest, self).__init__(**kwargs) + self.model = model + self.uri = uri + self.name = name + self.comment = comment + self.tags = tags + self.system_tags = system_tags + self.framework = framework + self.design = design + self.labels = labels + self.ready = ready + self.project = project + self.parent = parent + self.task = task + self.iteration = iteration + self.metadata = metadata + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + @schema_property("uri") + def uri(self): + return self._property_uri + + @uri.setter + def uri(self, value): + if value is None: + self._property_uri = None + return + + self.assert_isinstance(value, "uri", six.string_types) + self._property_uri = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("framework") + def framework(self): + return self._property_framework + + @framework.setter + def framework(self, value): + if value is None: + self._property_framework = None + return + + self.assert_isinstance(value, "framework", six.string_types) + self._property_framework = value + + @schema_property("design") + def design(self): + return self._property_design + + @design.setter + def design(self, value): + if value is None: + self._property_design = None + return + + self.assert_isinstance(value, "design", (dict,)) + self._property_design = value + + @schema_property("labels") + def labels(self): + return self._property_labels + + @labels.setter + def labels(self, value): + if value is None: + self._property_labels = None + return + + self.assert_isinstance(value, "labels", (dict,)) + self._property_labels = value + + @schema_property("ready") + def ready(self): + return self._property_ready + + @ready.setter + def ready(self, value): + if value is None: + self._property_ready = None + return + + self.assert_isinstance(value, "ready", (bool,)) + self._property_ready = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("parent") + def parent(self): + return self._property_parent + + @parent.setter + def parent(self, value): + if value is None: + self._property_parent = None + return + + self.assert_isinstance(value, "parent", six.string_types) + self._property_parent = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("iteration") + def iteration(self): + return self._property_iteration + + @iteration.setter + def iteration(self, value): + if value is None: + self._property_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iteration", six.integer_types) + self._property_iteration = value + + @schema_property("metadata") + def metadata(self): + return self._property_metadata + + @metadata.setter + def metadata(self, value): + if value is None: + self._property_metadata = None + return + self.assert_isinstance(value, "metadata", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + MetadataItem.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "metadata", MetadataItem, is_array=True) + self._property_metadata = value + + +class EditResponse(Response): + """ + Response of models.edit endpoint. + + :param updated: Number of models updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "models" + _action = "edit" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of models updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(EditResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class GetAllRequest(Request): + """ + Get all models + + :param name: Get only models whose name matches this pattern (python regular + expression syntax) + :type name: str + :param user: List of user IDs used to filter results by the model's creating + user + :type user: Sequence[str] + :param ready: Indication whether to retrieve only models that are marked ready + If not supplied returns both ready and not-ready projects. + :type ready: bool + :param tags: User-defined tags list used to filter results. Prepend '-' to tag + name to indicate exclusion + :type tags: Sequence[str] + :param system_tags: System tags list used to filter results. Prepend '-' to + system tag name to indicate exclusion + :type system_tags: Sequence[str] + :param only_fields: List of model field names (if applicable, nesting is + supported using '.'). If provided, this list defines the query's projection + (only these fields will be returned for each result entry) + :type only_fields: Sequence[str] + :param page: Page number, returns a specific page out of the resulting list of + models + :type page: int + :param page_size: Page size, specifies the number of results returned in each + page (last page may contain fewer results) + :type page_size: int + :param project: List of associated project IDs + :type project: Sequence[str] + :param order_by: List of field names to order by. When search_text is used, + '@text_score' can be used as a field representing the text score of returned + documents. Use '-' prefix to specify descending order. Optional, recommended + when using page + :type order_by: Sequence[str] + :param task: List of associated task IDs + :type task: Sequence[str] + :param id: List of model IDs + :type id: Sequence[str] + :param search_text: Free text search query + :type search_text: str + :param framework: List of frameworks + :type framework: Sequence[str] + :param uri: List of model URIs + :type uri: Sequence[str] + :param _all_: Multi-field pattern condition (all fields match pattern) + :type _all_: MultiFieldPatternData + :param _any_: Multi-field pattern condition (any field matches pattern) + :type _any_: MultiFieldPatternData + :param scroll_id: Scroll ID returned from the previos calls to get_all + :type scroll_id: str + :param refresh_scroll: If set then all the data received with this scroll will + be requeried + :type refresh_scroll: bool + :param size: The number of models to retrieve + :type size: int + """ + + _service = "models" + _action = "get_all" + _version = "2.20" + _schema = { + "definitions": { + "multi_field_pattern_data": { + "properties": { + "fields": { + "description": "List of field names", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "pattern": { + "description": "Pattern string (regex)", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "dependencies": {"page": ["page_size"]}, + "properties": { + "_all_": { + "description": "Multi-field pattern condition (all fields match pattern)", + "oneOf": [ + {"$ref": "#/definitions/multi_field_pattern_data"}, + {"type": "null"}, + ], + }, + "_any_": { + "description": "Multi-field pattern condition (any field matches pattern)", + "oneOf": [ + {"$ref": "#/definitions/multi_field_pattern_data"}, + {"type": "null"}, + ], + }, + "framework": { + "description": "List of frameworks", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "id": { + "description": "List of model IDs", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "last_update": { + "description": "Model last update time", + "format": "date-time", + "type": ["string", "null"], + }, + "name": { + "description": "Get only models whose name matches this pattern (python regular expression syntax)", + "type": ["string", "null"], + }, + "only_fields": { + "description": "List of model field names (if applicable, nesting is supported using '.'). If provided, this list defines the query's projection (only these fields will be returned for each result entry)", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "order_by": { + "description": "List of field names to order by. When search_text is used, '@text_score' can be used as a field representing the text score of returned documents. Use '-' prefix to specify descending order. Optional, recommended when using page", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "page": { + "description": "Page number, returns a specific page out of the resulting list of models", + "minimum": 0, + "type": ["integer", "null"], + }, + "page_size": { + "description": "Page size, specifies the number of results returned in each page (last page may contain fewer results)", + "minimum": 1, + "type": ["integer", "null"], + }, + "project": { + "description": "List of associated project IDs", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "ready": { + "description": "Indication whether to retrieve only models that are marked ready If not supplied returns both ready and not-ready projects.", + "type": ["boolean", "null"], + }, + "refresh_scroll": { + "description": "If set then all the data " + "received with this scroll " + "will be requeried", + "type": ["boolean", "null"], + }, + "scroll_id": { + "description": "Scroll ID returned from the " + "previos calls to get_all", + "type": ["string", "null"], + }, + "search_text": { + "description": "Free text search query", + "type": ["string", "null"], + }, + "size": { + "description": "The number of models to retrieve", + "minimum": 1, + "type": ["integer", "null"], + }, + "system_tags": { + "description": "System tags list used to filter results. Prepend '-' to system tag name to indicate exclusion", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags list used to filter results. Prepend '-' to tag name to indicate exclusion", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "task": { + "description": "List of associated task IDs", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "uri": { + "description": "List of model URIs", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "user": { + "description": "List of user IDs used to filter results by the model's creating user", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + name=None, + user=None, + ready=None, + tags=None, + system_tags=None, + only_fields=None, + page=None, + page_size=None, + project=None, + order_by=None, + task=None, + id=None, + search_text=None, + framework=None, + uri=None, + _all_=None, + _any_=None, + last_update=None, + scroll_id=None, + refresh_scroll=None, + size=None, + **kwargs + ): + super(GetAllRequest, self).__init__(**kwargs) + self.name = name + self.user = user + self.ready = ready + self.tags = tags + self.system_tags = system_tags + self.only_fields = only_fields + self.page = page + self.page_size = page_size + self.project = project + self.order_by = order_by + self.task = task + self.id = id + self.search_text = search_text + self.framework = framework + self.uri = uri + self._all_ = _all_ + self._any_ = _any_ + self.last_update = last_update + self.scroll_id = scroll_id + self.refresh_scroll = refresh_scroll + self.size = size + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("user") + def user(self): + return self._property_user + + @user.setter + def user(self, value): + if value is None: + self._property_user = None + return + + self.assert_isinstance(value, "user", (list, tuple)) + + self.assert_isinstance(value, "user", six.string_types, is_array=True) + self._property_user = value + + @schema_property("ready") + def ready(self): + return self._property_ready + + @ready.setter + def ready(self, value): + if value is None: + self._property_ready = None + return + + self.assert_isinstance(value, "ready", (bool,)) + self._property_ready = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("only_fields") + def only_fields(self): + return self._property_only_fields + + @only_fields.setter + def only_fields(self, value): + if value is None: + self._property_only_fields = None + return + + self.assert_isinstance(value, "only_fields", (list, tuple)) + + self.assert_isinstance(value, "only_fields", six.string_types, is_array=True) + self._property_only_fields = value + + @schema_property("page") + def page(self): + return self._property_page + + @page.setter + def page(self, value): + if value is None: + self._property_page = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page", six.integer_types) + self._property_page = value + + @schema_property("page_size") + def page_size(self): + return self._property_page_size + + @page_size.setter + def page_size(self, value): + if value is None: + self._property_page_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page_size", six.integer_types) + self._property_page_size = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", (list, tuple)) + + self.assert_isinstance(value, "project", six.string_types, is_array=True) + self._property_project = value + + @schema_property("order_by") + def order_by(self): + return self._property_order_by + + @order_by.setter + def order_by(self, value): + if value is None: + self._property_order_by = None + return + + self.assert_isinstance(value, "order_by", (list, tuple)) + + self.assert_isinstance(value, "order_by", six.string_types, is_array=True) + self._property_order_by = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", (list, tuple)) + + self.assert_isinstance(value, "task", six.string_types, is_array=True) + self._property_task = value + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", (list, tuple)) + + self.assert_isinstance(value, "id", six.string_types, is_array=True) + self._property_id = value + + @schema_property("search_text") + def search_text(self): + return self._property_search_text + + @search_text.setter + def search_text(self, value): + if value is None: + self._property_search_text = None + return + + self.assert_isinstance(value, "search_text", six.string_types) + self._property_search_text = value + + @schema_property("framework") + def framework(self): + return self._property_framework + + @framework.setter + def framework(self, value): + if value is None: + self._property_framework = None + return + + self.assert_isinstance(value, "framework", (list, tuple)) + + self.assert_isinstance(value, "framework", six.string_types, is_array=True) + self._property_framework = value + + @schema_property("uri") + def uri(self): + return self._property_uri + + @uri.setter + def uri(self, value): + if value is None: + self._property_uri = None + return + + self.assert_isinstance(value, "uri", (list, tuple)) + + self.assert_isinstance(value, "uri", six.string_types, is_array=True) + self._property_uri = value + + @schema_property("_all_") + def _all_(self): + return self._property__all_ + + @_all_.setter + def _all_(self, value): + if value is None: + self._property__all_ = None + return + if isinstance(value, dict): + value = MultiFieldPatternData.from_dict(value) + else: + self.assert_isinstance(value, "_all_", MultiFieldPatternData) + self._property__all_ = value + + @schema_property("_any_") + def _any_(self): + return self._property__any_ + + @_any_.setter + def _any_(self, value): + if value is None: + self._property__any_ = None + return + if isinstance(value, dict): + value = MultiFieldPatternData.from_dict(value) + else: + self.assert_isinstance(value, "_any_", MultiFieldPatternData) + self._property__any_ = value + + @schema_property("last_update") + def last_update(self): + return self._property_last_update + + @last_update.setter + def last_update(self, value): + if value is None: + self._property_last_update = None + return + + self.assert_isinstance(value, "last_update", six.string_types) + self._property_last_update = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("refresh_scroll") + def refresh_scroll(self): + return self._property_refresh_scroll + + @refresh_scroll.setter + def refresh_scroll(self, value): + if value is None: + self._property_refresh_scroll = None + return + + self.assert_isinstance(value, "refresh_scroll", (bool,)) + self._property_refresh_scroll = value + + @schema_property("size") + def size(self): + return self._property_size + + @size.setter + def size(self, value): + if value is None: + self._property_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "size", six.integer_types) + self._property_size = value + + +class GetAllResponse(Response): + """ + Response of models.get_all endpoint. + + :param models: Models list + :type models: Sequence[Model] + :param scroll_id: Scroll ID that can be used with the next calls to get_all to + retrieve more data + :type scroll_id: str + """ + + _service = "models" + _action = "get_all" + _version = "2.20" + + _schema = { + "definitions": { + "metadata_item": { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": ["string", "null"], + }, + "type": { + "description": "The type of the metadata item", + "type": ["string", "null"], + }, + "value": { + "description": "The value stored in the metadata item", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "model": { + "properties": { + "comment": { + "description": "Model comment", + "type": ["string", "null"], + }, + "company": { + "description": "Company id", + "type": ["string", "null"], + }, + "created": { + "description": "Model creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "design": { + "additionalProperties": True, + "description": "Json object representing the model design. Should be identical to the network design of the task which created the model", + "type": ["object", "null"], + }, + "framework": { + "description": "Framework on which the model is based. Should be identical to the framework of the task which created the model", + "type": ["string", "null"], + }, + "id": {"description": "Model id", "type": ["string", "null"]}, + "labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model. The keys are the layers' names and the values are the ids.", + "type": ["object", "null"], + }, + "last_update": { + "description": "Model last update time", + "format": "date-time", + "type": ["string", "null"], + }, + "metadata": { + "additionalProperties": {"$ref": "#/definitions/metadata_item"}, + "description": "Model metadata", + "type": ["object", "null"], + }, + "name": {"description": "Model name", "type": ["string", "null"]}, + "parent": { + "description": "Parent model ID", + "type": ["string", "null"], + }, + "project": { + "description": "Associated project ID", + "type": ["string", "null"], + }, + "ready": { + "description": "Indication if the model is final and can be used by other tasks", + "type": ["boolean", "null"], + }, + "stats": { + "description": "Model statistics", + "properties": { + "labels_count": { + "description": "Number of the model labels", + "type": "integer", + } + }, + "type": ["object", "null"], + }, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "task": { + "description": "Task ID of task in which the model was created", + "type": ["string", "null"], + }, + "ui_cache": { + "additionalProperties": True, + "description": "UI cache for this model", + "type": ["object", "null"], + }, + "uri": { + "description": "URI for the model, pointing to the destination storage.", + "type": ["string", "null"], + }, + "user": { + "description": "Associated user id", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + }, + "properties": { + "models": { + "description": "Models list", + "items": {"$ref": "#/definitions/model"}, + "type": ["array", "null"], + }, + "scroll_id": { + "description": "Scroll ID that can be used with the next calls to get_all to retrieve more data", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, models=None, scroll_id=None, **kwargs): + super(GetAllResponse, self).__init__(**kwargs) + self.models = models + self.scroll_id = scroll_id + + @schema_property("models") + def models(self): + return self._property_models + + @models.setter + def models(self, value): + if value is None: + self._property_models = None + return + + self.assert_isinstance(value, "models", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [Model.from_dict(v) if isinstance(v, dict) else v for v in value] + else: + self.assert_isinstance(value, "models", Model, is_array=True) + self._property_models = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class GetByIdRequest(Request): + """ + Gets model information + + :param model: Model id + :type model: str + """ + + _service = "models" + _action = "get_by_id" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"model": {"description": "Model id", "type": "string"}}, + "required": ["model"], + "type": "object", + } + + def __init__(self, model, **kwargs): + super(GetByIdRequest, self).__init__(**kwargs) + self.model = model + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + +class GetByIdResponse(Response): + """ + Response of models.get_by_id endpoint. + + :param model: Model info + :type model: Model + """ + + _service = "models" + _action = "get_by_id" + _version = "2.20" + + _schema = { + "definitions": { + "metadata_item": { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": ["string", "null"], + }, + "type": { + "description": "The type of the metadata item", + "type": ["string", "null"], + }, + "value": { + "description": "The value stored in the metadata item", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "model": { + "properties": { + "comment": { + "description": "Model comment", + "type": ["string", "null"], + }, + "company": { + "description": "Company id", + "type": ["string", "null"], + }, + "created": { + "description": "Model creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "design": { + "additionalProperties": True, + "description": "Json object representing the model design. Should be identical to the network design of the task which created the model", + "type": ["object", "null"], + }, + "framework": { + "description": "Framework on which the model is based. Should be identical to the framework of the task which created the model", + "type": ["string", "null"], + }, + "id": {"description": "Model id", "type": ["string", "null"]}, + "labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model. The keys are the layers' names and the values are the ids.", + "type": ["object", "null"], + }, + "last_update": { + "description": "Model last update time", + "format": "date-time", + "type": ["string", "null"], + }, + "metadata": { + "additionalProperties": {"$ref": "#/definitions/metadata_item"}, + "description": "Model metadata", + "type": ["object", "null"], + }, + "name": {"description": "Model name", "type": ["string", "null"]}, + "parent": { + "description": "Parent model ID", + "type": ["string", "null"], + }, + "project": { + "description": "Associated project ID", + "type": ["string", "null"], + }, + "ready": { + "description": "Indication if the model is final and can be used by other tasks", + "type": ["boolean", "null"], + }, + "stats": { + "description": "Model " "statistics", + "properties": { + "labels_count": { + "description": "Number of the model labels", + "type": "integer", + } + }, + "type": ["object", "null"], + }, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "task": { + "description": "Task ID of task in which the model was created", + "type": ["string", "null"], + }, + "ui_cache": { + "additionalProperties": True, + "description": "UI cache for this model", + "type": ["object", "null"], + }, + "uri": { + "description": "URI for the model, pointing to the destination storage.", + "type": ["string", "null"], + }, + "user": { + "description": "Associated user id", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + }, + "properties": { + "model": { + "description": "Model info", + "oneOf": [{"$ref": "#/definitions/model"}, {"type": "null"}], + } + }, + "type": "object", + } + + def __init__(self, model=None, **kwargs): + super(GetByIdResponse, self).__init__(**kwargs) + self.model = model + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + if isinstance(value, dict): + value = Model.from_dict(value) + else: + self.assert_isinstance(value, "model", Model) + self._property_model = value + + +class GetByTaskIdRequest(Request): + """ + Gets model information + + :param task: Task id + :type task: str + """ + + _service = "models" + _action = "get_by_task_id" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"task": {"description": "Task id", "type": ["string", "null"]}}, + "type": "object", + } + + def __init__(self, task=None, **kwargs): + super(GetByTaskIdRequest, self).__init__(**kwargs) + self.task = task + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class GetByTaskIdResponse(Response): + """ + Response of models.get_by_task_id endpoint. + + :param model: Model info + :type model: Model + """ + + _service = "models" + _action = "get_by_task_id" + _version = "2.20" + + _schema = { + "definitions": { + "metadata_item": { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": ["string", "null"], + }, + "type": { + "description": "The type of the metadata item", + "type": ["string", "null"], + }, + "value": { + "description": "The value stored in the metadata item", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "model": { + "properties": { + "comment": { + "description": "Model comment", + "type": ["string", "null"], + }, + "company": { + "description": "Company id", + "type": ["string", "null"], + }, + "created": { + "description": "Model creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "design": { + "additionalProperties": True, + "description": "Json object representing the model design. Should be identical to the network design of the task which created the model", + "type": ["object", "null"], + }, + "framework": { + "description": "Framework on which the model is based. Should be identical to the framework of the task which created the model", + "type": ["string", "null"], + }, + "id": {"description": "Model id", "type": ["string", "null"]}, + "labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model. The keys are the layers' names and the values are the ids.", + "type": ["object", "null"], + }, + "last_update": { + "description": "Model last update time", + "format": "date-time", + "type": ["string", "null"], + }, + "metadata": { + "additionalProperties": {"$ref": "#/definitions/metadata_item"}, + "description": "Model metadata", + "type": ["object", "null"], + }, + "name": {"description": "Model name", "type": ["string", "null"]}, + "parent": { + "description": "Parent model ID", + "type": ["string", "null"], + }, + "project": { + "description": "Associated project ID", + "type": ["string", "null"], + }, + "ready": { + "description": "Indication if the model is final and can be used by other tasks", + "type": ["boolean", "null"], + }, + "stats": { + "description": "Model " "statistics", + "properties": { + "labels_count": { + "description": "Number of the model labels", + "type": "integer", + } + }, + "type": ["object", "null"], + }, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "task": { + "description": "Task ID of task in which the model was created", + "type": ["string", "null"], + }, + "ui_cache": { + "additionalProperties": True, + "description": "UI cache for this model", + "type": ["object", "null"], + }, + "uri": { + "description": "URI for the model, pointing to the destination storage.", + "type": ["string", "null"], + }, + "user": { + "description": "Associated user id", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + }, + "properties": { + "model": { + "description": "Model info", + "oneOf": [{"$ref": "#/definitions/model"}, {"type": "null"}], + } + }, + "type": "object", + } + + def __init__(self, model=None, **kwargs): + super(GetByTaskIdResponse, self).__init__(**kwargs) + self.model = model + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + if isinstance(value, dict): + value = Model.from_dict(value) + else: + self.assert_isinstance(value, "model", Model) + self._property_model = value + + +class MakePrivateRequest(Request): + """ + Convert public models to private + + :param ids: Ids of the models to convert. Only the models originated by the + company can be converted + :type ids: Sequence[str] + """ + + _service = "models" + _action = "make_private" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "Ids of the models to convert. Only the models originated by the company can be converted", + "items": {"type": "string"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, ids=None, **kwargs): + super(MakePrivateRequest, self).__init__(**kwargs) + self.ids = ids + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + +class MakePrivateResponse(Response): + """ + Response of models.make_private endpoint. + + :param updated: Number of models updated + :type updated: int + """ + + _service = "models" + _action = "make_private" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of models updated", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(MakePrivateResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class MakePublicRequest(Request): + """ + Convert company models to public + + :param ids: Ids of the models to convert + :type ids: Sequence[str] + """ + + _service = "models" + _action = "make_public" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "Ids of the models to convert", + "items": {"type": "string"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, ids=None, **kwargs): + super(MakePublicRequest, self).__init__(**kwargs) + self.ids = ids + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + +class MakePublicResponse(Response): + """ + Response of models.make_public endpoint. + + :param updated: Number of models updated + :type updated: int + """ + + _service = "models" + _action = "make_public" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of models updated", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(MakePublicResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class GetFrameworksRequest(Request): + """ + Get the list of frameworks used in the company models + + :param projects: The list of projects which models will be analyzed. If not + passed or empty then all the company and public models will be analyzed + :type projects: Sequence[str] + """ + + _service = "models" + _action = "get_frameworks" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "projects": { + "description": "The list of projects which models will be analyzed. If not passed or empty then all the company and public models will be analyzed", + "items": {"type": "string"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, projects=None, **kwargs): + super(GetFrameworksRequest, self).__init__(**kwargs) + self.projects = projects + + @schema_property("projects") + def projects(self): + return self._property_projects + + @projects.setter + def projects(self, value): + if value is None: + self._property_projects = None + return + + self.assert_isinstance(value, "projects", (list, tuple)) + + self.assert_isinstance(value, "projects", six.string_types, is_array=True) + self._property_projects = value + + +class GetFrameworksResponse(Response): + """ + Response of models.get_frameworks endpoint. + + :param frameworks: Unique list of the frameworks used in the company models + :type frameworks: Sequence[str] + """ + + _service = "models" + _action = "get_frameworks" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "frameworks": { + "description": "Unique list of the frameworks used in the company models", + "items": {"type": "string"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, frameworks=None, **kwargs): + super(GetFrameworksResponse, self).__init__(**kwargs) + self.frameworks = frameworks + + @schema_property("frameworks") + def frameworks(self): + return self._property_frameworks + + @frameworks.setter + def frameworks(self, value): + if value is None: + self._property_frameworks = None + return + + self.assert_isinstance(value, "frameworks", (list, tuple)) + + self.assert_isinstance(value, "frameworks", six.string_types, is_array=True) + self._property_frameworks = value + + +class MoveRequest(Request): + """ + Move models to a project + + :param ids: Models to move + :type ids: Sequence[str] + :param project: Target project ID. If not provided, `project_name` must be + provided. + :type project: str + :param project_name: Target project name. If provided and a project with this + name does not exist, a new project will be created. If not provided, `project` + must be provided. + :type project_name: str + """ + + _service = "models" + _action = "move" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "Models to move", + "items": {"type": "string"}, + "type": "array", + }, + "project": { + "description": "Target project ID. If notprovided, `project_name` must beprovided.", + "type": "string", + }, + "project_name": { + "description": "Target project name. Ifprovided and a project withthis name does not exist, anew project will be created.If not provided, `project`must be provided.", + "type": "string", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__(self, ids, project=None, project_name=None, **kwargs): + super(MoveRequest, self).__init__(**kwargs) + self.ids = ids + self.project = project + self.project_name = project_name + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("project_name") + def project_name(self): + return self._property_project_name + + @project_name.setter + def project_name(self, value): + if value is None: + self._property_project_name = None + return + + self.assert_isinstance(value, "project_name", six.string_types) + self._property_project_name = value + + +class MoveResponse(Response): + """ + Response of models.move endpoint. + + """ + + _service = "models" + _action = "move" + _version = "2.20" + + _schema = {"additionalProperties": True, "definitions": {}, "type": "object"} + + +class PublishManyRequest(Request): + """ + Publish models + + :param ids: IDs of the models to publish + :type ids: Sequence[str] + :param force_publish_task: Publish the associated tasks (if exist) even if they + are not in the 'stopped' state. Optional, the default value is False. + :type force_publish_task: bool + :param publish_tasks: Indicates that the associated tasks (if exist) should be + published. Optional, the default value is True. + :type publish_tasks: bool + """ + + _service = "models" + _action = "publish_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force_publish_task": { + "description": "Publish the associated tasks (if exist) even if they are not in the 'stopped' state. Optional, the default value is False.", + "type": "boolean", + }, + "ids": { + "description": "IDs of the models to publish", + "items": {"type": "string"}, + "type": "array", + }, + "publish_tasks": { + "description": "Indicates that the associated tasks (if exist) should be published. Optional, the default value is True.", + "type": "boolean", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__(self, ids, force_publish_task=None, publish_tasks=None, **kwargs): + super(PublishManyRequest, self).__init__(**kwargs) + self.ids = ids + self.force_publish_task = force_publish_task + self.publish_tasks = publish_tasks + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("force_publish_task") + def force_publish_task(self): + return self._property_force_publish_task + + @force_publish_task.setter + def force_publish_task(self, value): + if value is None: + self._property_force_publish_task = None + return + + self.assert_isinstance(value, "force_publish_task", (bool,)) + self._property_force_publish_task = value + + @schema_property("publish_tasks") + def publish_tasks(self): + return self._property_publish_tasks + + @publish_tasks.setter + def publish_tasks(self, value): + if value is None: + self._property_publish_tasks = None + return + + self.assert_isinstance(value, "publish_tasks", (bool,)) + self._property_publish_tasks = value + + +class PublishManyResponse(Response): + """ + Response of models.publish_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "models" + _action = "publish_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "published_task": { + "description": "Result of publishing of the model's associated task (if exists). " + "Returned only if the task was published successfully as part of the model publishing.", + "properties": { + "data": { + "description": "Data returned from the task publishing operation.", + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": "object", + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": "integer", + }, + }, + "type": "object", + }, + "id": {"description": "Task id", "type": "string"}, + }, + "type": "object", + }, + "updated": { + "description": "Indicates whether the model was updated", + "type": "boolean", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(PublishManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class SetReadyRequest(Request): + """ + Set the model ready flag to True. If the model is an output model of a task then try to publish the task. + + :param model: Model id + :type model: str + :param force_publish_task: Publish the associated task (if exists) even if it + is not in the 'stopped' state. Optional, the default value is False. + :type force_publish_task: bool + :param publish_task: Indicates that the associated task (if exists) should be + published. Optional, the default value is True. + :type publish_task: bool + """ + + _service = "models" + _action = "set_ready" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force_publish_task": { + "description": "Publish the associated task (if exists) even if it is not in the 'stopped' state. Optional, the default value is False.", + "type": "boolean", + }, + "model": {"description": "Model id", "type": "string"}, + "publish_task": { + "description": "Indicates that the associated task (if exists) should be published. Optional, the default value is True.", + "type": "boolean", + }, + }, + "required": ["model"], + "type": "object", + } + + def __init__(self, model, force_publish_task=None, publish_task=None, **kwargs): + super(SetReadyRequest, self).__init__(**kwargs) + self.model = model + self.force_publish_task = force_publish_task + self.publish_task = publish_task + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + @schema_property("force_publish_task") + def force_publish_task(self): + return self._property_force_publish_task + + @force_publish_task.setter + def force_publish_task(self, value): + if value is None: + self._property_force_publish_task = None + return + + self.assert_isinstance(value, "force_publish_task", (bool,)) + self._property_force_publish_task = value + + @schema_property("publish_task") + def publish_task(self): + return self._property_publish_task + + @publish_task.setter + def publish_task(self, value): + if value is None: + self._property_publish_task = None + return + + self.assert_isinstance(value, "publish_task", (bool,)) + self._property_publish_task = value + + +class SetReadyResponse(Response): + """ + Response of models.set_ready endpoint. + + :param updated: Number of models updated (0 or 1) + :type updated: int + :param published_task: Result of publishing of the model's associated task (if + exists). Returned only if the task was published successfully as part of the + model publishing. + :type published_task: dict + """ + + _service = "models" + _action = "set_ready" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "published_task": { + "description": "Result of publishing of the model's associated task (if exists). Returned only if the task was published successfully as part of the model publishing.", + "properties": { + "data": { + "description": "Data returned from the task publishing operation.", + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": "object", + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": "integer", + }, + }, + "type": "object", + }, + "id": {"description": "Task id", "type": "string"}, + }, + "type": ["object", "null"], + }, + "updated": { + "description": "Number of models updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, published_task=None, **kwargs): + super(SetReadyResponse, self).__init__(**kwargs) + self.updated = updated + self.published_task = published_task + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("published_task") + def published_task(self): + return self._property_published_task + + @published_task.setter + def published_task(self, value): + if value is None: + self._property_published_task = None + return + + self.assert_isinstance(value, "published_task", (dict,)) + self._property_published_task = value + + +class UnarchiveManyRequest(Request): + """ + Unarchive models + + :param ids: IDs of the models to unarchive + :type ids: Sequence[str] + """ + + _service = "models" + _action = "unarchive_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "IDs of the models to unarchive", + "items": {"type": "string"}, + "type": "array", + } + }, + "required": ["ids"], + "type": "object", + } + + def __init__(self, ids, **kwargs): + super(UnarchiveManyRequest, self).__init__(**kwargs) + self.ids = ids + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + +class UnarchiveManyResponse(Response): + """ + Response of models.unarchive_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "models" + _action = "unarchive_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "unarchived": { + "description": "Indicates whether the model was unarchived", + "type": "boolean", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(UnarchiveManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class UpdateRequest(Request): + """ + Update a model + + :param model: Model id + :type model: str + :param name: Model name Unique within the company. + :type name: str + :param comment: Model comment + :type comment: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param ready: Indication if the model is final and can be used by other tasks + Default is false. + :type ready: bool + :param created: Model creation time (UTC) + :type created: datetime.datetime + :param ui_cache: UI cache for this model + :type ui_cache: dict + :param project: Project to which to model belongs + :type project: str + :param task: Associated task ID + :type task: str + :param iteration: Iteration (used to update task statistics if an associated + task is reported) + :type iteration: int + """ + + _service = "models" + _action = "update" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "comment": {"description": "Model comment", "type": "string"}, + "created": { + "description": "Model creation time (UTC) ", + "format": "date-time", + "type": "string", + }, + "iteration": { + "description": "Iteration (used to update task statistics if an associated task is reported)", + "type": "integer", + }, + "model": {"description": "Model id", "type": "string"}, + "name": { + "description": "Model name Unique within the company.", + "type": "string", + }, + "project": { + "description": "Project to which to model belongs", + "type": "string", + }, + "ready": { + "default": False, + "description": "Indication if the model is final and can be used by other tasks Default is false.", + "type": "boolean", + }, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + "task": {"description": "Associated task ID", "type": "string"}, + "ui_cache": { + "additionalProperties": True, + "description": "UI cache for this model", + "type": "object", + }, + }, + "required": ["model"], + "type": "object", + } + + def __init__( + self, + model, + name=None, + comment=None, + tags=None, + system_tags=None, + ready=False, + created=None, + ui_cache=None, + project=None, + task=None, + iteration=None, + **kwargs + ): + super(UpdateRequest, self).__init__(**kwargs) + self.model = model + self.name = name + self.comment = comment + self.tags = tags + self.system_tags = system_tags + self.ready = ready + self.created = created + self.ui_cache = ui_cache + self.project = project + self.task = task + self.iteration = iteration + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("ready") + def ready(self): + return self._property_ready + + @ready.setter + def ready(self, value): + if value is None: + self._property_ready = None + return + + self.assert_isinstance(value, "ready", (bool,)) + self._property_ready = value + + @schema_property("created") + def created(self): + return self._property_created + + @created.setter + def created(self, value): + if value is None: + self._property_created = None + return + + self.assert_isinstance(value, "created", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_created = value + + @schema_property("ui_cache") + def ui_cache(self): + return self._property_ui_cache + + @ui_cache.setter + def ui_cache(self, value): + if value is None: + self._property_ui_cache = None + return + + self.assert_isinstance(value, "ui_cache", (dict,)) + self._property_ui_cache = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("iteration") + def iteration(self): + return self._property_iteration + + @iteration.setter + def iteration(self, value): + if value is None: + self._property_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iteration", six.integer_types) + self._property_iteration = value + + +class UpdateResponse(Response): + """ + Response of models.update endpoint. + + :param updated: Number of models updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "models" + _action = "update" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of models updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(UpdateResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class UpdateForTaskRequest(Request): + """ + Create or update a new model for a task + + :param task: Task id + :type task: str + :param uri: URI for the model. Exactly one of uri or override_model_id is a + required. + :type uri: str + :param name: Model name Unique within the company. + :type name: str + :param comment: Model comment + :type comment: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param override_model_id: Override model ID. If provided, this model is updated + in the task. Exactly one of override_model_id or uri is required. + :type override_model_id: str + :param iteration: Iteration (used to update task statistics) + :type iteration: int + """ + + _service = "models" + _action = "update_for_task" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "comment": {"description": "Model comment", "type": "string"}, + "iteration": { + "description": "Iteration (used to update task statistics)", + "type": "integer", + }, + "name": { + "description": "Model name Unique within the company.", + "type": "string", + }, + "override_model_id": { + "description": "Override model ID. If provided, this model is updated in the task. Exactly one of override_model_id or uri is required.", + "type": "string", + }, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + "task": {"description": "Task id", "type": "string"}, + "uri": { + "description": "URI for the model. Exactly one of uri or override_model_id is a required.", + "type": "string", + }, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + uri=None, + name=None, + comment=None, + tags=None, + system_tags=None, + override_model_id=None, + iteration=None, + **kwargs + ): + super(UpdateForTaskRequest, self).__init__(**kwargs) + self.task = task + self.uri = uri + self.name = name + self.comment = comment + self.tags = tags + self.system_tags = system_tags + self.override_model_id = override_model_id + self.iteration = iteration + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("uri") + def uri(self): + return self._property_uri + + @uri.setter + def uri(self, value): + if value is None: + self._property_uri = None + return + + self.assert_isinstance(value, "uri", six.string_types) + self._property_uri = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("override_model_id") + def override_model_id(self): + return self._property_override_model_id + + @override_model_id.setter + def override_model_id(self, value): + if value is None: + self._property_override_model_id = None + return + + self.assert_isinstance(value, "override_model_id", six.string_types) + self._property_override_model_id = value + + @schema_property("iteration") + def iteration(self): + return self._property_iteration + + @iteration.setter + def iteration(self, value): + if value is None: + self._property_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iteration", six.integer_types) + self._property_iteration = value + + +class UpdateForTaskResponse(Response): + """ + Response of models.update_for_task endpoint. + + :param id: ID of the model + :type id: str + :param created: Was the model created + :type created: bool + :param updated: Number of models updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "models" + _action = "update_for_task" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "created": { + "description": "Was the model created", + "type": ["boolean", "null"], + }, + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "id": {"description": "ID of the model", "type": ["string", "null"]}, + "updated": { + "description": "Number of models updated (0 or 1)", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, id=None, created=None, updated=None, fields=None, **kwargs): + super(UpdateForTaskResponse, self).__init__(**kwargs) + self.id = id + self.created = created + self.updated = updated + self.fields = fields + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("created") + def created(self): + return self._property_created + + @created.setter + def created(self, value): + if value is None: + self._property_created = None + return + + self.assert_isinstance(value, "created", (bool,)) + self._property_created = value + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +response_mapping = { + GetByIdRequest: GetByIdResponse, + GetByTaskIdRequest: GetByTaskIdResponse, + GetAllRequest: GetAllResponse, + GetFrameworksRequest: GetFrameworksResponse, + UpdateForTaskRequest: UpdateForTaskResponse, + CreateRequest: CreateResponse, + EditRequest: EditResponse, + UpdateRequest: UpdateResponse, + PublishManyRequest: PublishManyResponse, + SetReadyRequest: SetReadyResponse, + ArchiveManyRequest: ArchiveManyResponse, + UnarchiveManyRequest: UnarchiveManyResponse, + DeleteManyRequest: DeleteManyResponse, + DeleteRequest: DeleteResponse, + MakePublicRequest: MakePublicResponse, + MakePrivateRequest: MakePrivateResponse, + MoveRequest: MoveResponse, + AddOrUpdateMetadataRequest: AddOrUpdateMetadataResponse, + DeleteMetadataRequest: DeleteMetadataResponse, +} diff --git a/clearml/backend_api/services/v2_20/organization.py b/clearml/backend_api/services/v2_20/organization.py new file mode 100644 index 00000000..3dd2fa32 --- /dev/null +++ b/clearml/backend_api/services/v2_20/organization.py @@ -0,0 +1,155 @@ +""" +organization service + +This service provides organization level operations +""" +import six + +from clearml.backend_api.session import Request, Response, schema_property + + +class GetTagsRequest(Request): + """ + Get all the user and system tags used for the company tasks and models + + :param include_system: If set to 'true' then the list of the system tags is + also returned. The default value is 'false' + :type include_system: bool + :param filter: Filter on entities to collect tags from + :type filter: dict + """ + + _service = "organization" + _action = "get_tags" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "filter": { + "description": "Filter on entities to collect tags from", + "properties": { + "system_tags": { + "description": "The list of system tag values to filter by. Use 'null' value to specify empty system tags. Use '__Snot' value to specify that the following value should be excluded", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "The list of tag values to filter by. Use 'null' value to specify empty tags. Use '__Snot' value to specify that the following value should be excluded", + "items": {"type": "string"}, + "type": "array", + }, + }, + "type": ["object", "null"], + }, + "include_system": { + "default": False, + "description": "If set to 'true' then the list of the system tags is also returned. The default value is 'false'", + "type": ["boolean", "null"], + }, + }, + "type": "object", + } + + def __init__(self, include_system=False, filter=None, **kwargs): + super(GetTagsRequest, self).__init__(**kwargs) + self.include_system = include_system + self.filter = filter + + @schema_property("include_system") + def include_system(self): + return self._property_include_system + + @include_system.setter + def include_system(self, value): + if value is None: + self._property_include_system = None + return + + self.assert_isinstance(value, "include_system", (bool,)) + self._property_include_system = value + + @schema_property("filter") + def filter(self): + return self._property_filter + + @filter.setter + def filter(self, value): + if value is None: + self._property_filter = None + return + + self.assert_isinstance(value, "filter", (dict,)) + self._property_filter = value + + +class GetTagsResponse(Response): + """ + Response of organization.get_tags endpoint. + + :param tags: The list of unique tag values + :type tags: Sequence[str] + :param system_tags: The list of unique system tag values. Returned only if + 'include_system' is set to 'true' in the request + :type system_tags: Sequence[str] + """ + + _service = "organization" + _action = "get_tags" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "system_tags": { + "description": "The list of unique system tag values. Returned only if 'include_system' is set to 'true' in the request", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "The list of unique tag values", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, tags=None, system_tags=None, **kwargs): + super(GetTagsResponse, self).__init__(**kwargs) + self.tags = tags + self.system_tags = system_tags + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + +response_mapping = { + GetTagsRequest: GetTagsResponse, +} diff --git a/clearml/backend_api/services/v2_20/pipelines.py b/clearml/backend_api/services/v2_20/pipelines.py new file mode 100644 index 00000000..006b123c --- /dev/null +++ b/clearml/backend_api/services/v2_20/pipelines.py @@ -0,0 +1,169 @@ +""" +pipelines service + +Provides a management API for pipelines in the system. +""" +import six + +from clearml.backend_api.session import ( + Request, + Response, + schema_property, +) + + +class StartPipelineRequest(Request): + """ + Start a pipeline + + :param task: ID of the task on which the pipeline will be based + :type task: str + :param queue: Queue ID in which the created pipeline task will be enqueued + :type queue: str + :param args: Task arguments, name/value to be placed in the hyperparameters + Args section + :type args: Sequence[dict] + """ + + _service = "pipelines" + _action = "start_pipeline" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "args": { + "description": "Task arguments, name/value to be placed in the hyperparameters Args section", + "items": { + "properties": { + "name": {"type": "string"}, + "value": {"type": ["string", "null"]}, + }, + "type": "object", + }, + "type": "array", + }, + "queue": { + "description": "Queue ID in which the created pipeline task will be enqueued", + "type": "string", + }, + "task": { + "description": "ID of the task on which the pipeline will be based", + "type": "string", + }, + }, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, queue=None, args=None, **kwargs): + super(StartPipelineRequest, self).__init__(**kwargs) + self.task = task + self.queue = queue + self.args = args + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("args") + def args(self): + return self._property_args + + @args.setter + def args(self, value): + if value is None: + self._property_args = None + return + + self.assert_isinstance(value, "args", (list, tuple)) + + self.assert_isinstance(value, "args", (dict,), is_array=True) + self._property_args = value + + +class StartPipelineResponse(Response): + """ + Response of pipelines.start_pipeline endpoint. + + :param pipeline: ID of the new pipeline task + :type pipeline: str + :param enqueued: True if the task was successfuly enqueued + :type enqueued: bool + """ + + _service = "pipelines" + _action = "start_pipeline" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "enqueued": { + "description": "True if the task was successfuly enqueued", + "type": ["boolean", "null"], + }, + "pipeline": { + "description": "ID of the new pipeline task", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, pipeline=None, enqueued=None, **kwargs): + super(StartPipelineResponse, self).__init__(**kwargs) + self.pipeline = pipeline + self.enqueued = enqueued + + @schema_property("pipeline") + def pipeline(self): + return self._property_pipeline + + @pipeline.setter + def pipeline(self, value): + if value is None: + self._property_pipeline = None + return + + self.assert_isinstance(value, "pipeline", six.string_types) + self._property_pipeline = value + + @schema_property("enqueued") + def enqueued(self): + return self._property_enqueued + + @enqueued.setter + def enqueued(self, value): + if value is None: + self._property_enqueued = None + return + + self.assert_isinstance(value, "enqueued", (bool,)) + self._property_enqueued = value + + +response_mapping = { + StartPipelineRequest: StartPipelineResponse, +} diff --git a/clearml/backend_api/services/v2_20/projects.py b/clearml/backend_api/services/v2_20/projects.py new file mode 100644 index 00000000..561ffa1e --- /dev/null +++ b/clearml/backend_api/services/v2_20/projects.py @@ -0,0 +1,4718 @@ +""" +projects service + +Provides support for defining Projects containing Tasks, Models and Dataset Versions. +""" +import six +from datetime import datetime + +from dateutil.parser import parse as parse_datetime + +from clearml.backend_api.session import ( + Request, + Response, + NonStrictDataModel, + schema_property, +) + + +class MultiFieldPatternData(NonStrictDataModel): + """ + :param pattern: Pattern string (regex) + :type pattern: str + :param fields: List of field names + :type fields: Sequence[str] + """ + + _schema = { + "properties": { + "fields": { + "description": "List of field names", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "pattern": { + "description": "Pattern string (regex)", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, pattern=None, fields=None, **kwargs): + super(MultiFieldPatternData, self).__init__(**kwargs) + self.pattern = pattern + self.fields = fields + + @schema_property("pattern") + def pattern(self): + return self._property_pattern + + @pattern.setter + def pattern(self, value): + if value is None: + self._property_pattern = None + return + + self.assert_isinstance(value, "pattern", six.string_types) + self._property_pattern = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (list, tuple)) + + self.assert_isinstance(value, "fields", six.string_types, is_array=True) + self._property_fields = value + + +class Project(NonStrictDataModel): + """ + :param id: Project id + :type id: str + :param name: Project name + :type name: str + :param basename: Project base name + :type basename: str + :param description: Project description + :type description: str + :param user: Associated user id + :type user: str + :param company: Company id + :type company: str + :param created: Creation time + :type created: datetime.datetime + :param last_update: Last project update time. Reflects the last time the + project metadata was changed or a task in this project has changed status + :type last_update: datetime.datetime + :param tags: User-defined tags + :type tags: Sequence[str] + :param system_tags: System tags. This field is reserved for system use, please + don't use it. + :type system_tags: Sequence[str] + :param default_output_destination: The default output destination URL for new + tasks under this project + :type default_output_destination: str + """ + + _schema = { + "properties": { + "basename": { + "description": "Project base name", + "type": ["string", "null"], + }, + "company": {"description": "Company id", "type": ["string", "null"]}, + "created": { + "description": "Creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "default_output_destination": { + "description": "The default output destination URL for new tasks under this project", + "type": ["string", "null"], + }, + "description": { + "description": "Project description", + "type": ["string", "null"], + }, + "id": {"description": "Project id", "type": ["string", "null"]}, + "last_update": { + "description": "Last project update time. Reflects the last time the project metadata was changed or a task in this project has changed status", + "format": "date-time", + "type": ["string", "null"], + }, + "name": {"description": "Project name", "type": ["string", "null"]}, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "user": {"description": "Associated user id", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__( + self, + id=None, + name=None, + basename=None, + description=None, + user=None, + company=None, + created=None, + last_update=None, + tags=None, + system_tags=None, + default_output_destination=None, + **kwargs + ): + super(Project, self).__init__(**kwargs) + self.id = id + self.name = name + self.basename = basename + self.description = description + self.user = user + self.company = company + self.created = created + self.last_update = last_update + self.tags = tags + self.system_tags = system_tags + self.default_output_destination = default_output_destination + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("basename") + def basename(self): + return self._property_basename + + @basename.setter + def basename(self, value): + if value is None: + self._property_basename = None + return + + self.assert_isinstance(value, "basename", six.string_types) + self._property_basename = value + + @schema_property("description") + def description(self): + return self._property_description + + @description.setter + def description(self, value): + if value is None: + self._property_description = None + return + + self.assert_isinstance(value, "description", six.string_types) + self._property_description = value + + @schema_property("user") + def user(self): + return self._property_user + + @user.setter + def user(self, value): + if value is None: + self._property_user = None + return + + self.assert_isinstance(value, "user", six.string_types) + self._property_user = value + + @schema_property("company") + def company(self): + return self._property_company + + @company.setter + def company(self, value): + if value is None: + self._property_company = None + return + + self.assert_isinstance(value, "company", six.string_types) + self._property_company = value + + @schema_property("created") + def created(self): + return self._property_created + + @created.setter + def created(self, value): + if value is None: + self._property_created = None + return + + self.assert_isinstance(value, "created", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_created = value + + @schema_property("last_update") + def last_update(self): + return self._property_last_update + + @last_update.setter + def last_update(self, value): + if value is None: + self._property_last_update = None + return + + self.assert_isinstance(value, "last_update", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_last_update = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("default_output_destination") + def default_output_destination(self): + return self._property_default_output_destination + + @default_output_destination.setter + def default_output_destination(self, value): + if value is None: + self._property_default_output_destination = None + return + + self.assert_isinstance(value, "default_output_destination", six.string_types) + self._property_default_output_destination = value + + +class StatsStatusCount(NonStrictDataModel): + """ + :param total_runtime: Total run time of all tasks in project (in seconds) + :type total_runtime: int + :param total_tasks: Number of tasks + :type total_tasks: int + :param completed_tasks_24h: Number of tasks completed in the last 24 hours + :type completed_tasks_24h: int + :param last_task_run: The most recent started time of a task + :type last_task_run: int + :param status_count: Status counts + :type status_count: dict + """ + + _schema = { + "properties": { + "completed_tasks_24h": { + "description": "Number of tasks completed in the last 24 hours", + "type": ["integer", "null"], + }, + "last_task_run": { + "description": "The most recent started time of a task", + "type": ["integer", "null"], + }, + "status_count": { + "description": "Status counts", + "properties": { + "closed": { + "description": "Number of 'closed' tasks in project", + "type": "integer", + }, + "completed": { + "description": "Number " + "of " + "'completed' " + "tasks " + "in " + "project", + "type": "integer", + }, + "created": { + "description": "Number of 'created' tasks in project", + "type": "integer", + }, + "failed": { + "description": "Number of 'failed' tasks in project", + "type": "integer", + }, + "in_progress": { + "description": "Number of 'in_progress' tasks in project", + "type": "integer", + }, + "published": { + "description": "Number of 'published' tasks in project", + "type": "integer", + }, + "queued": { + "description": "Number of 'queued' tasks in project", + "type": "integer", + }, + "stopped": { + "description": "Number of 'stopped' tasks in project", + "type": "integer", + }, + "unknown": { + "description": "Number of 'unknown' tasks in project", + "type": "integer", + }, + }, + "type": ["object", "null"], + }, + "total_runtime": { + "description": "Total run time of all tasks in project (in seconds)", + "type": ["integer", "null"], + }, + "total_tasks": { + "description": "Number of tasks", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + total_runtime=None, + total_tasks=None, + completed_tasks_24h=None, + last_task_run=None, + status_count=None, + **kwargs + ): + super(StatsStatusCount, self).__init__(**kwargs) + self.total_runtime = total_runtime + self.total_tasks = total_tasks + self.completed_tasks_24h = completed_tasks_24h + self.last_task_run = last_task_run + self.status_count = status_count + + @schema_property("total_runtime") + def total_runtime(self): + return self._property_total_runtime + + @total_runtime.setter + def total_runtime(self, value): + if value is None: + self._property_total_runtime = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "total_runtime", six.integer_types) + self._property_total_runtime = value + + @schema_property("total_tasks") + def total_tasks(self): + return self._property_total_tasks + + @total_tasks.setter + def total_tasks(self, value): + if value is None: + self._property_total_tasks = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "total_tasks", six.integer_types) + self._property_total_tasks = value + + @schema_property("completed_tasks_24h") + def completed_tasks_24h(self): + return self._property_completed_tasks_24h + + @completed_tasks_24h.setter + def completed_tasks_24h(self, value): + if value is None: + self._property_completed_tasks_24h = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "completed_tasks_24h", six.integer_types) + self._property_completed_tasks_24h = value + + @schema_property("last_task_run") + def last_task_run(self): + return self._property_last_task_run + + @last_task_run.setter + def last_task_run(self, value): + if value is None: + self._property_last_task_run = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "last_task_run", six.integer_types) + self._property_last_task_run = value + + @schema_property("status_count") + def status_count(self): + return self._property_status_count + + @status_count.setter + def status_count(self, value): + if value is None: + self._property_status_count = None + return + + self.assert_isinstance(value, "status_count", (dict,)) + self._property_status_count = value + + +class Stats(NonStrictDataModel): + """ + :param active: Stats for active tasks + :type active: StatsStatusCount + :param archived: Stats for archived tasks + :type archived: StatsStatusCount + """ + + _schema = { + "properties": { + "active": { + "description": "Stats for active tasks", + "oneOf": [ + {"$ref": "#/definitions/stats_status_count"}, + {"type": "null"}, + ], + }, + "archived": { + "description": "Stats for archived tasks", + "oneOf": [ + {"$ref": "#/definitions/stats_status_count"}, + {"type": "null"}, + ], + }, + }, + "type": "object", + } + + def __init__(self, active=None, archived=None, **kwargs): + super(Stats, self).__init__(**kwargs) + self.active = active + self.archived = archived + + @schema_property("active") + def active(self): + return self._property_active + + @active.setter + def active(self, value): + if value is None: + self._property_active = None + return + if isinstance(value, dict): + value = StatsStatusCount.from_dict(value) + else: + self.assert_isinstance(value, "active", StatsStatusCount) + self._property_active = value + + @schema_property("archived") + def archived(self): + return self._property_archived + + @archived.setter + def archived(self, value): + if value is None: + self._property_archived = None + return + if isinstance(value, dict): + value = StatsStatusCount.from_dict(value) + else: + self.assert_isinstance(value, "archived", StatsStatusCount) + self._property_archived = value + + +class ProjectsGetAllResponseSingle(NonStrictDataModel): + """ + :param id: Project id + :type id: str + :param name: Project name + :type name: str + :param basename: Project base name + :type basename: str + :param description: Project description + :type description: str + :param user: Associated user id + :type user: str + :param company: Company id + :type company: str + :param created: Creation time + :type created: datetime.datetime + :param last_update: Last update time + :type last_update: datetime.datetime + :param tags: User-defined tags + :type tags: Sequence[str] + :param system_tags: System tags. This field is reserved for system use, please + don't use it. + :type system_tags: Sequence[str] + :param default_output_destination: The default output destination URL for new + tasks under this project + :type default_output_destination: str + :param stats: Additional project stats + :type stats: Stats + :param sub_projects: The list of sub projects + :type sub_projects: Sequence[dict] + :param own_tasks: The amount of tasks under this project (without children + projects). Returned if 'check_own_contents' flag is set in the request + :type own_tasks: int + :param own_models: The amount of models under this project (without children + projects). Returned if 'check_own_contents' flag is set in the request + :type own_models: int + :param dataset_stats: Project dataset statistics + :type dataset_stats: dict + """ + + _schema = { + "properties": { + "basename": { + "description": "Project base name", + "type": ["string", "null"], + }, + "company": {"description": "Company id", "type": ["string", "null"]}, + "created": { + "description": "Creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "dataset_stats": { + "description": "Project dataset statistics", + "properties": { + "file_count": { + "description": "The number of files stored in the dataset", + "type": "integer", + }, + "total_size": { + "description": "The total dataset size in bytes", + "type": "integer", + }, + }, + "type": ["object", "null"], + }, + "default_output_destination": { + "description": "The default output destination URL for new tasks under this project", + "type": ["string", "null"], + }, + "description": { + "description": "Project description", + "type": ["string", "null"], + }, + "id": {"description": "Project id", "type": ["string", "null"]}, + "last_update": { + "description": "Last update time", + "format": "date-time", + "type": ["string", "null"], + }, + "name": {"description": "Project name", "type": ["string", "null"]}, + "own_models": { + "description": "The amount of models under this project (without children projects). Returned if " + "'check_own_contents' flag is set in the request", + "type": ["integer", "null"], + }, + "own_tasks": { + "description": "The amount of tasks under this project (without children projects). Returned if " + "'check_own_contents' flag is set in the request", + "type": ["integer", "null"], + }, + "stats": { + "description": "Additional project stats", + "oneOf": [{"$ref": "#/definitions/stats"}, {"type": "null"}], + }, + "sub_projects": { + "description": "The list of sub projects", + "items": { + "properties": { + "id": {"description": "Subproject ID", "type": "string"}, + "name": {"description": "Subproject name", "type": "string"}, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "user": {"description": "Associated user id", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__( + self, + id=None, + name=None, + basename=None, + description=None, + user=None, + company=None, + created=None, + last_update=None, + tags=None, + system_tags=None, + default_output_destination=None, + stats=None, + sub_projects=None, + own_tasks=None, + own_models=None, + dataset_stats=None, + **kwargs + ): + super(ProjectsGetAllResponseSingle, self).__init__(**kwargs) + self.id = id + self.name = name + self.basename = basename + self.description = description + self.user = user + self.company = company + self.created = created + self.last_update = last_update + self.tags = tags + self.system_tags = system_tags + self.default_output_destination = default_output_destination + self.stats = stats + self.sub_projects = sub_projects + self.own_tasks = own_tasks + self.own_models = own_models + self.dataset_stats = dataset_stats + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("basename") + def basename(self): + return self._property_basename + + @basename.setter + def basename(self, value): + if value is None: + self._property_basename = None + return + + self.assert_isinstance(value, "basename", six.string_types) + self._property_basename = value + + @schema_property("description") + def description(self): + return self._property_description + + @description.setter + def description(self, value): + if value is None: + self._property_description = None + return + + self.assert_isinstance(value, "description", six.string_types) + self._property_description = value + + @schema_property("user") + def user(self): + return self._property_user + + @user.setter + def user(self, value): + if value is None: + self._property_user = None + return + + self.assert_isinstance(value, "user", six.string_types) + self._property_user = value + + @schema_property("company") + def company(self): + return self._property_company + + @company.setter + def company(self, value): + if value is None: + self._property_company = None + return + + self.assert_isinstance(value, "company", six.string_types) + self._property_company = value + + @schema_property("created") + def created(self): + return self._property_created + + @created.setter + def created(self, value): + if value is None: + self._property_created = None + return + + self.assert_isinstance(value, "created", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_created = value + + @schema_property("last_update") + def last_update(self): + return self._property_last_update + + @last_update.setter + def last_update(self, value): + if value is None: + self._property_last_update = None + return + + self.assert_isinstance(value, "last_update", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_last_update = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("default_output_destination") + def default_output_destination(self): + return self._property_default_output_destination + + @default_output_destination.setter + def default_output_destination(self, value): + if value is None: + self._property_default_output_destination = None + return + + self.assert_isinstance(value, "default_output_destination", six.string_types) + self._property_default_output_destination = value + + @schema_property("stats") + def stats(self): + return self._property_stats + + @stats.setter + def stats(self, value): + if value is None: + self._property_stats = None + return + if isinstance(value, dict): + value = Stats.from_dict(value) + else: + self.assert_isinstance(value, "stats", Stats) + self._property_stats = value + + @schema_property("sub_projects") + def sub_projects(self): + return self._property_sub_projects + + @sub_projects.setter + def sub_projects(self, value): + if value is None: + self._property_sub_projects = None + return + + self.assert_isinstance(value, "sub_projects", (list, tuple)) + + self.assert_isinstance(value, "sub_projects", (dict,), is_array=True) + self._property_sub_projects = value + + @schema_property("own_tasks") + def own_tasks(self): + return self._property_own_tasks + + @own_tasks.setter + def own_tasks(self, value): + if value is None: + self._property_own_tasks = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "own_tasks", six.integer_types) + self._property_own_tasks = value + + @schema_property("own_models") + def own_models(self): + return self._property_own_models + + @own_models.setter + def own_models(self, value): + if value is None: + self._property_own_models = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "own_models", six.integer_types) + self._property_own_models = value + + @schema_property("dataset_stats") + def dataset_stats(self): + return self._property_dataset_stats + + @dataset_stats.setter + def dataset_stats(self, value): + if value is None: + self._property_dataset_stats = None + return + + self.assert_isinstance(value, "dataset_stats", (dict,)) + self._property_dataset_stats = value + + +class MetricVariantResult(NonStrictDataModel): + """ + :param metric: Metric name + :type metric: str + :param metric_hash: Metric name hash. Used instead of the metric name when + categorizing last metrics events in task objects. + :type metric_hash: str + :param variant: Variant name + :type variant: str + :param variant_hash: Variant name hash. Used instead of the variant name when + categorizing last metrics events in task objects. + :type variant_hash: str + """ + + _schema = { + "properties": { + "metric": {"description": "Metric name", "type": ["string", "null"]}, + "metric_hash": { + "description": "Metric name hash. Used instead of the metric name when categorizing " + " last metrics events in task objects.", + "type": ["string", "null"], + }, + "variant": {"description": "Variant name", "type": ["string", "null"]}, + "variant_hash": { + "description": "Variant name hash. Used instead of the variant name when categorizing " + "last metrics events in task objects.", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, metric=None, metric_hash=None, variant=None, variant_hash=None, **kwargs + ): + super(MetricVariantResult, self).__init__(**kwargs) + self.metric = metric + self.metric_hash = metric_hash + self.variant = variant + self.variant_hash = variant_hash + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("metric_hash") + def metric_hash(self): + return self._property_metric_hash + + @metric_hash.setter + def metric_hash(self, value): + if value is None: + self._property_metric_hash = None + return + + self.assert_isinstance(value, "metric_hash", six.string_types) + self._property_metric_hash = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + @schema_property("variant_hash") + def variant_hash(self): + return self._property_variant_hash + + @variant_hash.setter + def variant_hash(self, value): + if value is None: + self._property_variant_hash = None + return + + self.assert_isinstance(value, "variant_hash", six.string_types) + self._property_variant_hash = value + + +class Urls(NonStrictDataModel): + """ + :param model_urls: + :type model_urls: Sequence[str] + :param event_urls: + :type event_urls: Sequence[str] + :param artifact_urls: + :type artifact_urls: Sequence[str] + """ + + _schema = { + "properties": { + "artifact_urls": {"items": {"type": "string"}, "type": ["array", "null"]}, + "event_urls": {"items": {"type": "string"}, "type": ["array", "null"]}, + "model_urls": {"items": {"type": "string"}, "type": ["array", "null"]}, + }, + "type": "object", + } + + def __init__(self, model_urls=None, event_urls=None, artifact_urls=None, **kwargs): + super(Urls, self).__init__(**kwargs) + self.model_urls = model_urls + self.event_urls = event_urls + self.artifact_urls = artifact_urls + + @schema_property("model_urls") + def model_urls(self): + return self._property_model_urls + + @model_urls.setter + def model_urls(self, value): + if value is None: + self._property_model_urls = None + return + + self.assert_isinstance(value, "model_urls", (list, tuple)) + + self.assert_isinstance(value, "model_urls", six.string_types, is_array=True) + self._property_model_urls = value + + @schema_property("event_urls") + def event_urls(self): + return self._property_event_urls + + @event_urls.setter + def event_urls(self, value): + if value is None: + self._property_event_urls = None + return + + self.assert_isinstance(value, "event_urls", (list, tuple)) + + self.assert_isinstance(value, "event_urls", six.string_types, is_array=True) + self._property_event_urls = value + + @schema_property("artifact_urls") + def artifact_urls(self): + return self._property_artifact_urls + + @artifact_urls.setter + def artifact_urls(self, value): + if value is None: + self._property_artifact_urls = None + return + + self.assert_isinstance(value, "artifact_urls", (list, tuple)) + + self.assert_isinstance(value, "artifact_urls", six.string_types, is_array=True) + self._property_artifact_urls = value + + +class CreateRequest(Request): + """ + Create a new project + + :param name: Project name Unique within the company. + :type name: str + :param description: Project description. + :type description: str + :param tags: User-defined tags + :type tags: Sequence[str] + :param system_tags: System tags. This field is reserved for system use, please + don't use it. + :type system_tags: Sequence[str] + :param default_output_destination: The default output destination URL for new + tasks under this project + :type default_output_destination: str + """ + + _service = "projects" + _action = "create" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "default_output_destination": { + "description": "The default output destination URL for new tasks under this project", + "type": "string", + }, + "description": {"description": "Project description.", "type": "string"}, + "name": { + "description": "Project name Unique within the company.", + "type": "string", + }, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["name"], + "type": "object", + } + + def __init__( + self, + name, + description=None, + tags=None, + system_tags=None, + default_output_destination=None, + **kwargs + ): + super(CreateRequest, self).__init__(**kwargs) + self.name = name + self.description = description + self.tags = tags + self.system_tags = system_tags + self.default_output_destination = default_output_destination + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("description") + def description(self): + return self._property_description + + @description.setter + def description(self, value): + if value is None: + self._property_description = None + return + + self.assert_isinstance(value, "description", six.string_types) + self._property_description = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("default_output_destination") + def default_output_destination(self): + return self._property_default_output_destination + + @default_output_destination.setter + def default_output_destination(self, value): + if value is None: + self._property_default_output_destination = None + return + + self.assert_isinstance(value, "default_output_destination", six.string_types) + self._property_default_output_destination = value + + +class CreateResponse(Response): + """ + Response of projects.create endpoint. + + :param id: Project id + :type id: str + """ + + _service = "projects" + _action = "create" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": {"id": {"description": "Project id", "type": ["string", "null"]}}, + "type": "object", + } + + def __init__(self, id=None, **kwargs): + super(CreateResponse, self).__init__(**kwargs) + self.id = id + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + +class DeleteRequest(Request): + """ + Deletes a project + + :param project: Project ID + :type project: str + :param force: If not true, fails if project has tasks. If true, and project has + tasks, they will be unassigned + :type force: bool + :param delete_contents: If set to 'true' then the project tasks and models will + be deleted. Otherwise their project property will be unassigned. Default value + is 'false' + :type delete_contents: bool + """ + + _service = "projects" + _action = "delete" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "delete_contents": { + "description": "If set to 'true' then the project tasks, models and dataviews will be deleted. Otherwise their project property will be unassigned. Default value is 'false'", + "type": "boolean", + }, + "force": { + "default": False, + "description": "If not true, fails if project has tasks. If true, and project has tasks, they will be " + "unassigned", + "type": "boolean", + }, + "project": {"description": "Project ID", "type": "string"}, + }, + "required": ["project"], + "type": "object", + } + + def __init__(self, project, force=False, delete_contents=None, **kwargs): + super(DeleteRequest, self).__init__(**kwargs) + self.project = project + self.force = force + self.delete_contents = delete_contents + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("delete_contents") + def delete_contents(self): + return self._property_delete_contents + + @delete_contents.setter + def delete_contents(self, value): + if value is None: + self._property_delete_contents = None + return + + self.assert_isinstance(value, "delete_contents", (bool,)) + self._property_delete_contents = value + + +class DeleteResponse(Response): + """ + Response of projects.delete endpoint. + + :param deleted: Number of projects deleted (0 or 1) + :type deleted: int + :param disassociated_tasks: Number of tasks disassociated from the deleted + project + :type disassociated_tasks: int + :param urls: The urls of the files that were uploaded by the project tasks and + models. Returned if the 'delete_contents' was set to 'true' + :type urls: Urls + :param deleted_models: Number of models deleted + :type deleted_models: int + :param deleted_tasks: Number of tasks deleted + :type deleted_tasks: int + """ + + _service = "projects" + _action = "delete" + _version = "2.20" + + _schema = { + "definitions": { + "urls": { + "properties": { + "artifact_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "event_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "model_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "deleted": { + "description": "Number of projects deleted (0 or 1)", + "type": ["integer", "null"], + }, + "deleted_models": { + "description": "Number of models deleted", + "type": ["integer", "null"], + }, + "deleted_tasks": { + "description": "Number of tasks deleted", + "type": ["integer", "null"], + }, + "disassociated_tasks": { + "description": "Number of tasks disassociated from the deleted project", + "type": ["integer", "null"], + }, + "urls": { + "description": "The urls of the files that were uploaded by the project tasks and models. Returned if the 'delete_contents' was set to 'true'", + "oneOf": [{"$ref": "#/definitions/urls"}, {"type": "null"}], + }, + }, + "type": "object", + } + + def __init__( + self, + deleted=None, + disassociated_tasks=None, + urls=None, + deleted_models=None, + deleted_tasks=None, + **kwargs + ): + super(DeleteResponse, self).__init__(**kwargs) + self.deleted = deleted + self.disassociated_tasks = disassociated_tasks + self.urls = urls + self.deleted_models = deleted_models + self.deleted_tasks = deleted_tasks + + @schema_property("deleted") + def deleted(self): + return self._property_deleted + + @deleted.setter + def deleted(self, value): + if value is None: + self._property_deleted = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "deleted", six.integer_types) + self._property_deleted = value + + @schema_property("disassociated_tasks") + def disassociated_tasks(self): + return self._property_disassociated_tasks + + @disassociated_tasks.setter + def disassociated_tasks(self, value): + if value is None: + self._property_disassociated_tasks = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "disassociated_tasks", six.integer_types) + self._property_disassociated_tasks = value + + @schema_property("urls") + def urls(self): + return self._property_urls + + @urls.setter + def urls(self, value): + if value is None: + self._property_urls = None + return + if isinstance(value, dict): + value = Urls.from_dict(value) + else: + self.assert_isinstance(value, "urls", Urls) + self._property_urls = value + + @schema_property("deleted_models") + def deleted_models(self): + return self._property_deleted_models + + @deleted_models.setter + def deleted_models(self, value): + if value is None: + self._property_deleted_models = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "deleted_models", six.integer_types) + self._property_deleted_models = value + + @schema_property("deleted_tasks") + def deleted_tasks(self): + return self._property_deleted_tasks + + @deleted_tasks.setter + def deleted_tasks(self, value): + if value is None: + self._property_deleted_tasks = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "deleted_tasks", six.integer_types) + self._property_deleted_tasks = value + + +class GetAllRequest(Request): + """ + Get all the company's projects and all public projects + + :param id: List of IDs to filter by + :type id: Sequence[str] + :param name: Get only projects whose name matches this pattern (python regular + expression syntax) + :type name: str + :param basename: Project base name + :type basename: str + :param description: Get only projects whose description matches this pattern + (python regular expression syntax) + :type description: str + :param tags: User-defined tags list used to filter results. Prepend '-' to tag + name to indicate exclusion + :type tags: Sequence[str] + :param system_tags: System tags list used to filter results. Prepend '-' to + system tag name to indicate exclusion + :type system_tags: Sequence[str] + :param order_by: List of field names to order by. When search_text is used, + '@text_score' can be used as a field representing the text score of returned + documents. Use '-' prefix to specify descending order. Optional, recommended + when using page + :type order_by: Sequence[str] + :param page: Page number, returns a specific page out of the resulting list of + projects + :type page: int + :param page_size: Page size, specifies the number of results returned in each + page (last page may contain fewer results) + :type page_size: int + :param search_text: Free text search query + :type search_text: str + :param only_fields: List of document's field names (nesting is supported using + '.', e.g. execution.model_labels). If provided, this list defines the query's + projection (only these fields will be returned for each result entry) + :type only_fields: Sequence[str] + :param _all_: Multi-field pattern condition (all fields match pattern) + :type _all_: MultiFieldPatternData + :param _any_: Multi-field pattern condition (any field matches pattern) + :type _any_: MultiFieldPatternData + :param shallow_search: If set to 'true' then the search with the specified + criteria is performed among top level projects only (or if parents specified, + among the direct children of the these parents). Otherwise the search is + performed among all the company projects (or among all of the descendants of + the specified parents). + :type shallow_search: bool + :param search_hidden: If set to 'true' then hidden projects are included in the + search results + :type search_hidden: bool + :param scroll_id: Scroll ID returned from the previos calls to get_all_ex + :type scroll_id: str + :param refresh_scroll: If set then all the data received with this scroll will + be requeried + :type refresh_scroll: bool + :param size: The number of projects to retrieve + :type size: int + """ + + _service = "projects" + _action = "get_all" + _version = "2.20" + _schema = { + "definitions": { + "multi_field_pattern_data": { + "properties": { + "fields": { + "description": "List of field names", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "pattern": { + "description": "Pattern string (regex)", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "_all_": { + "description": "Multi-field pattern condition (all fields match pattern)", + "oneOf": [ + {"$ref": "#/definitions/multi_field_pattern_data"}, + {"type": "null"}, + ], + }, + "_any_": { + "description": "Multi-field pattern condition (any field matches pattern)", + "oneOf": [ + {"$ref": "#/definitions/multi_field_pattern_data"}, + {"type": "null"}, + ], + }, + "basename": { + "description": "Project base name", + "type": ["string", "null"], + }, + "description": { + "description": "Get only projects whose description matches this pattern (python regular expression syntax)", + "type": ["string", "null"], + }, + "id": { + "description": "List of IDs to filter by", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "name": { + "description": "Get only projects whose name matches this pattern (python regular expression syntax)", + "type": ["string", "null"], + }, + "only_fields": { + "description": "List of document's field names (nesting is supported using '.', e.g. execution.model_labels). If provided, this list defines the query's projection (only these fields will be returned for each result entry)", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "order_by": { + "description": "List of field names to order by. When search_text is used, '@text_score' can be used as a field representing the text score of returned documents. Use '-' prefix to specify descending order. Optional, recommended when using page", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "page": { + "description": "Page number, returns a specific page out of the resulting list of dataviews", + "minimum": 0, + "type": ["integer", "null"], + }, + "page_size": { + "description": "Page size, specifies the number of results returned in each page (last page may contain fewer results)", + "minimum": 1, + "type": ["integer", "null"], + }, + "refresh_scroll": { + "description": "If set then all the data received with this scroll will be requeried", + "type": ["boolean", "null"], + }, + "scroll_id": { + "description": "Scroll ID returned from the previos calls to get_all_ex", + "type": ["string", "null"], + }, + "search_hidden": { + "default": False, + "description": "If set to 'true' then hidden projects are included in the search results", + "type": ["boolean", "null"], + }, + "search_text": { + "description": "Free text search query", + "type": ["string", "null"], + }, + "shallow_search": { + "default": False, + "description": "If set to 'true' then the search with the specified criteria is performed among top level projects only (or if parents specified, among the direct children of the these parents). Otherwise the search is performed among all the company projects (or among all of the descendants of the specified parents).", + "type": ["boolean", "null"], + }, + "size": { + "description": "The number of projects to retrieve", + "minimum": 1, + "type": ["integer", "null"], + }, + "system_tags": { + "description": "System tags list used to filter results. Prepend '-' to system tag name to indicate exclusion", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags list used to filter results. Prepend '-' to tag name to indicate exclusion", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + id=None, + name=None, + basename=None, + description=None, + tags=None, + system_tags=None, + order_by=None, + page=None, + page_size=None, + search_text=None, + only_fields=None, + _all_=None, + _any_=None, + shallow_search=False, + search_hidden=False, + scroll_id=None, + refresh_scroll=None, + size=None, + **kwargs + ): + super(GetAllRequest, self).__init__(**kwargs) + self.id = id + self.name = name + self.basename = basename + self.description = description + self.tags = tags + self.system_tags = system_tags + self.order_by = order_by + self.page = page + self.page_size = page_size + self.search_text = search_text + self.only_fields = only_fields + self._all_ = _all_ + self._any_ = _any_ + self.shallow_search = shallow_search + self.search_hidden = search_hidden + self.scroll_id = scroll_id + self.refresh_scroll = refresh_scroll + self.size = size + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", (list, tuple)) + + self.assert_isinstance(value, "id", six.string_types, is_array=True) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("basename") + def basename(self): + return self._property_basename + + @basename.setter + def basename(self, value): + if value is None: + self._property_basename = None + return + + self.assert_isinstance(value, "basename", six.string_types) + self._property_basename = value + + @schema_property("description") + def description(self): + return self._property_description + + @description.setter + def description(self, value): + if value is None: + self._property_description = None + return + + self.assert_isinstance(value, "description", six.string_types) + self._property_description = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("order_by") + def order_by(self): + return self._property_order_by + + @order_by.setter + def order_by(self, value): + if value is None: + self._property_order_by = None + return + + self.assert_isinstance(value, "order_by", (list, tuple)) + + self.assert_isinstance(value, "order_by", six.string_types, is_array=True) + self._property_order_by = value + + @schema_property("page") + def page(self): + return self._property_page + + @page.setter + def page(self, value): + if value is None: + self._property_page = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page", six.integer_types) + self._property_page = value + + @schema_property("page_size") + def page_size(self): + return self._property_page_size + + @page_size.setter + def page_size(self, value): + if value is None: + self._property_page_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page_size", six.integer_types) + self._property_page_size = value + + @schema_property("search_text") + def search_text(self): + return self._property_search_text + + @search_text.setter + def search_text(self, value): + if value is None: + self._property_search_text = None + return + + self.assert_isinstance(value, "search_text", six.string_types) + self._property_search_text = value + + @schema_property("only_fields") + def only_fields(self): + return self._property_only_fields + + @only_fields.setter + def only_fields(self, value): + if value is None: + self._property_only_fields = None + return + + self.assert_isinstance(value, "only_fields", (list, tuple)) + + self.assert_isinstance(value, "only_fields", six.string_types, is_array=True) + self._property_only_fields = value + + @schema_property("_all_") + def _all_(self): + return self._property__all_ + + @_all_.setter + def _all_(self, value): + if value is None: + self._property__all_ = None + return + if isinstance(value, dict): + value = MultiFieldPatternData.from_dict(value) + else: + self.assert_isinstance(value, "_all_", MultiFieldPatternData) + self._property__all_ = value + + @schema_property("_any_") + def _any_(self): + return self._property__any_ + + @_any_.setter + def _any_(self, value): + if value is None: + self._property__any_ = None + return + if isinstance(value, dict): + value = MultiFieldPatternData.from_dict(value) + else: + self.assert_isinstance(value, "_any_", MultiFieldPatternData) + self._property__any_ = value + + @schema_property("shallow_search") + def shallow_search(self): + return self._property_shallow_search + + @shallow_search.setter + def shallow_search(self, value): + if value is None: + self._property_shallow_search = None + return + + self.assert_isinstance(value, "shallow_search", (bool,)) + self._property_shallow_search = value + + @schema_property("search_hidden") + def search_hidden(self): + return self._property_search_hidden + + @search_hidden.setter + def search_hidden(self, value): + if value is None: + self._property_search_hidden = None + return + + self.assert_isinstance(value, "search_hidden", (bool,)) + self._property_search_hidden = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("refresh_scroll") + def refresh_scroll(self): + return self._property_refresh_scroll + + @refresh_scroll.setter + def refresh_scroll(self, value): + if value is None: + self._property_refresh_scroll = None + return + + self.assert_isinstance(value, "refresh_scroll", (bool,)) + self._property_refresh_scroll = value + + @schema_property("size") + def size(self): + return self._property_size + + @size.setter + def size(self, value): + if value is None: + self._property_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "size", six.integer_types) + self._property_size = value + + +class GetAllResponse(Response): + """ + Response of projects.get_all endpoint. + + :param projects: Projects list + :type projects: Sequence[ProjectsGetAllResponseSingle] + :param scroll_id: Scroll ID that can be used with the next calls to get_all_ex + to retrieve more data + :type scroll_id: str + """ + + _service = "projects" + _action = "get_all" + _version = "2.20" + + _schema = { + "definitions": { + "projects_get_all_response_single": { + "properties": { + "basename": { + "description": "Project base name", + "type": ["string", "null"], + }, + "company": { + "description": "Company id", + "type": ["string", "null"], + }, + "created": { + "description": "Creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "dataset_stats": { + "description": "Project dataset statistics", + "properties": { + "file_count": { + "description": "The number of files stored in the dataset", + "type": "integer", + }, + "total_size": { + "description": "The total dataset size in bytes", + "type": "integer", + }, + }, + "type": ["object", "null"], + }, + "default_output_destination": { + "description": "The default output destination URL for new tasks under this project", + "type": ["string", "null"], + }, + "description": { + "description": "Project description", + "type": ["string", "null"], + }, + "id": {"description": "Project id", "type": ["string", "null"]}, + "last_update": { + "description": "Last update time", + "format": "date-time", + "type": ["string", "null"], + }, + "name": { + "description": "Project name", + "type": ["string", "null"], + }, + "own_models": { + "description": "The amount of models under this project (without children projects). " + "Returned if 'check_own_contents' flag is set in the request", + "type": ["integer", "null"], + }, + "own_tasks": { + "description": "The amount of tasks under this project (without children projects). " + "Returned if 'check_own_contents' flag is set in the request", + "type": ["integer", "null"], + }, + "stats": { + "description": "Additional project stats", + "oneOf": [{"$ref": "#/definitions/stats"}, {"type": "null"}], + }, + "sub_projects": { + "description": "The list of sub projects", + "items": { + "properties": { + "id": { + "description": "Subproject ID", + "type": "string", + }, + "name": { + "description": "Subproject name", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "user": { + "description": "Associated user id", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "stats": { + "properties": { + "active": { + "description": "Stats for active tasks", + "oneOf": [ + {"$ref": "#/definitions/stats_status_count"}, + {"type": "null"}, + ], + }, + "archived": { + "description": "Stats for archived tasks", + "oneOf": [ + {"$ref": "#/definitions/stats_status_count"}, + {"type": "null"}, + ], + }, + }, + "type": "object", + }, + "stats_status_count": { + "properties": { + "completed_tasks_24h": { + "description": "Number of tasks completed in the last 24 hours", + "type": ["integer", "null"], + }, + "last_task_run": { + "description": "The most recent started time of a task", + "type": ["integer", "null"], + }, + "status_count": { + "description": "Status counts", + "properties": { + "closed": { + "description": "Number of 'closed' tasks in project", + "type": "integer", + }, + "completed": { + "description": "Number of 'completed' tasks in project", + "type": "integer", + }, + "created": { + "description": "Number of 'created' tasks in project", + "type": "integer", + }, + "failed": { + "description": "Number of 'failed' tasks in project", + "type": "integer", + }, + "in_progress": { + "description": "Number of 'in_progress' tasks in project", + "type": "integer", + }, + "published": { + "description": "Number of 'published' tasks in project", + "type": "integer", + }, + "queued": { + "description": "Number of 'queued' tasks in project", + "type": "integer", + }, + "stopped": { + "description": "Number of 'stopped' tasks in project", + "type": "integer", + }, + "unknown": { + "description": "Number of 'unknown' tasks in project", + "type": "integer", + }, + }, + "type": ["object", "null"], + }, + "total_runtime": { + "description": "Total run time of all tasks in project (in seconds)", + "type": ["integer", "null"], + }, + "total_tasks": { + "description": "Number of tasks", + "type": ["integer", "null"], + }, + }, + "type": "object", + }, + }, + "properties": { + "projects": { + "description": "Projects list", + "items": {"$ref": "#/definitions/projects_get_all_response_single"}, + "type": ["array", "null"], + }, + "scroll_id": { + "description": "Scroll ID that can be used with the next calls to get_all_ex to retrieve more data", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, projects=None, scroll_id=None, **kwargs): + super(GetAllResponse, self).__init__(**kwargs) + self.projects = projects + self.scroll_id = scroll_id + + @schema_property("projects") + def projects(self): + return self._property_projects + + @projects.setter + def projects(self, value): + if value is None: + self._property_projects = None + return + + self.assert_isinstance(value, "projects", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + ProjectsGetAllResponseSingle.from_dict(v) if isinstance(v, dict) else v + for v in value + ] + else: + self.assert_isinstance( + value, "projects", ProjectsGetAllResponseSingle, is_array=True + ) + self._property_projects = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class GetByIdRequest(Request): + """ + :param project: Project id + :type project: str + """ + + _service = "projects" + _action = "get_by_id" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"project": {"description": "Project id", "type": "string"}}, + "required": ["project"], + "type": "object", + } + + def __init__(self, project, **kwargs): + super(GetByIdRequest, self).__init__(**kwargs) + self.project = project + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + +class GetByIdResponse(Response): + """ + Response of projects.get_by_id endpoint. + + :param project: Project info + :type project: Project + """ + + _service = "projects" + _action = "get_by_id" + _version = "2.20" + + _schema = { + "definitions": { + "project": { + "properties": { + "basename": { + "description": "Project base name", + "type": ["string", "null"], + }, + "company": { + "description": "Company id", + "type": ["string", "null"], + }, + "created": { + "description": "Creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "default_output_destination": { + "description": "The default output destination URL for new tasks under this project", + "type": ["string", "null"], + }, + "description": { + "description": "Project description", + "type": ["string", "null"], + }, + "id": {"description": "Project id", "type": ["string", "null"]}, + "last_update": { + "description": "Last project update time. Reflects the last time the project metadata was changed or a task in this project has changed status", + "format": "date-time", + "type": ["string", "null"], + }, + "name": { + "description": "Project name", + "type": ["string", "null"], + }, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "user": { + "description": "Associated user id", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "project": { + "description": "Project info", + "oneOf": [{"$ref": "#/definitions/project"}, {"type": "null"}], + } + }, + "type": "object", + } + + def __init__(self, project=None, **kwargs): + super(GetByIdResponse, self).__init__(**kwargs) + self.project = project + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + if isinstance(value, dict): + value = Project.from_dict(value) + else: + self.assert_isinstance(value, "project", Project) + self._property_project = value + + +class GetHyperParametersRequest(Request): + """ + Get a list of all hyper parameter sections and names used in tasks within the given project. + + :param project: Project ID + :type project: str + :param page: Page number + :type page: int + :param page_size: Page size + :type page_size: int + :param include_subprojects: If set to 'true' and the project field is set then + the result includes hyper parameters from the subproject tasks + :type include_subprojects: bool + """ + + _service = "projects" + _action = "get_hyper_parameters" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "include_subprojects": { + "default": True, + "description": "If set to 'true' and the project field is set then the result includes hyper parameters from the subproject tasks", + "type": "boolean", + }, + "page": {"default": 0, "description": "Page number", "type": "integer"}, + "page_size": { + "default": 500, + "description": "Page size", + "type": "integer", + }, + "project": {"description": "Project ID", "type": "string"}, + }, + "required": ["project"], + "type": "object", + } + + def __init__( + self, project, page=0, page_size=500, include_subprojects=True, **kwargs + ): + super(GetHyperParametersRequest, self).__init__(**kwargs) + self.project = project + self.page = page + self.page_size = page_size + self.include_subprojects = include_subprojects + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("page") + def page(self): + return self._property_page + + @page.setter + def page(self, value): + if value is None: + self._property_page = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page", six.integer_types) + self._property_page = value + + @schema_property("page_size") + def page_size(self): + return self._property_page_size + + @page_size.setter + def page_size(self, value): + if value is None: + self._property_page_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page_size", six.integer_types) + self._property_page_size = value + + @schema_property("include_subprojects") + def include_subprojects(self): + return self._property_include_subprojects + + @include_subprojects.setter + def include_subprojects(self, value): + if value is None: + self._property_include_subprojects = None + return + + self.assert_isinstance(value, "include_subprojects", (bool,)) + self._property_include_subprojects = value + + +class GetHyperParametersResponse(Response): + """ + Response of projects.get_hyper_parameters endpoint. + + :param parameters: A list of parameter sections and names + :type parameters: Sequence[dict] + :param remaining: Remaining results + :type remaining: int + :param total: Total number of results + :type total: int + """ + + _service = "projects" + _action = "get_hyper_parameters" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "parameters": { + "description": "A list of parameter sections and names", + "items": {"type": "object"}, + "type": ["array", "null"], + }, + "remaining": { + "description": "Remaining results", + "type": ["integer", "null"], + }, + "total": { + "description": "Total number of results", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, parameters=None, remaining=None, total=None, **kwargs): + super(GetHyperParametersResponse, self).__init__(**kwargs) + self.parameters = parameters + self.remaining = remaining + self.total = total + + @schema_property("parameters") + def parameters(self): + return self._property_parameters + + @parameters.setter + def parameters(self, value): + if value is None: + self._property_parameters = None + return + + self.assert_isinstance(value, "parameters", (list, tuple)) + + self.assert_isinstance(value, "parameters", (dict,), is_array=True) + self._property_parameters = value + + @schema_property("remaining") + def remaining(self): + return self._property_remaining + + @remaining.setter + def remaining(self, value): + if value is None: + self._property_remaining = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "remaining", six.integer_types) + self._property_remaining = value + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "total", six.integer_types) + self._property_total = value + + +class GetHyperparamValuesRequest(Request): + """ + Get a list of distinct values for the chosen hyperparameter + + :param projects: Project IDs + :type projects: Sequence[str] + :param section: Hyperparameter section name + :type section: str + :param name: Hyperparameter name + :type name: str + :param allow_public: If set to 'true' then collect values from both company and + public tasks otherwise company tasks only. The default is 'true' + :type allow_public: bool + :param include_subprojects: If set to 'true' and the project field is set then + the result includes hyper parameters values from the subproject tasks + :type include_subprojects: bool + """ + + _service = "projects" + _action = "get_hyperparam_values" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "allow_public": { + "description": "If set to 'true' then collect values from both company and public tasks otherwise company tasks only. The default is 'true'", + "type": "boolean", + }, + "include_subprojects": { + "default": True, + "description": "If set to 'true' and the project field is set then the result includes hyper parameters values from the subproject tasks", + "type": "boolean", + }, + "name": {"description": "Hyperparameter name", "type": "string"}, + "projects": { + "description": "Project IDs", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "section": {"description": "Hyperparameter section name", "type": "string"}, + }, + "required": ["section", "name"], + "type": "object", + } + + def __init__( + self, + section, + name, + projects=None, + allow_public=None, + include_subprojects=True, + **kwargs + ): + super(GetHyperparamValuesRequest, self).__init__(**kwargs) + self.projects = projects + self.section = section + self.name = name + self.allow_public = allow_public + self.include_subprojects = include_subprojects + + @schema_property("projects") + def projects(self): + return self._property_projects + + @projects.setter + def projects(self, value): + if value is None: + self._property_projects = None + return + + self.assert_isinstance(value, "projects", (list, tuple)) + + self.assert_isinstance(value, "projects", six.string_types, is_array=True) + self._property_projects = value + + @schema_property("section") + def section(self): + return self._property_section + + @section.setter + def section(self, value): + if value is None: + self._property_section = None + return + + self.assert_isinstance(value, "section", six.string_types) + self._property_section = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("allow_public") + def allow_public(self): + return self._property_allow_public + + @allow_public.setter + def allow_public(self, value): + if value is None: + self._property_allow_public = None + return + + self.assert_isinstance(value, "allow_public", (bool,)) + self._property_allow_public = value + + @schema_property("include_subprojects") + def include_subprojects(self): + return self._property_include_subprojects + + @include_subprojects.setter + def include_subprojects(self, value): + if value is None: + self._property_include_subprojects = None + return + + self.assert_isinstance(value, "include_subprojects", (bool,)) + self._property_include_subprojects = value + + +class GetHyperparamValuesResponse(Response): + """ + Response of projects.get_hyperparam_values endpoint. + + :param total: Total number of distinct parameter values + :type total: int + :param values: The list of the unique values for the parameter + :type values: Sequence[str] + """ + + _service = "projects" + _action = "get_hyperparam_values" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "total": { + "description": "Total number of distinct parameter values", + "type": ["integer", "null"], + }, + "values": { + "description": "The list of the unique values for the parameter", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, total=None, values=None, **kwargs): + super(GetHyperparamValuesResponse, self).__init__(**kwargs) + self.total = total + self.values = values + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "total", six.integer_types) + self._property_total = value + + @schema_property("values") + def values(self): + return self._property_values + + @values.setter + def values(self, value): + if value is None: + self._property_values = None + return + + self.assert_isinstance(value, "values", (list, tuple)) + + self.assert_isinstance(value, "values", six.string_types, is_array=True) + self._property_values = value + + +class GetModelMetadataKeysRequest(Request): + """ + Get a list of all metadata keys used in models within the given project. + + :param project: Project ID + :type project: str + :param include_subprojects: If set to 'true' and the project field is set then + the result includes metadate keys from the subproject models + :type include_subprojects: bool + :param page: Page number + :type page: int + :param page_size: Page size + :type page_size: int + """ + + _service = "projects" + _action = "get_model_metadata_keys" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "include_subprojects": { + "default": True, + "description": "If set to 'true' and " + "the project field is " + "set then the result " + "includes metadate keys " + "from the subproject " + "models", + "type": "boolean", + }, + "page": {"default": 0, "description": "Page number", "type": "integer"}, + "page_size": { + "default": 500, + "description": "Page size", + "type": "integer", + }, + "project": {"description": "Project ID", "type": "string"}, + }, + "required": ["project"], + "type": "object", + } + + def __init__( + self, project, include_subprojects=True, page=0, page_size=500, **kwargs + ): + super(GetModelMetadataKeysRequest, self).__init__(**kwargs) + self.project = project + self.include_subprojects = include_subprojects + self.page = page + self.page_size = page_size + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("include_subprojects") + def include_subprojects(self): + return self._property_include_subprojects + + @include_subprojects.setter + def include_subprojects(self, value): + if value is None: + self._property_include_subprojects = None + return + + self.assert_isinstance(value, "include_subprojects", (bool,)) + self._property_include_subprojects = value + + @schema_property("page") + def page(self): + return self._property_page + + @page.setter + def page(self, value): + if value is None: + self._property_page = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page", six.integer_types) + self._property_page = value + + @schema_property("page_size") + def page_size(self): + return self._property_page_size + + @page_size.setter + def page_size(self, value): + if value is None: + self._property_page_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page_size", six.integer_types) + self._property_page_size = value + + +class GetModelMetadataKeysResponse(Response): + """ + Response of projects.get_model_metadata_keys endpoint. + + :param keys: A list of model keys + :type keys: Sequence[str] + :param remaining: Remaining results + :type remaining: int + :param total: Total number of results + :type total: int + """ + + _service = "projects" + _action = "get_model_metadata_keys" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "keys": { + "description": "A list of model keys", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "remaining": { + "description": "Remaining results", + "type": ["integer", "null"], + }, + "total": { + "description": "Total number of results", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, keys=None, remaining=None, total=None, **kwargs): + super(GetModelMetadataKeysResponse, self).__init__(**kwargs) + self.keys = keys + self.remaining = remaining + self.total = total + + @schema_property("keys") + def keys(self): + return self._property_keys + + @keys.setter + def keys(self, value): + if value is None: + self._property_keys = None + return + + self.assert_isinstance(value, "keys", (list, tuple)) + + self.assert_isinstance(value, "keys", six.string_types, is_array=True) + self._property_keys = value + + @schema_property("remaining") + def remaining(self): + return self._property_remaining + + @remaining.setter + def remaining(self, value): + if value is None: + self._property_remaining = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "remaining", six.integer_types) + self._property_remaining = value + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "total", six.integer_types) + self._property_total = value + + +class GetModelMetadataValuesRequest(Request): + """ + Get a list of distinct values for the chosen model metadata key + + :param projects: Project IDs + :type projects: Sequence[str] + :param key: Metadata key + :type key: str + :param allow_public: If set to 'true' then collect values from both company and + public models otherwise company modeels only. The default is 'true' + :type allow_public: bool + :param include_subprojects: If set to 'true' and the project field is set then + the result includes metadata values from the subproject models + :type include_subprojects: bool + """ + + _service = "projects" + _action = "get_model_metadata_values" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "allow_public": { + "description": "If set to 'true' then collect values from both company and " + "public models otherwise company modeels only. The default is 'true'", + "type": "boolean", + }, + "include_subprojects": { + "default": True, + "description": "If set to 'true' and " + "the project field is " + "set then the result " + "includes metadata " + "values from the " + "subproject models", + "type": "boolean", + }, + "key": {"description": "Metadata key", "type": "string"}, + "projects": { + "description": "Project IDs", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "required": ["key"], + "type": "object", + } + + def __init__( + self, key, projects=None, allow_public=None, include_subprojects=True, **kwargs + ): + super(GetModelMetadataValuesRequest, self).__init__(**kwargs) + self.projects = projects + self.key = key + self.allow_public = allow_public + self.include_subprojects = include_subprojects + + @schema_property("projects") + def projects(self): + return self._property_projects + + @projects.setter + def projects(self, value): + if value is None: + self._property_projects = None + return + + self.assert_isinstance(value, "projects", (list, tuple)) + + self.assert_isinstance(value, "projects", six.string_types, is_array=True) + self._property_projects = value + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + + self.assert_isinstance(value, "key", six.string_types) + self._property_key = value + + @schema_property("allow_public") + def allow_public(self): + return self._property_allow_public + + @allow_public.setter + def allow_public(self, value): + if value is None: + self._property_allow_public = None + return + + self.assert_isinstance(value, "allow_public", (bool,)) + self._property_allow_public = value + + @schema_property("include_subprojects") + def include_subprojects(self): + return self._property_include_subprojects + + @include_subprojects.setter + def include_subprojects(self, value): + if value is None: + self._property_include_subprojects = None + return + + self.assert_isinstance(value, "include_subprojects", (bool,)) + self._property_include_subprojects = value + + +class GetModelMetadataValuesResponse(Response): + """ + Response of projects.get_model_metadata_values endpoint. + + :param total: Total number of distinct values + :type total: int + :param values: The list of the unique values + :type values: Sequence[str] + """ + + _service = "projects" + _action = "get_model_metadata_values" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "total": { + "description": "Total number of distinct values", + "type": ["integer", "null"], + }, + "values": { + "description": "The list of the unique values", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, total=None, values=None, **kwargs): + super(GetModelMetadataValuesResponse, self).__init__(**kwargs) + self.total = total + self.values = values + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "total", six.integer_types) + self._property_total = value + + @schema_property("values") + def values(self): + return self._property_values + + @values.setter + def values(self, value): + if value is None: + self._property_values = None + return + + self.assert_isinstance(value, "values", (list, tuple)) + + self.assert_isinstance(value, "values", six.string_types, is_array=True) + self._property_values = value + + +class GetModelTagsRequest(Request): + """ + Get user and system tags used for the models under the specified projects + + :param include_system: If set to 'true' then the list of the system tags is + also returned. The default value is 'false' + :type include_system: bool + :param projects: The list of projects under which the tags are searched. If not + passed or empty then all the projects are searched + :type projects: Sequence[str] + :param filter: Filter on entities to collect tags from + :type filter: dict + """ + + _service = "projects" + _action = "get_model_tags" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "filter": { + "description": "Filter on entities to collect tags from", + "properties": { + "system_tags": { + "description": "The list of system tag values to filter by. Use 'null' value to specify empty system tags. Use '__Snot' value to specify that the following value should be excluded", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "The list of tag values to filter by. Use 'null' value to specify empty tags. Use '__Snot' value to specify that the following value should be excluded", + "items": {"type": "string"}, + "type": "array", + }, + }, + "type": ["object", "null"], + }, + "include_system": { + "default": False, + "description": "If set to 'true' then the list of the system tags is also returned. The default value is 'false'", + "type": ["boolean", "null"], + }, + "projects": { + "description": "The list of projects under which the tags are searched. If not passed or empty then all the projects are searched", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, include_system=False, projects=None, filter=None, **kwargs): + super(GetModelTagsRequest, self).__init__(**kwargs) + self.include_system = include_system + self.projects = projects + self.filter = filter + + @schema_property("include_system") + def include_system(self): + return self._property_include_system + + @include_system.setter + def include_system(self, value): + if value is None: + self._property_include_system = None + return + + self.assert_isinstance(value, "include_system", (bool,)) + self._property_include_system = value + + @schema_property("projects") + def projects(self): + return self._property_projects + + @projects.setter + def projects(self, value): + if value is None: + self._property_projects = None + return + + self.assert_isinstance(value, "projects", (list, tuple)) + + self.assert_isinstance(value, "projects", six.string_types, is_array=True) + self._property_projects = value + + @schema_property("filter") + def filter(self): + return self._property_filter + + @filter.setter + def filter(self, value): + if value is None: + self._property_filter = None + return + + self.assert_isinstance(value, "filter", (dict,)) + self._property_filter = value + + +class GetModelTagsResponse(Response): + """ + Response of projects.get_model_tags endpoint. + + :param tags: The list of unique tag values + :type tags: Sequence[str] + :param system_tags: The list of unique system tag values. Returned only if + 'include_system' is set to 'true' in the request + :type system_tags: Sequence[str] + """ + + _service = "projects" + _action = "get_model_tags" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "system_tags": { + "description": "The list of unique system tag values. Returned only if 'include_system' is set to 'true' in the request", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "The list of unique tag values", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, tags=None, system_tags=None, **kwargs): + super(GetModelTagsResponse, self).__init__(**kwargs) + self.tags = tags + self.system_tags = system_tags + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + +class GetProjectTagsRequest(Request): + """ + Get user and system tags used for the specified projects and their children + + :param include_system: If set to 'true' then the list of the system tags is + also returned. The default value is 'false' + :type include_system: bool + :param projects: The list of projects under which the tags are searched. If not + passed or empty then all the projects are searched + :type projects: Sequence[str] + :param filter: Filter on entities to collect tags from + :type filter: dict + """ + + _service = "projects" + _action = "get_project_tags" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "filter": { + "description": "Filter on entities to collect tags from", + "properties": { + "system_tags": { + "description": "The list of system tag values to filter by. Use 'null' value to specify empty " + "system tags. Use '__$not' value to specify that the following value should be excluded", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "The list of tag values to filter by. Use 'null' value to specify empty tags. " + "Use '__$not' value to specify that the following value should be excluded", + "items": {"type": "string"}, + "type": "array", + }, + }, + "type": ["object", "null"], + }, + "include_system": { + "default": False, + "description": "If set to 'true' then the list of the system tags is also returned. The default value is 'false'", + "type": ["boolean", "null"], + }, + "projects": { + "description": "The list of projects under which the tags are searched. If not passed or empty then all the projects are searched", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, include_system=False, projects=None, filter=None, **kwargs): + super(GetProjectTagsRequest, self).__init__(**kwargs) + self.include_system = include_system + self.projects = projects + self.filter = filter + + @schema_property("include_system") + def include_system(self): + return self._property_include_system + + @include_system.setter + def include_system(self, value): + if value is None: + self._property_include_system = None + return + + self.assert_isinstance(value, "include_system", (bool,)) + self._property_include_system = value + + @schema_property("projects") + def projects(self): + return self._property_projects + + @projects.setter + def projects(self, value): + if value is None: + self._property_projects = None + return + + self.assert_isinstance(value, "projects", (list, tuple)) + + self.assert_isinstance(value, "projects", six.string_types, is_array=True) + self._property_projects = value + + @schema_property("filter") + def filter(self): + return self._property_filter + + @filter.setter + def filter(self, value): + if value is None: + self._property_filter = None + return + + self.assert_isinstance(value, "filter", (dict,)) + self._property_filter = value + + +class GetProjectTagsResponse(Response): + """ + Response of projects.get_project_tags endpoint. + + :param tags: The list of unique tag values + :type tags: Sequence[str] + :param system_tags: The list of unique system tag values. Returned only if + 'include_system' is set to 'true' in the request + :type system_tags: Sequence[str] + """ + + _service = "projects" + _action = "get_project_tags" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "system_tags": { + "description": "The list of unique system tag values. Returned only if 'include_system' is set to 'true' in the request", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "The list of unique tag values", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, tags=None, system_tags=None, **kwargs): + super(GetProjectTagsResponse, self).__init__(**kwargs) + self.tags = tags + self.system_tags = system_tags + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + +class GetTaskParentsRequest(Request): + """ + Get unique parent tasks for the tasks in the specified projects + + :param projects: The list of projects which task parents are retieved. If not + passed or empty then all the projects are searched + :type projects: Sequence[str] + :param tasks_state: Return parents for tasks in the specified state. If Null is + provided, parents for all task states will be returned. + :type tasks_state: str + :param include_subprojects: If set to 'true' and the projects field is not + empty then the result includes tasks parents from the subproject tasks + :type include_subprojects: bool + """ + + _service = "projects" + _action = "get_task_parents" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "include_subprojects": { + "default": True, + "description": "If set to 'true' and the projects field is not empty then the result includes tasks " + "parents from the subproject tasks", + "type": ["boolean", "null"], + }, + "projects": { + "description": "The list of projects which task parents are retieved. If not passed or empty then all the " + "projects are searched", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tasks_state": { + "default": "active", + "description": "Return parents for tasks in the specified state. If Null is provided, parents for all " + "task states will be returned.", + "enum": ["active", "archived"], + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, projects=None, tasks_state="active", include_subprojects=True, **kwargs + ): + super(GetTaskParentsRequest, self).__init__(**kwargs) + self.projects = projects + self.tasks_state = tasks_state + self.include_subprojects = include_subprojects + + @schema_property("projects") + def projects(self): + return self._property_projects + + @projects.setter + def projects(self, value): + if value is None: + self._property_projects = None + return + + self.assert_isinstance(value, "projects", (list, tuple)) + + self.assert_isinstance(value, "projects", six.string_types, is_array=True) + self._property_projects = value + + @schema_property("tasks_state") + def tasks_state(self): + return self._property_tasks_state + + @tasks_state.setter + def tasks_state(self, value): + if value is None: + self._property_tasks_state = None + return + + self.assert_isinstance(value, "tasks_state", six.string_types) + self._property_tasks_state = value + + @schema_property("include_subprojects") + def include_subprojects(self): + return self._property_include_subprojects + + @include_subprojects.setter + def include_subprojects(self, value): + if value is None: + self._property_include_subprojects = None + return + + self.assert_isinstance(value, "include_subprojects", (bool,)) + self._property_include_subprojects = value + + +class GetTaskParentsResponse(Response): + """ + Response of projects.get_task_parents endpoint. + + :param parents: The list of unique task parents sorted by their names + :type parents: Sequence[dict] + """ + + _service = "projects" + _action = "get_task_parents" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "parents": { + "description": "The list of unique task parents sorted by their names", + "items": { + "properties": { + "id": { + "description": "The ID of the parent task", + "type": "string", + }, + "name": { + "description": "The name of the parent task", + "type": "string", + }, + "project": { + "id": { + "description": "The ID of the parent task project", + "type": "string", + }, + "name": { + "description": "The name of the parent task project", + "type": "string", + }, + "type": "object", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, parents=None, **kwargs): + super(GetTaskParentsResponse, self).__init__(**kwargs) + self.parents = parents + + @schema_property("parents") + def parents(self): + return self._property_parents + + @parents.setter + def parents(self, value): + if value is None: + self._property_parents = None + return + + self.assert_isinstance(value, "parents", (list, tuple)) + + self.assert_isinstance(value, "parents", (dict,), is_array=True) + self._property_parents = value + + +class GetTaskTagsRequest(Request): + """ + Get user and system tags used for the tasks under the specified projects + + :param include_system: If set to 'true' then the list of the system tags is + also returned. The default value is 'false' + :type include_system: bool + :param projects: The list of projects under which the tags are searched. If not + passed or empty then all the projects are searched + :type projects: Sequence[str] + :param filter: Filter on entities to collect tags from + :type filter: dict + """ + + _service = "projects" + _action = "get_task_tags" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "filter": { + "description": "Filter on entities to collect tags from", + "properties": { + "system_tags": { + "description": "The list of system tag values to filter by. Use 'null' value to specify empty system tags. Use '__Snot' value to specify that the following value should be excluded", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "The list of tag values to filter by. Use 'null' value to specify empty tags. Use '__Snot' value to specify that the following value should be excluded", + "items": {"type": "string"}, + "type": "array", + }, + }, + "type": ["object", "null"], + }, + "include_system": { + "default": False, + "description": "If set to 'true' then the list of the system tags is also returned. The default value is 'false'", + "type": ["boolean", "null"], + }, + "projects": { + "description": "The list of projects under which the tags are searched. If not passed or empty then all the projects are searched", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, include_system=False, projects=None, filter=None, **kwargs): + super(GetTaskTagsRequest, self).__init__(**kwargs) + self.include_system = include_system + self.projects = projects + self.filter = filter + + @schema_property("include_system") + def include_system(self): + return self._property_include_system + + @include_system.setter + def include_system(self, value): + if value is None: + self._property_include_system = None + return + + self.assert_isinstance(value, "include_system", (bool,)) + self._property_include_system = value + + @schema_property("projects") + def projects(self): + return self._property_projects + + @projects.setter + def projects(self, value): + if value is None: + self._property_projects = None + return + + self.assert_isinstance(value, "projects", (list, tuple)) + + self.assert_isinstance(value, "projects", six.string_types, is_array=True) + self._property_projects = value + + @schema_property("filter") + def filter(self): + return self._property_filter + + @filter.setter + def filter(self, value): + if value is None: + self._property_filter = None + return + + self.assert_isinstance(value, "filter", (dict,)) + self._property_filter = value + + +class GetTaskTagsResponse(Response): + """ + Response of projects.get_task_tags endpoint. + + :param tags: The list of unique tag values + :type tags: Sequence[str] + :param system_tags: The list of unique system tag values. Returned only if + 'include_system' is set to 'true' in the request + :type system_tags: Sequence[str] + """ + + _service = "projects" + _action = "get_task_tags" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "system_tags": { + "description": "The list of unique system tag values. Returned only if 'include_system' is set to 'true' in the request", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "The list of unique tag values", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, tags=None, system_tags=None, **kwargs): + super(GetTaskTagsResponse, self).__init__(**kwargs) + self.tags = tags + self.system_tags = system_tags + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + +class GetUniqueMetricVariantsRequest(Request): + """ + Get all metric/variant pairs reported for tasks in a specific project. + If no project is specified, metrics/variant paris reported for all tasks will be returned. + If the project does not exist, an empty list will be returned. + + :param project: Project ID + :type project: str + :param include_subprojects: If set to 'true' and the project field is set then + the result includes metrics/variants from the subproject tasks + :type include_subprojects: bool + """ + + _service = "projects" + _action = "get_unique_metric_variants" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "include_subprojects": { + "default": True, + "description": "If set to 'true' and the project field is set then the result includes metrics/variants from the subproject tasks", + "type": ["boolean", "null"], + }, + "project": {"description": "Project ID", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, project=None, include_subprojects=True, **kwargs): + super(GetUniqueMetricVariantsRequest, self).__init__(**kwargs) + self.project = project + self.include_subprojects = include_subprojects + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("include_subprojects") + def include_subprojects(self): + return self._property_include_subprojects + + @include_subprojects.setter + def include_subprojects(self, value): + if value is None: + self._property_include_subprojects = None + return + + self.assert_isinstance(value, "include_subprojects", (bool,)) + self._property_include_subprojects = value + + +class GetUniqueMetricVariantsResponse(Response): + """ + Response of projects.get_unique_metric_variants endpoint. + + :param metrics: A list of metric variants reported for tasks in this project + :type metrics: Sequence[MetricVariantResult] + """ + + _service = "projects" + _action = "get_unique_metric_variants" + _version = "2.20" + + _schema = { + "definitions": { + "metric_variant_result": { + "properties": { + "metric": { + "description": "Metric name", + "type": ["string", "null"], + }, + "metric_hash": { + "description": "Metric name hash. Used instead of the metric name when categorizing last metrics events in task objects.", + "type": ["string", "null"], + }, + "variant": { + "description": "Variant name", + "type": ["string", "null"], + }, + "variant_hash": { + "description": "Variant name hash. Used instead of the variant name when categorizing last metrics events in task objects.", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "metrics": { + "description": "A list of metric variants reported for tasks in this project", + "items": {"$ref": "#/definitions/metric_variant_result"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, metrics=None, **kwargs): + super(GetUniqueMetricVariantsResponse, self).__init__(**kwargs) + self.metrics = metrics + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + MetricVariantResult.from_dict(v) if isinstance(v, dict) else v + for v in value + ] + else: + self.assert_isinstance(value, "metrics", MetricVariantResult, is_array=True) + self._property_metrics = value + + +class MakePrivateRequest(Request): + """ + Convert public projects to private + + :param ids: Ids of the projects to convert. Only the projects originated by the + company can be converted + :type ids: Sequence[str] + """ + + _service = "projects" + _action = "make_private" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "Ids of the projects to convert. Only the projects originated by the company can be converted", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, ids=None, **kwargs): + super(MakePrivateRequest, self).__init__(**kwargs) + self.ids = ids + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + +class MakePrivateResponse(Response): + """ + Response of projects.make_private endpoint. + + :param updated: Number of projects updated + :type updated: int + """ + + _service = "projects" + _action = "make_private" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of projects updated", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(MakePrivateResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class MakePublicRequest(Request): + """ + Convert company projects to public + + :param ids: Ids of the projects to convert + :type ids: Sequence[str] + """ + + _service = "projects" + _action = "make_public" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "Ids of the projects to convert", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, ids=None, **kwargs): + super(MakePublicRequest, self).__init__(**kwargs) + self.ids = ids + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + +class MakePublicResponse(Response): + """ + Response of projects.make_public endpoint. + + :param updated: Number of projects updated + :type updated: int + """ + + _service = "projects" + _action = "make_public" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of projects updated", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(MakePublicResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class MergeRequest(Request): + """ + Moves all the source project's contents to the destination project and remove the source project + + :param project: Project id + :type project: str + :param destination_project: The ID of the destination project + :type destination_project: str + """ + + _service = "projects" + _action = "merge" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "destination_project": { + "description": "The ID of the destination project", + "type": "string", + }, + "project": {"description": "Project id", "type": "string"}, + }, + "required": ["project"], + "type": "object", + } + + def __init__(self, project, destination_project=None, **kwargs): + super(MergeRequest, self).__init__(**kwargs) + self.project = project + self.destination_project = destination_project + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("destination_project") + def destination_project(self): + return self._property_destination_project + + @destination_project.setter + def destination_project(self, value): + if value is None: + self._property_destination_project = None + return + + self.assert_isinstance(value, "destination_project", six.string_types) + self._property_destination_project = value + + +class MergeResponse(Response): + """ + Response of projects.merge endpoint. + + :param moved_entities: The number of tasks and models moved from the merged + project into the destination + :type moved_entities: int + :param moved_projects: The number of child projects moved from the merged + project into the destination + :type moved_projects: int + """ + + _service = "projects" + _action = "merge" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "moved_entities": { + "description": "The number of tasks, models and dataviews moved from the merged project into the destination", + "type": ["integer", "null"], + }, + "moved_projects": { + "description": "The number of child projects moved from the merged project into the destination", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, moved_entities=None, moved_projects=None, **kwargs): + super(MergeResponse, self).__init__(**kwargs) + self.moved_entities = moved_entities + self.moved_projects = moved_projects + + @schema_property("moved_entities") + def moved_entities(self): + return self._property_moved_entities + + @moved_entities.setter + def moved_entities(self, value): + if value is None: + self._property_moved_entities = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "moved_entities", six.integer_types) + self._property_moved_entities = value + + @schema_property("moved_projects") + def moved_projects(self): + return self._property_moved_projects + + @moved_projects.setter + def moved_projects(self, value): + if value is None: + self._property_moved_projects = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "moved_projects", six.integer_types) + self._property_moved_projects = value + + +class MoveRequest(Request): + """ + Moves a project and all of its subprojects under the different location + + :param project: Project id + :type project: str + :param new_location: The name location for the project + :type new_location: str + """ + + _service = "projects" + _action = "move" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "new_location": { + "description": "The name location for the project", + "type": "string", + }, + "project": {"description": "Project id", "type": "string"}, + }, + "required": ["project"], + "type": "object", + } + + def __init__(self, project, new_location=None, **kwargs): + super(MoveRequest, self).__init__(**kwargs) + self.project = project + self.new_location = new_location + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("new_location") + def new_location(self): + return self._property_new_location + + @new_location.setter + def new_location(self, value): + if value is None: + self._property_new_location = None + return + + self.assert_isinstance(value, "new_location", six.string_types) + self._property_new_location = value + + +class MoveResponse(Response): + """ + Response of projects.move endpoint. + + :param moved: The number of projects moved + :type moved: int + """ + + _service = "projects" + _action = "move" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "moved": { + "description": "The number of projects moved", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, moved=None, **kwargs): + super(MoveResponse, self).__init__(**kwargs) + self.moved = moved + + @schema_property("moved") + def moved(self): + return self._property_moved + + @moved.setter + def moved(self, value): + if value is None: + self._property_moved = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "moved", six.integer_types) + self._property_moved = value + + +class UpdateRequest(Request): + """ + Update project information + + :param project: Project id + :type project: str + :param name: Project name. Unique within the company. + :type name: str + :param description: Project description + :type description: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param default_output_destination: The default output destination URL for new + tasks under this project + :type default_output_destination: str + """ + + _service = "projects" + _action = "update" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "default_output_destination": { + "description": "The default output destination URL for new tasks under this project", + "type": "string", + }, + "description": {"description": "Project description", "type": "string"}, + "name": { + "description": "Project name. Unique within the company.", + "type": "string", + }, + "project": {"description": "Project id", "type": "string"}, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["project"], + "type": "object", + } + + def __init__( + self, + project, + name=None, + description=None, + tags=None, + system_tags=None, + default_output_destination=None, + **kwargs + ): + super(UpdateRequest, self).__init__(**kwargs) + self.project = project + self.name = name + self.description = description + self.tags = tags + self.system_tags = system_tags + self.default_output_destination = default_output_destination + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("description") + def description(self): + return self._property_description + + @description.setter + def description(self, value): + if value is None: + self._property_description = None + return + + self.assert_isinstance(value, "description", six.string_types) + self._property_description = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("default_output_destination") + def default_output_destination(self): + return self._property_default_output_destination + + @default_output_destination.setter + def default_output_destination(self, value): + if value is None: + self._property_default_output_destination = None + return + + self.assert_isinstance(value, "default_output_destination", six.string_types) + self._property_default_output_destination = value + + +class UpdateResponse(Response): + """ + Response of projects.update endpoint. + + :param updated: Number of projects updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "projects" + _action = "update" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of projects updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(UpdateResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class ValidateDeleteRequest(Request): + """ + Validates that the project existis and can be deleted + + :param project: Project ID + :type project: str + """ + + _service = "projects" + _action = "validate_delete" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"project": {"description": "Project ID", "type": "string"}}, + "required": ["project"], + "type": "object", + } + + def __init__(self, project, **kwargs): + super(ValidateDeleteRequest, self).__init__(**kwargs) + self.project = project + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + +class ValidateDeleteResponse(Response): + """ + Response of projects.validate_delete endpoint. + + :param tasks: The total number of tasks under the project and all its children + :type tasks: int + :param non_archived_tasks: The total number of non-archived tasks under the + project and all its children + :type non_archived_tasks: int + :param models: The total number of models under the project and all its + children + :type models: int + :param non_archived_models: The total number of non-archived models under the + project and all its children + :type non_archived_models: int + """ + + _service = "projects" + _action = "validate_delete" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "models": { + "description": "The total number of models under the project and all its children", + "type": ["integer", "null"], + }, + "non_archived_models": { + "description": "The total number of non-archived models under the project and all its children", + "type": ["integer", "null"], + }, + "non_archived_tasks": { + "description": "The total number of non-archived tasks under the project and all its children", + "type": ["integer", "null"], + }, + "tasks": { + "description": "The total number of tasks under the project and all its children", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + tasks=None, + non_archived_tasks=None, + models=None, + non_archived_models=None, + **kwargs + ): + super(ValidateDeleteResponse, self).__init__(**kwargs) + self.tasks = tasks + self.non_archived_tasks = non_archived_tasks + self.models = models + self.non_archived_models = non_archived_models + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "tasks", six.integer_types) + self._property_tasks = value + + @schema_property("non_archived_tasks") + def non_archived_tasks(self): + return self._property_non_archived_tasks + + @non_archived_tasks.setter + def non_archived_tasks(self, value): + if value is None: + self._property_non_archived_tasks = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "non_archived_tasks", six.integer_types) + self._property_non_archived_tasks = value + + @schema_property("models") + def models(self): + return self._property_models + + @models.setter + def models(self, value): + if value is None: + self._property_models = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "models", six.integer_types) + self._property_models = value + + @schema_property("non_archived_models") + def non_archived_models(self): + return self._property_non_archived_models + + @non_archived_models.setter + def non_archived_models(self, value): + if value is None: + self._property_non_archived_models = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "non_archived_models", six.integer_types) + self._property_non_archived_models = value + + +response_mapping = { + CreateRequest: CreateResponse, + GetByIdRequest: GetByIdResponse, + GetAllRequest: GetAllResponse, + UpdateRequest: UpdateResponse, + MoveRequest: MoveResponse, + MergeRequest: MergeResponse, + ValidateDeleteRequest: ValidateDeleteResponse, + DeleteRequest: DeleteResponse, + GetUniqueMetricVariantsRequest: GetUniqueMetricVariantsResponse, + GetHyperparamValuesRequest: GetHyperparamValuesResponse, + GetHyperParametersRequest: GetHyperParametersResponse, + GetModelMetadataValuesRequest: GetModelMetadataValuesResponse, + GetModelMetadataKeysRequest: GetModelMetadataKeysResponse, + GetProjectTagsRequest: GetProjectTagsResponse, + GetTaskTagsRequest: GetTaskTagsResponse, + GetModelTagsRequest: GetModelTagsResponse, + MakePublicRequest: MakePublicResponse, + MakePrivateRequest: MakePrivateResponse, + GetTaskParentsRequest: GetTaskParentsResponse, +} diff --git a/clearml/backend_api/services/v2_20/queues.py b/clearml/backend_api/services/v2_20/queues.py new file mode 100644 index 00000000..b2849aaf --- /dev/null +++ b/clearml/backend_api/services/v2_20/queues.py @@ -0,0 +1,2980 @@ +""" +queues service + +Provides a management API for queues of tasks waiting to be executed by workers deployed anywhere (see Workers Service). +""" +import six +from datetime import datetime + +from dateutil.parser import parse as parse_datetime + +from clearml.backend_api.session import ( + Request, + Response, + NonStrictDataModel, + schema_property, +) + + +class QueueMetrics(NonStrictDataModel): + """ + :param queue: ID of the queue + :type queue: str + :param dates: List of timestamps (in seconds from epoch) in the acceding order. + The timestamps are separated by the requested interval. Timestamps where no + queue status change was recorded are omitted. + :type dates: Sequence[int] + :param avg_waiting_times: List of average waiting times for tasks in the queue. + The points correspond to the timestamps in the dates list. If more than one + value exists for the given interval then the maximum value is taken. + :type avg_waiting_times: Sequence[float] + :param queue_lengths: List of tasks counts in the queue. The points correspond + to the timestamps in the dates list. If more than one value exists for the + given interval then the count that corresponds to the maximum average value is + taken. + :type queue_lengths: Sequence[int] + """ + + _schema = { + "properties": { + "avg_waiting_times": { + "description": "List of average waiting times for tasks in the queue. The points correspond to the timestamps in the dates list. If more than one value exists for the given interval then the maximum value is taken.", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "dates": { + "description": "List of timestamps (in seconds from epoch) in the acceding order. The timestamps are separated by the requested interval. Timestamps where no queue status change was recorded are omitted.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "queue": {"description": "ID of the queue", "type": ["string", "null"]}, + "queue_lengths": { + "description": "List of tasks counts in the queue. The points correspond to the timestamps in the dates list. If more than one value exists for the given interval then the count that corresponds to the maximum average value is taken.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + queue=None, + dates=None, + avg_waiting_times=None, + queue_lengths=None, + **kwargs + ): + super(QueueMetrics, self).__init__(**kwargs) + self.queue = queue + self.dates = dates + self.avg_waiting_times = avg_waiting_times + self.queue_lengths = queue_lengths + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("dates") + def dates(self): + return self._property_dates + + @dates.setter + def dates(self, value): + if value is None: + self._property_dates = None + return + + self.assert_isinstance(value, "dates", (list, tuple)) + value = [ + int(v) if isinstance(v, float) and v.is_integer() else v for v in value + ] + + self.assert_isinstance(value, "dates", six.integer_types, is_array=True) + self._property_dates = value + + @schema_property("avg_waiting_times") + def avg_waiting_times(self): + return self._property_avg_waiting_times + + @avg_waiting_times.setter + def avg_waiting_times(self, value): + if value is None: + self._property_avg_waiting_times = None + return + + self.assert_isinstance(value, "avg_waiting_times", (list, tuple)) + + self.assert_isinstance( + value, "avg_waiting_times", six.integer_types + (float,), is_array=True + ) + self._property_avg_waiting_times = value + + @schema_property("queue_lengths") + def queue_lengths(self): + return self._property_queue_lengths + + @queue_lengths.setter + def queue_lengths(self, value): + if value is None: + self._property_queue_lengths = None + return + + self.assert_isinstance(value, "queue_lengths", (list, tuple)) + value = [ + int(v) if isinstance(v, float) and v.is_integer() else v for v in value + ] + + self.assert_isinstance(value, "queue_lengths", six.integer_types, is_array=True) + self._property_queue_lengths = value + + +class Entry(NonStrictDataModel): + """ + :param task: Queued task ID + :type task: str + :param added: Time this entry was added to the queue + :type added: datetime.datetime + """ + + _schema = { + "properties": { + "added": { + "description": "Time this entry was added to the queue", + "format": "date-time", + "type": ["string", "null"], + }, + "task": {"description": "Queued task ID", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, task=None, added=None, **kwargs): + super(Entry, self).__init__(**kwargs) + self.task = task + self.added = added + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("added") + def added(self): + return self._property_added + + @added.setter + def added(self, value): + if value is None: + self._property_added = None + return + + self.assert_isinstance(value, "added", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_added = value + + +class MetadataItem(NonStrictDataModel): + """ + :param key: The key uniquely identifying the metadata item inside the given + entity + :type key: str + :param type: The type of the metadata item + :type type: str + :param value: The value stored in the metadata item + :type value: str + """ + + _schema = { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": ["string", "null"], + }, + "type": { + "description": "The type of the metadata item", + "type": ["string", "null"], + }, + "value": { + "description": "The value stored in the metadata item", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, key=None, type=None, value=None, **kwargs): + super(MetadataItem, self).__init__(**kwargs) + self.key = key + self.type = type + self.value = value + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + + self.assert_isinstance(value, "key", six.string_types) + self._property_key = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + + self.assert_isinstance(value, "type", six.string_types) + self._property_type = value + + @schema_property("value") + def value(self): + return self._property_value + + @value.setter + def value(self, value): + if value is None: + self._property_value = None + return + + self.assert_isinstance(value, "value", six.string_types) + self._property_value = value + + +class Queue(NonStrictDataModel): + """ + :param id: Queue id + :type id: str + :param name: Queue name + :type name: str + :param user: Associated user id + :type user: str + :param company: Company id + :type company: str + :param created: Queue creation time + :type created: datetime.datetime + :param tags: User-defined tags + :type tags: Sequence[str] + :param system_tags: System tags. This field is reserved for system use, please + don't use it. + :type system_tags: Sequence[str] + :param entries: List of ordered queue entries + :type entries: Sequence[Entry] + :param metadata: Queue metadata + :type metadata: list + """ + + _schema = { + "definitions": { + "metadata_item": { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": "string", + }, + "type": { + "description": "The type of the metadata item", + "type": "string", + }, + "value": { + "description": "The value stored in the metadata item", + "type": "string", + }, + }, + "type": "object", + } + }, + "properties": { + "company": {"description": "Company id", "type": ["string", "null"]}, + "created": { + "description": "Queue creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "entries": { + "description": "List of ordered queue entries", + "items": {"$ref": "#/definitions/entry"}, + "type": ["array", "null"], + }, + "id": {"description": "Queue id", "type": ["string", "null"]}, + "metadata": { + "type": "array", + "items": {"$ref": "#/definitions/metadata_item"}, + "description": "Queue metadata", + }, + "name": {"description": "Queue name", "type": ["string", "null"]}, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "user": {"description": "Associated user id", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__( + self, + id=None, + name=None, + user=None, + company=None, + created=None, + tags=None, + system_tags=None, + entries=None, + metadata=None, + **kwargs + ): + super(Queue, self).__init__(**kwargs) + self.id = id + self.name = name + self.user = user + self.company = company + self.created = created + self.tags = tags + self.system_tags = system_tags + self.entries = entries + self.metadata = metadata + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("user") + def user(self): + return self._property_user + + @user.setter + def user(self, value): + if value is None: + self._property_user = None + return + + self.assert_isinstance(value, "user", six.string_types) + self._property_user = value + + @schema_property("company") + def company(self): + return self._property_company + + @company.setter + def company(self, value): + if value is None: + self._property_company = None + return + + self.assert_isinstance(value, "company", six.string_types) + self._property_company = value + + @schema_property("created") + def created(self): + return self._property_created + + @created.setter + def created(self, value): + if value is None: + self._property_created = None + return + + self.assert_isinstance(value, "created", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_created = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("entries") + def entries(self): + return self._property_entries + + @entries.setter + def entries(self, value): + if value is None: + self._property_entries = None + return + + self.assert_isinstance(value, "entries", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [Entry.from_dict(v) if isinstance(v, dict) else v for v in value] + else: + self.assert_isinstance(value, "entries", Entry, is_array=True) + self._property_entries = value + + @schema_property("metadata") + def metadata(self): + return self._property_metadata + + @metadata.setter + def metadata(self, value): + if value is None: + self._property_metadata = None + return + self.assert_isinstance(value, "metadata", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + MetadataItem.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "metadata", MetadataItem, is_array=True) + self._property_metadata = value + + +class AddOrUpdateMetadataRequest(Request): + """ + Add or update queue metadata + + :param queue: ID of the queue + :type queue: str + :param metadata: Metadata items to add or update + :type metadata: Sequence[MetadataItem] + :param replace_metadata: If set then the all the metadata items will be + replaced with the provided ones. Otherwise only the provided metadata items + will be updated or added + :type replace_metadata: bool + """ + + _service = "queues" + _action = "add_or_update_metadata" + _version = "2.20" + _schema = { + "definitions": { + "metadata_item": { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": ["string", "null"], + }, + "type": { + "description": "The type of the metadata item", + "type": ["string", "null"], + }, + "value": { + "description": "The value stored in the metadata item", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "metadata": { + "description": "Metadata items to add or update", + "items": {"$ref": "#/definitions/metadata_item"}, + "type": "array", + }, + "queue": {"description": "ID of the queue", "type": "string"}, + "replace_metadata": { + "default": False, + "description": "If set then the all the metadata items will be replaced with the provided ones. Otherwise only the provided metadata items will be updated or added", + "type": "boolean", + }, + }, + "required": ["queue", "metadata"], + "type": "object", + } + + def __init__(self, queue, metadata, replace_metadata=False, **kwargs): + super(AddOrUpdateMetadataRequest, self).__init__(**kwargs) + self.queue = queue + self.metadata = metadata + self.replace_metadata = replace_metadata + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("metadata") + def metadata(self): + return self._property_metadata + + @metadata.setter + def metadata(self, value): + if value is None: + self._property_metadata = None + return + + self.assert_isinstance(value, "metadata", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + MetadataItem.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "metadata", MetadataItem, is_array=True) + self._property_metadata = value + + @schema_property("replace_metadata") + def replace_metadata(self): + return self._property_replace_metadata + + @replace_metadata.setter + def replace_metadata(self, value): + if value is None: + self._property_replace_metadata = None + return + + self.assert_isinstance(value, "replace_metadata", (bool,)) + self._property_replace_metadata = value + + +class AddOrUpdateMetadataResponse(Response): + """ + Response of queues.add_or_update_metadata endpoint. + + :param updated: Number of queues updated (0 or 1) + :type updated: int + """ + + _service = "queues" + _action = "add_or_update_metadata" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of queues updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(AddOrUpdateMetadataResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class AddTaskRequest(Request): + """ + Adds a task entry to the queue. + + :param queue: Queue id + :type queue: str + :param task: Task id + :type task: str + """ + + _service = "queues" + _action = "add_task" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "queue": {"description": "Queue id", "type": "string"}, + "task": {"description": "Task id", "type": "string"}, + }, + "required": ["queue", "task"], + "type": "object", + } + + def __init__(self, queue, task, **kwargs): + super(AddTaskRequest, self).__init__(**kwargs) + self.queue = queue + self.task = task + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class AddTaskResponse(Response): + """ + Response of queues.add_task endpoint. + + :param added: Number of tasks added (0 or 1) + :type added: int + """ + + _service = "queues" + _action = "add_task" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "added": { + "description": "Number of tasks added (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, added=None, **kwargs): + super(AddTaskResponse, self).__init__(**kwargs) + self.added = added + + @schema_property("added") + def added(self): + return self._property_added + + @added.setter + def added(self, value): + if value is None: + self._property_added = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "added", six.integer_types) + self._property_added = value + + +class CreateRequest(Request): + """ + Create a new queue + + :param name: Queue name Unique within the company. + :type name: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + """ + + _service = "queues" + _action = "create" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "name": { + "description": "Queue name Unique within the company.", + "type": "string", + }, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["name"], + "type": "object", + } + + def __init__(self, name, tags=None, system_tags=None, **kwargs): + super(CreateRequest, self).__init__(**kwargs) + self.name = name + self.tags = tags + self.system_tags = system_tags + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + +class CreateResponse(Response): + """ + Response of queues.create endpoint. + + :param id: New queue ID + :type id: str + """ + + _service = "queues" + _action = "create" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "id": {"description": "New queue ID", "type": ["string", "null"]} + }, + "type": "object", + } + + def __init__(self, id=None, **kwargs): + super(CreateResponse, self).__init__(**kwargs) + self.id = id + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + +class DeleteRequest(Request): + """ + Deletes a queue. If the queue is not empty and force is not set to true, queue will not be deleted. + + :param queue: Queue id + :type queue: str + :param force: Force delete of non-empty queue. Defaults to false + :type force: bool + """ + + _service = "queues" + _action = "delete" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "Force delete of non-empty queue. Defaults to false", + "type": "boolean", + }, + "queue": {"description": "Queue id", "type": "string"}, + }, + "required": ["queue"], + "type": "object", + } + + def __init__(self, queue, force=False, **kwargs): + super(DeleteRequest, self).__init__(**kwargs) + self.queue = queue + self.force = force + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class DeleteResponse(Response): + """ + Response of queues.delete endpoint. + + :param deleted: Number of queues deleted (0 or 1) + :type deleted: int + """ + + _service = "queues" + _action = "delete" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "deleted": { + "description": "Number of queues deleted (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, deleted=None, **kwargs): + super(DeleteResponse, self).__init__(**kwargs) + self.deleted = deleted + + @schema_property("deleted") + def deleted(self): + return self._property_deleted + + @deleted.setter + def deleted(self, value): + if value is None: + self._property_deleted = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "deleted", six.integer_types) + self._property_deleted = value + + +class DeleteMetadataRequest(Request): + """ + Delete metadata from queue + + :param queue: ID of the queue + :type queue: str + :param keys: The list of metadata keys to delete + :type keys: Sequence[str] + """ + + _service = "queues" + _action = "delete_metadata" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "keys": { + "description": "The list of metadata keys to delete", + "items": {"type": "string"}, + "type": "array", + }, + "queue": {"description": "ID of the queue", "type": "string"}, + }, + "required": ["queue", "keys"], + "type": "object", + } + + def __init__(self, queue, keys, **kwargs): + super(DeleteMetadataRequest, self).__init__(**kwargs) + self.queue = queue + self.keys = keys + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("keys") + def keys(self): + return self._property_keys + + @keys.setter + def keys(self, value): + if value is None: + self._property_keys = None + return + + self.assert_isinstance(value, "keys", (list, tuple)) + + self.assert_isinstance(value, "keys", six.string_types, is_array=True) + self._property_keys = value + + +class DeleteMetadataResponse(Response): + """ + Response of queues.delete_metadata endpoint. + + :param updated: Number of queues updated (0 or 1) + :type updated: int + """ + + _service = "queues" + _action = "delete_metadata" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of queues updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(DeleteMetadataResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class GetAllRequest(Request): + """ + Get all queues + + :param name: Get only queues whose name matches this pattern (python regular + expression syntax) + :type name: str + :param id: List of Queue IDs used to filter results + :type id: Sequence[str] + :param tags: User-defined tags list used to filter results. Prepend '-' to tag + name to indicate exclusion + :type tags: Sequence[str] + :param system_tags: System tags list used to filter results. Prepend '-' to + system tag name to indicate exclusion + :type system_tags: Sequence[str] + :param page: Page number, returns a specific page out of the result list of + results. + :type page: int + :param page_size: Page size, specifies the number of results returned in each + page (last page may contain fewer results) + :type page_size: int + :param order_by: List of field names to order by. When search_text is used, + '@text_score' can be used as a field representing the text score of returned + documents. Use '-' prefix to specify descending order. Optional, recommended + when using page + :type order_by: Sequence[str] + :param search_text: Free text search query + :type search_text: str + :param only_fields: List of document field names (nesting is supported using + '.', e.g. execution.model_labels). If provided, this list defines the query's + projection (only these fields will be returned for each result entry) + :type only_fields: Sequence[str] + :param scroll_id: Scroll ID returned from the previos calls to get_all + :type scroll_id: str + :param refresh_scroll: If set then all the data received with this scroll will + be requeried + :type refresh_scroll: bool + :param size: The number of queues to retrieve + :type size: int + :param max_task_entries: Max number of queue task entries to return + :type max_task_entries: int + """ + + _service = "queues" + _action = "get_all" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "id": { + "description": "List of Queue IDs used to filter results", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "max_task_entries": { + "description": "Max number of queue task entries to return", + "type": ["integer", "null"], + }, + "name": { + "description": "Get only queues whose name matches this pattern (python regular expression syntax)", + "type": ["string", "null"], + }, + "only_fields": { + "description": "List of document field names (nesting is supported using '.', e.g. execution.model_labels). If provided, this list defines the query's projection (only these fields will be returned for each result entry)", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "order_by": { + "description": "List of field names to order by. When search_text is used, '@text_score' can be used as a field representing the text score of returned documents. Use '-' prefix to specify descending order. Optional, recommended when using page", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "page": { + "description": "Page number, returns a specific page out of the result list of results.", + "minimum": 0, + "type": ["integer", "null"], + }, + "page_size": { + "description": "Page size, specifies the number of results returned in each page (last page may contain fewer results)", + "minimum": 1, + "type": ["integer", "null"], + }, + "refresh_scroll": { + "description": "If set then all the data received with this scroll will be requeried", + "type": ["boolean", "null"], + }, + "scroll_id": { + "description": "Scroll ID returned from the previos calls to get_all", + "type": ["string", "null"], + }, + "search_text": { + "description": "Free text search query", + "type": ["string", "null"], + }, + "size": { + "description": "The number of queues to retrieve", + "minimum": 1, + "type": ["integer", "null"], + }, + "system_tags": { + "description": "System tags list used to filter results. Prepend '-' to system tag name to indicate exclusion", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags list used to filter results. Prepend '-' to tag name to indicate exclusion", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + name=None, + id=None, + tags=None, + system_tags=None, + page=None, + page_size=None, + order_by=None, + search_text=None, + only_fields=None, + scroll_id=None, + refresh_scroll=None, + size=None, + max_task_entries=None, + **kwargs + ): + super(GetAllRequest, self).__init__(**kwargs) + self.name = name + self.id = id + self.tags = tags + self.system_tags = system_tags + self.page = page + self.page_size = page_size + self.order_by = order_by + self.search_text = search_text + self.only_fields = only_fields + self.scroll_id = scroll_id + self.refresh_scroll = refresh_scroll + self.size = size + self.max_task_entries = max_task_entries + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", (list, tuple)) + + self.assert_isinstance(value, "id", six.string_types, is_array=True) + self._property_id = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("page") + def page(self): + return self._property_page + + @page.setter + def page(self, value): + if value is None: + self._property_page = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page", six.integer_types) + self._property_page = value + + @schema_property("page_size") + def page_size(self): + return self._property_page_size + + @page_size.setter + def page_size(self, value): + if value is None: + self._property_page_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page_size", six.integer_types) + self._property_page_size = value + + @schema_property("order_by") + def order_by(self): + return self._property_order_by + + @order_by.setter + def order_by(self, value): + if value is None: + self._property_order_by = None + return + + self.assert_isinstance(value, "order_by", (list, tuple)) + + self.assert_isinstance(value, "order_by", six.string_types, is_array=True) + self._property_order_by = value + + @schema_property("search_text") + def search_text(self): + return self._property_search_text + + @search_text.setter + def search_text(self, value): + if value is None: + self._property_search_text = None + return + + self.assert_isinstance(value, "search_text", six.string_types) + self._property_search_text = value + + @schema_property("only_fields") + def only_fields(self): + return self._property_only_fields + + @only_fields.setter + def only_fields(self, value): + if value is None: + self._property_only_fields = None + return + + self.assert_isinstance(value, "only_fields", (list, tuple)) + + self.assert_isinstance(value, "only_fields", six.string_types, is_array=True) + self._property_only_fields = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("refresh_scroll") + def refresh_scroll(self): + return self._property_refresh_scroll + + @refresh_scroll.setter + def refresh_scroll(self, value): + if value is None: + self._property_refresh_scroll = None + return + + self.assert_isinstance(value, "refresh_scroll", (bool,)) + self._property_refresh_scroll = value + + @schema_property("size") + def size(self): + return self._property_size + + @size.setter + def size(self, value): + if value is None: + self._property_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "size", six.integer_types) + self._property_size = value + + @schema_property("max_task_entries") + def max_task_entries(self): + return self._property_max_task_entries + + @max_task_entries.setter + def max_task_entries(self, value): + if value is None: + self._property_max_task_entries = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "max_task_entries", six.integer_types) + self._property_max_task_entries = value + + +class GetAllResponse(Response): + """ + Response of queues.get_all endpoint. + + :param queues: Queues list + :type queues: Sequence[Queue] + :param scroll_id: Scroll ID that can be used with the next calls to get_all to + retrieve more data + :type scroll_id: str + """ + + _service = "queues" + _action = "get_all" + _version = "2.20" + + _schema = { + "definitions": { + "entry": { + "properties": { + "added": { + "description": "Time this entry was added to the queue", + "format": "date-time", + "type": ["string", "null"], + }, + "task": { + "description": "Queued task ID", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "metadata": { + "items": { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": "string", + }, + "type": { + "description": "The type of the metadata item", + "type": "string", + }, + "value": { + "description": "The value stored in the metadata item", + "type": "string", + }, + }, + "type": "object", + }, + "type": "array", + }, + "queue": { + "properties": { + "company": { + "description": "Company id", + "type": ["string", "null"], + }, + "created": { + "description": "Queue creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "entries": { + "description": "List of ordered queue entries", + "items": {"$ref": "#/definitions/entry"}, + "type": ["array", "null"], + }, + "id": {"description": "Queue id", "type": ["string", "null"]}, + "metadata": { + "description": "Queue metadata", + "oneOf": [{"$ref": "#/definitions/metadata"}, {"type": "null"}], + }, + "name": {"description": "Queue name", "type": ["string", "null"]}, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "user": { + "description": "Associated user id", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + }, + "properties": { + "queues": { + "description": "Queues list", + "items": {"$ref": "#/definitions/queue"}, + "type": ["array", "null"], + }, + "scroll_id": { + "description": "Scroll ID that can be used with the next calls to get_all to retrieve more data", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, queues=None, scroll_id=None, **kwargs): + super(GetAllResponse, self).__init__(**kwargs) + self.queues = queues + self.scroll_id = scroll_id + + @schema_property("queues") + def queues(self): + return self._property_queues + + @queues.setter + def queues(self, value): + if value is None: + self._property_queues = None + return + + self.assert_isinstance(value, "queues", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [Queue.from_dict(v) if isinstance(v, dict) else v for v in value] + else: + self.assert_isinstance(value, "queues", Queue, is_array=True) + self._property_queues = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class GetByIdRequest(Request): + """ + Gets queue information + + :param queue: Queue ID + :type queue: str + :param max_task_entries: Max number of queue task entries to return + :type max_task_entries: int + """ + + _service = "queues" + _action = "get_by_id" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "max_task_entries": { + "description": "Max number of queue task entries to return", + "type": "integer", + }, + "queue": {"description": "Queue ID", "type": "string"}, + }, + "required": ["queue"], + "type": "object", + } + + def __init__(self, queue, max_task_entries=None, **kwargs): + super(GetByIdRequest, self).__init__(**kwargs) + self.queue = queue + self.max_task_entries = max_task_entries + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("max_task_entries") + def max_task_entries(self): + return self._property_max_task_entries + + @max_task_entries.setter + def max_task_entries(self, value): + if value is None: + self._property_max_task_entries = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "max_task_entries", six.integer_types) + self._property_max_task_entries = value + + +class GetByIdResponse(Response): + """ + Response of queues.get_by_id endpoint. + + :param queue: Queue info + :type queue: Queue + """ + + _service = "queues" + _action = "get_by_id" + _version = "2.20" + + _schema = { + "definitions": { + "entry": { + "properties": { + "added": { + "description": "Time this entry was added to the queue", + "format": "date-time", + "type": ["string", "null"], + }, + "task": { + "description": "Queued task ID", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "metadata": { + "items": { + "properties": { + "key": { + "description": "The key uniquely identifying the metadata item inside the given entity", + "type": "string", + }, + "type": { + "description": "The type of the metadata item", + "type": "string", + }, + "value": { + "description": "The value stored in the metadata item", + "type": "string", + }, + }, + "type": "object", + }, + "type": "array", + }, + "queue": { + "properties": { + "company": { + "description": "Company id", + "type": ["string", "null"], + }, + "created": { + "description": "Queue creation time", + "format": "date-time", + "type": ["string", "null"], + }, + "entries": { + "description": "List of ordered queue entries", + "items": {"$ref": "#/definitions/entry"}, + "type": ["array", "null"], + }, + "id": {"description": "Queue id", "type": ["string", "null"]}, + "metadata": { + "description": "Queue metadata", + "oneOf": [{"$ref": "#/definitions/metadata"}, {"type": "null"}], + }, + "name": {"description": "Queue name", "type": ["string", "null"]}, + "system_tags": { + "description": "System tags. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "user": { + "description": "Associated user id", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + }, + "properties": { + "queue": { + "description": "Queue info", + "oneOf": [{"$ref": "#/definitions/queue"}, {"type": "null"}], + } + }, + "type": "object", + } + + def __init__(self, queue=None, **kwargs): + super(GetByIdResponse, self).__init__(**kwargs) + self.queue = queue + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + if isinstance(value, dict): + value = Queue.from_dict(value) + else: + self.assert_isinstance(value, "queue", Queue) + self._property_queue = value + + +class GetDefaultRequest(Request): + """ """ + + _service = "queues" + _action = "get_default" + _version = "2.20" + _schema = { + "additionalProperties": False, + "definitions": {}, + "properties": {}, + "type": "object", + } + + +class GetDefaultResponse(Response): + """ + Response of queues.get_default endpoint. + + :param id: Queue id + :type id: str + :param name: Queue name + :type name: str + """ + + _service = "queues" + _action = "get_default" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "id": {"description": "Queue id", "type": ["string", "null"]}, + "name": {"description": "Queue name", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, id=None, name=None, **kwargs): + super(GetDefaultResponse, self).__init__(**kwargs) + self.id = id + self.name = name + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + +class GetNextTaskRequest(Request): + """ + Gets the next task from the top of the queue (FIFO). The task entry is removed from the queue. + + :param queue: Queue id + :type queue: str + """ + + _service = "queues" + _action = "get_next_task" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"queue": {"description": "Queue id", "type": "string"}}, + "required": ["queue"], + "type": "object", + } + + def __init__(self, queue, **kwargs): + super(GetNextTaskRequest, self).__init__(**kwargs) + self.queue = queue + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + +class GetNextTaskResponse(Response): + """ + Response of queues.get_next_task endpoint. + + :param entry: Entry information + :type entry: Entry + """ + + _service = "queues" + _action = "get_next_task" + _version = "2.20" + + _schema = { + "definitions": { + "entry": { + "properties": { + "added": { + "description": "Time this entry was added to the queue", + "format": "date-time", + "type": ["string", "null"], + }, + "task": { + "description": "Queued task ID", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "entry": { + "description": "Entry information", + "oneOf": [{"$ref": "#/definitions/entry"}, {"type": "null"}], + } + }, + "type": "object", + } + + def __init__(self, entry=None, **kwargs): + super(GetNextTaskResponse, self).__init__(**kwargs) + self.entry = entry + + @schema_property("entry") + def entry(self): + return self._property_entry + + @entry.setter + def entry(self, value): + if value is None: + self._property_entry = None + return + if isinstance(value, dict): + value = Entry.from_dict(value) + else: + self.assert_isinstance(value, "entry", Entry) + self._property_entry = value + + +class GetNumEntriesRequest(Request): + """ + Get the number of task entries in the given queue + + :param queue: ID of the queue + :type queue: str + """ + + _service = "queues" + _action = "get_num_entries" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"queue": {"description": "ID of the queue", "type": "string"}}, + "required": ["queue"], + "type": "object", + } + + def __init__(self, queue, **kwargs): + super(GetNumEntriesRequest, self).__init__(**kwargs) + self.queue = queue + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + +class GetNumEntriesResponse(Response): + """ + Response of queues.get_num_entries endpoint. + + :param num: Number of entries + :type num: int + """ + + _service = "queues" + _action = "get_num_entries" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "num": {"description": "Number of entries", "type": ["integer", "null"]} + }, + "type": "object", + } + + def __init__(self, num=None, **kwargs): + super(GetNumEntriesResponse, self).__init__(**kwargs) + self.num = num + + @schema_property("num") + def num(self): + return self._property_num + + @num.setter + def num(self, value): + if value is None: + self._property_num = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "num", six.integer_types) + self._property_num = value + + +class GetQueueMetricsRequest(Request): + """ + Returns metrics of the company queues. The metrics are avaraged in the specified interval. + + :param from_date: Starting time (in seconds from epoch) for collecting metrics + :type from_date: float + :param to_date: Ending time (in seconds from epoch) for collecting metrics + :type to_date: float + :param interval: Time interval in seconds for a single metrics point. The + minimal value is 1 + :type interval: int + :param queue_ids: List of queue ids to collect metrics for. If not provided or + empty then all then average metrics across all the company queues will be + returned. + :type queue_ids: Sequence[str] + :param refresh: If set then the new queue metrics is taken + :type refresh: bool + """ + + _service = "queues" + _action = "get_queue_metrics" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "from_date": { + "description": "Starting time (in seconds from epoch) for collecting metrics", + "type": "number", + }, + "interval": { + "description": "Time interval in seconds for a single metrics point. The minimal value is 1", + "type": "integer", + }, + "queue_ids": { + "description": "List of queue ids to collect metrics for. If not provided or empty then all then average metrics across all the company queues will be returned.", + "items": {"type": "string"}, + "type": "array", + }, + "refresh": { + "default": False, + "description": "If set then the new queue metrics is taken", + "type": "boolean", + }, + "to_date": { + "description": "Ending time (in seconds from epoch) for collecting metrics", + "type": "number", + }, + }, + "required": ["from_date", "to_date", "interval"], + "type": "object", + } + + def __init__( + self, from_date, to_date, interval, queue_ids=None, refresh=False, **kwargs + ): + super(GetQueueMetricsRequest, self).__init__(**kwargs) + self.from_date = from_date + self.to_date = to_date + self.interval = interval + self.queue_ids = queue_ids + self.refresh = refresh + + @schema_property("from_date") + def from_date(self): + return self._property_from_date + + @from_date.setter + def from_date(self, value): + if value is None: + self._property_from_date = None + return + + self.assert_isinstance(value, "from_date", six.integer_types + (float,)) + self._property_from_date = value + + @schema_property("to_date") + def to_date(self): + return self._property_to_date + + @to_date.setter + def to_date(self, value): + if value is None: + self._property_to_date = None + return + + self.assert_isinstance(value, "to_date", six.integer_types + (float,)) + self._property_to_date = value + + @schema_property("interval") + def interval(self): + return self._property_interval + + @interval.setter + def interval(self, value): + if value is None: + self._property_interval = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "interval", six.integer_types) + self._property_interval = value + + @schema_property("queue_ids") + def queue_ids(self): + return self._property_queue_ids + + @queue_ids.setter + def queue_ids(self, value): + if value is None: + self._property_queue_ids = None + return + + self.assert_isinstance(value, "queue_ids", (list, tuple)) + + self.assert_isinstance(value, "queue_ids", six.string_types, is_array=True) + self._property_queue_ids = value + + @schema_property("refresh") + def refresh(self): + return self._property_refresh + + @refresh.setter + def refresh(self, value): + if value is None: + self._property_refresh = None + return + + self.assert_isinstance(value, "refresh", (bool,)) + self._property_refresh = value + + +class GetQueueMetricsResponse(Response): + """ + Response of queues.get_queue_metrics endpoint. + + :param queues: List of the requested queues with their metrics. If no queue ids + were requested then 'all' queue is returned with the metrics averaged accross + all the company queues. + :type queues: Sequence[QueueMetrics] + """ + + _service = "queues" + _action = "get_queue_metrics" + _version = "2.20" + + _schema = { + "definitions": { + "queue_metrics": { + "properties": { + "avg_waiting_times": { + "description": "List of average waiting times for tasks in the queue. The points correspond to the timestamps in the dates list. If more than one value exists for the given interval then the maximum value is taken.", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "dates": { + "description": "List of timestamps (in seconds from epoch) in the acceding order. The timestamps are separated by the requested interval. Timestamps where no queue status change was recorded are omitted.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "queue": { + "description": "ID of the queue", + "type": ["string", "null"], + }, + "queue_lengths": { + "description": "List of tasks counts in the queue. The points correspond to the timestamps in the dates list. If more than one value exists for the given interval then the count that corresponds to the maximum average value is taken.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "queues": { + "description": "List of the requested queues with their metrics. If no queue ids were requested then 'all' queue is returned with the metrics averaged accross all the company queues.", + "items": {"$ref": "#/definitions/queue_metrics"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, queues=None, **kwargs): + super(GetQueueMetricsResponse, self).__init__(**kwargs) + self.queues = queues + + @schema_property("queues") + def queues(self): + return self._property_queues + + @queues.setter + def queues(self, value): + if value is None: + self._property_queues = None + return + + self.assert_isinstance(value, "queues", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + QueueMetrics.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "queues", QueueMetrics, is_array=True) + self._property_queues = value + + +class MoveTaskBackwardRequest(Request): + """ + :param queue: Queue id + :type queue: str + :param task: Task id + :type task: str + :param count: Number of positions in the queue to move the task forward + relative to the current position. Optional, the default value is 1. + :type count: int + """ + + _service = "queues" + _action = "move_task_backward" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "count": { + "description": "Number of positions in the queue to move the task forward relative to the current position. Optional, the default value is 1.", + "type": "integer", + }, + "queue": {"description": "Queue id", "type": "string"}, + "task": {"description": "Task id", "type": "string"}, + }, + "required": ["queue", "task"], + "type": "object", + } + + def __init__(self, queue, task, count=None, **kwargs): + super(MoveTaskBackwardRequest, self).__init__(**kwargs) + self.queue = queue + self.task = task + self.count = count + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("count") + def count(self): + return self._property_count + + @count.setter + def count(self, value): + if value is None: + self._property_count = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "count", six.integer_types) + self._property_count = value + + +class MoveTaskBackwardResponse(Response): + """ + Response of queues.move_task_backward endpoint. + + :param position: The new position of the task entry in the queue (index, -1 + represents bottom of queue) + :type position: int + """ + + _service = "queues" + _action = "move_task_backward" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "position": { + "description": "The new position of the task entry in the queue (index, -1 represents bottom of queue)", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, position=None, **kwargs): + super(MoveTaskBackwardResponse, self).__init__(**kwargs) + self.position = position + + @schema_property("position") + def position(self): + return self._property_position + + @position.setter + def position(self, value): + if value is None: + self._property_position = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "position", six.integer_types) + self._property_position = value + + +class MoveTaskForwardRequest(Request): + """ + Moves a task entry one step forward towards the top of the queue. + + :param queue: Queue id + :type queue: str + :param task: Task id + :type task: str + :param count: Number of positions in the queue to move the task forward + relative to the current position. Optional, the default value is 1. + :type count: int + """ + + _service = "queues" + _action = "move_task_forward" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "count": { + "description": "Number of positions in the queue to move the task forward relative to the current position. Optional, the default value is 1.", + "type": "integer", + }, + "queue": {"description": "Queue id", "type": "string"}, + "task": {"description": "Task id", "type": "string"}, + }, + "required": ["queue", "task"], + "type": "object", + } + + def __init__(self, queue, task, count=None, **kwargs): + super(MoveTaskForwardRequest, self).__init__(**kwargs) + self.queue = queue + self.task = task + self.count = count + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("count") + def count(self): + return self._property_count + + @count.setter + def count(self, value): + if value is None: + self._property_count = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "count", six.integer_types) + self._property_count = value + + +class MoveTaskForwardResponse(Response): + """ + Response of queues.move_task_forward endpoint. + + :param position: The new position of the task entry in the queue (index, -1 + represents bottom of queue) + :type position: int + """ + + _service = "queues" + _action = "move_task_forward" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "position": { + "description": "The new position of the task entry in the queue (index, -1 represents bottom of queue)", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, position=None, **kwargs): + super(MoveTaskForwardResponse, self).__init__(**kwargs) + self.position = position + + @schema_property("position") + def position(self): + return self._property_position + + @position.setter + def position(self, value): + if value is None: + self._property_position = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "position", six.integer_types) + self._property_position = value + + +class MoveTaskToBackRequest(Request): + """ + :param queue: Queue id + :type queue: str + :param task: Task id + :type task: str + """ + + _service = "queues" + _action = "move_task_to_back" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "queue": {"description": "Queue id", "type": "string"}, + "task": {"description": "Task id", "type": "string"}, + }, + "required": ["queue", "task"], + "type": "object", + } + + def __init__(self, queue, task, **kwargs): + super(MoveTaskToBackRequest, self).__init__(**kwargs) + self.queue = queue + self.task = task + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class MoveTaskToBackResponse(Response): + """ + Response of queues.move_task_to_back endpoint. + + :param position: The new position of the task entry in the queue (index, -1 + represents bottom of queue) + :type position: int + """ + + _service = "queues" + _action = "move_task_to_back" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "position": { + "description": "The new position of the task entry in the queue (index, -1 represents bottom of queue)", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, position=None, **kwargs): + super(MoveTaskToBackResponse, self).__init__(**kwargs) + self.position = position + + @schema_property("position") + def position(self): + return self._property_position + + @position.setter + def position(self, value): + if value is None: + self._property_position = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "position", six.integer_types) + self._property_position = value + + +class MoveTaskToFrontRequest(Request): + """ + :param queue: Queue id + :type queue: str + :param task: Task id + :type task: str + """ + + _service = "queues" + _action = "move_task_to_front" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "queue": {"description": "Queue id", "type": "string"}, + "task": {"description": "Task id", "type": "string"}, + }, + "required": ["queue", "task"], + "type": "object", + } + + def __init__(self, queue, task, **kwargs): + super(MoveTaskToFrontRequest, self).__init__(**kwargs) + self.queue = queue + self.task = task + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class MoveTaskToFrontResponse(Response): + """ + Response of queues.move_task_to_front endpoint. + + :param position: The new position of the task entry in the queue (index, -1 + represents bottom of queue) + :type position: int + """ + + _service = "queues" + _action = "move_task_to_front" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "position": { + "description": "The new position of the task entry in the queue (index, -1 represents bottom of queue)", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, position=None, **kwargs): + super(MoveTaskToFrontResponse, self).__init__(**kwargs) + self.position = position + + @schema_property("position") + def position(self): + return self._property_position + + @position.setter + def position(self, value): + if value is None: + self._property_position = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "position", six.integer_types) + self._property_position = value + + +class PeekTaskRequest(Request): + """ + Peek the next task from a given queue + + :param queue: ID of the queue + :type queue: str + """ + + _service = "queues" + _action = "peek_task" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"queue": {"description": "ID of the queue", "type": "string"}}, + "required": ["queue"], + "type": "object", + } + + def __init__(self, queue, **kwargs): + super(PeekTaskRequest, self).__init__(**kwargs) + self.queue = queue + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + +class PeekTaskResponse(Response): + """ + Response of queues.peek_task endpoint. + + :param task: Task ID + :type task: str + """ + + _service = "queues" + _action = "peek_task" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": {"task": {"description": "Task ID", "type": ["string", "null"]}}, + "type": "object", + } + + def __init__(self, task=None, **kwargs): + super(PeekTaskResponse, self).__init__(**kwargs) + self.task = task + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class RemoveTaskRequest(Request): + """ + Removes a task entry from the queue. + + :param queue: Queue id + :type queue: str + :param task: Task id + :type task: str + """ + + _service = "queues" + _action = "remove_task" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "queue": {"description": "Queue id", "type": "string"}, + "task": {"description": "Task id", "type": "string"}, + }, + "required": ["queue", "task"], + "type": "object", + } + + def __init__(self, queue, task, **kwargs): + super(RemoveTaskRequest, self).__init__(**kwargs) + self.queue = queue + self.task = task + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class RemoveTaskResponse(Response): + """ + Response of queues.remove_task endpoint. + + :param removed: Number of tasks removed (0 or 1) + :type removed: int + """ + + _service = "queues" + _action = "remove_task" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "removed": { + "description": "Number of tasks removed (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, removed=None, **kwargs): + super(RemoveTaskResponse, self).__init__(**kwargs) + self.removed = removed + + @schema_property("removed") + def removed(self): + return self._property_removed + + @removed.setter + def removed(self, value): + if value is None: + self._property_removed = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "removed", six.integer_types) + self._property_removed = value + + +class UpdateRequest(Request): + """ + Update queue information + + :param queue: Queue id + :type queue: str + :param name: Queue name Unique within the company. + :type name: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + """ + + _service = "queues" + _action = "update" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "name": { + "description": "Queue name Unique within the company.", + "type": "string", + }, + "queue": {"description": "Queue id", "type": "string"}, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["queue"], + "type": "object", + } + + def __init__(self, queue, name=None, tags=None, system_tags=None, **kwargs): + super(UpdateRequest, self).__init__(**kwargs) + self.queue = queue + self.name = name + self.tags = tags + self.system_tags = system_tags + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + +class UpdateResponse(Response): + """ + Response of queues.update endpoint. + + :param updated: Number of queues updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "queues" + _action = "update" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of queues updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(UpdateResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +response_mapping = { + GetByIdRequest: GetByIdResponse, + GetAllRequest: GetAllResponse, + GetDefaultRequest: GetDefaultResponse, + CreateRequest: CreateResponse, + UpdateRequest: UpdateResponse, + DeleteRequest: DeleteResponse, + AddTaskRequest: AddTaskResponse, + GetNextTaskRequest: GetNextTaskResponse, + RemoveTaskRequest: RemoveTaskResponse, + MoveTaskForwardRequest: MoveTaskForwardResponse, + MoveTaskBackwardRequest: MoveTaskBackwardResponse, + MoveTaskToFrontRequest: MoveTaskToFrontResponse, + MoveTaskToBackRequest: MoveTaskToBackResponse, + GetQueueMetricsRequest: GetQueueMetricsResponse, + AddOrUpdateMetadataRequest: AddOrUpdateMetadataResponse, + DeleteMetadataRequest: DeleteMetadataResponse, + PeekTaskRequest: PeekTaskResponse, + GetNumEntriesRequest: GetNumEntriesResponse, +} diff --git a/clearml/backend_api/services/v2_20/tasks.py b/clearml/backend_api/services/v2_20/tasks.py new file mode 100644 index 00000000..a4bc4d0b --- /dev/null +++ b/clearml/backend_api/services/v2_20/tasks.py @@ -0,0 +1,13231 @@ +""" +tasks service + +Provides a management API for tasks in the system. +""" +import six +from datetime import datetime +import enum + +from dateutil.parser import parse as parse_datetime + +from clearml.backend_api.session import ( + Request, + BatchRequest, + Response, + NonStrictDataModel, + schema_property, + StringEnum, +) + + +class MultiFieldPatternData(NonStrictDataModel): + """ + :param pattern: Pattern string (regex) + :type pattern: str + :param fields: List of field names + :type fields: Sequence[str] + """ + + _schema = { + "properties": { + "fields": { + "description": "List of field names", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "pattern": { + "description": "Pattern string (regex)", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, pattern=None, fields=None, **kwargs): + super(MultiFieldPatternData, self).__init__(**kwargs) + self.pattern = pattern + self.fields = fields + + @schema_property("pattern") + def pattern(self): + return self._property_pattern + + @pattern.setter + def pattern(self, value): + if value is None: + self._property_pattern = None + return + + self.assert_isinstance(value, "pattern", six.string_types) + self._property_pattern = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (list, tuple)) + + self.assert_isinstance(value, "fields", six.string_types, is_array=True) + self._property_fields = value + + +class ModelTypeEnum(StringEnum): + input = "input" + output = "output" + + +class TaskModelItem(NonStrictDataModel): + """ + :param name: The task model name + :type name: str + :param model: The model ID + :type model: str + """ + + _schema = { + "properties": { + "model": {"description": "The model ID", "type": "string"}, + "name": {"description": "The task model name", "type": "string"}, + }, + "required": ["name", "model"], + "type": "object", + } + + def __init__(self, name, model, **kwargs): + super(TaskModelItem, self).__init__(**kwargs) + self.name = name + self.model = model + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + +class Script(NonStrictDataModel): + """ + :param binary: Binary to use when running the script + :type binary: str + :param repository: Name of the repository where the script is located + :type repository: str + :param tag: Repository tag + :type tag: str + :param branch: Repository branch id If not provided and tag not provided, + default repository branch is used. + :type branch: str + :param version_num: Version (changeset) number. Optional (default is head + version) Unused if tag is provided. + :type version_num: str + :param entry_point: Path to execute within the repository + :type entry_point: str + :param working_dir: Path to the folder from which to run the script Default - + root folder of repository + :type working_dir: str + :param requirements: A JSON object containing requirements strings by key + :type requirements: dict + :param diff: Uncommitted changes found in the repository when task was run + :type diff: str + """ + + _schema = { + "properties": { + "binary": { + "default": "python", + "description": "Binary to use when running the script", + "type": ["string", "null"], + }, + "branch": { + "description": "Repository branch id If not provided and tag not provided, default repository branch is used.", + "type": ["string", "null"], + }, + "diff": { + "description": "Uncommitted changes found in the repository when task was run", + "type": ["string", "null"], + }, + "entry_point": { + "description": "Path to execute within the repository", + "type": ["string", "null"], + }, + "repository": { + "description": "Name of the repository where the script is located", + "type": ["string", "null"], + }, + "requirements": { + "description": "A JSON object containing requirements strings by key", + "type": ["object", "null"], + }, + "tag": {"description": "Repository tag", "type": ["string", "null"]}, + "version_num": { + "description": "Version (changeset) number. Optional (default is head version) Unused if tag is provided.", + "type": ["string", "null"], + }, + "working_dir": { + "description": "Path to the folder from which to run the script Default - root folder of repository", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + binary="python", + repository=None, + tag=None, + branch=None, + version_num=None, + entry_point=None, + working_dir=None, + requirements=None, + diff=None, + **kwargs + ): + super(Script, self).__init__(**kwargs) + self.binary = binary + self.repository = repository + self.tag = tag + self.branch = branch + self.version_num = version_num + self.entry_point = entry_point + self.working_dir = working_dir + self.requirements = requirements + self.diff = diff + + @schema_property("binary") + def binary(self): + return self._property_binary + + @binary.setter + def binary(self, value): + if value is None: + self._property_binary = None + return + + self.assert_isinstance(value, "binary", six.string_types) + self._property_binary = value + + @schema_property("repository") + def repository(self): + return self._property_repository + + @repository.setter + def repository(self, value): + if value is None: + self._property_repository = None + return + + self.assert_isinstance(value, "repository", six.string_types) + self._property_repository = value + + @schema_property("tag") + def tag(self): + return self._property_tag + + @tag.setter + def tag(self, value): + if value is None: + self._property_tag = None + return + + self.assert_isinstance(value, "tag", six.string_types) + self._property_tag = value + + @schema_property("branch") + def branch(self): + return self._property_branch + + @branch.setter + def branch(self, value): + if value is None: + self._property_branch = None + return + + self.assert_isinstance(value, "branch", six.string_types) + self._property_branch = value + + @schema_property("version_num") + def version_num(self): + return self._property_version_num + + @version_num.setter + def version_num(self, value): + if value is None: + self._property_version_num = None + return + + self.assert_isinstance(value, "version_num", six.string_types) + self._property_version_num = value + + @schema_property("entry_point") + def entry_point(self): + return self._property_entry_point + + @entry_point.setter + def entry_point(self, value): + if value is None: + self._property_entry_point = None + return + + self.assert_isinstance(value, "entry_point", six.string_types) + self._property_entry_point = value + + @schema_property("working_dir") + def working_dir(self): + return self._property_working_dir + + @working_dir.setter + def working_dir(self, value): + if value is None: + self._property_working_dir = None + return + + self.assert_isinstance(value, "working_dir", six.string_types) + self._property_working_dir = value + + @schema_property("requirements") + def requirements(self): + return self._property_requirements + + @requirements.setter + def requirements(self, value): + if value is None: + self._property_requirements = None + return + + self.assert_isinstance(value, "requirements", (dict,)) + self._property_requirements = value + + @schema_property("diff") + def diff(self): + return self._property_diff + + @diff.setter + def diff(self, value): + if value is None: + self._property_diff = None + return + + self.assert_isinstance(value, "diff", six.string_types) + self._property_diff = value + + +class Output(NonStrictDataModel): + """ + :param destination: Storage id. This is where output files will be stored. + :type destination: str + :param model: Model id. + :type model: str + :param result: Task result. Values: 'success', 'failure' + :type result: str + :param error: Last error text + :type error: str + """ + + _schema = { + "properties": { + "destination": { + "description": "Storage id. This is where output files will be stored.", + "type": ["string", "null"], + }, + "error": {"description": "Last error text", "type": ["string", "null"]}, + "model": {"description": "Model id.", "type": ["string", "null"]}, + "result": { + "description": "Task result. Values: 'success', 'failure'", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, destination=None, model=None, result=None, error=None, **kwargs): + super(Output, self).__init__(**kwargs) + self.destination = destination + self.model = model + self.result = result + self.error = error + + @schema_property("destination") + def destination(self): + return self._property_destination + + @destination.setter + def destination(self, value): + if value is None: + self._property_destination = None + return + + self.assert_isinstance(value, "destination", six.string_types) + self._property_destination = value + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + @schema_property("result") + def result(self): + return self._property_result + + @result.setter + def result(self, value): + if value is None: + self._property_result = None + return + + self.assert_isinstance(value, "result", six.string_types) + self._property_result = value + + @schema_property("error") + def error(self): + return self._property_error + + @error.setter + def error(self, value): + if value is None: + self._property_error = None + return + + self.assert_isinstance(value, "error", six.string_types) + self._property_error = value + + +class ArtifactTypeData(NonStrictDataModel): + """ + :param preview: Description or textual data + :type preview: str + :param content_type: System defined raw data content type + :type content_type: str + :param data_hash: Hash of raw data, without any headers or descriptive parts + :type data_hash: str + """ + + _schema = { + "properties": { + "content_type": { + "description": "System defined raw data content type", + "type": ["string", "null"], + }, + "data_hash": { + "description": "Hash of raw data, without any headers or descriptive parts", + "type": ["string", "null"], + }, + "preview": { + "description": "Description or textual data", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, preview=None, content_type=None, data_hash=None, **kwargs): + super(ArtifactTypeData, self).__init__(**kwargs) + self.preview = preview + self.content_type = content_type + self.data_hash = data_hash + + @schema_property("preview") + def preview(self): + return self._property_preview + + @preview.setter + def preview(self, value): + if value is None: + self._property_preview = None + return + + self.assert_isinstance(value, "preview", six.string_types) + self._property_preview = value + + @schema_property("content_type") + def content_type(self): + return self._property_content_type + + @content_type.setter + def content_type(self, value): + if value is None: + self._property_content_type = None + return + + self.assert_isinstance(value, "content_type", six.string_types) + self._property_content_type = value + + @schema_property("data_hash") + def data_hash(self): + return self._property_data_hash + + @data_hash.setter + def data_hash(self, value): + if value is None: + self._property_data_hash = None + return + + self.assert_isinstance(value, "data_hash", six.string_types) + self._property_data_hash = value + + +class ArtifactModeEnum(StringEnum): + input = "input" + output = "output" + + +class Artifact(NonStrictDataModel): + """ + :param key: Entry key + :type key: str + :param type: System defined type + :type type: str + :param mode: System defined input/output indication + :type mode: ArtifactModeEnum + :param uri: Raw data location + :type uri: str + :param content_size: Raw data length in bytes + :type content_size: int + :param hash: Hash of entire raw data + :type hash: str + :param timestamp: Epoch time when artifact was created + :type timestamp: int + :param type_data: Additional fields defined by the system + :type type_data: ArtifactTypeData + :param display_data: User-defined list of key/value pairs, sorted + :type display_data: Sequence[Sequence[str]] + """ + + _schema = { + "properties": { + "content_size": { + "description": "Raw data length in bytes", + "type": "integer", + }, + "display_data": { + "description": "User-defined list of " "key/value pairs, sorted", + "items": {"items": {"type": "string"}, "type": "array"}, + "type": "array", + }, + "hash": {"description": "Hash of entire raw data", "type": "string"}, + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output " "indication", + }, + "timestamp": { + "description": "Epoch time when artifact was " "created", + "type": "integer", + }, + "type": {"description": "System defined type", "type": "string"}, + "type_data": { + "$ref": "#/definitions/artifact_type_data", + "description": "Additional fields defined by the " "system", + }, + "uri": {"description": "Raw data location", "type": "string"}, + }, + "required": ["key", "type"], + "type": "object", + } + + def __init__( + self, + key, + type, + mode=None, + uri=None, + content_size=None, + hash=None, + timestamp=None, + type_data=None, + display_data=None, + **kwargs + ): + super(Artifact, self).__init__(**kwargs) + self.key = key + self.type = type + self.mode = mode + self.uri = uri + self.content_size = content_size + self.hash = hash + self.timestamp = timestamp + self.type_data = type_data + self.display_data = display_data + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + + self.assert_isinstance(value, "key", six.string_types) + self._property_key = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + + self.assert_isinstance(value, "type", six.string_types) + self._property_type = value + + @schema_property("mode") + def mode(self): + return self._property_mode + + @mode.setter + def mode(self, value): + if value is None: + self._property_mode = None + return + if isinstance(value, six.string_types): + try: + value = ArtifactModeEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "mode", enum.Enum) + self._property_mode = value + + @schema_property("uri") + def uri(self): + return self._property_uri + + @uri.setter + def uri(self, value): + if value is None: + self._property_uri = None + return + + self.assert_isinstance(value, "uri", six.string_types) + self._property_uri = value + + @schema_property("content_size") + def content_size(self): + return self._property_content_size + + @content_size.setter + def content_size(self, value): + if value is None: + self._property_content_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "content_size", six.integer_types) + self._property_content_size = value + + @schema_property("hash") + def hash(self): + return self._property_hash + + @hash.setter + def hash(self, value): + if value is None: + self._property_hash = None + return + + self.assert_isinstance(value, "hash", six.string_types) + self._property_hash = value + + @schema_property("timestamp") + def timestamp(self): + return self._property_timestamp + + @timestamp.setter + def timestamp(self, value): + if value is None: + self._property_timestamp = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "timestamp", six.integer_types) + self._property_timestamp = value + + @schema_property("type_data") + def type_data(self): + return self._property_type_data + + @type_data.setter + def type_data(self, value): + if value is None: + self._property_type_data = None + return + if isinstance(value, dict): + value = ArtifactTypeData.from_dict(value) + else: + self.assert_isinstance(value, "type_data", ArtifactTypeData) + self._property_type_data = value + + @schema_property("display_data") + def display_data(self): + return self._property_display_data + + @display_data.setter + def display_data(self, value): + if value is None: + self._property_display_data = None + return + + self.assert_isinstance(value, "display_data", (list, tuple)) + + self.assert_isinstance(value, "display_data", (list, tuple), is_array=True) + self._property_display_data = value + + +class ArtifactId(NonStrictDataModel): + """ + :param key: Entry key + :type key: str + :param mode: System defined input/output indication + :type mode: ArtifactModeEnum + """ + + _schema = { + "properties": { + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output " "indication", + }, + }, + "required": ["key"], + "type": "object", + } + + def __init__(self, key, mode=None, **kwargs): + super(ArtifactId, self).__init__(**kwargs) + self.key = key + self.mode = mode + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + + self.assert_isinstance(value, "key", six.string_types) + self._property_key = value + + @schema_property("mode") + def mode(self): + return self._property_mode + + @mode.setter + def mode(self, value): + if value is None: + self._property_mode = None + return + if isinstance(value, six.string_types): + try: + value = ArtifactModeEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "mode", enum.Enum) + self._property_mode = value + + +class TaskModels(NonStrictDataModel): + """ + :param input: The list of task input models + :type input: Sequence[TaskModelItem] + :param output: The list of task output models + :type output: Sequence[TaskModelItem] + """ + + _schema = { + "properties": { + "input": { + "description": "The list of task input models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + "output": { + "description": "The list of task output models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, input=None, output=None, **kwargs): + super(TaskModels, self).__init__(**kwargs) + self.input = input + self.output = output + + @schema_property("input") + def input(self): + return self._property_input + + @input.setter + def input(self, value): + if value is None: + self._property_input = None + return + + self.assert_isinstance(value, "input", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + TaskModelItem.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "input", TaskModelItem, is_array=True) + self._property_input = value + + @schema_property("output") + def output(self): + return self._property_output + + @output.setter + def output(self, value): + if value is None: + self._property_output = None + return + + self.assert_isinstance(value, "output", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + TaskModelItem.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "output", TaskModelItem, is_array=True) + self._property_output = value + + +class Execution(NonStrictDataModel): + """ + :param queue: Queue ID where task was queued. + :type queue: str + :param parameters: Json object containing the Task parameters + :type parameters: dict + :param model_desc: Json object representing the Model descriptors + :type model_desc: dict + :param model_labels: Json object representing the ids of the labels in the + model. The keys are the layers' names and the values are the IDs. Not + applicable for Register (Import) tasks. Mandatory for Training tasks + :type model_labels: dict + :param framework: Framework related to the task. Case insensitive. Mandatory + for Training tasks. + :type framework: str + :param artifacts: Task artifacts + :type artifacts: Sequence[Artifact] + """ + + _schema = { + "properties": { + "artifacts": { + "description": "Task artifacts", + "items": {"$ref": "#/definitions/artifact"}, + "type": ["array", "null"], + }, + "framework": { + "description": "Framework related to the task. Case insensitive. Mandatory for Training tasks. ", + "type": ["string", "null"], + }, + "model_desc": { + "additionalProperties": True, + "description": "Json object representing the Model descriptors", + "type": ["object", "null"], + }, + "model_labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model.\n The keys are the layers' names and the values are the IDs.\n Not applicable for Register (Import) tasks.\n Mandatory for Training tasks", + "type": ["object", "null"], + }, + "parameters": { + "additionalProperties": True, + "description": "Json object containing the Task parameters", + "type": ["object", "null"], + }, + "queue": { + "description": "Queue ID where task was queued.", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + queue=None, + parameters=None, + model_desc=None, + model_labels=None, + framework=None, + artifacts=None, + **kwargs + ): + super(Execution, self).__init__(**kwargs) + self.queue = queue + self.parameters = parameters + self.model_desc = model_desc + self.model_labels = model_labels + self.framework = framework + self.artifacts = artifacts + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("parameters") + def parameters(self): + return self._property_parameters + + @parameters.setter + def parameters(self, value): + if value is None: + self._property_parameters = None + return + + self.assert_isinstance(value, "parameters", (dict,)) + self._property_parameters = value + + @schema_property("model_desc") + def model_desc(self): + return self._property_model_desc + + @model_desc.setter + def model_desc(self, value): + if value is None: + self._property_model_desc = None + return + + self.assert_isinstance(value, "model_desc", (dict,)) + self._property_model_desc = value + + @schema_property("model_labels") + def model_labels(self): + return self._property_model_labels + + @model_labels.setter + def model_labels(self, value): + if value is None: + self._property_model_labels = None + return + + self.assert_isinstance(value, "model_labels", (dict,)) + self._property_model_labels = value + + @schema_property("framework") + def framework(self): + return self._property_framework + + @framework.setter + def framework(self, value): + if value is None: + self._property_framework = None + return + + self.assert_isinstance(value, "framework", six.string_types) + self._property_framework = value + + @schema_property("artifacts") + def artifacts(self): + return self._property_artifacts + + @artifacts.setter + def artifacts(self, value): + if value is None: + self._property_artifacts = None + return + + self.assert_isinstance(value, "artifacts", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [Artifact.from_dict(v) if isinstance(v, dict) else v for v in value] + else: + self.assert_isinstance(value, "artifacts", Artifact, is_array=True) + self._property_artifacts = value + + +class TaskStatusEnum(StringEnum): + created = "created" + queued = "queued" + in_progress = "in_progress" + stopped = "stopped" + published = "published" + publishing = "publishing" + closed = "closed" + failed = "failed" + completed = "completed" + unknown = "unknown" + + +class TaskTypeEnum(StringEnum): + training = "training" + testing = "testing" + inference = "inference" + data_processing = "data_processing" + application = "application" + monitor = "monitor" + controller = "controller" + optimizer = "optimizer" + service = "service" + qc = "qc" + custom = "custom" + + +class LastMetricsEvent(NonStrictDataModel): + """ + :param metric: Metric name + :type metric: str + :param variant: Variant name + :type variant: str + :param value: Last value reported + :type value: float + :param min_value: Minimum value reported + :type min_value: float + :param max_value: Maximum value reported + :type max_value: float + """ + + _schema = { + "properties": { + "max_value": { + "description": "Maximum value reported", + "type": ["number", "null"], + }, + "metric": {"description": "Metric name", "type": ["string", "null"]}, + "min_value": { + "description": "Minimum value reported", + "type": ["number", "null"], + }, + "value": {"description": "Last value reported", "type": ["number", "null"]}, + "variant": {"description": "Variant name", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__( + self, + metric=None, + variant=None, + value=None, + min_value=None, + max_value=None, + **kwargs + ): + super(LastMetricsEvent, self).__init__(**kwargs) + self.metric = metric + self.variant = variant + self.value = value + self.min_value = min_value + self.max_value = max_value + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + @schema_property("value") + def value(self): + return self._property_value + + @value.setter + def value(self, value): + if value is None: + self._property_value = None + return + + self.assert_isinstance(value, "value", six.integer_types + (float,)) + self._property_value = value + + @schema_property("min_value") + def min_value(self): + return self._property_min_value + + @min_value.setter + def min_value(self, value): + if value is None: + self._property_min_value = None + return + + self.assert_isinstance(value, "min_value", six.integer_types + (float,)) + self._property_min_value = value + + @schema_property("max_value") + def max_value(self): + return self._property_max_value + + @max_value.setter + def max_value(self, value): + if value is None: + self._property_max_value = None + return + + self.assert_isinstance(value, "max_value", six.integer_types + (float,)) + self._property_max_value = value + + +class LastMetricsVariants(NonStrictDataModel): + """ + Last metric events, one for each variant hash + + """ + + _schema = { + "additionalProperties": {"$ref": "#/definitions/last_metrics_event"}, + "description": "Last metric events, one for each variant hash", + "type": "object", + } + + +class ParamsItem(NonStrictDataModel): + """ + :param section: Section that the parameter belongs to + :type section: str + :param name: Name of the parameter. The combination of section and name should + be unique + :type name: str + :param value: Value of the parameter + :type value: str + :param type: Type of the parameter. Optional + :type type: str + :param description: The parameter description. Optional + :type description: str + """ + + _schema = { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. The combination of section and name should be unique", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, section=None, name=None, value=None, type=None, description=None, **kwargs + ): + super(ParamsItem, self).__init__(**kwargs) + self.section = section + self.name = name + self.value = value + self.type = type + self.description = description + + @schema_property("section") + def section(self): + return self._property_section + + @section.setter + def section(self, value): + if value is None: + self._property_section = None + return + + self.assert_isinstance(value, "section", six.string_types) + self._property_section = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("value") + def value(self): + return self._property_value + + @value.setter + def value(self, value): + if value is None: + self._property_value = None + return + + self.assert_isinstance(value, "value", six.string_types) + self._property_value = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + + self.assert_isinstance(value, "type", six.string_types) + self._property_type = value + + @schema_property("description") + def description(self): + return self._property_description + + @description.setter + def description(self, value): + if value is None: + self._property_description = None + return + + self.assert_isinstance(value, "description", six.string_types) + self._property_description = value + + +class ConfigurationItem(NonStrictDataModel): + """ + :param name: Name of the parameter. Should be unique + :type name: str + :param value: Value of the parameter + :type value: str + :param type: Type of the parameter. Optional + :type type: str + :param description: The parameter description. Optional + :type description: str + """ + + _schema = { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. Should be unique", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, name=None, value=None, type=None, description=None, **kwargs): + super(ConfigurationItem, self).__init__(**kwargs) + self.name = name + self.value = value + self.type = type + self.description = description + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("value") + def value(self): + return self._property_value + + @value.setter + def value(self, value): + if value is None: + self._property_value = None + return + + self.assert_isinstance(value, "value", six.string_types) + self._property_value = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + + self.assert_isinstance(value, "type", six.string_types) + self._property_type = value + + @schema_property("description") + def description(self): + return self._property_description + + @description.setter + def description(self, value): + if value is None: + self._property_description = None + return + + self.assert_isinstance(value, "description", six.string_types) + self._property_description = value + + +class ParamKey(NonStrictDataModel): + """ + :param section: Section that the parameter belongs to + :type section: str + :param name: Name of the parameter. If the name is ommitted then the + corresponding operation is performed on the whole section + :type name: str + """ + + _schema = { + "properties": { + "name": { + "description": "Name of the parameter. If the name is ommitted then the corresponding operation is performed on the whole section", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, section=None, name=None, **kwargs): + super(ParamKey, self).__init__(**kwargs) + self.section = section + self.name = name + + @schema_property("section") + def section(self): + return self._property_section + + @section.setter + def section(self, value): + if value is None: + self._property_section = None + return + + self.assert_isinstance(value, "section", six.string_types) + self._property_section = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + +class SectionParams(dict, NonStrictDataModel): + """ + Task section params + + """ + + _schema = { + # 'additionalProperties': {'$ref': '#/definitions/params_item'}, + "additionalProperties": True, + "description": "Task section params", + "type": "object", + } + + def __init__(self, *args, **kwargs): + self.assert_isinstance(args, "section_params", dict, is_array=True) + kwargs.update(args) + self.assert_isinstance( + kwargs.values(), "params", (ParamsItem, dict), is_array=True + ) + for k, v in kwargs.items(): + if isinstance(v, dict): + kwargs[k] = ParamsItem(**v) + super(SectionParams, self).__init__(**kwargs) + + +class ReplaceHyperparamsEnum(StringEnum): + none = "none" + section = "section" + all = "all" + + +class Task(NonStrictDataModel): + """ + :param id: Task id + :type id: str + :param name: Task Name + :type name: str + :param user: Associated user id + :type user: str + :param company: Company ID + :type company: str + :param type: Type of task. Values: 'training', 'testing' + :type type: TaskTypeEnum + :param status: + :type status: TaskStatusEnum + :param comment: Free text comment + :type comment: str + :param created: Task creation time (UTC) + :type created: datetime.datetime + :param started: Task start time (UTC) + :type started: datetime.datetime + :param completed: Task end time (UTC) + :type completed: datetime.datetime + :param active_duration: Task duration time (seconds) + :type active_duration: int + :param parent: Parent task id + :type parent: str + :param project: Project ID of the project to which this task is assigned + :type project: str + :param output: Task output params + :type output: Output + :param execution: Task execution params + :type execution: Execution + :param container: Docker container parameters + :type container: dict + :param models: Task models + :type models: TaskModels + :param script: Script info + :type script: Script + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param status_changed: Last status change time + :type status_changed: datetime.datetime + :param status_message: free text string representing info about the status + :type status_message: str + :param status_reason: Reason for last status change + :type status_reason: str + :param published: Last status change time + :type published: datetime.datetime + :param last_worker: ID of last worker that handled the task + :type last_worker: str + :param last_worker_report: Last time a worker reported while working on this + task + :type last_worker_report: datetime.datetime + :param last_update: Last time this task was created, updated, changed or events + for this task were reported + :type last_update: datetime.datetime + :param last_change: Last time any update was done to the task + :type last_change: datetime.datetime + :param last_iteration: Last iteration reported for this task + :type last_iteration: int + :param last_metrics: Last metric variants (hash to events), one for each metric + hash + :type last_metrics: dict + :param hyperparams: Task hyper params per section + :type hyperparams: dict + :param configuration: Task configuration params + :type configuration: dict + :param runtime: Task runtime mapping + :type runtime: dict + """ + + _schema = { + "properties": { + "active_duration": { + "description": "Task duration time (seconds)", + "type": ["integer", "null"], + }, + "comment": {"description": "Free text comment", "type": ["string", "null"]}, + "company": {"description": "Company ID", "type": ["string", "null"]}, + "completed": { + "description": "Task end time (UTC)", + "format": "date-time", + "type": ["string", "null"], + }, + "configuration": { + "additionalProperties": {"$ref": "#/definitions/configuration_item"}, + "description": "Task configuration params", + "type": ["object", "null"], + }, + "container": { + "additionalProperties": {"type": ["string", "null"]}, + "description": "Docker container parameters", + "type": ["object", "null"], + }, + "created": { + "description": "Task creation time (UTC) ", + "format": "date-time", + "type": ["string", "null"], + }, + "execution": { + "description": "Task execution params", + "oneOf": [{"$ref": "#/definitions/execution"}, {"type": "null"}], + }, + "hyperparams": { + "additionalProperties": {"$ref": "#/definitions/section_params"}, + "description": "Task hyper params per section", + "type": ["object", "null"], + }, + "id": {"description": "Task id", "type": ["string", "null"]}, + "last_change": { + "description": "Last time any update was done to the task", + "format": "date-time", + "type": ["string", "null"], + }, + "last_iteration": { + "description": "Last iteration reported for this task", + "type": ["integer", "null"], + }, + "last_metrics": { + "additionalProperties": {"$ref": "#/definitions/last_metrics_variants"}, + "description": "Last metric variants (hash to events), one for each metric hash", + "type": ["object", "null"], + }, + "last_update": { + "description": "Last time this task was created, edited, changed or events for this task were reported", + "format": "date-time", + "type": ["string", "null"], + }, + "last_worker": { + "description": "ID of last worker that handled the task", + "type": ["string", "null"], + }, + "last_worker_report": { + "description": "Last time a worker reported while working on this task", + "format": "date-time", + "type": ["string", "null"], + }, + "models": { + "description": "Task models", + "oneOf": [{"$ref": "#/definitions/task_models"}, {"type": "null"}], + }, + "name": {"description": "Task Name", "type": ["string", "null"]}, + "output": { + "description": "Task output params", + "oneOf": [{"$ref": "#/definitions/output"}, {"type": "null"}], + }, + "parent": {"description": "Parent task id", "type": ["string", "null"]}, + "project": { + "description": "Project ID of the project to which this task is assigned", + "type": ["string", "null"], + }, + "published": { + "description": "Last status change time", + "format": "date-time", + "type": ["string", "null"], + }, + "runtime": { + "additionalProperties": True, + "description": "Task runtime mapping", + "type": ["object", "null"], + }, + "script": { + "description": "Script info", + "oneOf": [{"$ref": "#/definitions/script"}, {"type": "null"}], + }, + "started": { + "description": "Task start time (UTC)", + "format": "date-time", + "type": ["string", "null"], + }, + "status": { + "description": "", + "oneOf": [{"$ref": "#/definitions/task_status_enum"}, {"type": "null"}], + }, + "status_changed": { + "description": "Last status change time", + "format": "date-time", + "type": ["string", "null"], + }, + "status_message": { + "description": "free text string representing info about the status", + "type": ["string", "null"], + }, + "status_reason": { + "description": "Reason for last status change", + "type": ["string", "null"], + }, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "type": { + "description": "Type of task. Values: 'training', 'testing'", + "oneOf": [{"$ref": "#/definitions/task_type_enum"}, {"type": "null"}], + }, + "user": {"description": "Associated user id", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__( + self, + id=None, + name=None, + user=None, + company=None, + type=None, + status=None, + comment=None, + created=None, + started=None, + completed=None, + active_duration=None, + parent=None, + project=None, + output=None, + execution=None, + container=None, + models=None, + script=None, + tags=None, + system_tags=None, + status_changed=None, + status_message=None, + status_reason=None, + published=None, + last_worker=None, + last_worker_report=None, + last_update=None, + last_change=None, + last_iteration=None, + last_metrics=None, + hyperparams=None, + configuration=None, + runtime=None, + **kwargs + ): + super(Task, self).__init__(**kwargs) + self.id = id + self.name = name + self.user = user + self.company = company + self.type = type + self.status = status + self.comment = comment + self.created = created + self.started = started + self.completed = completed + self.active_duration = active_duration + self.parent = parent + self.project = project + self.output = output + self.execution = execution + self.container = container + self.models = models + self.script = script + self.tags = tags + self.system_tags = system_tags + self.status_changed = status_changed + self.status_message = status_message + self.status_reason = status_reason + self.published = published + self.last_worker = last_worker + self.last_worker_report = last_worker_report + self.last_update = last_update + self.last_change = last_change + self.last_iteration = last_iteration + self.last_metrics = last_metrics + self.hyperparams = hyperparams + self.configuration = configuration + self.runtime = runtime + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("user") + def user(self): + return self._property_user + + @user.setter + def user(self, value): + if value is None: + self._property_user = None + return + + self.assert_isinstance(value, "user", six.string_types) + self._property_user = value + + @schema_property("company") + def company(self): + return self._property_company + + @company.setter + def company(self, value): + if value is None: + self._property_company = None + return + + self.assert_isinstance(value, "company", six.string_types) + self._property_company = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + if isinstance(value, six.string_types): + try: + value = TaskTypeEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "type", enum.Enum) + self._property_type = value + + @schema_property("status") + def status(self): + return self._property_status + + @status.setter + def status(self, value): + if value is None: + self._property_status = None + return + if isinstance(value, six.string_types): + try: + value = TaskStatusEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "status", enum.Enum) + self._property_status = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("created") + def created(self): + return self._property_created + + @created.setter + def created(self, value): + if value is None: + self._property_created = None + return + + self.assert_isinstance(value, "created", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_created = value + + @schema_property("started") + def started(self): + return self._property_started + + @started.setter + def started(self, value): + if value is None: + self._property_started = None + return + + self.assert_isinstance(value, "started", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_started = value + + @schema_property("completed") + def completed(self): + return self._property_completed + + @completed.setter + def completed(self, value): + if value is None: + self._property_completed = None + return + + self.assert_isinstance(value, "completed", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_completed = value + + @schema_property("active_duration") + def active_duration(self): + return self._property_active_duration + + @active_duration.setter + def active_duration(self, value): + if value is None: + self._property_active_duration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "active_duration", six.integer_types) + self._property_active_duration = value + + @schema_property("parent") + def parent(self): + return self._property_parent + + @parent.setter + def parent(self, value): + if value is None: + self._property_parent = None + return + + self.assert_isinstance(value, "parent", six.string_types) + self._property_parent = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("output") + def output(self): + return self._property_output + + @output.setter + def output(self, value): + if value is None: + self._property_output = None + return + if isinstance(value, dict): + value = Output.from_dict(value) + else: + self.assert_isinstance(value, "output", Output) + self._property_output = value + + @schema_property("execution") + def execution(self): + return self._property_execution + + @execution.setter + def execution(self, value): + if value is None: + self._property_execution = None + return + if isinstance(value, dict): + value = Execution.from_dict(value) + else: + self.assert_isinstance(value, "execution", Execution) + self._property_execution = value + + @schema_property("container") + def container(self): + return self._property_container + + @container.setter + def container(self, value): + if value is None: + self._property_container = None + return + + self.assert_isinstance(value, "container", (dict,)) + self._property_container = value + + @schema_property("models") + def models(self): + return self._property_models + + @models.setter + def models(self, value): + if value is None: + self._property_models = None + return + if isinstance(value, dict): + value = TaskModels.from_dict(value) + else: + self.assert_isinstance(value, "models", TaskModels) + self._property_models = value + + @schema_property("script") + def script(self): + return self._property_script + + @script.setter + def script(self, value): + if value is None: + self._property_script = None + return + if isinstance(value, dict): + value = Script.from_dict(value) + else: + self.assert_isinstance(value, "script", Script) + self._property_script = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("status_changed") + def status_changed(self): + return self._property_status_changed + + @status_changed.setter + def status_changed(self, value): + if value is None: + self._property_status_changed = None + return + + self.assert_isinstance(value, "status_changed", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_status_changed = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("published") + def published(self): + return self._property_published + + @published.setter + def published(self, value): + if value is None: + self._property_published = None + return + + self.assert_isinstance(value, "published", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_published = value + + @schema_property("last_worker") + def last_worker(self): + return self._property_last_worker + + @last_worker.setter + def last_worker(self, value): + if value is None: + self._property_last_worker = None + return + + self.assert_isinstance(value, "last_worker", six.string_types) + self._property_last_worker = value + + @schema_property("last_worker_report") + def last_worker_report(self): + return self._property_last_worker_report + + @last_worker_report.setter + def last_worker_report(self, value): + if value is None: + self._property_last_worker_report = None + return + + self.assert_isinstance( + value, "last_worker_report", six.string_types + (datetime,) + ) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_last_worker_report = value + + @schema_property("last_update") + def last_update(self): + return self._property_last_update + + @last_update.setter + def last_update(self, value): + if value is None: + self._property_last_update = None + return + + self.assert_isinstance(value, "last_update", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_last_update = value + + @schema_property("last_change") + def last_change(self): + return self._property_last_change + + @last_change.setter + def last_change(self, value): + if value is None: + self._property_last_change = None + return + + self.assert_isinstance(value, "last_change", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_last_change = value + + @schema_property("last_iteration") + def last_iteration(self): + return self._property_last_iteration + + @last_iteration.setter + def last_iteration(self, value): + if value is None: + self._property_last_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "last_iteration", six.integer_types) + self._property_last_iteration = value + + @schema_property("last_metrics") + def last_metrics(self): + return self._property_last_metrics + + @last_metrics.setter + def last_metrics(self, value): + if value is None: + self._property_last_metrics = None + return + + self.assert_isinstance(value, "last_metrics", (dict,)) + self._property_last_metrics = value + + @schema_property("hyperparams") + def hyperparams(self): + return self._property_hyperparams + + @hyperparams.setter + def hyperparams(self, value): + if value is None: + self._property_hyperparams = None + return + + self.assert_isinstance(value, "hyperparams", dict) + self.assert_isinstance( + value.keys(), "hyperparams_keys", six.string_types, is_array=True + ) + self.assert_isinstance( + value.values(), "hyperparams_values", (SectionParams, dict), is_array=True + ) + value = dict( + (k, SectionParams(**v) if isinstance(v, dict) else v) + for k, v in value.items() + ) + + self._property_hyperparams = value + + @schema_property("configuration") + def configuration(self): + return self._property_configuration + + @configuration.setter + def configuration(self, value): + if value is None: + self._property_configuration = None + return + + self.assert_isinstance(value, "configuration", dict) + self.assert_isinstance( + value.keys(), "configuration_keys", six.string_types, is_array=True + ) + self.assert_isinstance( + value.values(), + "configuration_values", + (ConfigurationItem, dict), + is_array=True, + ) + + value = dict( + (k, ConfigurationItem(**v) if isinstance(v, dict) else v) + for k, v in value.items() + ) + + self._property_configuration = value + + @schema_property("runtime") + def runtime(self): + return self._property_runtime + + @runtime.setter + def runtime(self, value): + if value is None: + self._property_runtime = None + return + + self.assert_isinstance(value, "runtime", (dict,)) + self._property_runtime = value + + +class TaskUrls(NonStrictDataModel): + """ + :param model_urls: + :type model_urls: Sequence[str] + :param event_urls: + :type event_urls: Sequence[str] + :param artifact_urls: + :type artifact_urls: Sequence[str] + """ + + _schema = { + "properties": { + "artifact_urls": {"items": {"type": "string"}, "type": ["array", "null"]}, + "event_urls": {"items": {"type": "string"}, "type": ["array", "null"]}, + "model_urls": {"items": {"type": "string"}, "type": ["array", "null"]}, + }, + "type": "object", + } + + def __init__(self, model_urls=None, event_urls=None, artifact_urls=None, **kwargs): + super(TaskUrls, self).__init__(**kwargs) + self.model_urls = model_urls + self.event_urls = event_urls + self.artifact_urls = artifact_urls + + @schema_property("model_urls") + def model_urls(self): + return self._property_model_urls + + @model_urls.setter + def model_urls(self, value): + if value is None: + self._property_model_urls = None + return + + self.assert_isinstance(value, "model_urls", (list, tuple)) + + self.assert_isinstance(value, "model_urls", six.string_types, is_array=True) + self._property_model_urls = value + + @schema_property("event_urls") + def event_urls(self): + return self._property_event_urls + + @event_urls.setter + def event_urls(self, value): + if value is None: + self._property_event_urls = None + return + + self.assert_isinstance(value, "event_urls", (list, tuple)) + + self.assert_isinstance(value, "event_urls", six.string_types, is_array=True) + self._property_event_urls = value + + @schema_property("artifact_urls") + def artifact_urls(self): + return self._property_artifact_urls + + @artifact_urls.setter + def artifact_urls(self, value): + if value is None: + self._property_artifact_urls = None + return + + self.assert_isinstance(value, "artifact_urls", (list, tuple)) + + self.assert_isinstance(value, "artifact_urls", six.string_types, is_array=True) + self._property_artifact_urls = value + + +class AddOrUpdateArtifactsRequest(Request): + """ + Update existing artifacts (search by key/mode) and add new ones + + :param task: Task ID + :type task: str + :param artifacts: Artifacts to add or update + :type artifacts: Sequence[Artifact] + :param force: If set to True then both new and running task artifacts can be + edited. Otherwise only the new task ones. Default is False + :type force: bool + """ + + _service = "tasks" + _action = "add_or_update_artifacts" + _version = "2.20" + _schema = { + "definitions": { + "artifact": { + "properties": { + "content_size": { + "description": "Raw data length in bytes", + "type": "integer", + }, + "display_data": { + "description": "User-defined list of key/value pairs, sorted", + "items": {"items": {"type": "string"}, "type": "array"}, + "type": "array", + }, + "hash": { + "description": "Hash of entire raw data", + "type": "string", + }, + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output indication", + }, + "timestamp": { + "description": "Epoch time when artifact was created", + "type": "integer", + }, + "type": { + "description": "System defined type", + "type": "string", + }, + "type_data": { + "$ref": "#/definitions/artifact_type_data", + "description": "Additional fields defined by the system", + }, + "uri": {"description": "Raw data location", "type": "string"}, + }, + "required": ["key", "type"], + "type": "object", + }, + "artifact_mode_enum": { + "default": "output", + "enum": ["input", "output"], + "type": "string", + }, + "artifact_type_data": { + "properties": { + "content_type": { + "description": "System defined raw data content type", + "type": ["string", "null"], + }, + "data_hash": { + "description": "Hash of raw data, without any headers or descriptive parts", + "type": ["string", "null"], + }, + "preview": { + "description": "Description or textual data", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + }, + "properties": { + "artifacts": { + "description": "Artifacts to add or update", + "items": {"$ref": "#/definitions/artifact"}, + "type": "array", + }, + "force": { + "description": "If set to True then both new and running task artifacts can be edited. Otherwise only the new task ones. Default is False", + "type": "boolean", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "artifacts"], + "type": "object", + } + + def __init__(self, task, artifacts, force=None, **kwargs): + super(AddOrUpdateArtifactsRequest, self).__init__(**kwargs) + self.task = task + self.artifacts = artifacts + self.force = force + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("artifacts") + def artifacts(self): + return self._property_artifacts + + @artifacts.setter + def artifacts(self, value): + if value is None: + self._property_artifacts = None + return + + self.assert_isinstance(value, "artifacts", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [Artifact.from_dict(v) if isinstance(v, dict) else v for v in value] + else: + self.assert_isinstance(value, "artifacts", Artifact, is_array=True) + self._property_artifacts = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class AddOrUpdateArtifactsResponse(Response): + """ + Response of tasks.add_or_update_artifacts endpoint. + + :param updated: Indicates if the task was updated successfully + :type updated: int + """ + + _service = "tasks" + _action = "add_or_update_artifacts" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Indicates if the task was updated successfully", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(AddOrUpdateArtifactsResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class AddOrUpdateModelRequest(Request): + """ + Add or update task model + + :param task: ID of the task + :type task: str + :param name: The task model name + :type name: str + :param model: The model ID + :type model: str + :param type: The task model type + :type type: ModelTypeEnum + :param iteration: Iteration (used to update task statistics) + :type iteration: int + """ + + _service = "tasks" + _action = "add_or_update_model" + _version = "2.20" + _schema = { + "definitions": { + "model_type_enum": {"enum": ["input", "output"], "type": "string"} + }, + "properties": { + "iteration": { + "description": "Iteration (used to update task statistics)", + "type": "integer", + }, + "model": {"description": "The model ID", "type": "string"}, + "name": {"description": "The task model name", "type": "string"}, + "task": {"description": "ID of the task", "type": "string"}, + "type": { + "$ref": "#/definitions/model_type_enum", + "description": "The task model type", + }, + }, + "required": ["task", "name", "model", "type"], + "type": "object", + } + + def __init__(self, task, name, model, type, iteration=None, **kwargs): + super(AddOrUpdateModelRequest, self).__init__(**kwargs) + self.task = task + self.name = name + self.model = model + self.type = type + self.iteration = iteration + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("model") + def model(self): + return self._property_model + + @model.setter + def model(self, value): + if value is None: + self._property_model = None + return + + self.assert_isinstance(value, "model", six.string_types) + self._property_model = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + if isinstance(value, six.string_types): + try: + value = ModelTypeEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "type", enum.Enum) + self._property_type = value + + @schema_property("iteration") + def iteration(self): + return self._property_iteration + + @iteration.setter + def iteration(self, value): + if value is None: + self._property_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "iteration", six.integer_types) + self._property_iteration = value + + +class AddOrUpdateModelResponse(Response): + """ + Response of tasks.add_or_update_model endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + """ + + _service = "tasks" + _action = "add_or_update_model" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(AddOrUpdateModelResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class ArchiveRequest(Request): + """ + Archive tasks. + If a task is queued it will first be dequeued and then archived. + + + :param tasks: List of task ids + :type tasks: Sequence[str] + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "archive" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "tasks": { + "description": "List of task ids", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["tasks"], + "type": "object", + } + + def __init__(self, tasks, status_reason=None, status_message=None, **kwargs): + super(ArchiveRequest, self).__init__(**kwargs) + self.tasks = tasks + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + + self.assert_isinstance(value, "tasks", six.string_types, is_array=True) + self._property_tasks = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class ArchiveResponse(Response): + """ + Response of tasks.archive endpoint. + + :param archived: Indicates number of archived tasks + :type archived: int + """ + + _service = "tasks" + _action = "archive" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "archived": { + "description": "Indicates number of archived tasks", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, archived=None, **kwargs): + super(ArchiveResponse, self).__init__(**kwargs) + self.archived = archived + + @schema_property("archived") + def archived(self): + return self._property_archived + + @archived.setter + def archived(self, value): + if value is None: + self._property_archived = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "archived", six.integer_types) + self._property_archived = value + + +class ArchiveManyRequest(Request): + """ + Archive tasks + + :param ids: IDs of the tasks to archive + :type ids: Sequence[str] + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "archive_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "IDs of the tasks to archive", + "items": {"type": "string"}, + "type": "array", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + }, + "required": ["ids"], + "response": { + "properties": { + "succeeded": { + "items": { + "properties": { + "archived": { + "description": "Indicates whether the task was archived", + "type": "boolean", + } + } + } + } + } + }, + "type": "object", + } + + def __init__(self, ids, status_reason=None, status_message=None, **kwargs): + super(ArchiveManyRequest, self).__init__(**kwargs) + self.ids = ids + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class ArchiveManyResponse(Response): + """ + Response of tasks.archive_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "tasks" + _action = "archive_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "id": { + "description": "ID of the succeeded entity", + "type": "string", + } + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(ArchiveManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class CloneRequest(Request): + """ + Clone an existing task + + :param task: ID of the task + :type task: str + :param new_task_name: The name of the cloned task. If not provided then taken + from the original task + :type new_task_name: str + :param new_task_comment: The comment of the cloned task. If not provided then + taken from the original task + :type new_task_comment: str + :param new_task_tags: The user-defined tags of the cloned task. If not provided + then taken from the original task + :type new_task_tags: Sequence[str] + :param new_task_system_tags: The system tags of the cloned task. If not + provided then empty + :type new_task_system_tags: Sequence[str] + :param new_task_parent: The parent of the cloned task. If not provided then + taken from the original task + :type new_task_parent: str + :param new_task_project: The project of the cloned task. If not provided then + taken from the original task + :type new_task_project: str + :param new_task_hyperparams: The hyper params for the new task. If not provided + then taken from the original task + :type new_task_hyperparams: dict + :param new_task_configuration: The configuration for the new task. If not + provided then taken from the original task + :type new_task_configuration: dict + :param execution_overrides: The execution params for the cloned task. The + params not specified are taken from the original task + :type execution_overrides: Execution + :param validate_references: If set to 'false' then the task fields that are + copied from the original task are not validated. The default is false. + :type validate_references: bool + :param new_project_name: Clone task to a new project by this name (only if + `new_task_project` is not provided). If a project by this name already exists, + task will be cloned to existing project. + :type new_project_name: str + :param new_task_input_models: The list of input models for the cloned task. If + not specifed then copied from the original task + :type new_task_input_models: Sequence[TaskModelItem] + :param new_task_container: The docker container properties for the new task. If + not provided then taken from the original task + :type new_task_container: dict + """ + + _service = "tasks" + _action = "clone" + _version = "2.20" + _schema = { + "definitions": { + "artifact": { + "properties": { + "content_size": { + "description": "Raw data length in bytes", + "type": "integer", + }, + "display_data": { + "description": "User-defined list of key/value pairs, sorted", + "items": {"items": {"type": "string"}, "type": "array"}, + "type": "array", + }, + "hash": { + "description": "Hash of entire raw data", + "type": "string", + }, + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output indication", + }, + "timestamp": { + "description": "Epoch time when artifact was created", + "type": "integer", + }, + "type": { + "description": "System defined type", + "type": "string", + }, + "type_data": { + "$ref": "#/definitions/artifact_type_data", + "description": "Additional fields defined by the system", + }, + "uri": {"description": "Raw data location", "type": "string"}, + }, + "required": ["key", "type"], + "type": "object", + }, + "artifact_mode_enum": { + "default": "output", + "enum": ["input", "output"], + "type": "string", + }, + "artifact_type_data": { + "properties": { + "content_type": { + "description": "System defined raw data content type", + "type": ["string", "null"], + }, + "data_hash": { + "description": "Hash of raw data, without any headers or descriptive parts", + "type": ["string", "null"], + }, + "preview": { + "description": "Description or textual data", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "configuration_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. Should be unique", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "execution": { + "properties": { + "artifacts": { + "description": "Task artifacts", + "items": {"$ref": "#/definitions/artifact"}, + "type": ["array", "null"], + }, + "framework": { + "description": "Framework related to the task. Case insensitive. Mandatory for Training tasks. ", + "type": ["string", "null"], + }, + "model_desc": { + "additionalProperties": True, + "description": "Json object representing the Model descriptors", + "type": ["object", "null"], + }, + "model_labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model.\n The keys are the layers' names and the values are the IDs.\n Not applicable for Register (Import) tasks.\n Mandatory for Training tasks", + "type": ["object", "null"], + }, + "parameters": { + "additionalProperties": True, + "description": "Json object containing the Task parameters", + "type": ["object", "null"], + }, + "queue": { + "description": "Queue ID where task was queued.", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "params_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. The combination of section and name should be unique", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "section_params": { + "additionalProperties": {"$ref": "#/definitions/params_item"}, + "description": "Task section params", + "type": "object", + }, + "task_model_item": { + "properties": { + "model": {"description": "The model ID", "type": "string"}, + "name": { + "description": "The task model name", + "type": "string", + }, + }, + "required": ["name", "model"], + "type": "object", + }, + }, + "properties": { + "execution_overrides": { + "$ref": "#/definitions/execution", + "description": "The execution params for the cloned task. The params not specified are taken from the original task", + }, + "new_project_name": { + "description": "Clone task to a new project by this name (only if `new_task_project` is not provided). If a project by this name already exists, task will be cloned to existing project.", + "type": "string", + }, + "new_task_comment": { + "description": "The comment of the cloned task. If not provided then taken from the original task", + "type": "string", + }, + "new_task_configuration": { + "additionalProperties": {"$ref": "#/definitions/configuration_item"}, + "description": "The configuration for the new task. If not provided then taken from the original task", + "type": "object", + }, + "new_task_container": { + "additionalProperties": {"type": ["string", "null"]}, + "description": "The docker container properties for the new task. If not provided then taken from the original task", + "type": "object", + }, + "new_task_hyperparams": { + "additionalProperties": {"$ref": "#/definitions/section_params"}, + "description": "The hyper params for the new task. If not provided then taken from the original task", + "type": "object", + }, + "new_task_input_models": { + "description": "The list of input models for the cloned task. If not specifed then copied from the original task", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": "array", + }, + "new_task_name": { + "description": "The name of the cloned task. If not provided then taken from the original task", + "type": "string", + }, + "new_task_parent": { + "description": "The parent of the cloned task. If not provided then taken from the original task", + "type": "string", + }, + "new_task_project": { + "description": "The project of the cloned task. If not provided then taken from the original task", + "type": "string", + }, + "new_task_system_tags": { + "description": "The system tags of the cloned task. If not provided then empty", + "items": {"type": "string"}, + "type": "array", + }, + "new_task_tags": { + "description": "The user-defined tags of the cloned task. If not provided then taken from the original task", + "items": {"type": "string"}, + "type": "array", + }, + "task": {"description": "ID of the task", "type": "string"}, + "validate_references": { + "description": "If set to 'false' then the task fields that are copied from the original task are not validated. The default is false.", + "type": "boolean", + }, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + new_task_name=None, + new_task_comment=None, + new_task_tags=None, + new_task_system_tags=None, + new_task_parent=None, + new_task_project=None, + new_task_hyperparams=None, + new_task_configuration=None, + execution_overrides=None, + validate_references=None, + new_project_name=None, + new_task_input_models=None, + new_task_container=None, + **kwargs + ): + super(CloneRequest, self).__init__(**kwargs) + self.task = task + self.new_task_name = new_task_name + self.new_task_comment = new_task_comment + self.new_task_tags = new_task_tags + self.new_task_system_tags = new_task_system_tags + self.new_task_parent = new_task_parent + self.new_task_project = new_task_project + self.new_task_hyperparams = new_task_hyperparams + self.new_task_configuration = new_task_configuration + self.execution_overrides = execution_overrides + self.validate_references = validate_references + self.new_project_name = new_project_name + self.new_task_input_models = new_task_input_models + self.new_task_container = new_task_container + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("new_task_name") + def new_task_name(self): + return self._property_new_task_name + + @new_task_name.setter + def new_task_name(self, value): + if value is None: + self._property_new_task_name = None + return + + self.assert_isinstance(value, "new_task_name", six.string_types) + self._property_new_task_name = value + + @schema_property("new_task_comment") + def new_task_comment(self): + return self._property_new_task_comment + + @new_task_comment.setter + def new_task_comment(self, value): + if value is None: + self._property_new_task_comment = None + return + + self.assert_isinstance(value, "new_task_comment", six.string_types) + self._property_new_task_comment = value + + @schema_property("new_task_tags") + def new_task_tags(self): + return self._property_new_task_tags + + @new_task_tags.setter + def new_task_tags(self, value): + if value is None: + self._property_new_task_tags = None + return + + self.assert_isinstance(value, "new_task_tags", (list, tuple)) + + self.assert_isinstance(value, "new_task_tags", six.string_types, is_array=True) + self._property_new_task_tags = value + + @schema_property("new_task_system_tags") + def new_task_system_tags(self): + return self._property_new_task_system_tags + + @new_task_system_tags.setter + def new_task_system_tags(self, value): + if value is None: + self._property_new_task_system_tags = None + return + + self.assert_isinstance(value, "new_task_system_tags", (list, tuple)) + + self.assert_isinstance( + value, "new_task_system_tags", six.string_types, is_array=True + ) + self._property_new_task_system_tags = value + + @schema_property("new_task_parent") + def new_task_parent(self): + return self._property_new_task_parent + + @new_task_parent.setter + def new_task_parent(self, value): + if value is None: + self._property_new_task_parent = None + return + + self.assert_isinstance(value, "new_task_parent", six.string_types) + self._property_new_task_parent = value + + @schema_property("new_task_project") + def new_task_project(self): + return self._property_new_task_project + + @new_task_project.setter + def new_task_project(self, value): + if value is None: + self._property_new_task_project = None + return + + self.assert_isinstance(value, "new_task_project", six.string_types) + self._property_new_task_project = value + + @schema_property("new_task_hyperparams") + def new_task_hyperparams(self): + return self._property_new_task_hyperparams + + @new_task_hyperparams.setter + def new_task_hyperparams(self, value): + if value is None: + self._property_new_task_hyperparams = None + return + + self.assert_isinstance(value, "new_task_hyperparams", (dict,)) + self._property_new_task_hyperparams = value + + @schema_property("new_task_configuration") + def new_task_configuration(self): + return self._property_new_task_configuration + + @new_task_configuration.setter + def new_task_configuration(self, value): + if value is None: + self._property_new_task_configuration = None + return + + self.assert_isinstance(value, "new_task_configuration", (dict,)) + self._property_new_task_configuration = value + + @schema_property("execution_overrides") + def execution_overrides(self): + return self._property_execution_overrides + + @execution_overrides.setter + def execution_overrides(self, value): + if value is None: + self._property_execution_overrides = None + return + if isinstance(value, dict): + value = Execution.from_dict(value) + else: + self.assert_isinstance(value, "execution_overrides", Execution) + self._property_execution_overrides = value + + @schema_property("validate_references") + def validate_references(self): + return self._property_validate_references + + @validate_references.setter + def validate_references(self, value): + if value is None: + self._property_validate_references = None + return + + self.assert_isinstance(value, "validate_references", (bool,)) + self._property_validate_references = value + + @schema_property("new_project_name") + def new_project_name(self): + return self._property_new_project_name + + @new_project_name.setter + def new_project_name(self, value): + if value is None: + self._property_new_project_name = None + return + + self.assert_isinstance(value, "new_project_name", six.string_types) + self._property_new_project_name = value + + @schema_property("new_task_input_models") + def new_task_input_models(self): + return self._property_new_task_input_models + + @new_task_input_models.setter + def new_task_input_models(self, value): + if value is None: + self._property_new_task_input_models = None + return + + self.assert_isinstance(value, "new_task_input_models", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + TaskModelItem.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance( + value, "new_task_input_models", TaskModelItem, is_array=True + ) + self._property_new_task_input_models = value + + @schema_property("new_task_container") + def new_task_container(self): + return self._property_new_task_container + + @new_task_container.setter + def new_task_container(self, value): + if value is None: + self._property_new_task_container = None + return + + self.assert_isinstance(value, "new_task_container", (dict,)) + self._property_new_task_container = value + + +class CloneResponse(Response): + """ + Response of tasks.clone endpoint. + + :param id: ID of the new task + :type id: str + :param new_project: In case the new_project_name was specified returns the + target project details + :type new_project: dict + """ + + _service = "tasks" + _action = "clone" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "id": {"description": "ID of the new task", "type": ["string", "null"]}, + "new_project": { + "description": "In case the new_project_name was specified returns the target project details", + "properties": { + "id": { + "description": "The ID of the target project", + "type": "string", + }, + "name": { + "description": "The name of the target project", + "type": "string", + }, + }, + "type": ["object", "null"], + }, + }, + "type": "object", + } + + def __init__(self, id=None, new_project=None, **kwargs): + super(CloneResponse, self).__init__(**kwargs) + self.id = id + self.new_project = new_project + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("new_project") + def new_project(self): + return self._property_new_project + + @new_project.setter + def new_project(self, value): + if value is None: + self._property_new_project = None + return + + self.assert_isinstance(value, "new_project", (dict,)) + self._property_new_project = value + + +class CloseRequest(Request): + """ + Indicates that task is closed + + :param force: Allows forcing state change even if transition is not supported + :type force: bool + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "close" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "Allows forcing state change even if transition is not supported", + "type": ["boolean", "null"], + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, task, force=False, status_reason=None, status_message=None, **kwargs + ): + super(CloseRequest, self).__init__(**kwargs) + self.force = force + self.task = task + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class CloseResponse(Response): + """ + Response of tasks.close endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "tasks" + _action = "close" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(CloseResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class CompletedRequest(Request): + """ + Signal a task has completed + + :param force: If not true, call fails if the task status is not + in_progress/stopped + :type force: bool + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + :param publish: If set and the task is completed successfully then it is + published + :type publish: bool + """ + + _service = "tasks" + _action = "completed" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "If not true, call fails if the task status is not in_progress/stopped", + "type": ["boolean", "null"], + }, + "publish": { + "default": False, + "description": "If set and the task is completed successfully then it is published", + "type": "boolean", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + force=False, + status_reason=None, + status_message=None, + publish=False, + **kwargs + ): + super(CompletedRequest, self).__init__(**kwargs) + self.force = force + self.task = task + self.status_reason = status_reason + self.status_message = status_message + self.publish = publish + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + @schema_property("publish") + def publish(self): + return self._property_publish + + @publish.setter + def publish(self, value): + if value is None: + self._property_publish = None + return + + self.assert_isinstance(value, "publish", (bool,)) + self._property_publish = value + + +class CompletedResponse(Response): + """ + Response of tasks.completed endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + :param published: Number of tasks published (0 or 1) + :type published: int + """ + + _service = "tasks" + _action = "completed" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "published": { + "description": "Number of tasks published (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, published=None, **kwargs): + super(CompletedResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + self.published = published + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + @schema_property("published") + def published(self): + return self._property_published + + @published.setter + def published(self, value): + if value is None: + self._property_published = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "published", six.integer_types) + self._property_published = value + + +class CreateRequest(Request): + """ + Create a new task + + :param name: Task name. Unique within the company. + :type name: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param type: Type of task + :type type: TaskTypeEnum + :param comment: Free text comment + :type comment: str + :param parent: Parent task id Must be a completed task. + :type parent: str + :param project: Project ID of the project to which this task is assigned Must + exist[ab] + :type project: str + :param output_dest: Output storage id Must be a reference to an existing + storage. + :type output_dest: str + :param execution: Task execution params + :type execution: Execution + :param script: Script info + :type script: Script + :param hyperparams: Task hyper params per section + :type hyperparams: dict + :param configuration: Task configuration params + :type configuration: dict + :param models: Task models + :type models: TaskModels + :param container: Docker container parameters + :type container: dict + """ + + _service = "tasks" + _action = "create" + _version = "2.20" + _schema = { + "definitions": { + "artifact": { + "properties": { + "content_size": { + "description": "Raw data length in bytes", + "type": "integer", + }, + "display_data": { + "description": "User-defined list of key/value pairs, sorted", + "items": {"items": {"type": "string"}, "type": "array"}, + "type": "array", + }, + "hash": { + "description": "Hash of entire raw data", + "type": "string", + }, + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output indication", + }, + "timestamp": { + "description": "Epoch time when artifact was created", + "type": "integer", + }, + "type": { + "description": "System defined type", + "type": "string", + }, + "type_data": { + "$ref": "#/definitions/artifact_type_data", + "description": "Additional fields defined by the system", + }, + "uri": {"description": "Raw data location", "type": "string"}, + }, + "required": ["key", "type"], + "type": "object", + }, + "artifact_mode_enum": { + "default": "output", + "enum": ["input", "output"], + "type": "string", + }, + "artifact_type_data": { + "properties": { + "content_type": { + "description": "System defined raw data content type", + "type": ["string", "null"], + }, + "data_hash": { + "description": "Hash of raw data, without any headers or descriptive parts", + "type": ["string", "null"], + }, + "preview": { + "description": "Description or textual data", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "configuration_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. Should be unique", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "execution": { + "properties": { + "artifacts": { + "description": "Task artifacts", + "items": {"$ref": "#/definitions/artifact"}, + "type": ["array", "null"], + }, + "framework": { + "description": "Framework related to the task. Case insensitive. Mandatory for Training tasks. ", + "type": ["string", "null"], + }, + "model_desc": { + "additionalProperties": True, + "description": "Json object representing the Model descriptors", + "type": ["object", "null"], + }, + "model_labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model.\n The keys are the layers' names and the values are the IDs.\n Not applicable for Register (Import) tasks.\n Mandatory for Training tasks", + "type": ["object", "null"], + }, + "parameters": { + "additionalProperties": True, + "description": "Json object containing the Task parameters", + "type": ["object", "null"], + }, + "queue": { + "description": "Queue ID where task was queued.", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "params_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. The combination of section and name should be unique", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "script": { + "properties": { + "binary": { + "default": "python", + "description": "Binary to use when running the script", + "type": ["string", "null"], + }, + "branch": { + "description": "Repository branch id If not provided and tag not provided, default repository branch is used.", + "type": ["string", "null"], + }, + "diff": { + "description": "Uncommitted changes found in the repository when task was run", + "type": ["string", "null"], + }, + "entry_point": { + "description": "Path to execute within the repository", + "type": ["string", "null"], + }, + "repository": { + "description": "Name of the repository where the script is located", + "type": ["string", "null"], + }, + "requirements": { + "description": "A JSON object containing requirements strings by key", + "type": ["object", "null"], + }, + "tag": { + "description": "Repository tag", + "type": ["string", "null"], + }, + "version_num": { + "description": "Version (changeset) number. Optional (default is head version) Unused if tag is provided.", + "type": ["string", "null"], + }, + "working_dir": { + "description": "Path to the folder from which to run the script Default - root folder of repository", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "section_params": { + "additionalProperties": {"$ref": "#/definitions/params_item"}, + "description": "Task section params", + "type": "object", + }, + "task_model_item": { + "properties": { + "model": {"description": "The model ID", "type": "string"}, + "name": { + "description": "The task model name", + "type": "string", + }, + }, + "required": ["name", "model"], + "type": "object", + }, + "task_models": { + "properties": { + "input": { + "description": "The list of task input models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + "output": { + "description": "The list of task output models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + }, + "type": "object", + }, + "task_type_enum": { + "enum": [ + "training", + "testing", + "inference", + "data_processing", + "application", + "monitor", + "controller", + "optimizer", + "service", + "qc", + "custom", + ], + "type": "string", + }, + }, + "properties": { + "comment": {"description": "Free text comment ", "type": "string"}, + "configuration": { + "additionalProperties": {"$ref": "#/definitions/configuration_item"}, + "description": "Task configuration params", + "type": "object", + }, + "container": { + "additionalProperties": {"type": ["string", "null"]}, + "description": "Docker container parameters", + "type": "object", + }, + "execution": { + "$ref": "#/definitions/execution", + "description": "Task execution params", + }, + "hyperparams": { + "additionalProperties": {"$ref": "#/definitions/section_params"}, + "description": "Task hyper params per section", + "type": "object", + }, + "models": { + "$ref": "#/definitions/task_models", + "description": "Task models", + }, + "name": { + "description": "Task name. Unique within the company.", + "type": "string", + }, + "output_dest": { + "description": "Output storage id Must be a reference to an existing storage.", + "type": "string", + }, + "parent": { + "description": "Parent task id Must be a completed task.", + "type": "string", + }, + "project": { + "description": "Project ID of the project to which this task is assigned Must exist[ab]", + "type": "string", + }, + "script": {"$ref": "#/definitions/script", "description": "Script info"}, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + "type": { + "$ref": "#/definitions/task_type_enum", + "description": "Type of task", + }, + }, + "required": ["name", "type"], + "type": "object", + } + + def __init__( + self, + name, + type, + tags=None, + system_tags=None, + comment=None, + parent=None, + project=None, + input=None, + output_dest=None, + execution=None, + script=None, + hyperparams=None, + configuration=None, + models=None, + container=None, + **kwargs + ): + super(CreateRequest, self).__init__(**kwargs) + self.name = name + self.tags = tags + self.system_tags = system_tags + self.type = type + self.comment = comment + self.parent = parent + self.project = project + self.input = input + self.output_dest = output_dest + self.execution = execution + self.script = script + self.hyperparams = hyperparams + self.configuration = configuration + self.models = models + self.container = container + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + if isinstance(value, six.string_types): + try: + value = TaskTypeEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "type", enum.Enum) + self._property_type = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("parent") + def parent(self): + return self._property_parent + + @parent.setter + def parent(self, value): + if value is None: + self._property_parent = None + return + + self.assert_isinstance(value, "parent", six.string_types) + self._property_parent = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("input") + def input(self): + return self._property_input + + @input.setter + def input(self, value): + self._property_input = value + + @schema_property("output_dest") + def output_dest(self): + return self._property_output_dest + + @output_dest.setter + def output_dest(self, value): + if value is None: + self._property_output_dest = None + return + + self.assert_isinstance(value, "output_dest", six.string_types) + self._property_output_dest = value + + @schema_property("execution") + def execution(self): + return self._property_execution + + @execution.setter + def execution(self, value): + if value is None: + self._property_execution = None + return + if isinstance(value, dict): + value = Execution.from_dict(value) + else: + self.assert_isinstance(value, "execution", Execution) + self._property_execution = value + + @schema_property("script") + def script(self): + return self._property_script + + @script.setter + def script(self, value): + if value is None: + self._property_script = None + return + if isinstance(value, dict): + value = Script.from_dict(value) + else: + self.assert_isinstance(value, "script", Script) + self._property_script = value + + @schema_property("hyperparams") + def hyperparams(self): + return self._property_hyperparams + + @hyperparams.setter + def hyperparams(self, value): + if value is None: + self._property_hyperparams = None + return + + self.assert_isinstance(value, "hyperparams", dict) + self.assert_isinstance( + value.keys(), "hyperparams_keys", six.string_types, is_array=True + ) + self.assert_isinstance( + value.values(), "hyperparams_values", (SectionParams, dict), is_array=True + ) + value = dict( + (k, SectionParams(**v) if isinstance(v, dict) else v) + for k, v in value.items() + ) + + self._property_hyperparams = value + + @schema_property("configuration") + def configuration(self): + return self._property_configuration + + @configuration.setter + def configuration(self, value): + if value is None: + self._property_configuration = None + return + + self.assert_isinstance(value, "configuration", dict) + self.assert_isinstance( + value.keys(), "configuration_keys", six.string_types, is_array=True + ) + self.assert_isinstance( + value.values(), + "configuration_values", + (ConfigurationItem, dict), + is_array=True, + ) + + value = dict( + (k, ConfigurationItem(**v) if isinstance(v, dict) else v) + for k, v in value.items() + ) + + self._property_configuration = value + + @schema_property("models") + def models(self): + return self._property_models + + @models.setter + def models(self, value): + if value is None: + self._property_models = None + return + if isinstance(value, dict): + value = TaskModels.from_dict(value) + else: + self.assert_isinstance(value, "models", TaskModels) + self._property_models = value + + @schema_property("container") + def container(self): + return self._property_container + + @container.setter + def container(self, value): + if value is None: + self._property_container = None + return + + self.assert_isinstance(value, "container", (dict,)) + self._property_container = value + + +class CreateResponse(Response): + """ + Response of tasks.create endpoint. + + :param id: ID of the task + :type id: str + """ + + _service = "tasks" + _action = "create" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "id": {"description": "ID of the task", "type": ["string", "null"]} + }, + "type": "object", + } + + def __init__(self, id=None, **kwargs): + super(CreateResponse, self).__init__(**kwargs) + self.id = id + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + +class DeleteRequest(Request): + """ + Delete a task along with any information stored for it (statistics, frame updates etc.) + Unless Force flag is provided, operation will fail if task has objects associated with it - i.e. children tasks and projects. + Models that refer to the deleted task will be updated with a task ID indicating a deleted task. + + + :param move_to_trash: Move task to trash instead of deleting it. For internal + use only, tasks in the trash are not visible from the API and cannot be + restored! + :type move_to_trash: bool + :param force: If not true, call fails if the task status is 'in_progress' + :type force: bool + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + :param return_file_urls: If set to 'true' then return the urls of the files + that were uploaded by this task. Default value is 'false' + :type return_file_urls: bool + """ + + _service = "tasks" + _action = "delete" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "If not true, call fails if the task status is 'in_progress'", + "type": ["boolean", "null"], + }, + "move_to_trash": { + "default": False, + "description": "Move task to trash instead of deleting it. For internal use only, tasks in the trash are not visible from the API and cannot be restored!", + "type": ["boolean", "null"], + }, + "return_file_urls": { + "description": "If set to 'true' then return the urls of the files that were uploaded by this task. Default value is 'false'", + "type": "boolean", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + move_to_trash=False, + force=False, + status_reason=None, + status_message=None, + return_file_urls=None, + **kwargs + ): + super(DeleteRequest, self).__init__(**kwargs) + self.move_to_trash = move_to_trash + self.force = force + self.task = task + self.status_reason = status_reason + self.status_message = status_message + self.return_file_urls = return_file_urls + + @schema_property("move_to_trash") + def move_to_trash(self): + return self._property_move_to_trash + + @move_to_trash.setter + def move_to_trash(self, value): + if value is None: + self._property_move_to_trash = None + return + + self.assert_isinstance(value, "move_to_trash", (bool,)) + self._property_move_to_trash = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + @schema_property("return_file_urls") + def return_file_urls(self): + return self._property_return_file_urls + + @return_file_urls.setter + def return_file_urls(self, value): + if value is None: + self._property_return_file_urls = None + return + + self.assert_isinstance(value, "return_file_urls", (bool,)) + self._property_return_file_urls = value + + +class DeleteResponse(Response): + """ + Response of tasks.delete endpoint. + + :param deleted: Indicates whether the task was deleted + :type deleted: bool + :param updated_children: Number of child tasks whose parent property was + updated + :type updated_children: int + :param updated_models: Number of models whose task property was updated + :type updated_models: int + :param events: Response from events.delete_for_task + :type events: dict + :param urls: The urls of the files that were uploaded by this task. Returned if + the 'return_file_urls' was set to 'true' + :type urls: TaskUrls + """ + + _service = "tasks" + _action = "delete" + _version = "2.20" + + _schema = { + "definitions": { + "task_urls": { + "properties": { + "artifact_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "event_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "model_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "deleted": { + "description": "Indicates whether the task was deleted", + "type": ["boolean", "null"], + }, + "events": { + "additionalProperties": True, + "description": "Response from events.delete_for_task", + "type": ["object", "null"], + }, + "updated_children": { + "description": "Number of child tasks whose parent property was updated", + "type": ["integer", "null"], + }, + "updated_models": { + "description": "Number of models whose task property was updated", + "type": ["integer", "null"], + }, + "urls": { + "description": "The urls of the files that were uploaded by this task. Returned if the 'return_file_urls' was set to 'true'", + "oneOf": [{"$ref": "#/definitions/task_urls"}, {"type": "null"}], + }, + }, + "type": "object", + } + + def __init__( + self, + deleted=None, + updated_children=None, + updated_models=None, + events=None, + urls=None, + **kwargs + ): + super(DeleteResponse, self).__init__(**kwargs) + self.deleted = deleted + self.updated_children = updated_children + self.updated_models = updated_models + self.events = events + self.urls = urls + + @schema_property("deleted") + def deleted(self): + return self._property_deleted + + @deleted.setter + def deleted(self, value): + if value is None: + self._property_deleted = None + return + + self.assert_isinstance(value, "deleted", (bool,)) + self._property_deleted = value + + @schema_property("updated_children") + def updated_children(self): + return self._property_updated_children + + @updated_children.setter + def updated_children(self, value): + if value is None: + self._property_updated_children = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated_children", six.integer_types) + self._property_updated_children = value + + @schema_property("updated_models") + def updated_models(self): + return self._property_updated_models + + @updated_models.setter + def updated_models(self, value): + if value is None: + self._property_updated_models = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated_models", six.integer_types) + self._property_updated_models = value + + @schema_property("events") + def events(self): + return self._property_events + + @events.setter + def events(self, value): + if value is None: + self._property_events = None + return + + self.assert_isinstance(value, "events", (dict,)) + self._property_events = value + + @schema_property("urls") + def urls(self): + return self._property_urls + + @urls.setter + def urls(self, value): + if value is None: + self._property_urls = None + return + if isinstance(value, dict): + value = TaskUrls.from_dict(value) + else: + self.assert_isinstance(value, "urls", TaskUrls) + self._property_urls = value + + +class DeleteArtifactsRequest(Request): + """ + Delete existing artifacts (search by key/mode) + + :param task: Task ID + :type task: str + :param artifacts: Artifacts to delete + :type artifacts: Sequence[ArtifactId] + :param force: If set to True then both new and running task artifacts can be + deleted. Otherwise only the new task ones. Default is False + :type force: bool + """ + + _service = "tasks" + _action = "delete_artifacts" + _version = "2.20" + _schema = { + "definitions": { + "artifact_id": { + "properties": { + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output indication", + }, + }, + "required": ["key"], + "type": "object", + }, + "artifact_mode_enum": { + "default": "output", + "enum": ["input", "output"], + "type": "string", + }, + }, + "properties": { + "artifacts": { + "description": "Artifacts to delete", + "items": {"$ref": "#/definitions/artifact_id"}, + "type": "array", + }, + "force": { + "description": "If set to True then both new and running task artifacts can be deleted. Otherwise only the new task ones. Default is False", + "type": "boolean", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "artifacts"], + "type": "object", + } + + def __init__(self, task, artifacts, force=None, **kwargs): + super(DeleteArtifactsRequest, self).__init__(**kwargs) + self.task = task + self.artifacts = artifacts + self.force = force + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("artifacts") + def artifacts(self): + return self._property_artifacts + + @artifacts.setter + def artifacts(self, value): + if value is None: + self._property_artifacts = None + return + + self.assert_isinstance(value, "artifacts", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + ArtifactId.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "artifacts", ArtifactId, is_array=True) + self._property_artifacts = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class DeleteArtifactsResponse(Response): + """ + Response of tasks.delete_artifacts endpoint. + + :param deleted: Indicates if the task was updated successfully + :type deleted: int + """ + + _service = "tasks" + _action = "delete_artifacts" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "deleted": { + "description": "Indicates if the task was updated successfully", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, deleted=None, **kwargs): + super(DeleteArtifactsResponse, self).__init__(**kwargs) + self.deleted = deleted + + @schema_property("deleted") + def deleted(self): + return self._property_deleted + + @deleted.setter + def deleted(self, value): + if value is None: + self._property_deleted = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "deleted", six.integer_types) + self._property_deleted = value + + +class DeleteConfigurationRequest(Request): + """ + Delete task configuration items + + :param task: Task ID + :type task: str + :param configuration: List of configuration itemss to delete + :type configuration: Sequence[str] + :param force: If set to True then both new and running task configuration can + be deleted. Otherwise only the new task ones. Default is False + :type force: bool + """ + + _service = "tasks" + _action = "delete_configuration" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "configuration": { + "description": "List of configuration itemss to delete", + "items": {"type": "string"}, + "type": "array", + }, + "force": { + "description": "If set to True then both new and running task configuration can be deleted. Otherwise only the new task ones. Default is False", + "type": "boolean", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "configuration"], + "type": "object", + } + + def __init__(self, task, configuration, force=None, **kwargs): + super(DeleteConfigurationRequest, self).__init__(**kwargs) + self.task = task + self.configuration = configuration + self.force = force + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("configuration") + def configuration(self): + return self._property_configuration + + @configuration.setter + def configuration(self, value): + if value is None: + self._property_configuration = None + return + + self.assert_isinstance(value, "configuration", dict) + self.assert_isinstance( + value.keys(), "configuration_keys", six.string_types, is_array=True + ) + self.assert_isinstance( + value.values(), + "configuration_values", + (ConfigurationItem, dict), + is_array=True, + ) + + value = dict( + (k, ConfigurationItem(**v) if isinstance(v, dict) else v) + for k, v in value.items() + ) + + self._property_configuration = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class DeleteConfigurationResponse(Response): + """ + Response of tasks.delete_configuration endpoint. + + :param deleted: Indicates if the task was updated successfully + :type deleted: int + """ + + _service = "tasks" + _action = "delete_configuration" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "deleted": { + "description": "Indicates if the task was updated successfully", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, deleted=None, **kwargs): + super(DeleteConfigurationResponse, self).__init__(**kwargs) + self.deleted = deleted + + @schema_property("deleted") + def deleted(self): + return self._property_deleted + + @deleted.setter + def deleted(self, value): + if value is None: + self._property_deleted = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "deleted", six.integer_types) + self._property_deleted = value + + +class DeleteHyperParamsRequest(Request): + """ + Delete task hyper parameters + + :param task: Task ID + :type task: str + :param hyperparams: List of hyper parameters to delete. In case a parameter + with an empty name is passed all the section will be deleted + :type hyperparams: Sequence[ParamKey] + :param force: If set to True then both new and running task hyper params can be + deleted. Otherwise only the new task ones. Default is False + :type force: bool + """ + + _service = "tasks" + _action = "delete_hyper_params" + _version = "2.20" + _schema = { + "definitions": { + "param_key": { + "properties": { + "name": { + "description": "Name of the parameter. If the name is ommitted then the corresponding operation is performed on the whole section", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "force": { + "description": "If set to True then both new and running task hyper params can be deleted. Otherwise only the new task ones. Default is False", + "type": "boolean", + }, + "hyperparams": { + "description": "List of hyper parameters to delete. In case a parameter with an empty name is passed all the section will be deleted", + "items": {"$ref": "#/definitions/param_key"}, + "type": "array", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "hyperparams"], + "type": "object", + } + + def __init__(self, task, hyperparams, force=None, **kwargs): + super(DeleteHyperParamsRequest, self).__init__(**kwargs) + self.task = task + self.hyperparams = hyperparams + self.force = force + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("hyperparams") + def hyperparams(self): + return self._property_hyperparams + + @hyperparams.setter + def hyperparams(self, value): + if value is None: + self._property_hyperparams = None + return + + self.assert_isinstance(value, "hyperparams", (ParamKey, dict), is_array=True) + value = [(ParamKey(**v) if isinstance(v, dict) else v) for v in value] + + self._property_hyperparams = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class DeleteHyperParamsResponse(Response): + """ + Response of tasks.delete_hyper_params endpoint. + + :param deleted: Indicates if the task was updated successfully + :type deleted: int + """ + + _service = "tasks" + _action = "delete_hyper_params" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "deleted": { + "description": "Indicates if the task was updated successfully", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, deleted=None, **kwargs): + super(DeleteHyperParamsResponse, self).__init__(**kwargs) + self.deleted = deleted + + @schema_property("deleted") + def deleted(self): + return self._property_deleted + + @deleted.setter + def deleted(self, value): + if value is None: + self._property_deleted = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "deleted", six.integer_types) + self._property_deleted = value + + +class DeleteManyRequest(Request): + """ + Delete tasks + + :param ids: IDs of the tasks to delete + :type ids: Sequence[str] + :param move_to_trash: Move task to trash instead of deleting it. For internal + use only, tasks in the trash are not visible from the API and cannot be + restored! + :type move_to_trash: bool + :param force: If not true, call fails if the task status is 'in_progress' + :type force: bool + :param return_file_urls: If set to 'true' then return the urls of the files + that were uploaded by the tasks. Default value is 'false' + :type return_file_urls: bool + :param delete_output_models: If set to 'true' then delete output models of the + tasks that are not referenced by other tasks. Default value is 'true' + :type delete_output_models: bool + """ + + _service = "tasks" + _action = "delete_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "delete_output_models": { + "description": "If set to 'true' then delete output models of the tasks that are not referenced by other tasks. Default value is 'true'", + "type": "boolean", + }, + "force": { + "default": False, + "description": "If not true, call fails if the task status is 'in_progress'", + "type": "boolean", + }, + "ids": { + "description": "IDs of the tasks to delete", + "items": {"type": "string"}, + "type": "array", + }, + "move_to_trash": { + "default": False, + "description": "Move task to trash instead of deleting it. For internal use only, tasks in the trash are not visible from the API and cannot be restored!", + "type": "boolean", + }, + "return_file_urls": { + "description": "If set to 'true' then return the urls of the files that were uploaded by the tasks. Default value is 'false'", + "type": "boolean", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__( + self, + ids, + move_to_trash=False, + force=False, + return_file_urls=None, + delete_output_models=None, + **kwargs + ): + super(DeleteManyRequest, self).__init__(**kwargs) + self.ids = ids + self.move_to_trash = move_to_trash + self.force = force + self.return_file_urls = return_file_urls + self.delete_output_models = delete_output_models + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("move_to_trash") + def move_to_trash(self): + return self._property_move_to_trash + + @move_to_trash.setter + def move_to_trash(self, value): + if value is None: + self._property_move_to_trash = None + return + + self.assert_isinstance(value, "move_to_trash", (bool,)) + self._property_move_to_trash = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("return_file_urls") + def return_file_urls(self): + return self._property_return_file_urls + + @return_file_urls.setter + def return_file_urls(self, value): + if value is None: + self._property_return_file_urls = None + return + + self.assert_isinstance(value, "return_file_urls", (bool,)) + self._property_return_file_urls = value + + @schema_property("delete_output_models") + def delete_output_models(self): + return self._property_delete_output_models + + @delete_output_models.setter + def delete_output_models(self, value): + if value is None: + self._property_delete_output_models = None + return + + self.assert_isinstance(value, "delete_output_models", (bool,)) + self._property_delete_output_models = value + + +class DeleteManyResponse(Response): + """ + Response of tasks.delete_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "tasks" + _action = "delete_many" + _version = "2.20" + + _schema = { + "definitions": { + "task_urls": { + "properties": { + "artifact_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "event_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "model_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "deleted": { + "description": "Indicates whether the task was deleted", + "type": "boolean", + }, + "deleted_models": { + "description": "Number of deleted output models", + "type": "integer", + }, + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "updated_children": { + "description": "Number of child tasks whose parent property was updated", + "type": ["integer", "null"], + }, + "updated_models": { + "description": "Number of models whose task property was updated", + "type": ["integer", "null"], + }, + "urls": { + "oneOf": [{"$ref": "#/definitions/task_urls"}, {"type": "null"}], + "description": "The urls of the files that were uploaded by the tasks. Returned if the 'return_file_urls' was set to 'true'", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(DeleteManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class DeleteModelsRequest(Request): + """ + Delete models from task + + :param task: ID of the task + :type task: str + :param models: The list of models to delete + :type models: Sequence[dict] + """ + + _service = "tasks" + _action = "delete_models" + _version = "2.20" + _schema = { + "definitions": { + "model_type_enum": {"enum": ["input", "output"], "type": "string"} + }, + "properties": { + "models": { + "description": "The list of models to delete", + "items": { + "properties": { + "name": { + "description": "The task model name", + "type": "string", + }, + "type": { + "$ref": "#/definitions/model_type_enum", + "description": "The task model type", + }, + }, + "required": ["name", "type"], + "type": "object", + }, + "type": "array", + }, + "task": {"description": "ID of the task", "type": "string"}, + }, + "required": ["task", "models"], + "type": "object", + } + + def __init__(self, task, models, **kwargs): + super(DeleteModelsRequest, self).__init__(**kwargs) + self.task = task + self.models = models + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("models") + def models(self): + return self._property_models + + @models.setter + def models(self, value): + if value is None: + self._property_models = None + return + + self.assert_isinstance(value, "models", (list, tuple)) + + self.assert_isinstance(value, "models", (dict,), is_array=True) + self._property_models = value + + +class DeleteModelsResponse(Response): + """ + Response of tasks.delete_models endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + """ + + _service = "tasks" + _action = "delete_models" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(DeleteModelsResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class DequeueRequest(Request): + """ + Remove a task from its queue. + Fails if task status is not queued. + + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "dequeue" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, status_reason=None, status_message=None, **kwargs): + super(DequeueRequest, self).__init__(**kwargs) + self.task = task + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class DequeueResponse(Response): + """ + Response of tasks.dequeue endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + :param dequeued: Number of tasks dequeued (0 or 1) + :type dequeued: int + """ + + _service = "tasks" + _action = "dequeue" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "dequeued": { + "description": "Number of tasks dequeued (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, dequeued=None, **kwargs): + super(DequeueResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + self.dequeued = dequeued + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + @schema_property("dequeued") + def dequeued(self): + return self._property_dequeued + + @dequeued.setter + def dequeued(self, value): + if value is None: + self._property_dequeued = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "dequeued", six.integer_types) + self._property_dequeued = value + + +class DequeueManyRequest(Request): + """ + Dequeue tasks + + :param ids: IDs of the tasks to dequeue + :type ids: Sequence[str] + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "dequeue_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "IDs of the tasks to dequeue", + "items": {"type": "string"}, + "type": "array", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__(self, ids, status_reason=None, status_message=None, **kwargs): + super(DequeueManyRequest, self).__init__(**kwargs) + self.ids = ids + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class DequeueManyResponse(Response): + """ + Response of tasks.dequeue_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "tasks" + _action = "dequeue_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "dequeued": { + "description": "Indicates whether the task was dequeued", + "type": "boolean", + }, + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": "object", + }, + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": "integer", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(DequeueManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class EditRequest(Request): + """ + Edit task's details. + + :param task: ID of the task + :type task: str + :param force: If not true, call fails if the task status is not 'created' + :type force: bool + :param name: Task name Unique within the company. + :type name: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param type: Type of task + :type type: TaskTypeEnum + :param comment: Free text comment + :type comment: str + :param parent: Parent task id Must be a completed task. + :type parent: str + :param project: Project ID of the project to which this task is assigned Must + exist[ab] + :type project: str + :param output_dest: Output storage id Must be a reference to an existing + storage. + :type output_dest: str + :param execution: Task execution params + :type execution: Execution + :param hyperparams: Task hyper params per section + :type hyperparams: dict + :param configuration: Task configuration params + :type configuration: dict + :param script: Script info + :type script: Script + :param models: Task models + :type models: TaskModels + :param container: Docker container parameters + :type container: dict + :param runtime: Task runtime mapping + :type runtime: dict + """ + + _service = "tasks" + _action = "edit" + _version = "2.20" + _schema = { + "definitions": { + "artifact": { + "properties": { + "content_size": { + "description": "Raw data length in bytes", + "type": "integer", + }, + "display_data": { + "description": "User-defined list of key/value pairs, sorted", + "items": {"items": {"type": "string"}, "type": "array"}, + "type": "array", + }, + "hash": { + "description": "Hash of entire raw data", + "type": "string", + }, + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output indication", + }, + "timestamp": { + "description": "Epoch time when artifact was created", + "type": "integer", + }, + "type": { + "description": "System defined type", + "type": "string", + }, + "type_data": { + "$ref": "#/definitions/artifact_type_data", + "description": "Additional fields defined by the system", + }, + "uri": {"description": "Raw data location", "type": "string"}, + }, + "required": ["key", "type"], + "type": "object", + }, + "artifact_mode_enum": { + "default": "output", + "enum": ["input", "output"], + "type": "string", + }, + "artifact_type_data": { + "properties": { + "content_type": { + "description": "System defined raw data content type", + "type": ["string", "null"], + }, + "data_hash": { + "description": "Hash of raw data, without any headers or descriptive parts", + "type": ["string", "null"], + }, + "preview": { + "description": "Description or textual data", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "configuration_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. Should be unique", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "execution": { + "properties": { + "artifacts": { + "description": "Task artifacts", + "items": {"$ref": "#/definitions/artifact"}, + "type": ["array", "null"], + }, + "framework": { + "description": "Framework related to the task. Case insensitive. Mandatory for Training tasks. ", + "type": ["string", "null"], + }, + "model_desc": { + "additionalProperties": True, + "description": "Json object representing the Model descriptors", + "type": ["object", "null"], + }, + "model_labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model.\n The keys are the layers' names and the values are the IDs.\n Not applicable for Register (Import) tasks.\n Mandatory for Training tasks", + "type": ["object", "null"], + }, + "parameters": { + "additionalProperties": True, + "description": "Json object containing the Task parameters", + "type": ["object", "null"], + }, + "queue": { + "description": "Queue ID where task was queued.", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "params_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. The combination of section and name should be unique", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "script": { + "properties": { + "binary": { + "default": "python", + "description": "Binary to use when running the script", + "type": ["string", "null"], + }, + "branch": { + "description": "Repository branch id If not provided and tag not provided, default repository branch is used.", + "type": ["string", "null"], + }, + "diff": { + "description": "Uncommitted changes found in the repository when task was run", + "type": ["string", "null"], + }, + "entry_point": { + "description": "Path to execute within the repository", + "type": ["string", "null"], + }, + "repository": { + "description": "Name of the repository where the script is located", + "type": ["string", "null"], + }, + "requirements": { + "description": "A JSON object containing requirements strings by key", + "type": ["object", "null"], + }, + "tag": { + "description": "Repository tag", + "type": ["string", "null"], + }, + "version_num": { + "description": "Version (changeset) number. Optional (default is head version) Unused if tag is provided.", + "type": ["string", "null"], + }, + "working_dir": { + "description": "Path to the folder from which to run the script Default - root folder of repository", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "section_params": { + "additionalProperties": {"$ref": "#/definitions/params_item"}, + "description": "Task section params", + "type": "object", + }, + "task_model_item": { + "properties": { + "model": {"description": "The model ID", "type": "string"}, + "name": { + "description": "The task model name", + "type": "string", + }, + }, + "required": ["name", "model"], + "type": "object", + }, + "task_models": { + "properties": { + "input": { + "description": "The list of task input models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + "output": { + "description": "The list of task output models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + }, + "type": "object", + }, + "task_type_enum": { + "enum": [ + "training", + "testing", + "inference", + "data_processing", + "application", + "monitor", + "controller", + "optimizer", + "service", + "qc", + "custom", + ], + "type": "string", + }, + }, + "properties": { + "comment": {"description": "Free text comment ", "type": "string"}, + "configuration": { + "additionalProperties": {"$ref": "#/definitions/configuration_item"}, + "description": "Task configuration params", + "type": "object", + }, + "container": { + "type": "object", + "description": "Docker container parameters", + "additionalProperties": {"type": ["string", "null"]}, + }, + "execution": { + "$ref": "#/definitions/execution", + "description": "Task execution params", + }, + "force": { + "default": False, + "description": "If not true, call fails if the task status is not 'created'", + "type": "boolean", + }, + "hyperparams": { + "additionalProperties": {"$ref": "#/definitions/section_params"}, + "description": "Task hyper params per section", + "type": "object", + }, + "models": { + "$ref": "#/definitions/task_models", + "description": "Task models", + }, + "name": { + "description": "Task name Unique within the company.", + "type": "string", + }, + "output_dest": { + "description": "Output storage id Must be a reference to an existing storage.", + "type": "string", + }, + "parent": { + "description": "Parent task id Must be a completed task.", + "type": "string", + }, + "project": { + "description": "Project ID of the project to which this task is assigned Must exist[ab]", + "type": "string", + }, + "runtime": { + "description": "Task runtime mapping", + "type": ["object", "null"], + "additionalProperties": True, + }, + "script": {"$ref": "#/definitions/script", "description": "Script info"}, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + "task": {"description": "ID of the task", "type": "string"}, + "type": { + "$ref": "#/definitions/task_type_enum", + "description": "Type of task", + }, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + force=False, + name=None, + tags=None, + system_tags=None, + type=None, + comment=None, + parent=None, + project=None, + output_dest=None, + execution=None, + hyperparams=None, + configuration=None, + script=None, + models=None, + container=None, + runtime=None, + **kwargs + ): + super(EditRequest, self).__init__(**kwargs) + self.task = task + self.force = force + self.name = name + self.tags = tags + self.system_tags = system_tags + self.type = type + self.comment = comment + self.parent = parent + self.project = project + self.output_dest = output_dest + self.execution = execution + self.hyperparams = hyperparams + self.configuration = configuration + self.script = script + self.models = models + self.container = container + self.runtime = runtime + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + if isinstance(value, six.string_types): + try: + value = TaskTypeEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "type", enum.Enum) + self._property_type = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("parent") + def parent(self): + return self._property_parent + + @parent.setter + def parent(self, value): + if value is None: + self._property_parent = None + return + + self.assert_isinstance(value, "parent", six.string_types) + self._property_parent = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("output_dest") + def output_dest(self): + return self._property_output_dest + + @output_dest.setter + def output_dest(self, value): + if value is None: + self._property_output_dest = None + return + + self.assert_isinstance(value, "output_dest", six.string_types) + self._property_output_dest = value + + @schema_property("execution") + def execution(self): + return self._property_execution + + @execution.setter + def execution(self, value): + if value is None: + self._property_execution = None + return + if isinstance(value, dict): + value = Execution.from_dict(value) + else: + self.assert_isinstance(value, "execution", Execution) + self._property_execution = value + + @schema_property("hyperparams") + def hyperparams(self): + return self._property_hyperparams + + @hyperparams.setter + def hyperparams(self, value): + if value is None: + self._property_hyperparams = None + return + + self.assert_isinstance(value, "hyperparams", dict) + self.assert_isinstance( + value.keys(), "hyperparams_keys", six.string_types, is_array=True + ) + self.assert_isinstance( + value.values(), "hyperparams_values", (SectionParams, dict), is_array=True + ) + value = dict( + (k, SectionParams(**v) if isinstance(v, dict) else v) + for k, v in value.items() + ) + + self._property_hyperparams = value + + @schema_property("configuration") + def configuration(self): + return self._property_configuration + + @configuration.setter + def configuration(self, value): + if value is None: + self._property_configuration = None + return + + self.assert_isinstance(value, "configuration", dict) + self.assert_isinstance( + value.keys(), "configuration_keys", six.string_types, is_array=True + ) + self.assert_isinstance( + value.values(), + "configuration_values", + (ConfigurationItem, dict), + is_array=True, + ) + + value = dict( + (k, ConfigurationItem(**v) if isinstance(v, dict) else v) + for k, v in value.items() + ) + + self._property_configuration = value + + @schema_property("script") + def script(self): + return self._property_script + + @script.setter + def script(self, value): + if value is None: + self._property_script = None + return + if isinstance(value, dict): + value = Script.from_dict(value) + else: + self.assert_isinstance(value, "script", Script) + self._property_script = value + + @schema_property("models") + def models(self): + return self._property_models + + @models.setter + def models(self, value): + if value is None: + self._property_models = None + return + if isinstance(value, dict): + value = TaskModels.from_dict(value) + else: + self.assert_isinstance(value, "models", TaskModels) + self._property_models = value + + @schema_property("container") + def container(self): + return self._property_container + + @container.setter + def container(self, value): + if value is None: + self._property_container = None + return + + self.assert_isinstance(value, "container", (dict,)) + self._property_container = value + + @schema_property("runtime") + def runtime(self): + return self._property_runtime + + @runtime.setter + def runtime(self, value): + if value is None: + self._property_runtime = None + return + + self.assert_isinstance(value, "runtime", (dict,)) + self._property_runtime = value + + +class EditResponse(Response): + """ + Response of tasks.edit endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "tasks" + _action = "edit" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(EditResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class EditConfigurationRequest(Request): + """ + Add or update task configuration + + :param task: Task ID + :type task: str + :param configuration: Task configuration items. The new ones will be added and + the already existing ones will be updated + :type configuration: Sequence[ConfigurationItem] + :param replace_configuration: If set then the all the configuration items will + be replaced with the provided ones. Otherwise only the provided configuration + items will be updated or added + :type replace_configuration: bool + :param force: If set to True then both new and running task configuration can + be edited. Otherwise only the new task ones. Default is False + :type force: bool + """ + + _service = "tasks" + _action = "edit_configuration" + _version = "2.20" + _schema = { + "definitions": { + "configuration_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. Should be unique", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "configuration": { + "description": "Task configuration items. The new ones will be added and the already existing ones will be updated", + "items": {"$ref": "#/definitions/configuration_item"}, + "type": "array", + }, + "force": { + "description": "If set to True then both new and running task configuration can be edited. Otherwise only the new task ones. Default is False", + "type": "boolean", + }, + "replace_configuration": { + "description": "If set then the all the configuration items will be replaced with the provided ones. Otherwise only the provided configuration items will be updated or added", + "type": "boolean", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "configuration"], + "type": "object", + } + + def __init__( + self, task, configuration, replace_configuration=None, force=None, **kwargs + ): + super(EditConfigurationRequest, self).__init__(**kwargs) + self.task = task + self.configuration = configuration + self.replace_configuration = replace_configuration + self.force = force + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("configuration") + def configuration(self): + return self._property_configuration + + @configuration.setter + def configuration(self, value): + if value is None: + self._property_configuration = None + return + + self.assert_isinstance( + value, "configuration", (dict, ConfigurationItem), is_array=True + ) + value = [(ConfigurationItem(**v) if isinstance(v, dict) else v) for v in value] + + self._property_configuration = value + + @schema_property("replace_configuration") + def replace_configuration(self): + return self._property_replace_configuration + + @replace_configuration.setter + def replace_configuration(self, value): + if value is None: + self._property_replace_configuration = None + return + + self.assert_isinstance(value, "replace_configuration", (bool,)) + self._property_replace_configuration = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class EditConfigurationResponse(Response): + """ + Response of tasks.edit_configuration endpoint. + + :param updated: Indicates if the task was updated successfully + :type updated: int + """ + + _service = "tasks" + _action = "edit_configuration" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Indicates if the task was updated successfully", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(EditConfigurationResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class EditHyperParamsRequest(Request): + """ + Add or update task hyper parameters + + :param task: Task ID + :type task: str + :param hyperparams: Task hyper parameters. The new ones will be added and the + already existing ones will be updated + :type hyperparams: Sequence[ParamsItem] + :param replace_hyperparams: Can be set to one of the following: 'all' - all the + hyper parameters will be replaced with the provided ones 'section' - the + sections that present in the new parameters will be replaced with the provided + parameters 'none' (the default value) - only the specific parameters will be + updated or added + :type replace_hyperparams: ReplaceHyperparamsEnum + :param force: If set to True then both new and running task hyper params can be + edited. Otherwise only the new task ones. Default is False + :type force: bool + """ + + _service = "tasks" + _action = "edit_hyper_params" + _version = "2.20" + _schema = { + "definitions": { + "params_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. The combination of section and name should be unique", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "replace_hyperparams_enum": { + "enum": ["none", "section", "all"], + "type": "string", + }, + }, + "properties": { + "force": { + "description": "If set to True then both new and running task hyper params can be edited. Otherwise only the new task ones. Default is False", + "type": "boolean", + }, + "hyperparams": { + "description": "Task hyper parameters. The new ones will be added and the already existing ones will be updated", + "items": {"$ref": "#/definitions/params_item"}, + "type": "array", + }, + "replace_hyperparams": { + "$ref": "#/definitions/replace_hyperparams_enum", + "description": "Can be set to one of the following:\n 'all' - all the hyper parameters will be replaced with the provided ones\n 'section' - the sections that present in the new parameters will be replaced with the provided parameters\n 'none' (the default value) - only the specific parameters will be updated or added", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "hyperparams"], + "type": "object", + } + + def __init__( + self, task, hyperparams, replace_hyperparams=None, force=None, **kwargs + ): + super(EditHyperParamsRequest, self).__init__(**kwargs) + self.task = task + self.hyperparams = hyperparams + self.replace_hyperparams = replace_hyperparams + self.force = force + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("hyperparams") + def hyperparams(self): + return self._property_hyperparams + + @hyperparams.setter + def hyperparams(self, value): + if value is None: + self._property_hyperparams = None + return + + self.assert_isinstance(value, "hyperparams", (dict, ParamsItem), is_array=True) + value = [(ParamsItem(**v) if isinstance(v, dict) else v) for v in value] + + self._property_hyperparams = value + + @schema_property("replace_hyperparams") + def replace_hyperparams(self): + return self._property_replace_hyperparams + + @replace_hyperparams.setter + def replace_hyperparams(self, value): + if value is None: + self._property_replace_hyperparams = None + return + if isinstance(value, six.string_types): + try: + value = ReplaceHyperparamsEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "replace_hyperparams", enum.Enum) + self._property_replace_hyperparams = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class EditHyperParamsResponse(Response): + """ + Response of tasks.edit_hyper_params endpoint. + + :param updated: Indicates if the task was updated successfully + :type updated: int + """ + + _service = "tasks" + _action = "edit_hyper_params" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Indicates if the task was updated successfully", + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(EditHyperParamsResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class EnqueueRequest(Request): + """ + Adds a task into a queue. + + Fails if task state is not 'created'. + + Fails if the following parameters in the task were not filled: + + * execution.script.repository + + * execution.script.entrypoint + + + :param queue: Queue id. If not provided and no queue name is passed then task + is added to the default queue. + :type queue: str + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + :param queue_name: The name of the queue. If the queue does not exist then it + is auto-created. Cannot be used together with the queue id + :type queue_name: str + """ + + _service = "tasks" + _action = "enqueue" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "queue": { + "description": "Queue id. If not provided, task is added to the default queue.", + "type": ["string", "null"], + }, + "queue_name": { + "description": "The name of the queue. If the queue does not exist then it is auto-created. Cannot be used together with the queue id", + "type": "string", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + queue=None, + status_reason=None, + status_message=None, + queue_name=None, + **kwargs + ): + super(EnqueueRequest, self).__init__(**kwargs) + self.queue = queue + self.task = task + self.status_reason = status_reason + self.status_message = status_message + self.queue_name = queue_name + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + @schema_property("queue_name") + def queue_name(self): + return self._property_queue_name + + @queue_name.setter + def queue_name(self, value): + if value is None: + self._property_queue_name = None + return + + self.assert_isinstance(value, "queue_name", six.string_types) + self._property_queue_name = value + + +class EnqueueResponse(Response): + """ + Response of tasks.enqueue endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + :param queued: Number of tasks queued (0 or 1) + :type queued: int + """ + + _service = "tasks" + _action = "enqueue" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "queued": { + "description": "Number of tasks queued (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, queued=None, **kwargs): + super(EnqueueResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + self.queued = queued + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + @schema_property("queued") + def queued(self): + return self._property_queued + + @queued.setter + def queued(self, value): + if value is None: + self._property_queued = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "queued", six.integer_types) + self._property_queued = value + + +class EnqueueManyRequest(Request): + """ + Enqueue tasks + + :param ids: IDs of the tasks to enqueue + :type ids: Sequence[str] + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + :param queue: Queue id. If not provided and no queue name is passed then tasks + are added to the default queue. + :type queue: str + :param validate_tasks: If set then tasks are validated before enqueue + :type validate_tasks: bool + :param queue_name: The name of the queue. If the queue does not exist then it + is auto-created. Cannot be used together with the queue id + :type queue_name: str + """ + + _service = "tasks" + _action = "enqueue_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "IDs of the tasks to enqueue", + "items": {"type": "string"}, + "type": "array", + }, + "queue": { + "description": "Queue id. If not provided and no queue name is passed then tasks are added to the default queue.", + "type": "string", + }, + "queue_name": { + "description": "The name of the queue. If the queue does not exist then it is auto-created. Cannot be used together with the queue id", + "type": "string", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "validate_tasks": { + "default": False, + "description": "If set then tasks are " "validated before enqueue", + "type": "boolean", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__( + self, + ids, + status_reason=None, + status_message=None, + queue=None, + validate_tasks=False, + queue_name=None, + **kwargs + ): + super(EnqueueManyRequest, self).__init__(**kwargs) + self.ids = ids + self.status_reason = status_reason + self.status_message = status_message + self.queue = queue + self.validate_tasks = validate_tasks + self.queue_name = queue_name + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("validate_tasks") + def validate_tasks(self): + return self._property_validate_tasks + + @validate_tasks.setter + def validate_tasks(self, value): + if value is None: + self._property_validate_tasks = None + return + + self.assert_isinstance(value, "validate_tasks", (bool,)) + self._property_validate_tasks = value + + @schema_property("queue_name") + def queue_name(self): + return self._property_queue_name + + @queue_name.setter + def queue_name(self, value): + if value is None: + self._property_queue_name = None + return + + self.assert_isinstance(value, "queue_name", six.string_types) + self._property_queue_name = value + + +class EnqueueManyResponse(Response): + """ + Response of tasks.enqueue_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "tasks" + _action = "enqueue_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": "object", + }, + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "queued": { + "description": "Indicates whether the task was queued", + "type": "boolean", + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": "integer", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(EnqueueManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class FailedRequest(Request): + """ + Indicates that task has failed + + :param force: Allows forcing state change even if transition is not supported + :type force: bool + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "failed" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "Allows forcing state change even if transition is not supported", + "type": ["boolean", "null"], + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, task, force=False, status_reason=None, status_message=None, **kwargs + ): + super(FailedRequest, self).__init__(**kwargs) + self.force = force + self.task = task + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class FailedResponse(Response): + """ + Response of tasks.failed endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "tasks" + _action = "failed" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(FailedResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class GetAllRequest(Request): + """ + Get all the company's tasks and all public tasks + + :param id: List of IDs to filter by + :type id: Sequence[str] + :param name: Get only tasks whose name matches this pattern (python regular + expression syntax) + :type name: str + :param user: List of user IDs used to filter results by the task's creating + user + :type user: Sequence[str] + :param project: List of project IDs + :type project: Sequence[str] + :param page: Page number, returns a specific page out of the resulting list of + tasks + :type page: int + :param page_size: Page size, specifies the number of results returned in each + page (last page may contain fewer results) + :type page_size: int + :param order_by: List of field names to order by. When search_text is used, + '@text_score' can be used as a field representing the text score of returned + documents. Use '-' prefix to specify descending order. Optional, recommended + when using page. If the first order field is a hyper parameter or metric then + string values are ordered according to numeric ordering rules where applicable + :type order_by: Sequence[str] + :param type: List of task types. One or more of: 'import', 'annotation', + 'training' or 'testing' (case insensitive) + :type type: Sequence[str] + :param tags: List of task user-defined tags. Use '-' prefix to exclude tags + :type tags: Sequence[str] + :param system_tags: List of task system tags. Use '-' prefix to exclude system + tags + :type system_tags: Sequence[str] + :param status: List of task status. + :type status: Sequence[TaskStatusEnum] + :param only_fields: List of task field names (nesting is supported using '.', + e.g. execution.model_labels). If provided, this list defines the query's + projection (only these fields will be returned for each result entry) + :type only_fields: Sequence[str] + :param parent: Parent ID + :type parent: str + :param status_changed: List of status changed constraint strings (utcformat, + epoch) with an optional prefix modifier (>, >=, <, <=) + :type status_changed: Sequence[str] + :param search_text: Free text search query + :type search_text: str + :param _all_: Multi-field pattern condition (all fields match pattern) + :type _all_: MultiFieldPatternData + :param _any_: Multi-field pattern condition (any field matches pattern) + :type _any_: MultiFieldPatternData + :param search_hidden: If set to 'true' then hidden tasks are included in the + search results + :type search_hidden: bool + :param scroll_id: Scroll ID returned from the previos calls to get_all + :type scroll_id: str + :param refresh_scroll: If set then all the data received with this scroll will + be requeried + :type refresh_scroll: bool + :param size: The number of tasks to retrieve + :type size: int + """ + + _service = "tasks" + _action = "get_all" + _version = "2.20" + _schema = { + "definitions": { + "multi_field_pattern_data": { + "properties": { + "fields": { + "description": "List of field names", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "pattern": { + "description": "Pattern string (regex)", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "task_status_enum": { + "enum": [ + "created", + "queued", + "in_progress", + "stopped", + "published", + "publishing", + "closed", + "failed", + "completed", + "unknown", + ], + "type": "string", + }, + }, + "dependencies": {"page": ["page_size"]}, + "properties": { + "_all_": { + "description": "Multi-field pattern condition (all fields match pattern)", + "oneOf": [ + {"$ref": "#/definitions/multi_field_pattern_data"}, + {"type": "null"}, + ], + }, + "_any_": { + "description": "Multi-field pattern condition (any field matches pattern)", + "oneOf": [ + {"$ref": "#/definitions/multi_field_pattern_data"}, + {"type": "null"}, + ], + }, + "id": { + "description": "List of IDs to filter by", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "name": { + "description": "Get only tasks whose name matches this pattern (python regular expression syntax)", + "type": ["string", "null"], + }, + "only_fields": { + "description": "List of task field names (nesting is supported using '.', e.g. execution.model_labels). If provided, this list defines the query's projection (only these fields will be returned for each result entry)", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "order_by": { + "description": "List of field names to order by. When search_text is used, '@text_score' can be used as a field representing the text score of returned documents. Use '-' prefix to specify descending order. Optional, recommended when using page", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "page": { + "description": "Page number, returns a specific page out of the resulting list of tasks", + "minimum": 0, + "type": ["integer", "null"], + }, + "page_size": { + "description": "Page size, specifies the number of results returned in each page (last page may contain fewer results)", + "minimum": 1, + "type": ["integer", "null"], + }, + "parent": {"description": "Parent ID", "type": ["string", "null"]}, + "project": { + "description": "List of project IDs", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "refresh_scroll": { + "description": "If set then all the data received with this scroll will be requeried", + "type": ["boolean", "null"], + }, + "scroll_id": { + "description": "Scroll ID returned from the previos calls to get_all", + "type": ["string", "null"], + }, + "search_hidden": { + "default": False, + "description": "If set to 'true' then hidden tasks are included in the search results", + "type": ["boolean", "null"], + }, + "search_text": { + "description": "Free text search query", + "type": ["string", "null"], + }, + "size": { + "description": "The number of tasks to retrieve", + "minimum": 1, + "type": ["integer", "null"], + }, + "status": { + "description": "List of task status.", + "items": {"$ref": "#/definitions/task_status_enum"}, + "type": ["array", "null"], + }, + "status_changed": { + "description": "List of status changed constraint strings (utcformat, epoch) with an optional prefix modifier (>, >=, <, <=)", + "items": {"pattern": "^(>=|>|<=|<)?.*$", "type": "string"}, + "type": ["array", "null"], + }, + "system_tags": { + "description": "List of task system tags. Use '-' prefix to exclude system tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "List of task user-defined tags. Use '-' prefix to exclude tags", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "type": { + "description": "List of task types. One or more of: 'training', 'testing', 'inference', 'data_processing', 'application', 'monitor', 'controller', 'optimizer', 'service', 'qc' or 'custom' (case insensitive)", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "user": { + "description": "List of user IDs used to filter results by the task's creating user", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + id=None, + name=None, + user=None, + project=None, + page=None, + page_size=None, + order_by=None, + type=None, + tags=None, + system_tags=None, + status=None, + only_fields=None, + parent=None, + status_changed=None, + search_text=None, + _all_=None, + _any_=None, + search_hidden=False, + scroll_id=None, + refresh_scroll=None, + size=None, + **kwargs + ): + super(GetAllRequest, self).__init__(**kwargs) + self.id = id + self.name = name + self.user = user + self.project = project + self.page = page + self.page_size = page_size + self.order_by = order_by + self.type = type + self.tags = tags + self.system_tags = system_tags + self.status = status + self.only_fields = only_fields + self.parent = parent + self.status_changed = status_changed + self.search_text = search_text + self._all_ = _all_ + self._any_ = _any_ + self.search_hidden = search_hidden + self.scroll_id = scroll_id + self.refresh_scroll = refresh_scroll + self.size = size + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", (list, tuple)) + + self.assert_isinstance(value, "id", six.string_types, is_array=True) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("user") + def user(self): + return self._property_user + + @user.setter + def user(self, value): + if value is None: + self._property_user = None + return + + self.assert_isinstance(value, "user", (list, tuple)) + + self.assert_isinstance(value, "user", six.string_types, is_array=True) + self._property_user = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", (list, tuple)) + + self.assert_isinstance(value, "project", six.string_types, is_array=True) + self._property_project = value + + @schema_property("page") + def page(self): + return self._property_page + + @page.setter + def page(self, value): + if value is None: + self._property_page = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page", six.integer_types) + self._property_page = value + + @schema_property("page_size") + def page_size(self): + return self._property_page_size + + @page_size.setter + def page_size(self, value): + if value is None: + self._property_page_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "page_size", six.integer_types) + self._property_page_size = value + + @schema_property("order_by") + def order_by(self): + return self._property_order_by + + @order_by.setter + def order_by(self, value): + if value is None: + self._property_order_by = None + return + + self.assert_isinstance(value, "order_by", (list, tuple)) + + self.assert_isinstance(value, "order_by", six.string_types, is_array=True) + self._property_order_by = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + + self.assert_isinstance(value, "type", (list, tuple)) + + self.assert_isinstance(value, "type", six.string_types, is_array=True) + self._property_type = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("status") + def status(self): + return self._property_status + + @status.setter + def status(self, value): + if value is None: + self._property_status = None + return + + self.assert_isinstance(value, "status", (list, tuple)) + if any(isinstance(v, six.string_types) for v in value): + value = [ + TaskStatusEnum(v) if isinstance(v, six.string_types) else v + for v in value + ] + else: + self.assert_isinstance(value, "status", TaskStatusEnum, is_array=True) + self._property_status = value + + @schema_property("only_fields") + def only_fields(self): + return self._property_only_fields + + @only_fields.setter + def only_fields(self, value): + if value is None: + self._property_only_fields = None + return + + self.assert_isinstance(value, "only_fields", (list, tuple)) + + self.assert_isinstance(value, "only_fields", six.string_types, is_array=True) + self._property_only_fields = value + + @schema_property("parent") + def parent(self): + return self._property_parent + + @parent.setter + def parent(self, value): + if value is None: + self._property_parent = None + return + + self.assert_isinstance(value, "parent", six.string_types) + self._property_parent = value + + @schema_property("status_changed") + def status_changed(self): + return self._property_status_changed + + @status_changed.setter + def status_changed(self, value): + if value is None: + self._property_status_changed = None + return + + self.assert_isinstance(value, "status_changed", (list, tuple)) + + self.assert_isinstance(value, "status_changed", six.string_types, is_array=True) + self._property_status_changed = value + + @schema_property("search_text") + def search_text(self): + return self._property_search_text + + @search_text.setter + def search_text(self, value): + if value is None: + self._property_search_text = None + return + + self.assert_isinstance(value, "search_text", six.string_types) + self._property_search_text = value + + @schema_property("_all_") + def _all_(self): + return self._property__all_ + + @_all_.setter + def _all_(self, value): + if value is None: + self._property__all_ = None + return + if isinstance(value, dict): + value = MultiFieldPatternData.from_dict(value) + else: + self.assert_isinstance(value, "_all_", MultiFieldPatternData) + self._property__all_ = value + + @schema_property("_any_") + def _any_(self): + return self._property__any_ + + @_any_.setter + def _any_(self, value): + if value is None: + self._property__any_ = None + return + if isinstance(value, dict): + value = MultiFieldPatternData.from_dict(value) + else: + self.assert_isinstance(value, "_any_", MultiFieldPatternData) + self._property__any_ = value + + @schema_property("search_hidden") + def search_hidden(self): + return self._property_search_hidden + + @search_hidden.setter + def search_hidden(self, value): + if value is None: + self._property_search_hidden = None + return + + self.assert_isinstance(value, "search_hidden", (bool,)) + self._property_search_hidden = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + @schema_property("refresh_scroll") + def refresh_scroll(self): + return self._property_refresh_scroll + + @refresh_scroll.setter + def refresh_scroll(self, value): + if value is None: + self._property_refresh_scroll = None + return + + self.assert_isinstance(value, "refresh_scroll", (bool,)) + self._property_refresh_scroll = value + + @schema_property("size") + def size(self): + return self._property_size + + @size.setter + def size(self, value): + if value is None: + self._property_size = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "size", six.integer_types) + self._property_size = value + + +class GetAllResponse(Response): + """ + Response of tasks.get_all endpoint. + + :param tasks: List of tasks + :type tasks: Sequence[Task] + :param scroll_id: Scroll ID that can be used with the next calls to get_all to + retrieve more data + :type scroll_id: str + """ + + _service = "tasks" + _action = "get_all" + _version = "2.20" + + _schema = { + "definitions": { + "artifact": { + "properties": { + "content_size": { + "description": "Raw data length in bytes", + "type": "integer", + }, + "display_data": { + "description": "User-defined list of key/value pairs, sorted", + "items": {"items": {"type": "string"}, "type": "array"}, + "type": "array", + }, + "hash": { + "description": "Hash of entire raw data", + "type": "string", + }, + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output indication", + }, + "timestamp": { + "description": "Epoch time when artifact was created", + "type": "integer", + }, + "type": { + "description": "System defined type", + "type": "string", + }, + "type_data": { + "$ref": "#/definitions/artifact_type_data", + "description": "Additional fields defined by the system", + }, + "uri": {"description": "Raw data location", "type": "string"}, + }, + "required": ["key", "type"], + "type": "object", + }, + "artifact_mode_enum": { + "default": "output", + "enum": ["input", "output"], + "type": "string", + }, + "artifact_type_data": { + "properties": { + "content_type": { + "description": "System defined raw data content type", + "type": ["string", "null"], + }, + "data_hash": { + "description": "Hash of raw data, without any headers or descriptive parts", + "type": ["string", "null"], + }, + "preview": { + "description": "Description or textual data", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "configuration_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. Should be unique", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "execution": { + "properties": { + "artifacts": { + "description": "Task artifacts", + "items": {"$ref": "#/definitions/artifact"}, + "type": ["array", "null"], + }, + "framework": { + "description": "Framework related to the task. Case insensitive. Mandatory for Training tasks. ", + "type": ["string", "null"], + }, + "model_desc": { + "additionalProperties": True, + "description": "Json object representing the Model descriptors", + "type": ["object", "null"], + }, + "model_labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model.\n The keys are the layers' names and the values are the IDs.\n Not applicable for Register (Import) tasks.\n Mandatory for Training tasks", + "type": ["object", "null"], + }, + "parameters": { + "additionalProperties": True, + "description": "Json object containing the Task parameters", + "type": ["object", "null"], + }, + "queue": { + "description": "Queue ID where task was queued.", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "last_metrics_event": { + "properties": { + "max_value": { + "description": "Maximum value reported", + "type": ["number", "null"], + }, + "metric": { + "description": "Metric name", + "type": ["string", "null"], + }, + "min_value": { + "description": "Minimum value reported", + "type": ["number", "null"], + }, + "value": { + "description": "Last value reported", + "type": ["number", "null"], + }, + "variant": { + "description": "Variant name", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "last_metrics_variants": { + "additionalProperties": {"$ref": "#/definitions/last_metrics_event"}, + "description": "Last metric events, one for each variant hash", + }, + "output": { + "properties": { + "destination": { + "description": "Storage id. This is where output files will be stored.", + "type": ["string", "null"], + }, + "error": { + "description": "Last error text", + "type": ["string", "null"], + }, + "model": {"description": "Model id.", "type": ["string", "null"]}, + "result": { + "description": "Task result. Values: 'success', 'failure'", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "params_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. The combination of section and name should be unique", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "script": { + "properties": { + "binary": { + "default": "python", + "description": "Binary to use when running the script", + "type": ["string", "null"], + }, + "branch": { + "description": "Repository branch id If not provided and tag not provided, default repository branch is used.", + "type": ["string", "null"], + }, + "diff": { + "description": "Uncommitted changes found in the repository when task was run", + "type": ["string", "null"], + }, + "entry_point": { + "description": "Path to execute within the repository", + "type": ["string", "null"], + }, + "repository": { + "description": "Name of the repository where the script is located", + "type": ["string", "null"], + }, + "requirements": { + "description": "A JSON object containing requirements strings by key", + "type": ["object", "null"], + }, + "tag": { + "description": "Repository tag", + "type": ["string", "null"], + }, + "version_num": { + "description": "Version (changeset) number. Optional (default is head version) Unused if tag is provided.", + "type": ["string", "null"], + }, + "working_dir": { + "description": "Path to the folder from which to run the script Default - root folder of repository", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "section_params": { + "additionalProperties": {"$ref": "#/definitions/params_item"}, + "description": "Task section params", + "type": "object", + }, + "task": { + "properties": { + "active_duration": { + "description": "Task duration time (seconds)", + "type": ["integer", "null"], + }, + "comment": { + "description": "Free text comment", + "type": ["string", "null"], + }, + "company": { + "description": "Company ID", + "type": ["string", "null"], + }, + "completed": { + "description": "Task end time (UTC)", + "format": "date-time", + "type": ["string", "null"], + }, + "configuration": { + "additionalProperties": { + "$ref": "#/definitions/configuration_item" + }, + "description": "Task configuration params", + "type": ["object", "null"], + }, + "container": { + "type": "object", + "description": "Docker container parameters", + "additionalProperties": {"type": ["string", "null"]}, + }, + "created": { + "description": "Task creation time (UTC) ", + "format": "date-time", + "type": ["string", "null"], + }, + "execution": { + "description": "Task execution params", + "oneOf": [ + {"$ref": "#/definitions/execution"}, + {"type": "null"}, + ], + }, + "hyperparams": { + "additionalProperties": { + "$ref": "#/definitions/section_params" + }, + "description": "Task hyper params per section", + "type": ["object", "null"], + }, + "id": {"description": "Task id", "type": ["string", "null"]}, + "last_change": { + "description": "Last time any update was done to the task", + "format": "date-time", + "type": ["string", "null"], + }, + "last_iteration": { + "description": "Last iteration reported for this task", + "type": ["integer", "null"], + }, + "last_metrics": { + "additionalProperties": { + "$ref": "#/definitions/last_metrics_variants" + }, + "description": "Last metric variants (hash to events), one for each metric hash", + "type": ["object", "null"], + }, + "last_update": { + "description": "Last time this task was created, edited, changed or events for this task were reported", + "format": "date-time", + "type": ["string", "null"], + }, + "last_worker": { + "description": "ID of last worker that handled the task", + "type": ["string", "null"], + }, + "last_worker_report": { + "description": "Last time a worker reported while working on this task", + "format": "date-time", + "type": ["string", "null"], + }, + "models": { + "description": "Task models", + "oneOf": [ + {"$ref": "#/definitions/task_models"}, + {"type": "null"}, + ], + }, + "name": {"description": "Task Name", "type": ["string", "null"]}, + "output": { + "description": "Task output params", + "oneOf": [{"$ref": "#/definitions/output"}, {"type": "null"}], + }, + "parent": { + "description": "Parent task id", + "type": ["string", "null"], + }, + "project": { + "description": "Project ID of the project to which this task is assigned", + "type": ["string", "null"], + }, + "published": { + "description": "Last status change time", + "format": "date-time", + "type": ["string", "null"], + }, + "script": { + "description": "Script info", + "oneOf": [{"$ref": "#/definitions/script"}, {"type": "null"}], + }, + "started": { + "description": "Task start time (UTC)", + "format": "date-time", + "type": ["string", "null"], + }, + "status": { + "description": "", + "oneOf": [ + {"$ref": "#/definitions/task_status_enum"}, + {"type": "null"}, + ], + }, + "status_changed": { + "description": "Last status change time", + "format": "date-time", + "type": ["string", "null"], + }, + "status_message": { + "description": "free text string representing info about the status", + "type": ["string", "null"], + }, + "status_reason": { + "description": "Reason for last status change", + "type": ["string", "null"], + }, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "type": { + "description": "Type of task. Values: 'training', 'testing'", + "oneOf": [ + {"$ref": "#/definitions/task_type_enum"}, + {"type": "null"}, + ], + }, + "user": { + "description": "Associated user id", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "task_model_item": { + "properties": { + "model": {"description": "The model ID", "type": "string"}, + "name": { + "description": "The task model name", + "type": "string", + }, + }, + "required": ["name", "model"], + "type": "object", + }, + "task_models": { + "properties": { + "input": { + "description": "The list of task input models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + "output": { + "description": "The list of task output models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + }, + "type": "object", + }, + "task_status_enum": { + "enum": [ + "created", + "queued", + "in_progress", + "stopped", + "published", + "publishing", + "closed", + "failed", + "completed", + "unknown", + ], + "type": "string", + }, + "task_type_enum": { + "enum": [ + "training", + "testing", + "inference", + "data_processing", + "application", + "monitor", + "controller", + "optimizer", + "service", + "qc", + "custom", + ], + "type": "string", + }, + }, + "properties": { + "scroll_id": { + "description": "Scroll ID that can be used with the next calls to get_all to retrieve more data", + "type": ["string", "null"], + }, + "tasks": { + "description": "List of tasks", + "items": {"$ref": "#/definitions/task"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, tasks=None, scroll_id=None, **kwargs): + super(GetAllResponse, self).__init__(**kwargs) + self.tasks = tasks + self.scroll_id = scroll_id + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [Task.from_dict(v) if isinstance(v, dict) else v for v in value] + else: + self.assert_isinstance(value, "tasks", Task, is_array=True) + self._property_tasks = value + + @schema_property("scroll_id") + def scroll_id(self): + return self._property_scroll_id + + @scroll_id.setter + def scroll_id(self, value): + if value is None: + self._property_scroll_id = None + return + + self.assert_isinstance(value, "scroll_id", six.string_types) + self._property_scroll_id = value + + +class GetByIdRequest(Request): + """ + Gets task information + + :param task: Task ID + :type task: str + """ + + _service = "tasks" + _action = "get_by_id" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"task": {"description": "Task ID", "type": "string"}}, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, **kwargs): + super(GetByIdRequest, self).__init__(**kwargs) + self.task = task + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class GetByIdResponse(Response): + """ + Response of tasks.get_by_id endpoint. + + :param task: Task info + :type task: Task + """ + + _service = "tasks" + _action = "get_by_id" + _version = "2.20" + + _schema = { + "definitions": { + "artifact": { + "properties": { + "content_size": { + "description": "Raw data length in bytes", + "type": "integer", + }, + "display_data": { + "description": "User-defined list of key/value pairs, sorted", + "items": {"items": {"type": "string"}, "type": "array"}, + "type": "array", + }, + "hash": { + "description": "Hash of entire raw data", + "type": "string", + }, + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output indication", + }, + "timestamp": { + "description": "Epoch time when artifact was created", + "type": "integer", + }, + "type": { + "description": "System defined type", + "type": "string", + }, + "type_data": { + "$ref": "#/definitions/artifact_type_data", + "description": "Additional fields defined by the system", + }, + "uri": {"description": "Raw data location", "type": "string"}, + }, + "required": ["key", "type"], + "type": "object", + }, + "artifact_mode_enum": { + "default": "output", + "enum": ["input", "output"], + "type": "string", + }, + "artifact_type_data": { + "properties": { + "content_type": { + "description": "System defined raw data content type", + "type": ["string", "null"], + }, + "data_hash": { + "description": "Hash of raw data, without any headers or descriptive parts", + "type": ["string", "null"], + }, + "preview": { + "description": "Description or textual data", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "configuration_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. Should be unique", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "execution": { + "properties": { + "artifacts": { + "description": "Task artifacts", + "items": {"$ref": "#/definitions/artifact"}, + "type": ["array", "null"], + }, + "framework": { + "description": "Framework related to the task. Case insensitive. Mandatory for Training tasks. ", + "type": ["string", "null"], + }, + "model_desc": { + "additionalProperties": True, + "description": "Json object representing the Model descriptors", + "type": ["object", "null"], + }, + "model_labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model.\n The keys are the layers' names and the values are the IDs.\n Not applicable for Register (Import) tasks.\n Mandatory for Training tasks", + "type": ["object", "null"], + }, + "parameters": { + "additionalProperties": True, + "description": "Json object containing the Task parameters", + "type": ["object", "null"], + }, + "queue": { + "description": "Queue ID where task was queued.", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "last_metrics_event": { + "properties": { + "max_value": { + "description": "Maximum value reported", + "type": ["number", "null"], + }, + "metric": { + "description": "Metric name", + "type": ["string", "null"], + }, + "min_value": { + "description": "Minimum value reported", + "type": ["number", "null"], + }, + "value": { + "description": "Last value reported", + "type": ["number", "null"], + }, + "variant": { + "description": "Variant name", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "last_metrics_variants": { + "additionalProperties": { + "$ref": "#/definitions/last_metrics_event", + }, + "description": "Last metric events, one for each variant hash", + "type": "object", + }, + "output": { + "properties": { + "destination": { + "description": "Storage id. This is where output files will be stored.", + "type": ["string", "null"], + }, + "error": { + "description": "Last error text", + "type": ["string", "null"], + }, + "model": {"description": "Model id.", "type": ["string", "null"]}, + "result": { + "description": "Task result. Values: 'success', 'failure'", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "params_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. The combination of section and name should be unique", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "script": { + "properties": { + "binary": { + "default": "python", + "description": "Binary to use when running the script", + "type": ["string", "null"], + }, + "branch": { + "description": "Repository branch id If not provided and tag not provided, default repository branch is used.", + "type": ["string", "null"], + }, + "diff": { + "description": "Uncommitted changes found in the repository when task was run", + "type": ["string", "null"], + }, + "entry_point": { + "description": "Path to execute within the repository", + "type": ["string", "null"], + }, + "repository": { + "description": "Name of the repository where the script is located", + "type": ["string", "null"], + }, + "requirements": { + "description": "A JSON object containing requirements strings by key", + "type": ["object", "null"], + }, + "tag": { + "description": "Repository tag", + "type": ["string", "null"], + }, + "version_num": { + "description": "Version (changeset) number. Optional (default is head version) Unused if tag is provided.", + "type": ["string", "null"], + }, + "working_dir": { + "description": "Path to the folder from which to run the script Default - root folder of repository", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "section_params": { + "additionalProperties": {"$ref": "#/definitions/params_item"}, + "description": "Task section params", + "type": "object", + }, + "task": { + "properties": { + "active_duration": { + "description": "Task duration time (seconds)", + "type": ["integer", "null"], + }, + "comment": { + "description": "Free text comment", + "type": ["string", "null"], + }, + "company": { + "description": "Company ID", + "type": ["string", "null"], + }, + "completed": { + "description": "Task end time (UTC)", + "format": "date-time", + "type": ["string", "null"], + }, + "configuration": { + "additionalProperties": { + "$ref": "#/definitions/configuration_item" + }, + "description": "Task configuration params", + "type": ["object", "null"], + }, + "container": { + "type": "object", + "description": "Docker container parameters", + "additionalProperties": {"type": ["string", "null"]}, + }, + "created": { + "description": "Task creation time (UTC) ", + "format": "date-time", + "type": ["string", "null"], + }, + "execution": { + "description": "Task execution params", + "oneOf": [ + {"$ref": "#/definitions/execution"}, + {"type": "null"}, + ], + }, + "hyperparams": { + "additionalProperties": { + "$ref": "#/definitions/section_params" + }, + "description": "Task hyper params per section", + "type": ["object", "null"], + }, + "id": {"description": "Task id", "type": ["string", "null"]}, + "last_change": { + "description": "Last time any update was done to the task", + "format": "date-time", + "type": ["string", "null"], + }, + "last_iteration": { + "description": "Last iteration reported for this task", + "type": ["integer", "null"], + }, + "last_metrics": { + "additionalProperties": { + "$ref": "#/definitions/last_metrics_variants" + }, + "description": "Last metric variants (hash to events), one for each metric hash", + "type": ["object", "null"], + }, + "last_update": { + "description": "Last time this task was created, edited, changed or events for this task were reported", + "format": "date-time", + "type": ["string", "null"], + }, + "last_worker": { + "description": "ID of last worker that handled the task", + "type": ["string", "null"], + }, + "last_worker_report": { + "description": "Last time a worker reported while working on this task", + "format": "date-time", + "type": ["string", "null"], + }, + "models": { + "description": "Task models", + "oneOf": [ + {"$ref": "#/definitions/task_models"}, + {"type": "null"}, + ], + }, + "name": {"description": "Task Name", "type": ["string", "null"]}, + "output": { + "description": "Task output params", + "oneOf": [{"$ref": "#/definitions/output"}, {"type": "null"}], + }, + "parent": { + "description": "Parent task id", + "type": ["string", "null"], + }, + "project": { + "description": "Project ID of the project to which this task is assigned", + "type": ["string", "null"], + }, + "published": { + "description": "Last status change time", + "format": "date-time", + "type": ["string", "null"], + }, + "script": { + "description": "Script info", + "oneOf": [{"$ref": "#/definitions/script"}, {"type": "null"}], + }, + "started": { + "description": "Task start time (UTC)", + "format": "date-time", + "type": ["string", "null"], + }, + "status": { + "description": "", + "oneOf": [ + {"$ref": "#/definitions/task_status_enum"}, + {"type": "null"}, + ], + }, + "status_changed": { + "description": "Last status change time", + "format": "date-time", + "type": ["string", "null"], + }, + "status_message": { + "description": "free text string representing info about the status", + "type": ["string", "null"], + }, + "status_reason": { + "description": "Reason for last status change", + "type": ["string", "null"], + }, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "type": { + "description": "Type of task. Values: 'training', 'testing'", + "oneOf": [ + {"$ref": "#/definitions/task_type_enum"}, + {"type": "null"}, + ], + }, + "user": { + "description": "Associated user id", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "task_model_item": { + "properties": { + "model": {"description": "The model ID", "type": "string"}, + "name": { + "description": "The task model name", + "type": "string", + }, + }, + "required": ["name", "model"], + "type": "object", + }, + "task_models": { + "properties": { + "input": { + "description": "The list of task input models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + "output": { + "description": "The list of task output models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + }, + "type": "object", + }, + "task_status_enum": { + "enum": [ + "created", + "queued", + "in_progress", + "stopped", + "published", + "publishing", + "closed", + "failed", + "completed", + "unknown", + ], + "type": "string", + }, + "task_type_enum": { + "enum": [ + "training", + "testing", + "inference", + "data_processing", + "application", + "monitor", + "controller", + "optimizer", + "service", + "qc", + "custom", + ], + "type": "string", + }, + }, + "properties": { + "task": { + "description": "Task info", + "oneOf": [{"$ref": "#/definitions/task"}, {"type": "null"}], + } + }, + "type": "object", + } + + def __init__(self, task=None, **kwargs): + super(GetByIdResponse, self).__init__(**kwargs) + self.task = task + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + if isinstance(value, dict): + value = Task.from_dict(value) + else: + self.assert_isinstance(value, "task", Task) + self._property_task = value + + +class GetConfigurationNamesRequest(Request): + """ + Get the list of task configuration items names + + :param tasks: Task IDs + :type tasks: Sequence[str] + :param skip_empty: If set to 'true' then the names for configurations with + missing values are not returned + :type skip_empty: bool + """ + + _service = "tasks" + _action = "get_configuration_names" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "skip_empty": { + "default": True, + "description": "If set to 'true' then the names for configurations with missing values are not returned", + "type": "boolean", + }, + "tasks": { + "description": "Task IDs", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["tasks"], + "type": "object", + } + + def __init__(self, tasks, skip_empty=True, **kwargs): + super(GetConfigurationNamesRequest, self).__init__(**kwargs) + self.tasks = tasks + self.skip_empty = skip_empty + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + + self.assert_isinstance(value, "tasks", six.string_types, is_array=True) + self._property_tasks = value + + @schema_property("skip_empty") + def skip_empty(self): + return self._property_skip_empty + + @skip_empty.setter + def skip_empty(self, value): + if value is None: + self._property_skip_empty = None + return + + self.assert_isinstance(value, "skip_empty", (bool,)) + self._property_skip_empty = value + + +class GetConfigurationNamesResponse(Response): + """ + Response of tasks.get_configuration_names endpoint. + + :param configurations: Names of task configuration items (keyed by task ID) + :type configurations: dict + """ + + _service = "tasks" + _action = "get_configuration_names" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "configurations": { + "description": "Names of task configuration items (keyed by task ID)", + "properties": { + "names": { + "description": "Configuration names", + "items": {"type": "string"}, + "type": "array", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "type": ["object", "null"], + } + }, + "type": "object", + } + + def __init__(self, configurations=None, **kwargs): + super(GetConfigurationNamesResponse, self).__init__(**kwargs) + self.configurations = configurations + + @schema_property("configurations") + def configurations(self): + return self._property_configurations + + @configurations.setter + def configurations(self, value): + if value is None: + self._property_configurations = None + return + + self.assert_isinstance(value, "configurations", (dict,)) + self._property_configurations = value + + +class GetConfigurationsRequest(Request): + """ + Get the list of task configurations + + :param tasks: Task IDs + :type tasks: Sequence[str] + :param names: Names of the configuration items to retreive. If not passed or + empty then all the configurations will be retreived. + :type names: Sequence[str] + """ + + _service = "tasks" + _action = "get_configurations" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "names": { + "description": "Names of the configuration items to retreive. If not passed or empty then all the configurations will be retreived.", + "items": {"type": "string"}, + "type": "array", + }, + "tasks": { + "description": "Task IDs", + "items": {"type": "string"}, + "type": "array", + }, + }, + "required": ["tasks"], + "type": "object", + } + + def __init__(self, tasks, names=None, **kwargs): + super(GetConfigurationsRequest, self).__init__(**kwargs) + self.tasks = tasks + self.names = names + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + + self.assert_isinstance(value, "tasks", six.string_types, is_array=True) + self._property_tasks = value + + @schema_property("names") + def names(self): + return self._property_names + + @names.setter + def names(self, value): + if value is None: + self._property_names = None + return + + self.assert_isinstance(value, "names", (list, tuple)) + + self.assert_isinstance(value, "names", six.string_types, is_array=True) + self._property_names = value + + +class GetConfigurationsResponse(Response): + """ + Response of tasks.get_configurations endpoint. + + :param configurations: Configurations (keyed by task ID) + :type configurations: Sequence[dict] + """ + + _service = "tasks" + _action = "get_configurations" + _version = "2.20" + + _schema = { + "definitions": { + "configuration_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. Should be unique", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "configurations": { + "description": "Configurations (keyed by task ID)", + "items": { + "properties": { + "configuration": { + "description": "Configuration list", + "items": {"$ref": "#/definitions/configuration_item"}, + "type": "array", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "type": "object", + }, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, configurations=None, **kwargs): + super(GetConfigurationsResponse, self).__init__(**kwargs) + self.configurations = configurations + + @schema_property("configurations") + def configurations(self): + return self._property_configurations + + @configurations.setter + def configurations(self, value): + if value is None: + self._property_configurations = None + return + + self.assert_isinstance(value, "configurations", (list, tuple)) + + self.assert_isinstance(value, "configurations", (dict,), is_array=True) + self._property_configurations = value + + +class GetHyperParamsRequest(Request): + """ + Get the list of task hyper parameters + + :param tasks: Task IDs + :type tasks: Sequence[str] + """ + + _service = "tasks" + _action = "get_hyper_params" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "tasks": { + "description": "Task IDs", + "items": {"type": "string"}, + "type": "array", + } + }, + "required": ["tasks"], + "type": "object", + } + + def __init__(self, tasks, **kwargs): + super(GetHyperParamsRequest, self).__init__(**kwargs) + self.tasks = tasks + + @schema_property("tasks") + def tasks(self): + return self._property_tasks + + @tasks.setter + def tasks(self, value): + if value is None: + self._property_tasks = None + return + + self.assert_isinstance(value, "tasks", (list, tuple)) + + self.assert_isinstance(value, "tasks", six.string_types, is_array=True) + self._property_tasks = value + + +class GetHyperParamsResponse(Response): + """ + Response of tasks.get_hyper_params endpoint. + + :param params: Hyper parameters (keyed by task ID) + :type params: Sequence[dict] + """ + + _service = "tasks" + _action = "get_hyper_params" + _version = "2.20" + + _schema = { + "definitions": { + "params_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. The combination of section and name should be unique", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "params": { + "description": "Hyper parameters (keyed by task ID)", + "items": { + "properties": { + "hyperparams": { + "description": "Hyper parameters", + "items": {"$ref": "#/definitions/params_item"}, + "type": "array", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "type": "object", + }, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, params=None, **kwargs): + super(GetHyperParamsResponse, self).__init__(**kwargs) + self.params = params + + @schema_property("params") + def params(self): + return self._property_params + + @params.setter + def params(self, value): + if value is None: + self._property_params = None + return + + self.assert_isinstance(value, "params", (list, tuple)) + + self.assert_isinstance(value, "params", (dict,), is_array=True) + self._property_params = value + + +class GetTypesRequest(Request): + """ + Get the list of task types used in the specified projects + + :param projects: The list of projects which tasks will be analyzed. If not + passed or empty then all the company and public tasks will be analyzed + :type projects: Sequence[str] + """ + + _service = "tasks" + _action = "get_types" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "projects": { + "description": "The list of projects which tasks will be analyzed. If not passed or empty then all the company and public tasks will be analyzed", + "items": {"type": "string"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, projects=None, **kwargs): + super(GetTypesRequest, self).__init__(**kwargs) + self.projects = projects + + @schema_property("projects") + def projects(self): + return self._property_projects + + @projects.setter + def projects(self, value): + if value is None: + self._property_projects = None + return + + self.assert_isinstance(value, "projects", (list, tuple)) + + self.assert_isinstance(value, "projects", six.string_types, is_array=True) + self._property_projects = value + + +class GetTypesResponse(Response): + """ + Response of tasks.get_types endpoint. + + :param types: Unique list of the task types used in the requested projects + :type types: Sequence[str] + """ + + _service = "tasks" + _action = "get_types" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "types": { + "description": "Unique list of the task types used in the requested projects", + "items": {"type": "string"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, types=None, **kwargs): + super(GetTypesResponse, self).__init__(**kwargs) + self.types = types + + @schema_property("types") # noqa: F811 + def types(self): + return self._property_types + + @types.setter + def types(self, value): + if value is None: + self._property_types = None + return + + self.assert_isinstance(value, "types", (list, tuple)) + + self.assert_isinstance(value, "types", six.string_types, is_array=True) + self._property_types = value + + +class MakePrivateRequest(Request): + """ + Convert public tasks to private + + :param ids: Ids of the tasks to convert. Only the tasks originated by the + company can be converted + :type ids: Sequence[str] + """ + + _service = "tasks" + _action = "make_private" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "Ids of the tasks to convert. Only the tasks originated by the company can be converted", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, ids=None, **kwargs): + super(MakePrivateRequest, self).__init__(**kwargs) + self.ids = ids + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + +class MakePrivateResponse(Response): + """ + Response of tasks.make_private endpoint. + + :param updated: Number of tasks updated + :type updated: int + """ + + _service = "tasks" + _action = "make_private" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of tasks updated", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(MakePrivateResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class MakePublicRequest(Request): + """ + Convert company tasks to public + + :param ids: Ids of the tasks to convert + :type ids: Sequence[str] + """ + + _service = "tasks" + _action = "make_public" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "Ids of the tasks to convert", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, ids=None, **kwargs): + super(MakePublicRequest, self).__init__(**kwargs) + self.ids = ids + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + +class MakePublicResponse(Response): + """ + Response of tasks.make_public endpoint. + + :param updated: Number of tasks updated + :type updated: int + """ + + _service = "tasks" + _action = "make_public" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of tasks updated", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(MakePublicResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class MoveRequest(Request): + """ + Move tasks to a project + + :param ids: Tasks to move + :type ids: Sequence[str] + :param project: Target project ID. If not provided, `project_name` must be + provided. + :type project: str + :param project_name: Target project name. If provided and a project with this + name does not exist, a new project will be created. If not provided, `project` + must be provided. + :type project_name: str + """ + + _service = "tasks" + _action = "move" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "Tasks to move", + "items": {"type": "string"}, + "type": "array", + }, + "project": { + "description": "Target project ID. If not provided, `project_name` must be provided.", + "type": "string", + }, + "project_name": { + "description": "Target project name. If provided and a project with this name does not exist, a new project will be created. If not provided, `project` must be provided.", + "type": "string", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__(self, ids, project=None, project_name=None, **kwargs): + super(MoveRequest, self).__init__(**kwargs) + self.ids = ids + self.project = project + self.project_name = project_name + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("project_name") + def project_name(self): + return self._property_project_name + + @project_name.setter + def project_name(self, value): + if value is None: + self._property_project_name = None + return + + self.assert_isinstance(value, "project_name", six.string_types) + self._property_project_name = value + + +class MoveResponse(Response): + """ + Response of tasks.move endpoint. + + """ + + _service = "tasks" + _action = "move" + _version = "2.20" + + _schema = {"additionalProperties": True, "definitions": {}, "type": "object"} + + +class PingRequest(Request): + """ + Refresh the task's last update time + + :param task: Task ID + :type task: str + """ + + _service = "tasks" + _action = "ping" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": {"task": {"description": "Task ID", "type": "string"}}, + "required": ["task"], + "type": "object", + } + + def __init__(self, task, **kwargs): + super(PingRequest, self).__init__(**kwargs) + self.task = task + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + +class PingResponse(Response): + """ + Response of tasks.ping endpoint. + + """ + + _service = "tasks" + _action = "ping" + _version = "2.20" + + _schema = {"additionalProperties": False, "definitions": {}, "type": "object"} + + +class PublishRequest(Request): + """ + Mark a task status as published. If a model was created, it should be set to ready. + + :param force: If not true, call fails if the task status is not 'stopped' + :type force: bool + :param publish_model: Indicates that the task output model (if exists) should + be published. Optional, the default value is True. + :type publish_model: bool + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "publish" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "If not true, call fails if the task status is not 'stopped'", + "type": ["boolean", "null"], + }, + "publish_model": { + "description": "Indicates that the task output model (if exists) should be published. Optional, the default value is True.", + "type": ["boolean", "null"], + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + force=False, + publish_model=None, + status_reason=None, + status_message=None, + **kwargs + ): + super(PublishRequest, self).__init__(**kwargs) + self.force = force + self.publish_model = publish_model + self.task = task + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("publish_model") + def publish_model(self): + return self._property_publish_model + + @publish_model.setter + def publish_model(self, value): + if value is None: + self._property_publish_model = None + return + + self.assert_isinstance(value, "publish_model", (bool,)) + self._property_publish_model = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class PublishResponse(Response): + """ + Response of tasks.publish endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "tasks" + _action = "publish" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(PublishResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class PublishManyRequest(Request): + """ + Publish tasks + + :param ids: IDs of the tasks to publish + :type ids: Sequence[str] + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + :param force: If not true, call fails if the task status is not 'stopped' + :type force: bool + :param publish_model: Indicates that the task output model (if exists) should + be published. Optional, the default value is True. + :type publish_model: bool + """ + + _service = "tasks" + _action = "publish_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "If not true, call fails if the task status is not 'stopped'", + "type": "boolean", + }, + "ids": { + "description": "IDs of the tasks to publish", + "items": {"type": "string"}, + "type": "array", + }, + "publish_model": { + "description": "Indicates that the task output model (if exists) should be published. Optional, the default value is True.", + "type": "boolean", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__( + self, + ids, + status_reason=None, + status_message=None, + force=False, + publish_model=None, + **kwargs + ): + super(PublishManyRequest, self).__init__(**kwargs) + self.ids = ids + self.status_reason = status_reason + self.status_message = status_message + self.force = force + self.publish_model = publish_model + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("publish_model") + def publish_model(self): + return self._property_publish_model + + @publish_model.setter + def publish_model(self, value): + if value is None: + self._property_publish_model = None + return + + self.assert_isinstance(value, "publish_model", (bool,)) + self._property_publish_model = value + + +class PublishManyResponse(Response): + """ + Response of tasks.publish_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "tasks" + _action = "publish_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": "object", + }, + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": "integer", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(PublishManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class ResetRequest(Request): + """ + Reset a task to its initial state, along with any information stored for it (statistics, frame updates etc.). + + :param force: If not true, call fails if the task status is 'completed' + :type force: bool + :param clear_all: Clear script and execution sections completely + :type clear_all: bool + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + :param return_file_urls: If set to 'true' then return the urls of the files + that were uploaded by this task. Default value is 'false' + :type return_file_urls: bool + """ + + _service = "tasks" + _action = "reset" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "clear_all": { + "default": False, + "description": "Clear script and execution sections completely", + "type": ["boolean", "null"], + }, + "force": { + "default": False, + "description": "If not true, call fails if the task status is 'completed'", + "type": ["boolean", "null"], + }, + "return_file_urls": { + "description": "If set to 'true' then return the urls of the files that were uploaded by this task. Default value is 'false'", + "type": "boolean", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + force=False, + clear_all=False, + status_reason=None, + status_message=None, + return_file_urls=None, + **kwargs + ): + super(ResetRequest, self).__init__(**kwargs) + self.force = force + self.clear_all = clear_all + self.task = task + self.status_reason = status_reason + self.status_message = status_message + self.return_file_urls = return_file_urls + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("clear_all") + def clear_all(self): + return self._property_clear_all + + @clear_all.setter + def clear_all(self, value): + if value is None: + self._property_clear_all = None + return + + self.assert_isinstance(value, "clear_all", (bool,)) + self._property_clear_all = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + @schema_property("return_file_urls") + def return_file_urls(self): + return self._property_return_file_urls + + @return_file_urls.setter + def return_file_urls(self, value): + if value is None: + self._property_return_file_urls = None + return + + self.assert_isinstance(value, "return_file_urls", (bool,)) + self._property_return_file_urls = value + + +class ResetResponse(Response): + """ + Response of tasks.reset endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + :param dequeued: Response from queues.remove_task + :type dequeued: dict + :param events: Response from events.delete_for_task + :type events: dict + :param deleted_models: Number of output models deleted by the reset + :type deleted_models: int + :param urls: The urls of the files that were uploaded by this task. Returned if + the 'return_file_urls' was set to 'true' + :type urls: TaskUrls + """ + + _service = "tasks" + _action = "reset" + _version = "2.20" + + _schema = { + "definitions": { + "task_urls": { + "properties": { + "artifact_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "event_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "model_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "deleted_models": { + "description": "Number of output models deleted by the reset", + "type": ["integer", "null"], + }, + "dequeued": { + "additionalProperties": True, + "description": "Response from queues.remove_task", + "type": ["object", "null"], + }, + "events": { + "additionalProperties": True, + "description": "Response from events.delete_for_task", + "type": ["object", "null"], + }, + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + "urls": { + "description": "The urls of the files that were uploaded by this task. Returned if the 'return_file_urls' was set to True", + "oneOf": [{"$ref": "#/definitions/task_urls"}, {"type": "null"}], + }, + }, + "type": "object", + } + + def __init__( + self, + updated=None, + fields=None, + dequeued=None, + events=None, + deleted_models=None, + urls=None, + **kwargs + ): + super(ResetResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + self.dequeued = dequeued + self.events = events + self.deleted_models = deleted_models + self.urls = urls + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + @schema_property("dequeued") + def dequeued(self): + return self._property_dequeued + + @dequeued.setter + def dequeued(self, value): + if value is None: + self._property_dequeued = None + return + + self.assert_isinstance(value, "dequeued", (dict,)) + self._property_dequeued = value + + @schema_property("events") + def events(self): + return self._property_events + + @events.setter + def events(self, value): + if value is None: + self._property_events = None + return + + self.assert_isinstance(value, "events", (dict,)) + self._property_events = value + + @schema_property("deleted_models") + def deleted_models(self): + return self._property_deleted_models + + @deleted_models.setter + def deleted_models(self, value): + if value is None: + self._property_deleted_models = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "deleted_models", six.integer_types) + self._property_deleted_models = value + + @schema_property("urls") + def urls(self): + return self._property_urls + + @urls.setter + def urls(self, value): + if value is None: + self._property_urls = None + return + if isinstance(value, dict): + value = TaskUrls.from_dict(value) + else: + self.assert_isinstance(value, "urls", TaskUrls) + self._property_urls = value + + +class ResetManyRequest(Request): + """ + Reset tasks + + :param ids: IDs of the tasks to reset + :type ids: Sequence[str] + :param force: If not true, call fails if the task status is 'completed' + :type force: bool + :param clear_all: Clear script and execution sections completely + :type clear_all: bool + :param return_file_urls: If set to 'true' then return the urls of the files + that were uploaded by the tasks. Default value is 'false' + :type return_file_urls: bool + :param delete_output_models: If set to 'true' then delete output models of the + tasks that are not referenced by other tasks. Default value is 'true' + :type delete_output_models: bool + """ + + _service = "tasks" + _action = "reset_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "clear_all": { + "default": False, + "description": "Clear script and execution sections completely", + "type": "boolean", + }, + "delete_output_models": { + "description": "If set to 'true' then delete output models of the tasks that are not referenced by other tasks. Default value is 'true'", + "type": "boolean", + }, + "force": { + "default": False, + "description": "If not true, call fails if the task status is 'completed'", + "type": "boolean", + }, + "ids": { + "description": "IDs of the tasks to reset", + "items": {"type": "string"}, + "type": "array", + }, + "return_file_urls": { + "description": "If set to 'true' then return the urls of the files that were uploaded by the tasks. Default value is 'false'", + "type": "boolean", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__( + self, + ids, + force=False, + clear_all=False, + return_file_urls=None, + delete_output_models=None, + **kwargs + ): + super(ResetManyRequest, self).__init__(**kwargs) + self.ids = ids + self.force = force + self.clear_all = clear_all + self.return_file_urls = return_file_urls + self.delete_output_models = delete_output_models + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("clear_all") + def clear_all(self): + return self._property_clear_all + + @clear_all.setter + def clear_all(self, value): + if value is None: + self._property_clear_all = None + return + + self.assert_isinstance(value, "clear_all", (bool,)) + self._property_clear_all = value + + @schema_property("return_file_urls") + def return_file_urls(self): + return self._property_return_file_urls + + @return_file_urls.setter + def return_file_urls(self, value): + if value is None: + self._property_return_file_urls = None + return + + self.assert_isinstance(value, "return_file_urls", (bool,)) + self._property_return_file_urls = value + + @schema_property("delete_output_models") + def delete_output_models(self): + return self._property_delete_output_models + + @delete_output_models.setter + def delete_output_models(self, value): + if value is None: + self._property_delete_output_models = None + return + + self.assert_isinstance(value, "delete_output_models", (bool,)) + self._property_delete_output_models = value + + +class ResetManyResponse(Response): + """ + Response of tasks.reset_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "tasks" + _action = "reset_many" + _version = "2.20" + + _schema = { + "definitions": { + "task_urls": { + "properties": { + "artifact_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "event_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "model_urls": { + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "deleted_models": { + "description": "Number of output models deleted by the reset", + "type": "integer", + }, + "dequeued": { + "description": "Indicates whether the task was dequeued", + "type": "boolean", + }, + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": "object", + }, + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": "integer", + }, + "urls": { + "oneOf": [{"$ref": "#/definitions/task_urls"}, {"type": "null"}], + "description": "The urls of the files that were uploaded by the tasks. Returned if the 'return_file_urls' was set to 'true'", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(ResetManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class SetRequirementsRequest(Request): + """ + Set the script requirements for a task + + :param task: Task ID + :type task: str + :param requirements: A JSON object containing requirements strings by key + :type requirements: dict + """ + + _service = "tasks" + _action = "set_requirements" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "requirements": { + "description": "A JSON object containing requirements strings by key", + "type": "object", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task", "requirements"], + "type": "object", + } + + def __init__(self, task, requirements, **kwargs): + super(SetRequirementsRequest, self).__init__(**kwargs) + self.task = task + self.requirements = requirements + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("requirements") + def requirements(self): + return self._property_requirements + + @requirements.setter + def requirements(self, value): + if value is None: + self._property_requirements = None + return + + self.assert_isinstance(value, "requirements", (dict,)) + self._property_requirements = value + + +class SetRequirementsResponse(Response): + """ + Response of tasks.set_requirements endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "tasks" + _action = "set_requirements" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(SetRequirementsResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class StartedRequest(Request): + """ + Mark a task status as in_progress. Optionally allows to set the task's execution progress. + + :param force: If not true, call fails if the task status is not 'not_started' + :type force: bool + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "started" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "If not true, call fails if the task status is not 'not_started'", + "type": ["boolean", "null"], + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, task, force=False, status_reason=None, status_message=None, **kwargs + ): + super(StartedRequest, self).__init__(**kwargs) + self.force = force + self.task = task + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class StartedResponse(Response): + """ + Response of tasks.started endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + :param started: Number of tasks started (0 or 1) + :type started: int + """ + + _service = "tasks" + _action = "started" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "started": { + "description": "Number of tasks started (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, started=None, **kwargs): + super(StartedResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + self.started = started + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + @schema_property("started") + def started(self): + return self._property_started + + @started.setter + def started(self, value): + if value is None: + self._property_started = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "started", six.integer_types) + self._property_started = value + + +class StopRequest(Request): + """ + Request to stop a running task + + :param force: If not true, call fails if the task status is not 'in_progress' + :type force: bool + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "stop" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "If not true, call fails if the task status is not 'in_progress'", + "type": ["boolean", "null"], + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, task, force=False, status_reason=None, status_message=None, **kwargs + ): + super(StopRequest, self).__init__(**kwargs) + self.force = force + self.task = task + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class StopResponse(Response): + """ + Response of tasks.stop endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "tasks" + _action = "stop" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(StopResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class StopManyRequest(Request): + """ + Request to stop running tasks + + :param ids: IDs of the tasks to stop + :type ids: Sequence[str] + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + :param force: If not true, call fails if the task status is not 'in_progress' + :type force: bool + """ + + _service = "tasks" + _action = "stop_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "If not true, call fails if the task status is not 'in_progress'", + "type": "boolean", + }, + "ids": { + "description": "IDs of the tasks to stop", + "items": {"type": "string"}, + "type": "array", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__( + self, ids, status_reason=None, status_message=None, force=False, **kwargs + ): + super(StopManyRequest, self).__init__(**kwargs) + self.ids = ids + self.status_reason = status_reason + self.status_message = status_message + self.force = force + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + +class StopManyResponse(Response): + """ + Response of tasks.stop_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "tasks" + _action = "stop_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": "object", + }, + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": "integer", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(StopManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class StoppedRequest(Request): + """ + Signal a task has stopped + + :param force: If not true, call fails if the task status is not 'stopped' + :type force: bool + :param task: Task ID + :type task: str + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "stopped" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "force": { + "default": False, + "description": "If not true, call fails if the task status is not 'stopped'", + "type": ["boolean", "null"], + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + "task": {"description": "Task ID", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, task, force=False, status_reason=None, status_message=None, **kwargs + ): + super(StoppedRequest, self).__init__(**kwargs) + self.force = force + self.task = task + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("force") + def force(self): + return self._property_force + + @force.setter + def force(self, value): + if value is None: + self._property_force = None + return + + self.assert_isinstance(value, "force", (bool,)) + self._property_force = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class StoppedResponse(Response): + """ + Response of tasks.stopped endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "tasks" + _action = "stopped" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(StoppedResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class UnarchiveManyRequest(Request): + """ + Unarchive tasks + + :param ids: IDs of the tasks to unarchive + :type ids: Sequence[str] + :param status_reason: Reason for status change + :type status_reason: str + :param status_message: Extra information regarding status change + :type status_message: str + """ + + _service = "tasks" + _action = "unarchive_many" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "ids": { + "description": "IDs of the tasks to unarchive", + "items": {"type": "string"}, + "type": "array", + }, + "status_message": { + "description": "Extra information regarding status change", + "type": "string", + }, + "status_reason": { + "description": "Reason for status change", + "type": "string", + }, + }, + "required": ["ids"], + "type": "object", + } + + def __init__(self, ids, status_reason=None, status_message=None, **kwargs): + super(UnarchiveManyRequest, self).__init__(**kwargs) + self.ids = ids + self.status_reason = status_reason + self.status_message = status_message + + @schema_property("ids") + def ids(self): + return self._property_ids + + @ids.setter + def ids(self, value): + if value is None: + self._property_ids = None + return + + self.assert_isinstance(value, "ids", (list, tuple)) + + self.assert_isinstance(value, "ids", six.string_types, is_array=True) + self._property_ids = value + + @schema_property("status_reason") + def status_reason(self): + return self._property_status_reason + + @status_reason.setter + def status_reason(self, value): + if value is None: + self._property_status_reason = None + return + + self.assert_isinstance(value, "status_reason", six.string_types) + self._property_status_reason = value + + @schema_property("status_message") + def status_message(self): + return self._property_status_message + + @status_message.setter + def status_message(self, value): + if value is None: + self._property_status_message = None + return + + self.assert_isinstance(value, "status_message", six.string_types) + self._property_status_message = value + + +class UnarchiveManyResponse(Response): + """ + Response of tasks.unarchive_many endpoint. + + :param succeeded: + :type succeeded: Sequence[dict] + :param failed: + :type failed: Sequence[dict] + """ + + _service = "tasks" + _action = "unarchive_many" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "failed": { + "items": { + "properties": { + "error": { + "description": "Error info", + "properties": { + "codes": { + "items": {"type": "integer"}, + "type": "array", + }, + "data": { + "additionalProperties": True, + "type": "object", + }, + "msg": {"type": "string"}, + }, + "type": "object", + }, + "id": { + "description": "ID of the failed entity", + "type": "string", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + "succeeded": { + "items": { + "properties": { + "id": { + "description": "ID of the succeeded entity", + "type": "string", + }, + "unarchived": { + "description": "Indicates whether the task was unarchived", + "type": "boolean", + }, + }, + "type": "object", + }, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, succeeded=None, failed=None, **kwargs): + super(UnarchiveManyResponse, self).__init__(**kwargs) + self.succeeded = succeeded + self.failed = failed + + @schema_property("succeeded") + def succeeded(self): + return self._property_succeeded + + @succeeded.setter + def succeeded(self, value): + if value is None: + self._property_succeeded = None + return + + self.assert_isinstance(value, "succeeded", (list, tuple)) + + self.assert_isinstance(value, "succeeded", (dict,), is_array=True) + self._property_succeeded = value + + @schema_property("failed") + def failed(self): + return self._property_failed + + @failed.setter + def failed(self, value): + if value is None: + self._property_failed = None + return + + self.assert_isinstance(value, "failed", (list, tuple)) + + self.assert_isinstance(value, "failed", (dict,), is_array=True) + self._property_failed = value + + +class UpdateRequest(Request): + """ + Update task's runtime parameters + + :param task: ID of the task + :type task: str + :param name: Task name Unique within the company. + :type name: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param comment: Free text comment + :type comment: str + :param project: Project ID of the project to which this task is assigned + :type project: str + :param output__error: Free text error + :type output__error: str + :param created: Task creation time (UTC) + :type created: datetime.datetime + """ + + _service = "tasks" + _action = "update" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "comment": {"description": "Free text comment ", "type": "string"}, + "created": { + "description": "Task creation time (UTC) ", + "format": "date-time", + "type": "string", + }, + "name": { + "description": "Task name Unique within the company.", + "type": "string", + }, + "output__error": {"description": "Free text error", "type": "string"}, + "project": { + "description": "Project ID of the project to which this task is assigned", + "type": "string", + }, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + "task": {"description": "ID of the task", "type": "string"}, + }, + "required": ["task"], + "type": "object", + } + + def __init__( + self, + task, + name=None, + tags=None, + system_tags=None, + comment=None, + project=None, + output__error=None, + created=None, + **kwargs + ): + super(UpdateRequest, self).__init__(**kwargs) + self.task = task + self.name = name + self.tags = tags + self.system_tags = system_tags + self.comment = comment + self.project = project + self.output__error = output__error + self.created = created + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("output__error") + def output__error(self): + return self._property_output__error + + @output__error.setter + def output__error(self, value): + if value is None: + self._property_output__error = None + return + + self.assert_isinstance(value, "output__error", six.string_types) + self._property_output__error = value + + @schema_property("created") + def created(self): + return self._property_created + + @created.setter + def created(self, value): + if value is None: + self._property_created = None + return + + self.assert_isinstance(value, "created", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_created = value + + +class UpdateResponse(Response): + """ + Response of tasks.update endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + + _service = "tasks" + _action = "update" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "fields": { + "additionalProperties": True, + "description": "Updated fields names and values", + "type": ["object", "null"], + }, + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, updated=None, fields=None, **kwargs): + super(UpdateResponse, self).__init__(**kwargs) + self.updated = updated + self.fields = fields + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + @schema_property("fields") + def fields(self): + return self._property_fields + + @fields.setter + def fields(self, value): + if value is None: + self._property_fields = None + return + + self.assert_isinstance(value, "fields", (dict,)) + self._property_fields = value + + +class UpdateBatchRequest(BatchRequest): + """ + Updates a batch of tasks. + Headers + Content type should be 'application/json-lines'. + + """ + + _service = "tasks" + _action = "update_batch" + _version = "2.20" + _batched_request_cls = UpdateRequest + + +class UpdateBatchResponse(Response): + """ + Response of tasks.update_batch endpoint. + + :param updated: Number of tasks updated (0 or 1) + :type updated: int + """ + + _service = "tasks" + _action = "update_batch" + _version = "2.20" + + _schema = { + "definitions": {}, + "properties": { + "updated": { + "description": "Number of tasks updated (0 or 1)", + "enum": [0, 1], + "type": ["integer", "null"], + } + }, + "type": "object", + } + + def __init__(self, updated=None, **kwargs): + super(UpdateBatchResponse, self).__init__(**kwargs) + self.updated = updated + + @schema_property("updated") + def updated(self): + return self._property_updated + + @updated.setter + def updated(self, value): + if value is None: + self._property_updated = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated", six.integer_types) + self._property_updated = value + + +class ValidateRequest(Request): + """ + Validate task properties (before create) + + :param name: Task name. Unique within the company. + :type name: str + :param tags: User-defined tags list + :type tags: Sequence[str] + :param system_tags: System tags list. This field is reserved for system use, + please don't use it. + :type system_tags: Sequence[str] + :param type: Type of task + :type type: TaskTypeEnum + :param comment: Free text comment + :type comment: str + :param parent: Parent task id Must be a completed task. + :type parent: str + :param project: Project ID of the project to which this task is assigned Must + exist[ab] + :type project: str + :param output_dest: Output storage id Must be a reference to an existing + storage. + :type output_dest: str + :param execution: Task execution params + :type execution: Execution + :param hyperparams: Task hyper params per section + :type hyperparams: dict + :param configuration: Task configuration params + :type configuration: dict + :param script: Script info + :type script: Script + :param models: Task models + :type models: TaskModels + :param container: Docker container parameters + :type container: dict + """ + + _service = "tasks" + _action = "validate" + _version = "2.20" + _schema = { + "definitions": { + "artifact": { + "properties": { + "content_size": { + "description": "Raw data length in bytes", + "type": "integer", + }, + "display_data": { + "description": "User-defined list of key/value pairs, sorted", + "items": {"items": {"type": "string"}, "type": "array"}, + "type": "array", + }, + "hash": { + "description": "Hash of entire raw data", + "type": "string", + }, + "key": {"description": "Entry key", "type": "string"}, + "mode": { + "$ref": "#/definitions/artifact_mode_enum", + "description": "System defined input/output indication", + }, + "timestamp": { + "description": "Epoch time when artifact was created", + "type": "integer", + }, + "type": { + "description": "System defined type", + "type": "string", + }, + "type_data": { + "$ref": "#/definitions/artifact_type_data", + "description": "Additional fields defined by the system", + }, + "uri": {"description": "Raw data location", "type": "string"}, + }, + "required": ["key", "type"], + "type": "object", + }, + "artifact_mode_enum": { + "default": "output", + "enum": ["input", "output"], + "type": "string", + }, + "artifact_type_data": { + "properties": { + "content_type": { + "description": "System defined raw data content type", + "type": ["string", "null"], + }, + "data_hash": { + "description": "Hash of raw data, without any headers or descriptive parts", + "type": ["string", "null"], + }, + "preview": { + "description": "Description or textual data", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "configuration_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. Should be unique", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "execution": { + "properties": { + "artifacts": { + "description": "Task artifacts", + "items": {"$ref": "#/definitions/artifact"}, + "type": ["array", "null"], + }, + "framework": { + "description": "Framework related to the task. Case insensitive. Mandatory for Training tasks. ", + "type": ["string", "null"], + }, + "model_desc": { + "additionalProperties": True, + "description": "Json object representing the Model descriptors", + "type": ["object", "null"], + }, + "model_labels": { + "additionalProperties": {"type": "integer"}, + "description": "Json object representing the ids of the labels in the model.\n The keys are the layers' names and the values are the IDs.\n Not applicable for Register (Import) tasks.\n Mandatory for Training tasks", + "type": ["object", "null"], + }, + "parameters": { + "additionalProperties": True, + "description": "Json object containing the Task parameters", + "type": ["object", "null"], + }, + "queue": { + "description": "Queue ID where task was queued.", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "params_item": { + "properties": { + "description": { + "description": "The parameter description. Optional", + "type": ["string", "null"], + }, + "name": { + "description": "Name of the parameter. The combination of section and name should be unique", + "type": ["string", "null"], + }, + "section": { + "description": "Section that the parameter belongs to", + "type": ["string", "null"], + }, + "type": { + "description": "Type of the parameter. Optional", + "type": ["string", "null"], + }, + "value": { + "description": "Value of the parameter", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "script": { + "properties": { + "binary": { + "default": "python", + "description": "Binary to use when running the script", + "type": ["string", "null"], + }, + "branch": { + "description": "Repository branch id If not provided and tag not provided, default repository branch is used.", + "type": ["string", "null"], + }, + "diff": { + "description": "Uncommitted changes found in the repository when task was run", + "type": ["string", "null"], + }, + "entry_point": { + "description": "Path to execute within the repository", + "type": ["string", "null"], + }, + "repository": { + "description": "Name of the repository where the script is located", + "type": ["string", "null"], + }, + "requirements": { + "description": "A JSON object containing requirements strings by key", + "type": ["object", "null"], + }, + "tag": { + "description": "Repository tag", + "type": ["string", "null"], + }, + "version_num": { + "description": "Version (changeset) number. Optional (default is head version) Unused if tag is provided.", + "type": ["string", "null"], + }, + "working_dir": { + "description": "Path to the folder from which to run the script Default - root folder of repository", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "section_params": { + "additionalProperties": {"$ref": "#/definitions/params_item"}, + "description": "Task section params", + "type": "object", + }, + "task_model_item": { + "properties": { + "model": {"description": "The model ID", "type": "string"}, + "name": { + "description": "The task model name", + "type": "string", + }, + }, + "required": ["name", "model"], + "type": "object", + }, + "task_models": { + "properties": { + "input": { + "description": "The list of task input models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + "output": { + "description": "The list of task output models", + "items": {"$ref": "#/definitions/task_model_item"}, + "type": ["array", "null"], + }, + }, + "type": "object", + }, + "task_type_enum": { + "enum": [ + "training", + "testing", + "inference", + "data_processing", + "application", + "monitor", + "controller", + "optimizer", + "service", + "qc", + "custom", + ], + "type": "string", + }, + }, + "properties": { + "comment": {"description": "Free text comment ", "type": "string"}, + "configuration": { + "additionalProperties": {"$ref": "#/definitions/configuration_item"}, + "description": "Task configuration params", + "type": "object", + }, + "container": { + "type": "object", + "description": "Docker container parameters", + "additionalProperties": {"type": ["string", "null"]}, + }, + "execution": { + "$ref": "#/definitions/execution", + "description": "Task execution params", + }, + "hyperparams": { + "additionalProperties": {"$ref": "#/definitions/section_params"}, + "description": "Task hyper params per section", + "type": "object", + }, + "models": { + "$ref": "#/definitions/task_models", + "description": "Task models", + }, + "name": { + "description": "Task name. Unique within the company.", + "type": "string", + }, + "output_dest": { + "description": "Output storage id Must be a reference to an existing storage.", + "type": "string", + }, + "parent": { + "description": "Parent task id Must be a completed task.", + "type": "string", + }, + "project": { + "description": "Project ID of the project to which this task is assigned Must exist[ab]", + "type": "string", + }, + "script": {"$ref": "#/definitions/script", "description": "Script info"}, + "system_tags": { + "description": "System tags list. This field is reserved for system use, please don't use it.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User-defined tags list", + "items": {"type": "string"}, + "type": "array", + }, + "type": { + "$ref": "#/definitions/task_type_enum", + "description": "Type of task", + }, + }, + "required": ["name", "type"], + "type": "object", + } + + def __init__( + self, + name, + type, + tags=None, + system_tags=None, + comment=None, + parent=None, + project=None, + output_dest=None, + execution=None, + hyperparams=None, + configuration=None, + script=None, + models=None, + container=None, + **kwargs + ): + super(ValidateRequest, self).__init__(**kwargs) + self.name = name + self.tags = tags + self.system_tags = system_tags + self.type = type + self.comment = comment + self.parent = parent + self.project = project + self.output_dest = output_dest + self.execution = execution + self.hyperparams = hyperparams + self.configuration = configuration + self.script = script + self.models = models + self.container = container + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + @schema_property("system_tags") + def system_tags(self): + return self._property_system_tags + + @system_tags.setter + def system_tags(self, value): + if value is None: + self._property_system_tags = None + return + + self.assert_isinstance(value, "system_tags", (list, tuple)) + + self.assert_isinstance(value, "system_tags", six.string_types, is_array=True) + self._property_system_tags = value + + @schema_property("type") + def type(self): + return self._property_type + + @type.setter + def type(self, value): + if value is None: + self._property_type = None + return + if isinstance(value, six.string_types): + try: + value = TaskTypeEnum(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "type", enum.Enum) + self._property_type = value + + @schema_property("comment") + def comment(self): + return self._property_comment + + @comment.setter + def comment(self, value): + if value is None: + self._property_comment = None + return + + self.assert_isinstance(value, "comment", six.string_types) + self._property_comment = value + + @schema_property("parent") + def parent(self): + return self._property_parent + + @parent.setter + def parent(self, value): + if value is None: + self._property_parent = None + return + + self.assert_isinstance(value, "parent", six.string_types) + self._property_parent = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + + self.assert_isinstance(value, "project", six.string_types) + self._property_project = value + + @schema_property("output_dest") + def output_dest(self): + return self._property_output_dest + + @output_dest.setter + def output_dest(self, value): + if value is None: + self._property_output_dest = None + return + + self.assert_isinstance(value, "output_dest", six.string_types) + self._property_output_dest = value + + @schema_property("execution") + def execution(self): + return self._property_execution + + @execution.setter + def execution(self, value): + if value is None: + self._property_execution = None + return + if isinstance(value, dict): + value = Execution.from_dict(value) + else: + self.assert_isinstance(value, "execution", Execution) + self._property_execution = value + + @schema_property("hyperparams") + def hyperparams(self): + return self._property_hyperparams + + @hyperparams.setter + def hyperparams(self, value): + if value is None: + self._property_hyperparams = None + return + + self.assert_isinstance(value, "hyperparams", dict) + self.assert_isinstance( + value.keys(), "hyperparams_keys", six.string_types, is_array=True + ) + self.assert_isinstance( + value.values(), "hyperparams_values", (SectionParams, dict), is_array=True + ) + value = dict( + (k, SectionParams(**v) if isinstance(v, dict) else v) + for k, v in value.items() + ) + + self._property_hyperparams = value + + @schema_property("configuration") + def configuration(self): + return self._property_configuration + + @configuration.setter + def configuration(self, value): + if value is None: + self._property_configuration = None + return + + self.assert_isinstance(value, "configuration", dict) + self.assert_isinstance( + value.keys(), "configuration_keys", six.string_types, is_array=True + ) + self.assert_isinstance( + value.values(), + "configuration_values", + (ConfigurationItem, dict), + is_array=True, + ) + + value = dict( + (k, ConfigurationItem(**v) if isinstance(v, dict) else v) + for k, v in value.items() + ) + + self._property_configuration = value + + @schema_property("script") + def script(self): + return self._property_script + + @script.setter + def script(self, value): + if value is None: + self._property_script = None + return + if isinstance(value, dict): + value = Script.from_dict(value) + else: + self.assert_isinstance(value, "script", Script) + self._property_script = value + + @schema_property("models") + def models(self): + return self._property_models + + @models.setter + def models(self, value): + if value is None: + self._property_models = None + return + if isinstance(value, dict): + value = TaskModels.from_dict(value) + else: + self.assert_isinstance(value, "models", TaskModels) + self._property_models = value + + @schema_property("container") + def container(self): + return self._property_container + + @container.setter + def container(self, value): + if value is None: + self._property_container = None + return + + self.assert_isinstance(value, "container", (dict,)) + self._property_container = value + + +class ValidateResponse(Response): + """ + Response of tasks.validate endpoint. + + """ + + _service = "tasks" + _action = "validate" + _version = "2.20" + + _schema = {"additionalProperties": False, "definitions": {}, "type": "object"} + + +response_mapping = { + GetByIdRequest: GetByIdResponse, + GetAllRequest: GetAllResponse, + GetTypesRequest: GetTypesResponse, + CloneRequest: CloneResponse, + AddOrUpdateModelRequest: AddOrUpdateModelResponse, + DeleteModelsRequest: DeleteModelsResponse, + CreateRequest: CreateResponse, + ValidateRequest: ValidateResponse, + UpdateRequest: UpdateResponse, + UpdateBatchRequest: UpdateBatchResponse, + EditRequest: EditResponse, + ResetRequest: ResetResponse, + ResetManyRequest: ResetManyResponse, + DeleteManyRequest: DeleteManyResponse, + DeleteRequest: DeleteResponse, + ArchiveRequest: ArchiveResponse, + ArchiveManyRequest: ArchiveManyResponse, + UnarchiveManyRequest: UnarchiveManyResponse, + StartedRequest: StartedResponse, + StopRequest: StopResponse, + StopManyRequest: StopManyResponse, + StoppedRequest: StoppedResponse, + FailedRequest: FailedResponse, + CloseRequest: CloseResponse, + PublishRequest: PublishResponse, + PublishManyRequest: PublishManyResponse, + EnqueueRequest: EnqueueResponse, + EnqueueManyRequest: EnqueueManyResponse, + DequeueRequest: DequeueResponse, + DequeueManyRequest: DequeueManyResponse, + SetRequirementsRequest: SetRequirementsResponse, + CompletedRequest: CompletedResponse, + PingRequest: PingResponse, + AddOrUpdateArtifactsRequest: AddOrUpdateArtifactsResponse, + DeleteArtifactsRequest: DeleteArtifactsResponse, + MakePublicRequest: MakePublicResponse, + MakePrivateRequest: MakePrivateResponse, + GetHyperParamsRequest: GetHyperParamsResponse, + EditHyperParamsRequest: EditHyperParamsResponse, + DeleteHyperParamsRequest: DeleteHyperParamsResponse, + GetConfigurationsRequest: GetConfigurationsResponse, + GetConfigurationNamesRequest: GetConfigurationNamesResponse, + EditConfigurationRequest: EditConfigurationResponse, + DeleteConfigurationRequest: DeleteConfigurationResponse, + MoveRequest: MoveResponse, +} diff --git a/clearml/backend_api/services/v2_20/workers.py b/clearml/backend_api/services/v2_20/workers.py new file mode 100644 index 00000000..579074a7 --- /dev/null +++ b/clearml/backend_api/services/v2_20/workers.py @@ -0,0 +1,2578 @@ +""" +workers service + +Provides an API for worker machines, allowing workers to report status and get tasks for execution +""" +import six +from datetime import datetime +import enum + +from dateutil.parser import parse as parse_datetime + +from clearml.backend_api.session import ( + Request, + Response, + NonStrictDataModel, + schema_property, + StringEnum, +) + + +class MetricsCategory(NonStrictDataModel): + """ + :param name: Name of the metrics category. + :type name: str + :param metric_keys: The names of the metrics in the category. + :type metric_keys: Sequence[str] + """ + + _schema = { + "properties": { + "metric_keys": { + "description": "The names of the metrics in the category.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "name": { + "description": "Name of the metrics category.", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, name=None, metric_keys=None, **kwargs): + super(MetricsCategory, self).__init__(**kwargs) + self.name = name + self.metric_keys = metric_keys + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("metric_keys") + def metric_keys(self): + return self._property_metric_keys + + @metric_keys.setter + def metric_keys(self, value): + if value is None: + self._property_metric_keys = None + return + + self.assert_isinstance(value, "metric_keys", (list, tuple)) + + self.assert_isinstance(value, "metric_keys", six.string_types, is_array=True) + self._property_metric_keys = value + + +class AggregationType(StringEnum): + avg = "avg" + min = "min" + max = "max" + + +class StatItem(NonStrictDataModel): + """ + :param key: Name of a metric + :type key: str + :param category: + :type category: AggregationType + """ + + _schema = { + "properties": { + "category": { + "oneOf": [{"$ref": "#/definitions/aggregation_type"}, {"type": "null"}] + }, + "key": {"description": "Name of a metric", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, key=None, category=None, **kwargs): + super(StatItem, self).__init__(**kwargs) + self.key = key + self.category = category + + @schema_property("key") + def key(self): + return self._property_key + + @key.setter + def key(self, value): + if value is None: + self._property_key = None + return + + self.assert_isinstance(value, "key", six.string_types) + self._property_key = value + + @schema_property("category") + def category(self): + return self._property_category + + @category.setter + def category(self, value): + if value is None: + self._property_category = None + return + if isinstance(value, six.string_types): + try: + value = AggregationType(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "category", enum.Enum) + self._property_category = value + + +class AggregationStats(NonStrictDataModel): + """ + :param aggregation: + :type aggregation: AggregationType + :param values: List of values corresponding to the dates in metric statistics + :type values: Sequence[float] + """ + + _schema = { + "properties": { + "aggregation": { + "oneOf": [{"$ref": "#/definitions/aggregation_type"}, {"type": "null"}] + }, + "values": { + "description": "List of values corresponding to the dates in metric statistics", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, aggregation=None, values=None, **kwargs): + super(AggregationStats, self).__init__(**kwargs) + self.aggregation = aggregation + self.values = values + + @schema_property("aggregation") + def aggregation(self): + return self._property_aggregation + + @aggregation.setter + def aggregation(self, value): + if value is None: + self._property_aggregation = None + return + if isinstance(value, six.string_types): + try: + value = AggregationType(value) + except ValueError: + pass + else: + self.assert_isinstance(value, "aggregation", enum.Enum) + self._property_aggregation = value + + @schema_property("values") + def values(self): + return self._property_values + + @values.setter + def values(self, value): + if value is None: + self._property_values = None + return + + self.assert_isinstance(value, "values", (list, tuple)) + + self.assert_isinstance( + value, "values", six.integer_types + (float,), is_array=True + ) + self._property_values = value + + +class MetricStats(NonStrictDataModel): + """ + :param metric: Name of the metric (cpu_usage, memory_used etc.) + :type metric: str + :param variant: Name of the metric component. Set only if 'split_by_variant' + was set in the request + :type variant: str + :param dates: List of timestamps (in seconds from epoch) in the acceding order. + The timestamps are separated by the requested interval. Timestamps where no + workers activity was recorded are omitted. + :type dates: Sequence[int] + :param stats: Statistics data by type + :type stats: Sequence[AggregationStats] + """ + + _schema = { + "properties": { + "dates": { + "description": "List of timestamps (in seconds from epoch) in the acceding order. The timestamps are separated by the requested interval. Timestamps where no workers activity was recorded are omitted.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "metric": { + "description": "Name of the metric (cpu_usage, memory_used etc.)", + "type": ["string", "null"], + }, + "stats": { + "description": "Statistics data by type", + "items": {"$ref": "#/definitions/aggregation_stats"}, + "type": ["array", "null"], + }, + "variant": { + "description": "Name of the metric component. Set only if 'split_by_variant' was set in the request", + "type": ["string", "null"], + }, + }, + "type": "object", + } + + def __init__(self, metric=None, variant=None, dates=None, stats=None, **kwargs): + super(MetricStats, self).__init__(**kwargs) + self.metric = metric + self.variant = variant + self.dates = dates + self.stats = stats + + @schema_property("metric") + def metric(self): + return self._property_metric + + @metric.setter + def metric(self, value): + if value is None: + self._property_metric = None + return + + self.assert_isinstance(value, "metric", six.string_types) + self._property_metric = value + + @schema_property("variant") + def variant(self): + return self._property_variant + + @variant.setter + def variant(self, value): + if value is None: + self._property_variant = None + return + + self.assert_isinstance(value, "variant", six.string_types) + self._property_variant = value + + @schema_property("dates") + def dates(self): + return self._property_dates + + @dates.setter + def dates(self, value): + if value is None: + self._property_dates = None + return + + self.assert_isinstance(value, "dates", (list, tuple)) + value = [ + int(v) if isinstance(v, float) and v.is_integer() else v for v in value + ] + + self.assert_isinstance(value, "dates", six.integer_types, is_array=True) + self._property_dates = value + + @schema_property("stats") + def stats(self): + return self._property_stats + + @stats.setter + def stats(self, value): + if value is None: + self._property_stats = None + return + + self.assert_isinstance(value, "stats", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + AggregationStats.from_dict(v) if isinstance(v, dict) else v + for v in value + ] + else: + self.assert_isinstance(value, "stats", AggregationStats, is_array=True) + self._property_stats = value + + +class WorkerStats(NonStrictDataModel): + """ + :param worker: ID of the worker + :type worker: str + :param metrics: List of the metrics statistics for the worker + :type metrics: Sequence[MetricStats] + """ + + _schema = { + "properties": { + "metrics": { + "description": "List of the metrics statistics for the worker", + "items": {"$ref": "#/definitions/metric_stats"}, + "type": ["array", "null"], + }, + "worker": {"description": "ID of the worker", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, worker=None, metrics=None, **kwargs): + super(WorkerStats, self).__init__(**kwargs) + self.worker = worker + self.metrics = metrics + + @schema_property("worker") + def worker(self): + return self._property_worker + + @worker.setter + def worker(self, value): + if value is None: + self._property_worker = None + return + + self.assert_isinstance(value, "worker", six.string_types) + self._property_worker = value + + @schema_property("metrics") + def metrics(self): + return self._property_metrics + + @metrics.setter + def metrics(self, value): + if value is None: + self._property_metrics = None + return + + self.assert_isinstance(value, "metrics", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + MetricStats.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "metrics", MetricStats, is_array=True) + self._property_metrics = value + + +class ActivitySeries(NonStrictDataModel): + """ + :param dates: List of timestamps (in seconds from epoch) in the acceding order. + The timestamps are separated by the requested interval. + :type dates: Sequence[int] + :param counts: List of worker counts corresponding to the timestamps in the + dates list. None values are returned for the dates with no workers. + :type counts: Sequence[int] + """ + + _schema = { + "properties": { + "counts": { + "description": "List of worker counts corresponding to the timestamps in the dates list. None values are returned for the dates with no workers.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "dates": { + "description": "List of timestamps (in seconds from epoch) in the acceding order. The timestamps are separated by the requested interval.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, dates=None, counts=None, **kwargs): + super(ActivitySeries, self).__init__(**kwargs) + self.dates = dates + self.counts = counts + + @schema_property("dates") + def dates(self): + return self._property_dates + + @dates.setter + def dates(self, value): + if value is None: + self._property_dates = None + return + + self.assert_isinstance(value, "dates", (list, tuple)) + value = [ + int(v) if isinstance(v, float) and v.is_integer() else v for v in value + ] + + self.assert_isinstance(value, "dates", six.integer_types, is_array=True) + self._property_dates = value + + @schema_property("counts") + def counts(self): + return self._property_counts + + @counts.setter + def counts(self, value): + if value is None: + self._property_counts = None + return + + self.assert_isinstance(value, "counts", (list, tuple)) + value = [ + int(v) if isinstance(v, float) and v.is_integer() else v for v in value + ] + + self.assert_isinstance(value, "counts", six.integer_types, is_array=True) + self._property_counts = value + + +class Worker(NonStrictDataModel): + """ + :param id: Worker ID + :type id: str + :param user: Associated user (under whose credentials are used by the worker + daemon) + :type user: IdNameEntry + :param company: Associated company + :type company: IdNameEntry + :param ip: IP of the worker + :type ip: str + :param register_time: Registration time + :type register_time: datetime.datetime + :param last_activity_time: Last activity time (even if an error occurred) + :type last_activity_time: datetime.datetime + :param last_report_time: Last successful report time + :type last_report_time: datetime.datetime + :param task: Task currently being run by the worker + :type task: CurrentTaskEntry + :param project: Project in which currently executing task resides + :type project: IdNameEntry + :param queue: Queue from which running task was taken + :type queue: QueueEntry + :param queues: List of queues on which the worker is listening + :type queues: Sequence[QueueEntry] + :param tags: User tags for the worker + :type tags: Sequence[str] + """ + + _schema = { + "properties": { + "company": { + "description": "Associated company", + "oneOf": [{"$ref": "#/definitions/id_name_entry"}, {"type": "null"}], + }, + "id": {"description": "Worker ID", "type": ["string", "null"]}, + "ip": {"description": "IP of the worker", "type": ["string", "null"]}, + "last_activity_time": { + "description": "Last activity time (even if an error occurred)", + "format": "date-time", + "type": ["string", "null"], + }, + "last_report_time": { + "description": "Last successful report time", + "format": "date-time", + "type": ["string", "null"], + }, + "project": { + "description": "Project in which currently executing task resides", + "oneOf": [{"$ref": "#/definitions/id_name_entry"}, {"type": "null"}], + }, + "queue": { + "description": "Queue from which running task was taken", + "oneOf": [{"$ref": "#/definitions/queue_entry"}, {"type": "null"}], + }, + "queues": { + "description": "List of queues on which the worker is listening", + "items": {"$ref": "#/definitions/queue_entry"}, + "type": ["array", "null"], + }, + "register_time": { + "description": "Registration time", + "format": "date-time", + "type": ["string", "null"], + }, + "tags": { + "description": "User tags for the worker", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "task": { + "description": "Task currently being run by the worker", + "oneOf": [ + {"$ref": "#/definitions/current_task_entry"}, + {"type": "null"}, + ], + }, + "user": { + "description": "Associated user (under whose credentials are used by the worker daemon)", + "oneOf": [{"$ref": "#/definitions/id_name_entry"}, {"type": "null"}], + }, + }, + "type": "object", + } + + def __init__( + self, + id=None, + user=None, + company=None, + ip=None, + register_time=None, + last_activity_time=None, + last_report_time=None, + task=None, + project=None, + queue=None, + queues=None, + tags=None, + **kwargs + ): + super(Worker, self).__init__(**kwargs) + self.id = id + self.user = user + self.company = company + self.ip = ip + self.register_time = register_time + self.last_activity_time = last_activity_time + self.last_report_time = last_report_time + self.task = task + self.project = project + self.queue = queue + self.queues = queues + self.tags = tags + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("user") + def user(self): + return self._property_user + + @user.setter + def user(self, value): + if value is None: + self._property_user = None + return + if isinstance(value, dict): + value = IdNameEntry.from_dict(value) + else: + self.assert_isinstance(value, "user", IdNameEntry) + self._property_user = value + + @schema_property("company") + def company(self): + return self._property_company + + @company.setter + def company(self, value): + if value is None: + self._property_company = None + return + if isinstance(value, dict): + value = IdNameEntry.from_dict(value) + else: + self.assert_isinstance(value, "company", IdNameEntry) + self._property_company = value + + @schema_property("ip") + def ip(self): + return self._property_ip + + @ip.setter + def ip(self, value): + if value is None: + self._property_ip = None + return + + self.assert_isinstance(value, "ip", six.string_types) + self._property_ip = value + + @schema_property("register_time") + def register_time(self): + return self._property_register_time + + @register_time.setter + def register_time(self, value): + if value is None: + self._property_register_time = None + return + + self.assert_isinstance(value, "register_time", six.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_register_time = value + + @schema_property("last_activity_time") + def last_activity_time(self): + return self._property_last_activity_time + + @last_activity_time.setter + def last_activity_time(self, value): + if value is None: + self._property_last_activity_time = None + return + + self.assert_isinstance( + value, "last_activity_time", six.string_types + (datetime,) + ) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_last_activity_time = value + + @schema_property("last_report_time") + def last_report_time(self): + return self._property_last_report_time + + @last_report_time.setter + def last_report_time(self, value): + if value is None: + self._property_last_report_time = None + return + + self.assert_isinstance( + value, "last_report_time", six.string_types + (datetime,) + ) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_last_report_time = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + if isinstance(value, dict): + value = CurrentTaskEntry.from_dict(value) + else: + self.assert_isinstance(value, "task", CurrentTaskEntry) + self._property_task = value + + @schema_property("project") + def project(self): + return self._property_project + + @project.setter + def project(self, value): + if value is None: + self._property_project = None + return + if isinstance(value, dict): + value = IdNameEntry.from_dict(value) + else: + self.assert_isinstance(value, "project", IdNameEntry) + self._property_project = value + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + if isinstance(value, dict): + value = QueueEntry.from_dict(value) + else: + self.assert_isinstance(value, "queue", QueueEntry) + self._property_queue = value + + @schema_property("queues") + def queues(self): + return self._property_queues + + @queues.setter + def queues(self, value): + if value is None: + self._property_queues = None + return + + self.assert_isinstance(value, "queues", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + QueueEntry.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "queues", QueueEntry, is_array=True) + self._property_queues = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + +class IdNameEntry(NonStrictDataModel): + """ + :param id: ID + :type id: str + :param name: Name + :type name: str + """ + + _schema = { + "properties": { + "id": {"description": "ID", "type": ["string", "null"]}, + "name": {"description": "Name", "type": ["string", "null"]}, + }, + "type": "object", + } + + def __init__(self, id=None, name=None, **kwargs): + super(IdNameEntry, self).__init__(**kwargs) + self.id = id + self.name = name + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + +class CurrentTaskEntry(NonStrictDataModel): + """ + :param id: ID + :type id: str + :param name: Name + :type name: str + :param running_time: Task running time + :type running_time: int + :param last_iteration: Last task iteration + :type last_iteration: int + """ + + _schema = { + "properties": { + "id": {"description": "ID", "type": ["string", "null"]}, + "last_iteration": { + "description": "Last task iteration", + "type": ["integer", "null"], + }, + "name": {"description": "Name", "type": ["string", "null"]}, + "running_time": { + "description": "Task running time", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, id=None, name=None, running_time=None, last_iteration=None, **kwargs + ): + super(CurrentTaskEntry, self).__init__(**kwargs) + self.id = id + self.name = name + self.running_time = running_time + self.last_iteration = last_iteration + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("running_time") + def running_time(self): + return self._property_running_time + + @running_time.setter + def running_time(self, value): + if value is None: + self._property_running_time = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "running_time", six.integer_types) + self._property_running_time = value + + @schema_property("last_iteration") + def last_iteration(self): + return self._property_last_iteration + + @last_iteration.setter + def last_iteration(self, value): + if value is None: + self._property_last_iteration = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "last_iteration", six.integer_types) + self._property_last_iteration = value + + +class QueueEntry(NonStrictDataModel): + """ + :param id: ID + :type id: str + :param name: Name + :type name: str + :param next_task: Next task in the queue + :type next_task: IdNameEntry + :param num_tasks: Number of task entries in the queue + :type num_tasks: int + """ + + _schema = { + "properties": { + "id": {"description": "ID", "type": ["string", "null"]}, + "name": {"description": "Name", "type": ["string", "null"]}, + "next_task": { + "description": "Next task in the queue", + "oneOf": [{"$ref": "#/definitions/id_name_entry"}, {"type": "null"}], + }, + "num_tasks": { + "description": "Number of task entries in the queue", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__(self, id=None, name=None, next_task=None, num_tasks=None, **kwargs): + super(QueueEntry, self).__init__(**kwargs) + self.id = id + self.name = name + self.next_task = next_task + self.num_tasks = num_tasks + + @schema_property("id") + def id(self): + return self._property_id + + @id.setter + def id(self, value): + if value is None: + self._property_id = None + return + + self.assert_isinstance(value, "id", six.string_types) + self._property_id = value + + @schema_property("name") + def name(self): + return self._property_name + + @name.setter + def name(self, value): + if value is None: + self._property_name = None + return + + self.assert_isinstance(value, "name", six.string_types) + self._property_name = value + + @schema_property("next_task") + def next_task(self): + return self._property_next_task + + @next_task.setter + def next_task(self, value): + if value is None: + self._property_next_task = None + return + if isinstance(value, dict): + value = IdNameEntry.from_dict(value) + else: + self.assert_isinstance(value, "next_task", IdNameEntry) + self._property_next_task = value + + @schema_property("num_tasks") + def num_tasks(self): + return self._property_num_tasks + + @num_tasks.setter + def num_tasks(self, value): + if value is None: + self._property_num_tasks = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "num_tasks", six.integer_types) + self._property_num_tasks = value + + +class MachineStats(NonStrictDataModel): + """ + :param cpu_usage: Average CPU usage per core + :type cpu_usage: Sequence[float] + :param gpu_usage: Average GPU usage per GPU card + :type gpu_usage: Sequence[float] + :param memory_used: Used memory MBs + :type memory_used: int + :param memory_free: Free memory MBs + :type memory_free: int + :param gpu_memory_free: GPU free memory MBs + :type gpu_memory_free: Sequence[int] + :param gpu_memory_used: GPU used memory MBs + :type gpu_memory_used: Sequence[int] + :param network_tx: Mbytes per second + :type network_tx: int + :param network_rx: Mbytes per second + :type network_rx: int + :param disk_free_home: Mbytes free space of /home drive + :type disk_free_home: int + :param disk_free_temp: Mbytes free space of /tmp drive + :type disk_free_temp: int + :param disk_read: Mbytes read per second + :type disk_read: int + :param disk_write: Mbytes write per second + :type disk_write: int + :param cpu_temperature: CPU temperature + :type cpu_temperature: Sequence[float] + :param gpu_temperature: GPU temperature + :type gpu_temperature: Sequence[float] + """ + + _schema = { + "properties": { + "cpu_temperature": { + "description": "CPU temperature", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "cpu_usage": { + "description": "Average CPU usage per core", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "disk_free_home": { + "description": "Mbytes free space of /home drive", + "type": ["integer", "null"], + }, + "disk_free_temp": { + "description": "Mbytes free space of /tmp drive", + "type": ["integer", "null"], + }, + "disk_read": { + "description": "Mbytes read per second", + "type": ["integer", "null"], + }, + "disk_write": { + "description": "Mbytes write per second", + "type": ["integer", "null"], + }, + "gpu_memory_free": { + "description": "GPU free memory MBs", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "gpu_memory_used": { + "description": "GPU used memory MBs", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "gpu_temperature": { + "description": "GPU temperature", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "gpu_usage": { + "description": "Average GPU usage per GPU card", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "memory_free": { + "description": "Free memory MBs", + "type": ["integer", "null"], + }, + "memory_used": { + "description": "Used memory MBs", + "type": ["integer", "null"], + }, + "network_rx": { + "description": "Mbytes per second", + "type": ["integer", "null"], + }, + "network_tx": { + "description": "Mbytes per second", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + + def __init__( + self, + cpu_usage=None, + gpu_usage=None, + memory_used=None, + memory_free=None, + gpu_memory_free=None, + gpu_memory_used=None, + network_tx=None, + network_rx=None, + disk_free_home=None, + disk_free_temp=None, + disk_read=None, + disk_write=None, + cpu_temperature=None, + gpu_temperature=None, + **kwargs + ): + super(MachineStats, self).__init__(**kwargs) + self.cpu_usage = cpu_usage + self.gpu_usage = gpu_usage + self.memory_used = memory_used + self.memory_free = memory_free + self.gpu_memory_free = gpu_memory_free + self.gpu_memory_used = gpu_memory_used + self.network_tx = network_tx + self.network_rx = network_rx + self.disk_free_home = disk_free_home + self.disk_free_temp = disk_free_temp + self.disk_read = disk_read + self.disk_write = disk_write + self.cpu_temperature = cpu_temperature + self.gpu_temperature = gpu_temperature + + @schema_property("cpu_usage") + def cpu_usage(self): + return self._property_cpu_usage + + @cpu_usage.setter + def cpu_usage(self, value): + if value is None: + self._property_cpu_usage = None + return + + self.assert_isinstance(value, "cpu_usage", (list, tuple)) + + self.assert_isinstance( + value, "cpu_usage", six.integer_types + (float,), is_array=True + ) + self._property_cpu_usage = value + + @schema_property("gpu_usage") + def gpu_usage(self): + return self._property_gpu_usage + + @gpu_usage.setter + def gpu_usage(self, value): + if value is None: + self._property_gpu_usage = None + return + + self.assert_isinstance(value, "gpu_usage", (list, tuple)) + + self.assert_isinstance( + value, "gpu_usage", six.integer_types + (float,), is_array=True + ) + self._property_gpu_usage = value + + @schema_property("memory_used") + def memory_used(self): + return self._property_memory_used + + @memory_used.setter + def memory_used(self, value): + if value is None: + self._property_memory_used = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "memory_used", six.integer_types) + self._property_memory_used = value + + @schema_property("memory_free") + def memory_free(self): + return self._property_memory_free + + @memory_free.setter + def memory_free(self, value): + if value is None: + self._property_memory_free = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "memory_free", six.integer_types) + self._property_memory_free = value + + @schema_property("gpu_memory_free") + def gpu_memory_free(self): + return self._property_gpu_memory_free + + @gpu_memory_free.setter + def gpu_memory_free(self, value): + if value is None: + self._property_gpu_memory_free = None + return + + self.assert_isinstance(value, "gpu_memory_free", (list, tuple)) + value = [ + int(v) if isinstance(v, float) and v.is_integer() else v for v in value + ] + + self.assert_isinstance( + value, "gpu_memory_free", six.integer_types, is_array=True + ) + self._property_gpu_memory_free = value + + @schema_property("gpu_memory_used") + def gpu_memory_used(self): + return self._property_gpu_memory_used + + @gpu_memory_used.setter + def gpu_memory_used(self, value): + if value is None: + self._property_gpu_memory_used = None + return + + self.assert_isinstance(value, "gpu_memory_used", (list, tuple)) + value = [ + int(v) if isinstance(v, float) and v.is_integer() else v for v in value + ] + + self.assert_isinstance( + value, "gpu_memory_used", six.integer_types, is_array=True + ) + self._property_gpu_memory_used = value + + @schema_property("network_tx") + def network_tx(self): + return self._property_network_tx + + @network_tx.setter + def network_tx(self, value): + if value is None: + self._property_network_tx = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "network_tx", six.integer_types) + self._property_network_tx = value + + @schema_property("network_rx") + def network_rx(self): + return self._property_network_rx + + @network_rx.setter + def network_rx(self, value): + if value is None: + self._property_network_rx = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "network_rx", six.integer_types) + self._property_network_rx = value + + @schema_property("disk_free_home") + def disk_free_home(self): + return self._property_disk_free_home + + @disk_free_home.setter + def disk_free_home(self, value): + if value is None: + self._property_disk_free_home = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "disk_free_home", six.integer_types) + self._property_disk_free_home = value + + @schema_property("disk_free_temp") + def disk_free_temp(self): + return self._property_disk_free_temp + + @disk_free_temp.setter + def disk_free_temp(self, value): + if value is None: + self._property_disk_free_temp = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "disk_free_temp", six.integer_types) + self._property_disk_free_temp = value + + @schema_property("disk_read") + def disk_read(self): + return self._property_disk_read + + @disk_read.setter + def disk_read(self, value): + if value is None: + self._property_disk_read = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "disk_read", six.integer_types) + self._property_disk_read = value + + @schema_property("disk_write") + def disk_write(self): + return self._property_disk_write + + @disk_write.setter + def disk_write(self, value): + if value is None: + self._property_disk_write = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "disk_write", six.integer_types) + self._property_disk_write = value + + @schema_property("cpu_temperature") + def cpu_temperature(self): + return self._property_cpu_temperature + + @cpu_temperature.setter + def cpu_temperature(self, value): + if value is None: + self._property_cpu_temperature = None + return + + self.assert_isinstance(value, "cpu_temperature", (list, tuple)) + + self.assert_isinstance( + value, "cpu_temperature", six.integer_types + (float,), is_array=True + ) + self._property_cpu_temperature = value + + @schema_property("gpu_temperature") + def gpu_temperature(self): + return self._property_gpu_temperature + + @gpu_temperature.setter + def gpu_temperature(self, value): + if value is None: + self._property_gpu_temperature = None + return + + self.assert_isinstance(value, "gpu_temperature", (list, tuple)) + + self.assert_isinstance( + value, "gpu_temperature", six.integer_types + (float,), is_array=True + ) + self._property_gpu_temperature = value + + +class GetActivityReportRequest(Request): + """ + Returns count of active company workers in the selected time range. + + :param from_date: Starting time (in seconds from epoch) for collecting + statistics + :type from_date: float + :param to_date: Ending time (in seconds from epoch) for collecting statistics + :type to_date: float + :param interval: Time interval in seconds for a single statistics point. The + minimal value is 1 + :type interval: int + """ + + _service = "workers" + _action = "get_activity_report" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "from_date": { + "description": "Starting time (in seconds from epoch) for collecting statistics", + "type": "number", + }, + "interval": { + "description": "Time interval in seconds for a single statistics point. The minimal value is 1", + "type": "integer", + }, + "to_date": { + "description": "Ending time (in seconds from epoch) for collecting statistics", + "type": "number", + }, + }, + "required": ["from_date", "to_date", "interval"], + "type": "object", + } + + def __init__(self, from_date, to_date, interval, **kwargs): + super(GetActivityReportRequest, self).__init__(**kwargs) + self.from_date = from_date + self.to_date = to_date + self.interval = interval + + @schema_property("from_date") + def from_date(self): + return self._property_from_date + + @from_date.setter + def from_date(self, value): + if value is None: + self._property_from_date = None + return + + self.assert_isinstance(value, "from_date", six.integer_types + (float,)) + self._property_from_date = value + + @schema_property("to_date") + def to_date(self): + return self._property_to_date + + @to_date.setter + def to_date(self, value): + if value is None: + self._property_to_date = None + return + + self.assert_isinstance(value, "to_date", six.integer_types + (float,)) + self._property_to_date = value + + @schema_property("interval") + def interval(self): + return self._property_interval + + @interval.setter + def interval(self, value): + if value is None: + self._property_interval = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "interval", six.integer_types) + self._property_interval = value + + +class GetActivityReportResponse(Response): + """ + Response of workers.get_activity_report endpoint. + + :param total: Activity series that include all the workers that sent reports in + the given time interval. + :type total: ActivitySeries + :param active: Activity series that include only workers that worked on a task + in the given time interval. + :type active: ActivitySeries + """ + + _service = "workers" + _action = "get_activity_report" + _version = "2.20" + + _schema = { + "definitions": { + "activity_series": { + "properties": { + "counts": { + "description": "List of worker counts corresponding to the timestamps in the dates list. None values are returned for the dates with no workers.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "dates": { + "description": "List of timestamps (in seconds from epoch) in the acceding order. The timestamps are separated by the requested interval.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "active": { + "description": "Activity series that include only workers that worked on a task in the given time interval.", + "oneOf": [{"$ref": "#/definitions/activity_series"}, {"type": "null"}], + }, + "total": { + "description": "Activity series that include all the workers that sent reports in the given time interval.", + "oneOf": [{"$ref": "#/definitions/activity_series"}, {"type": "null"}], + }, + }, + "type": "object", + } + + def __init__(self, total=None, active=None, **kwargs): + super(GetActivityReportResponse, self).__init__(**kwargs) + self.total = total + self.active = active + + @schema_property("total") + def total(self): + return self._property_total + + @total.setter + def total(self, value): + if value is None: + self._property_total = None + return + if isinstance(value, dict): + value = ActivitySeries.from_dict(value) + else: + self.assert_isinstance(value, "total", ActivitySeries) + self._property_total = value + + @schema_property("active") + def active(self): + return self._property_active + + @active.setter + def active(self, value): + if value is None: + self._property_active = None + return + if isinstance(value, dict): + value = ActivitySeries.from_dict(value) + else: + self.assert_isinstance(value, "active", ActivitySeries) + self._property_active = value + + +class GetAllRequest(Request): + """ + Returns information on all registered workers. + + :param last_seen: Filter out workers not active for more than last_seen + seconds. A value or 0 or 'none' will disable the filter. + :type last_seen: int + :param tags: The list of allowed worker tags. Prepend tag value with '-' in + order to exclude + :type tags: Sequence[str] + """ + + _service = "workers" + _action = "get_all" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "last_seen": { + "default": 3600, + "description": "Filter out workers not active for more than last_seen seconds.\n A value or 0 or 'none' will disable the filter.", + "type": ["integer", "null"], + }, + "tags": { + "description": "The list of allowed worker tags. Prepend tag value with '-' in order to exclude", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, last_seen=3600, tags=None, **kwargs): + super(GetAllRequest, self).__init__(**kwargs) + self.last_seen = last_seen + self.tags = tags + + @schema_property("last_seen") + def last_seen(self): + return self._property_last_seen + + @last_seen.setter + def last_seen(self, value): + if value is None: + self._property_last_seen = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "last_seen", six.integer_types) + self._property_last_seen = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + +class GetAllResponse(Response): + """ + Response of workers.get_all endpoint. + + :param workers: + :type workers: Sequence[Worker] + """ + + _service = "workers" + _action = "get_all" + _version = "2.20" + + _schema = { + "definitions": { + "current_task_entry": { + "properties": { + "id": {"description": "ID", "type": ["string", "null"]}, + "last_iteration": { + "description": "Last task iteration", + "type": ["integer", "null"], + }, + "name": {"description": "Name", "type": ["string", "null"]}, + "running_time": { + "description": "Task running time", + "type": ["integer", "null"], + }, + }, + "type": "object", + }, + "id_name_entry": { + "properties": { + "id": {"description": "ID", "type": ["string", "null"]}, + "name": {"description": "Name", "type": ["string", "null"]}, + }, + "type": "object", + }, + "queue_entry": { + "properties": { + "id": {"description": "ID", "type": ["string", "null"]}, + "name": {"description": "Name", "type": ["string", "null"]}, + "next_task": { + "description": "Next task in the queue", + "oneOf": [ + {"$ref": "#/definitions/id_name_entry"}, + {"type": "null"}, + ], + }, + "num_tasks": { + "description": "Number of task entries in the queue", + "type": ["integer", "null"], + }, + }, + "type": "object", + }, + "worker": { + "properties": { + "company": { + "description": "Associated company", + "oneOf": [ + {"$ref": "#/definitions/id_name_entry"}, + {"type": "null"}, + ], + }, + "id": {"description": "Worker ID", "type": ["string", "null"]}, + "ip": { + "description": "IP of the worker", + "type": ["string", "null"], + }, + "last_activity_time": { + "description": "Last activity time (even if an error occurred)", + "format": "date-time", + "type": ["string", "null"], + }, + "last_report_time": { + "description": "Last successful report time", + "format": "date-time", + "type": ["string", "null"], + }, + "project": { + "description": "Project in which currently executing task resides", + "oneOf": [ + {"$ref": "#/definitions/id_name_entry"}, + {"type": "null"}, + ], + }, + "queue": { + "description": "Queue from which running task was taken", + "oneOf": [ + {"$ref": "#/definitions/queue_entry"}, + {"type": "null"}, + ], + }, + "queues": { + "description": "List of queues on which the worker is listening", + "items": {"$ref": "#/definitions/queue_entry"}, + "type": ["array", "null"], + }, + "register_time": { + "description": "Registration time", + "format": "date-time", + "type": ["string", "null"], + }, + "tags": { + "description": "User tags for the worker", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "task": { + "description": "Task currently being run by the worker", + "oneOf": [ + {"$ref": "#/definitions/current_task_entry"}, + {"type": "null"}, + ], + }, + "user": { + "description": "Associated user (under whose credentials are used by the worker daemon)", + "oneOf": [ + {"$ref": "#/definitions/id_name_entry"}, + {"type": "null"}, + ], + }, + }, + "type": "object", + }, + }, + "properties": { + "workers": { + "items": {"$ref": "#/definitions/worker"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, workers=None, **kwargs): + super(GetAllResponse, self).__init__(**kwargs) + self.workers = workers + + @schema_property("workers") + def workers(self): + return self._property_workers + + @workers.setter + def workers(self, value): + if value is None: + self._property_workers = None + return + + self.assert_isinstance(value, "workers", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [Worker.from_dict(v) if isinstance(v, dict) else v for v in value] + else: + self.assert_isinstance(value, "workers", Worker, is_array=True) + self._property_workers = value + + +class GetMetricKeysRequest(Request): + """ + Returns worker statistics metric keys grouped by categories. + + :param worker_ids: List of worker ids to collect metrics for. If not provided + or empty then all the company workers metrics are analyzed. + :type worker_ids: Sequence[str] + """ + + _service = "workers" + _action = "get_metric_keys" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "worker_ids": { + "description": "List of worker ids to collect metrics for. If not provided or empty then all the company workers metrics are analyzed.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "type": "object", + } + + def __init__(self, worker_ids=None, **kwargs): + super(GetMetricKeysRequest, self).__init__(**kwargs) + self.worker_ids = worker_ids + + @schema_property("worker_ids") + def worker_ids(self): + return self._property_worker_ids + + @worker_ids.setter + def worker_ids(self, value): + if value is None: + self._property_worker_ids = None + return + + self.assert_isinstance(value, "worker_ids", (list, tuple)) + + self.assert_isinstance(value, "worker_ids", six.string_types, is_array=True) + self._property_worker_ids = value + + +class GetMetricKeysResponse(Response): + """ + Response of workers.get_metric_keys endpoint. + + :param categories: List of unique metric categories found in the statistics of + the requested workers. + :type categories: Sequence[MetricsCategory] + """ + + _service = "workers" + _action = "get_metric_keys" + _version = "2.20" + + _schema = { + "definitions": { + "metrics_category": { + "properties": { + "metric_keys": { + "description": "The names of the metrics in the category.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + "name": { + "description": "Name of the metrics category.", + "type": ["string", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "categories": { + "description": "List of unique metric categories found in the statistics of the requested workers.", + "items": {"$ref": "#/definitions/metrics_category"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, categories=None, **kwargs): + super(GetMetricKeysResponse, self).__init__(**kwargs) + self.categories = categories + + @schema_property("categories") + def categories(self): + return self._property_categories + + @categories.setter + def categories(self, value): + if value is None: + self._property_categories = None + return + + self.assert_isinstance(value, "categories", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + MetricsCategory.from_dict(v) if isinstance(v, dict) else v + for v in value + ] + else: + self.assert_isinstance(value, "categories", MetricsCategory, is_array=True) + self._property_categories = value + + +class GetStatsRequest(Request): + """ + Returns statistics for the selected workers and time range aggregated by date intervals. + + :param worker_ids: List of worker ids to collect metrics for. If not provided + or empty then all the company workers metrics are analyzed. + :type worker_ids: Sequence[str] + :param from_date: Starting time (in seconds from epoch) for collecting + statistics + :type from_date: float + :param to_date: Ending time (in seconds from epoch) for collecting statistics + :type to_date: float + :param interval: Time interval in seconds for a single statistics point. The + minimal value is 1 + :type interval: int + :param items: List of metric keys and requested statistics + :type items: Sequence[StatItem] + :param split_by_variant: If true then break statistics by hardware sub types + :type split_by_variant: bool + """ + + _service = "workers" + _action = "get_stats" + _version = "2.20" + _schema = { + "definitions": { + "aggregation_type": { + "description": "Metric aggregation type", + "enum": ["avg", "min", "max"], + "type": "string", + }, + "stat_item": { + "properties": { + "category": { + "oneOf": [ + {"$ref": "#/definitions/aggregation_type"}, + {"type": "null"}, + ] + }, + "key": { + "description": "Name of a metric", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + }, + "properties": { + "from_date": { + "description": "Starting time (in seconds from epoch) for collecting statistics", + "type": "number", + }, + "interval": { + "description": "Time interval in seconds for a single statistics point. The minimal value is 1", + "type": "integer", + }, + "items": { + "description": "List of metric keys and requested statistics", + "items": {"$ref": "#/definitions/stat_item"}, + "type": "array", + }, + "split_by_variant": { + "default": False, + "description": "If true then break statistics by hardware sub types", + "type": "boolean", + }, + "to_date": { + "description": "Ending time (in seconds from epoch) for collecting statistics", + "type": "number", + }, + "worker_ids": { + "description": "List of worker ids to collect metrics for. If not provided or empty then all the company workers metrics are analyzed.", + "items": {"type": "string"}, + "type": ["array", "null"], + }, + }, + "required": ["from_date", "to_date", "interval", "items"], + "type": "object", + } + + def __init__( + self, + from_date, + to_date, + interval, + items, + worker_ids=None, + split_by_variant=False, + **kwargs + ): + super(GetStatsRequest, self).__init__(**kwargs) + self.worker_ids = worker_ids + self.from_date = from_date + self.to_date = to_date + self.interval = interval + self.items = items + self.split_by_variant = split_by_variant + + @schema_property("worker_ids") + def worker_ids(self): + return self._property_worker_ids + + @worker_ids.setter + def worker_ids(self, value): + if value is None: + self._property_worker_ids = None + return + + self.assert_isinstance(value, "worker_ids", (list, tuple)) + + self.assert_isinstance(value, "worker_ids", six.string_types, is_array=True) + self._property_worker_ids = value + + @schema_property("from_date") + def from_date(self): + return self._property_from_date + + @from_date.setter + def from_date(self, value): + if value is None: + self._property_from_date = None + return + + self.assert_isinstance(value, "from_date", six.integer_types + (float,)) + self._property_from_date = value + + @schema_property("to_date") + def to_date(self): + return self._property_to_date + + @to_date.setter + def to_date(self, value): + if value is None: + self._property_to_date = None + return + + self.assert_isinstance(value, "to_date", six.integer_types + (float,)) + self._property_to_date = value + + @schema_property("interval") + def interval(self): + return self._property_interval + + @interval.setter + def interval(self, value): + if value is None: + self._property_interval = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "interval", six.integer_types) + self._property_interval = value + + @schema_property("items") + def items(self): + return self._property_items + + @items.setter + def items(self, value): + if value is None: + self._property_items = None + return + + self.assert_isinstance(value, "items", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [StatItem.from_dict(v) if isinstance(v, dict) else v for v in value] + else: + self.assert_isinstance(value, "items", StatItem, is_array=True) + self._property_items = value + + @schema_property("split_by_variant") + def split_by_variant(self): + return self._property_split_by_variant + + @split_by_variant.setter + def split_by_variant(self, value): + if value is None: + self._property_split_by_variant = None + return + + self.assert_isinstance(value, "split_by_variant", (bool,)) + self._property_split_by_variant = value + + +class GetStatsResponse(Response): + """ + Response of workers.get_stats endpoint. + + :param workers: List of the requested workers with their statistics + :type workers: Sequence[WorkerStats] + """ + + _service = "workers" + _action = "get_stats" + _version = "2.20" + + _schema = { + "definitions": { + "aggregation_stats": { + "properties": { + "aggregation": { + "oneOf": [ + {"$ref": "#/definitions/aggregation_type"}, + {"type": "null"}, + ] + }, + "values": { + "description": "List of values corresponding to the dates in metric statistics", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + }, + "type": "object", + }, + "aggregation_type": { + "description": "Metric aggregation type", + "enum": ["avg", "min", "max"], + "type": "string", + }, + "metric_stats": { + "properties": { + "dates": { + "description": "List of timestamps (in seconds from epoch) in the acceding order. The timestamps are separated by the requested interval. Timestamps where no workers activity was recorded are omitted.", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "metric": { + "description": "Name of the metric (cpu_usage, memory_used etc.)", + "type": ["string", "null"], + }, + "stats": { + "description": "Statistics data by type", + "items": {"$ref": "#/definitions/aggregation_stats"}, + "type": ["array", "null"], + }, + "variant": { + "description": "Name of the metric component. Set only if 'split_by_variant' was set in the request", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + "worker_stats": { + "properties": { + "metrics": { + "description": "List of the metrics statistics for the worker", + "items": {"$ref": "#/definitions/metric_stats"}, + "type": ["array", "null"], + }, + "worker": { + "description": "ID of the worker", + "type": ["string", "null"], + }, + }, + "type": "object", + }, + }, + "properties": { + "workers": { + "description": "List of the requested workers with their statistics", + "items": {"$ref": "#/definitions/worker_stats"}, + "type": ["array", "null"], + } + }, + "type": "object", + } + + def __init__(self, workers=None, **kwargs): + super(GetStatsResponse, self).__init__(**kwargs) + self.workers = workers + + @schema_property("workers") + def workers(self): + return self._property_workers + + @workers.setter + def workers(self, value): + if value is None: + self._property_workers = None + return + + self.assert_isinstance(value, "workers", (list, tuple)) + if any(isinstance(v, dict) for v in value): + value = [ + WorkerStats.from_dict(v) if isinstance(v, dict) else v for v in value + ] + else: + self.assert_isinstance(value, "workers", WorkerStats, is_array=True) + self._property_workers = value + + +class RegisterRequest(Request): + """ + Register a worker in the system. Called by the Worker Daemon. + + :param worker: Worker id. Must be unique in company. + :type worker: str + :param timeout: Registration timeout in seconds. If timeout seconds have passed + since the worker's last call to register or status_report, the worker is + automatically removed from the list of registered workers. + :type timeout: int + :param queues: List of queue IDs on which the worker is listening. + :type queues: Sequence[str] + :param tags: User tags for the worker + :type tags: Sequence[str] + """ + + _service = "workers" + _action = "register" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "queues": { + "description": "List of queue IDs on which the worker is listening.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "User tags for the worker", + "items": {"type": "string"}, + "type": "array", + }, + "timeout": { + "default": 600, + "description": "Registration timeout in seconds. If timeout seconds have passed since the worker's last call to register or status_report, the worker is automatically removed from the list of registered workers.", + "type": "integer", + }, + "worker": { + "description": "Worker id. Must be unique in company.", + "type": "string", + }, + }, + "required": ["worker"], + "type": "object", + } + + def __init__(self, worker, timeout=600, queues=None, tags=None, **kwargs): + super(RegisterRequest, self).__init__(**kwargs) + self.worker = worker + self.timeout = timeout + self.queues = queues + self.tags = tags + + @schema_property("worker") + def worker(self): + return self._property_worker + + @worker.setter + def worker(self, value): + if value is None: + self._property_worker = None + return + + self.assert_isinstance(value, "worker", six.string_types) + self._property_worker = value + + @schema_property("timeout") + def timeout(self): + return self._property_timeout + + @timeout.setter + def timeout(self, value): + if value is None: + self._property_timeout = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "timeout", six.integer_types) + self._property_timeout = value + + @schema_property("queues") + def queues(self): + return self._property_queues + + @queues.setter + def queues(self, value): + if value is None: + self._property_queues = None + return + + self.assert_isinstance(value, "queues", (list, tuple)) + + self.assert_isinstance(value, "queues", six.string_types, is_array=True) + self._property_queues = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + +class RegisterResponse(Response): + """ + Response of workers.register endpoint. + + """ + + _service = "workers" + _action = "register" + _version = "2.20" + + _schema = {"definitions": {}, "properties": {}, "type": "object"} + + +class StatusReportRequest(Request): + """ + Called periodically by the worker daemon to report machine status + + :param worker: Worker id. + :type worker: str + :param task: ID of a task currently being run by the worker. If no task is + sent, the worker's task field will be cleared. + :type task: str + :param queue: ID of the queue from which task was received. If no queue is + sent, the worker's queue field will be cleared. + :type queue: str + :param queues: List of queue IDs on which the worker is listening. If null, the + worker's queues list will not be updated. + :type queues: Sequence[str] + :param timestamp: UNIX time in seconds since epoch. + :type timestamp: int + :param machine_stats: The machine statistics. + :type machine_stats: MachineStats + :param tags: New user tags for the worker + :type tags: Sequence[str] + """ + + _service = "workers" + _action = "status_report" + _version = "2.20" + _schema = { + "definitions": { + "machine_stats": { + "properties": { + "cpu_temperature": { + "description": "CPU temperature", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "cpu_usage": { + "description": "Average CPU usage per core", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "disk_free_home": { + "description": "Mbytes free space of /home drive", + "type": ["integer", "null"], + }, + "disk_free_temp": { + "description": "Mbytes free space of /tmp drive", + "type": ["integer", "null"], + }, + "disk_read": { + "description": "Mbytes read per second", + "type": ["integer", "null"], + }, + "disk_write": { + "description": "Mbytes write per second", + "type": ["integer", "null"], + }, + "gpu_memory_free": { + "description": "GPU free memory MBs", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "gpu_memory_used": { + "description": "GPU used memory MBs", + "items": {"type": "integer"}, + "type": ["array", "null"], + }, + "gpu_temperature": { + "description": "GPU temperature", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "gpu_usage": { + "description": "Average GPU usage per GPU card", + "items": {"type": "number"}, + "type": ["array", "null"], + }, + "memory_free": { + "description": "Free memory MBs", + "type": ["integer", "null"], + }, + "memory_used": { + "description": "Used memory MBs", + "type": ["integer", "null"], + }, + "network_rx": { + "description": "Mbytes per second", + "type": ["integer", "null"], + }, + "network_tx": { + "description": "Mbytes per second", + "type": ["integer", "null"], + }, + }, + "type": "object", + } + }, + "properties": { + "machine_stats": { + "$ref": "#/definitions/machine_stats", + "description": "The machine statistics.", + }, + "queue": { + "description": "ID of the queue from which task was received. If no queue is sent, the worker's queue field will be cleared.", + "type": "string", + }, + "queues": { + "description": "List of queue IDs on which the worker is listening. If null, the worker's queues list will not be updated.", + "items": {"type": "string"}, + "type": "array", + }, + "tags": { + "description": "New user tags for the worker", + "items": {"type": "string"}, + "type": "array", + }, + "task": { + "description": "ID of a task currently being run by the worker. If no task is sent, the worker's task field will be cleared.", + "type": "string", + }, + "timestamp": { + "description": "UNIX time in seconds since epoch.", + "type": "integer", + }, + "worker": {"description": "Worker id.", "type": "string"}, + }, + "required": ["worker", "timestamp"], + "type": "object", + } + + def __init__( + self, + worker, + timestamp, + task=None, + queue=None, + queues=None, + machine_stats=None, + tags=None, + **kwargs + ): + super(StatusReportRequest, self).__init__(**kwargs) + self.worker = worker + self.task = task + self.queue = queue + self.queues = queues + self.timestamp = timestamp + self.machine_stats = machine_stats + self.tags = tags + + @schema_property("worker") + def worker(self): + return self._property_worker + + @worker.setter + def worker(self, value): + if value is None: + self._property_worker = None + return + + self.assert_isinstance(value, "worker", six.string_types) + self._property_worker = value + + @schema_property("task") + def task(self): + return self._property_task + + @task.setter + def task(self, value): + if value is None: + self._property_task = None + return + + self.assert_isinstance(value, "task", six.string_types) + self._property_task = value + + @schema_property("queue") + def queue(self): + return self._property_queue + + @queue.setter + def queue(self, value): + if value is None: + self._property_queue = None + return + + self.assert_isinstance(value, "queue", six.string_types) + self._property_queue = value + + @schema_property("queues") + def queues(self): + return self._property_queues + + @queues.setter + def queues(self, value): + if value is None: + self._property_queues = None + return + + self.assert_isinstance(value, "queues", (list, tuple)) + + self.assert_isinstance(value, "queues", six.string_types, is_array=True) + self._property_queues = value + + @schema_property("timestamp") + def timestamp(self): + return self._property_timestamp + + @timestamp.setter + def timestamp(self, value): + if value is None: + self._property_timestamp = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "timestamp", six.integer_types) + self._property_timestamp = value + + @schema_property("machine_stats") + def machine_stats(self): + return self._property_machine_stats + + @machine_stats.setter + def machine_stats(self, value): + if value is None: + self._property_machine_stats = None + return + if isinstance(value, dict): + value = MachineStats.from_dict(value) + else: + self.assert_isinstance(value, "machine_stats", MachineStats) + self._property_machine_stats = value + + @schema_property("tags") + def tags(self): + return self._property_tags + + @tags.setter + def tags(self, value): + if value is None: + self._property_tags = None + return + + self.assert_isinstance(value, "tags", (list, tuple)) + + self.assert_isinstance(value, "tags", six.string_types, is_array=True) + self._property_tags = value + + +class StatusReportResponse(Response): + """ + Response of workers.status_report endpoint. + + """ + + _service = "workers" + _action = "status_report" + _version = "2.20" + + _schema = {"definitions": {}, "properties": {}, "type": "object"} + + +class UnregisterRequest(Request): + """ + Unregister a worker in the system. Called by the Worker Daemon. + + :param worker: Worker id. Must be unique in company. + :type worker: str + """ + + _service = "workers" + _action = "unregister" + _version = "2.20" + _schema = { + "definitions": {}, + "properties": { + "worker": { + "description": "Worker id. Must be unique in company.", + "type": "string", + } + }, + "required": ["worker"], + "type": "object", + } + + def __init__(self, worker, **kwargs): + super(UnregisterRequest, self).__init__(**kwargs) + self.worker = worker + + @schema_property("worker") + def worker(self): + return self._property_worker + + @worker.setter + def worker(self, value): + if value is None: + self._property_worker = None + return + + self.assert_isinstance(value, "worker", six.string_types) + self._property_worker = value + + +class UnregisterResponse(Response): + """ + Response of workers.unregister endpoint. + + """ + + _service = "workers" + _action = "unregister" + _version = "2.20" + + _schema = {"definitions": {}, "properties": {}, "type": "object"} + + +response_mapping = { + GetAllRequest: GetAllResponse, + RegisterRequest: RegisterResponse, + UnregisterRequest: UnregisterResponse, + StatusReportRequest: StatusReportResponse, + GetMetricKeysRequest: GetMetricKeysResponse, + GetStatsRequest: GetStatsResponse, + GetActivityReportRequest: GetActivityReportResponse, +} diff --git a/clearml/backend_interface/task/task.py b/clearml/backend_interface/task/task.py index 0f623654..ed473b04 100644 --- a/clearml/backend_interface/task/task.py +++ b/clearml/backend_interface/task/task.py @@ -340,12 +340,13 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin): tags = [self._development_tag] if not running_remotely() else [] extra_properties = {'system_tags': tags} if Session.check_min_api_version('2.3') else {'tags': tags} + if not Session.check_min_api_version("2.20"): + extra_properties["input"] = {"view": {}} req = tasks.CreateRequest( name=task_name or make_message('Anonymous task (%(user)s@%(host)s %(time)s)'), type=tasks.TaskTypeEnum(task_type), comment=created_msg, project=project_id, - input={'view': {}}, **extra_properties ) res = self.send(req)