diff --git a/trains/backend_api/api_proxy.py b/trains/backend_api/api_proxy.py new file mode 100644 index 00000000..08ad9496 --- /dev/null +++ b/trains/backend_api/api_proxy.py @@ -0,0 +1,19 @@ +from .session import Session +import importlib + + +class ApiServiceProxy(object): + def __init__(self, module): + self.__wrapped_name__ = module + self.__wrapped_version__ = Session.api_version + + def __getattr__(self, attr): + if attr in ['__wrapped_name__', '__wrapped__', '__wrapped_version__']: + return self.__dict__.get(attr) + + if not self.__dict__.get('__wrapped__') or self.__dict__.get('__wrapped_version__') != Session.api_version: + self.__dict__['__wrapped_version__'] = Session.api_version + self.__dict__['__wrapped__'] = importlib.import_module('.v'+str(Session.api_version).replace('.', '_') + + '.' + self.__dict__.get('__wrapped_name__'), + package='trains.backend_api.services') + return getattr(self.__dict__['__wrapped__'], attr) diff --git a/trains/backend_api/services/__init__.py b/trains/backend_api/services/__init__.py index 6d86ff43..af869660 100644 --- a/trains/backend_api/services/__init__.py +++ b/trains/backend_api/services/__init__.py @@ -1,22 +1,19 @@ -from .v2_1 import async_request -from .v2_1 import auth -from .v2_1 import debug -from .v2_1 import events -from .v2_1 import models -from .v2_1 import news -from .v2_1 import projects -from .v2_1 import storage -from .v2_1 import tasks +from ..api_proxy import ApiServiceProxy +# allow us to replace the api version after we have completed the authentication process, +# and we know the backend server api version. +# ApiServiceProxy will dynamically load the correct api object based on the session api_version +auth = ApiServiceProxy('auth') +events = ApiServiceProxy('events') +models = ApiServiceProxy('models') +projects = ApiServiceProxy('projects') +tasks = ApiServiceProxy('tasks') + __all__ = [ - 'async_request', 'auth', - 'debug', 'events', 'models', - 'news', 'projects', - 'storage', 'tasks', ] diff --git a/trains/backend_api/services/v2_1/async_request.py b/trains/backend_api/services/v2_1/async_request.py deleted file mode 100644 index 8f466670..00000000 --- a/trains/backend_api/services/v2_1/async_request.py +++ /dev/null @@ -1,414 +0,0 @@ -""" -async service - -This service provides support for asynchronous API calls. -""" -import six -import types -from datetime import datetime -import enum - -from dateutil.parser import parse as parse_datetime - -from ....backend_api.session import Request, BatchRequest, Response, DataModel, NonStrictDataModel, CompoundRequest, schema_property, StringEnum - - -class Call(NonStrictDataModel): - """ - :param id: The job ID associated with this call. - :type id: str - :param status: The job's status. - :type status: str - :param created: Job creation time. - :type created: str - :param ended: Job end time. - :type ended: str - :param enqueued: Job enqueue time. - :type enqueued: str - :param meta: Metadata for this job, includes endpoint and additional relevant - call data. - :type meta: dict - :param company: The Company this job belongs to. - :type company: str - :param exec_info: Job execution information. - :type exec_info: str - """ - _schema = { - 'properties': { - 'company': { - 'description': 'The Company this job belongs to.', - 'type': ['string', 'null'], - }, - 'created': { - 'description': 'Job creation time.', - 'type': ['string', 'null'], - }, - 'ended': {'description': 'Job end time.', 'type': ['string', 'null']}, - 'enqueued': { - 'description': 'Job enqueue time.', - 'type': ['string', 'null'], - }, - 'exec_info': { - 'description': 'Job execution information.', - 'type': ['string', 'null'], - }, - 'id': { - 'description': 'The job ID associated with this call.', - 'type': ['string', 'null'], - }, - 'meta': { - 'additionalProperties': True, - 'description': 'Metadata for this job, includes endpoint and additional relevant call data.', - 'type': ['object', 'null'], - }, - 'status': { - 'description': "The job's status.", - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, id=None, status=None, created=None, ended=None, enqueued=None, meta=None, company=None, exec_info=None, **kwargs): - super(Call, self).__init__(**kwargs) - self.id = id - self.status = status - self.created = created - self.ended = ended - self.enqueued = enqueued - self.meta = meta - self.company = company - self.exec_info = exec_info - - @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('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", six.string_types) - self._property_status = 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) - self._property_created = value - - @schema_property('ended') - def ended(self): - return self._property_ended - - @ended.setter - def ended(self, value): - if value is None: - self._property_ended = None - return - - self.assert_isinstance(value, "ended", six.string_types) - self._property_ended = 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", six.string_types) - self._property_enqueued = value - - @schema_property('meta') - def meta(self): - return self._property_meta - - @meta.setter - def meta(self, value): - if value is None: - self._property_meta = None - return - - self.assert_isinstance(value, "meta", (dict,)) - self._property_meta = 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('exec_info') - def exec_info(self): - return self._property_exec_info - - @exec_info.setter - def exec_info(self, value): - if value is None: - self._property_exec_info = None - return - - self.assert_isinstance(value, "exec_info", six.string_types) - self._property_exec_info = value - - -class CallsRequest(Request): - """ - Get a list of all asynchronous API calls handled by the system. - This includes both previously handled calls, calls being executed and calls waiting in queue. - - :param status: Return only calls who's status is in this list. - :type status: Sequence[str] - :param endpoint: Return only calls handling this endpoint. Supports wildcards. - :type endpoint: str - :param task: Return only calls associated with this task ID. Supports - wildcards. - :type task: str - """ - - _service = "async" - _action = "calls" - _version = "1.5" - _schema = { - 'definitions': {}, - 'properties': { - 'endpoint': { - 'description': 'Return only calls handling this endpoint. Supports wildcards.', - 'type': ['string', 'null'], - }, - 'status': { - 'description': "Return only calls who's status is in this list.", - 'items': {'enum': ['queued', 'in_progress', 'completed'], 'type': 'string'}, - 'type': ['array', 'null'], - }, - 'task': { - 'description': 'Return only calls associated with this task ID. Supports wildcards.', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, status=None, endpoint=None, task=None, **kwargs): - super(CallsRequest, self).__init__(**kwargs) - self.status = status - self.endpoint = endpoint - self.task = task - - @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)) - - self.assert_isinstance(value, "status", six.string_types, is_array=True) - self._property_status = value - - @schema_property('endpoint') - def endpoint(self): - return self._property_endpoint - - @endpoint.setter - def endpoint(self, value): - if value is None: - self._property_endpoint = None - return - - self.assert_isinstance(value, "endpoint", six.string_types) - self._property_endpoint = 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 CallsResponse(Response): - """ - Response of async.calls endpoint. - - :param calls: A list of the current asynchronous calls handled by the system. - :type calls: Sequence[Call] - """ - _service = "async" - _action = "calls" - _version = "1.5" - - _schema = { - 'definitions': { - 'call': { - 'properties': { - 'company': { - 'description': 'The Company this job belongs to.', - 'type': ['string', 'null'], - }, - 'created': { - 'description': 'Job creation time.', - 'type': ['string', 'null'], - }, - 'ended': { - 'description': 'Job end time.', - 'type': ['string', 'null'], - }, - 'enqueued': { - 'description': 'Job enqueue time.', - 'type': ['string', 'null'], - }, - 'exec_info': { - 'description': 'Job execution information.', - 'type': ['string', 'null'], - }, - 'id': { - 'description': 'The job ID associated with this call.', - 'type': ['string', 'null'], - }, - 'meta': { - 'additionalProperties': True, - 'description': 'Metadata for this job, includes endpoint and additional relevant call data.', - 'type': ['object', 'null'], - }, - 'status': { - 'description': "The job's status.", - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - }, - 'properties': { - 'calls': { - 'description': 'A list of the current asynchronous calls handled by the system.', - 'items': {'$ref': '#/definitions/call'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, calls=None, **kwargs): - super(CallsResponse, self).__init__(**kwargs) - self.calls = calls - - @schema_property('calls') - def calls(self): - return self._property_calls - - @calls.setter - def calls(self, value): - if value is None: - self._property_calls = None - return - - self.assert_isinstance(value, "calls", (list, tuple)) - if any(isinstance(v, dict) for v in value): - value = [Call.from_dict(v) if isinstance(v, dict) else v for v in value] - else: - self.assert_isinstance(value, "calls", Call, is_array=True) - self._property_calls = value - - -class ResultRequest(Request): - """ - Try getting the result of a previously accepted asynchronous API call. - If execution for the asynchronous call has completed, the complete call response data will be returned. - Otherwise, a 202 code will be returned with no data - - :param id: The id returned by the accepted asynchronous API call. - :type id: str - """ - - _service = "async" - _action = "result" - _version = "1.5" - _schema = { - 'definitions': {}, - 'properties': { - 'id': { - 'description': 'The id returned by the accepted asynchronous API call.', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, id=None, **kwargs): - super(ResultRequest, 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 ResultResponse(Response): - """ - Response of async.result endpoint. - - """ - _service = "async" - _action = "result" - _version = "1.5" - - _schema = {'additionalProperties': True, 'definitions': {}, 'type': 'object'} - - -response_mapping = { - ResultRequest: ResultResponse, - CallsRequest: CallsResponse, -} diff --git a/trains/backend_api/services/v2_1/auth.py b/trains/backend_api/services/v2_1/auth.py index 7b7aa63c..c715e1e6 100644 --- a/trains/backend_api/services/v2_1/auth.py +++ b/trains/backend_api/services/v2_1/auth.py @@ -92,275 +92,6 @@ class CredentialKey(NonStrictDataModel): self._property_access_key = value -class AddUserRequest(Request): - """ - Add a new user manually. Only supported in on-premises deployments - - :param secret_key: A secret key (used as the user's password) - :type secret_key: str - :param name: User name (makes the auth entry more readable) - :type name: str - :param company: Associated company ID. If not provided, the caller's company ID - will be used - :type company: str - :param email: Email address uniquely identifying the user - :type email: str - :param provider: Provider ID indicating the external provider used to - authenticate the user - :type provider: str - :param provider_user_id: Unique user ID assigned by the external provider - :type provider_user_id: str - :param provider_token: Provider-issued token for this user - :type provider_token: str - :param given_name: Given name - :type given_name: str - :param family_name: Family name - :type family_name: str - :param avatar: Avatar URL - :type avatar: str - """ - - _service = "auth" - _action = "add_user" - _version = "1.5" - _schema = { - 'definitions': {}, - 'properties': { - 'avatar': {'description': 'Avatar URL', 'type': 'string'}, - 'company': { - 'description': "Associated company ID. If not provided, the caller's company ID will be used", - 'type': 'string', - }, - 'email': { - 'description': 'Email address uniquely identifying the user', - 'type': 'string', - }, - 'family_name': {'description': 'Family name', 'type': 'string'}, - 'given_name': {'description': 'Given name', 'type': 'string'}, - 'name': { - 'description': 'User name (makes the auth entry more readable)', - 'type': 'string', - }, - 'provider': { - 'description': 'Provider ID indicating the external provider used to authenticate the user', - 'type': 'string', - }, - 'provider_token': { - 'description': 'Provider-issued token for this user', - 'type': 'string', - }, - 'provider_user_id': { - 'description': 'Unique user ID assigned by the external provider', - 'type': 'string', - }, - 'secret_key': { - 'description': "A secret key (used as the user's password)", - 'type': ['string', 'null'], - }, - }, - 'required': ['name', 'email'], - 'type': 'object', - } - def __init__( - self, name, email, secret_key=None, company=None, provider=None, provider_user_id=None, provider_token=None, given_name=None, family_name=None, avatar=None, **kwargs): - super(AddUserRequest, self).__init__(**kwargs) - self.secret_key = secret_key - self.name = name - self.company = company - self.email = email - self.provider = provider - self.provider_user_id = provider_user_id - self.provider_token = provider_token - self.given_name = given_name - self.family_name = family_name - self.avatar = avatar - - @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('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('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('email') - def email(self): - return self._property_email - - @email.setter - def email(self, value): - if value is None: - self._property_email = None - return - - self.assert_isinstance(value, "email", six.string_types) - self._property_email = value - - @schema_property('provider') - def provider(self): - return self._property_provider - - @provider.setter - def provider(self, value): - if value is None: - self._property_provider = None - return - - self.assert_isinstance(value, "provider", six.string_types) - self._property_provider = value - - @schema_property('provider_user_id') - def provider_user_id(self): - return self._property_provider_user_id - - @provider_user_id.setter - def provider_user_id(self, value): - if value is None: - self._property_provider_user_id = None - return - - self.assert_isinstance(value, "provider_user_id", six.string_types) - self._property_provider_user_id = value - - @schema_property('provider_token') - def provider_token(self): - return self._property_provider_token - - @provider_token.setter - def provider_token(self, value): - if value is None: - self._property_provider_token = None - return - - self.assert_isinstance(value, "provider_token", six.string_types) - self._property_provider_token = value - - @schema_property('given_name') - def given_name(self): - return self._property_given_name - - @given_name.setter - def given_name(self, value): - if value is None: - self._property_given_name = None - return - - self.assert_isinstance(value, "given_name", six.string_types) - self._property_given_name = value - - @schema_property('family_name') - def family_name(self): - return self._property_family_name - - @family_name.setter - def family_name(self, value): - if value is None: - self._property_family_name = None - return - - self.assert_isinstance(value, "family_name", six.string_types) - self._property_family_name = value - - @schema_property('avatar') - def avatar(self): - return self._property_avatar - - @avatar.setter - def avatar(self, value): - if value is None: - self._property_avatar = None - return - - self.assert_isinstance(value, "avatar", six.string_types) - self._property_avatar = value - - -class AddUserResponse(Response): - """ - Response of auth.add_user endpoint. - - :param id: New user ID - :type id: str - :param secret: The secret key used as the user's password - :type secret: str - """ - _service = "auth" - _action = "add_user" - _version = "1.5" - - _schema = { - 'definitions': {}, - 'properties': { - 'id': {'description': 'New user ID', 'type': ['string', 'null']}, - 'secret': { - 'description': "The secret key used as the user's password", - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, id=None, secret=None, **kwargs): - super(AddUserResponse, self).__init__(**kwargs) - self.id = id - self.secret = secret - - @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('secret') - def secret(self): - return self._property_secret - - @secret.setter - def secret(self, value): - if value is None: - self._property_secret = None - return - - self.assert_isinstance(value, "secret", six.string_types) - self._property_secret = value class CreateCredentialsRequest(Request): @@ -706,105 +437,6 @@ class GetCredentialsResponse(Response): self._property_credentials = value -class GetTaskTokenRequest(Request): - """ - Get a task-limited token based on supplied credentials (token or key/secret). - Intended for use by users who wish to run a task under limited credentials. - Returned token will be limited so that all operations can only be performed on the - specified task. - - :param task: Task ID - :type task: str - :param expiration_sec: Requested token expiration time in seconds. Not - guaranteed, might be overridden by the service - :type expiration_sec: int - """ - - _service = "auth" - _action = "get_task_token" - _version = "1.5" - _schema = { - 'definitions': {}, - 'properties': { - 'expiration_sec': { - 'description': 'Requested token expiration time in seconds.\n Not guaranteed, might be overridden by the service', - 'type': 'integer', - }, - 'task': {'description': 'Task ID', 'type': 'string'}, - }, - 'required': ['task'], - 'type': 'object', - } - def __init__( - self, task, expiration_sec=None, **kwargs): - super(GetTaskTokenRequest, self).__init__(**kwargs) - self.task = task - self.expiration_sec = expiration_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('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 GetTaskTokenResponse(Response): - """ - Response of auth.get_task_token endpoint. - - :param token: Token string - :type token: str - """ - _service = "auth" - _action = "get_task_token" - _version = "1.5" - - _schema = { - 'definitions': {}, - 'properties': { - 'token': {'description': 'Token string', 'type': ['string', 'null']}, - }, - 'type': 'object', - } - def __init__( - self, token=None, **kwargs): - super(GetTaskTokenResponse, 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 LoginRequest(Request): @@ -890,28 +522,6 @@ class LoginResponse(Response): self._property_token = value -class ReloadConfigRequest(Request): - """ - Reload auth configuration (currently supports blocking tokens). For user roles associated with a company (Admin, Superuser) this call will only affect company-related configuration. - - """ - - _service = "auth" - _action = "reload_config" - _version = "1.5" - _schema = {'definitions': {}, 'properties': {}, 'type': 'object'} - - -class ReloadConfigResponse(Response): - """ - Response of auth.reload_config endpoint. - - """ - _service = "auth" - _action = "reload_config" - _version = "1.5" - - _schema = {'definitions': {}, 'properties': {}, 'type': 'object'} class RevokeCredentialsRequest(Request): @@ -999,114 +609,13 @@ class RevokeCredentialsResponse(Response): self._property_revoked = value -class SetCredentialsRequest(Request): - """ - Set a secret_key for a given access_key. Only supported in on-premises deployments - - :param access_key: Credentials key. Must be identical to the user's ID (this is - the only value supported in on-premises deployments) - :type access_key: str - :param secret_key: New secret key - :type secret_key: str - """ - - _service = "auth" - _action = "set_credentials" - _version = "1.5" - _schema = { - 'definitions': {}, - 'properties': { - 'access_key': { - 'description': "Credentials key. Must be identical to the user's ID (this is the only value supported in on-premises deployments)", - 'type': 'string', - }, - 'secret_key': {'description': 'New secret key', 'type': 'string'}, - }, - 'required': ['access_key', 'secret_key'], - 'type': 'object', - } - def __init__( - self, access_key, secret_key, **kwargs): - super(SetCredentialsRequest, self).__init__(**kwargs) - self.access_key = access_key - self.secret_key = secret_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 - - @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 - - -class SetCredentialsResponse(Response): - """ - Response of auth.set_credentials endpoint. - - :param set: True if secret was successfully set, False otherwise - :type set: bool - """ - _service = "auth" - _action = "set_credentials" - _version = "1.5" - - _schema = { - 'definitions': {}, - 'properties': { - 'set': { - 'description': 'True if secret was successfully set, False otherwise', - 'type': ['boolean', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, set=None, **kwargs): - super(SetCredentialsResponse, self).__init__(**kwargs) - self.set = set - - @schema_property('set') - def set(self): - return self._property_set - - @set.setter - def set(self, value): - if value is None: - self._property_set = None - return - - self.assert_isinstance(value, "set", (bool,)) - self._property_set = value response_mapping = { LoginRequest: LoginResponse, - GetTaskTokenRequest: GetTaskTokenResponse, CreateCredentialsRequest: CreateCredentialsResponse, GetCredentialsRequest: GetCredentialsResponse, RevokeCredentialsRequest: RevokeCredentialsResponse, - SetCredentialsRequest: SetCredentialsResponse, - AddUserRequest: AddUserResponse, DeleteUserRequest: DeleteUserResponse, - ReloadConfigRequest: ReloadConfigResponse, EditUserRequest: EditUserResponse, } diff --git a/trains/backend_api/services/v2_1/debug.py b/trains/backend_api/services/v2_1/debug.py deleted file mode 100644 index c5839336..00000000 --- a/trains/backend_api/services/v2_1/debug.py +++ /dev/null @@ -1,194 +0,0 @@ -""" -debug service - -Debugging utilities -""" -import six -import types -from datetime import datetime -import enum - -from dateutil.parser import parse as parse_datetime - -from ....backend_api.session import Request, BatchRequest, Response, DataModel, NonStrictDataModel, CompoundRequest, schema_property, StringEnum - - -class ApiexRequest(Request): - """ - """ - - _service = "debug" - _action = "apiex" - _version = "1.5" - _schema = {'definitions': {}, 'properties': {}, 'required': [], 'type': 'object'} - - -class ApiexResponse(Response): - """ - Response of debug.apiex endpoint. - - """ - _service = "debug" - _action = "apiex" - _version = "1.5" - - _schema = {'definitions': {}, 'properties': {}, 'type': 'object'} - - -class EchoRequest(Request): - """ - Return request data - - """ - - _service = "debug" - _action = "echo" - _version = "1.5" - _schema = {'definitions': {}, 'properties': {}, 'type': 'object'} - - -class EchoResponse(Response): - """ - Response of debug.echo endpoint. - - """ - _service = "debug" - _action = "echo" - _version = "1.5" - - _schema = {'definitions': {}, 'properties': {}, 'type': 'object'} - - -class ExRequest(Request): - """ - """ - - _service = "debug" - _action = "ex" - _version = "1.5" - _schema = {'definitions': {}, 'properties': {}, 'required': [], 'type': 'object'} - - -class ExResponse(Response): - """ - Response of debug.ex endpoint. - - """ - _service = "debug" - _action = "ex" - _version = "1.5" - - _schema = {'definitions': {}, 'properties': {}, 'type': 'object'} - - -class PingRequest(Request): - """ - Return a message. Does not require authorization. - - """ - - _service = "debug" - _action = "ping" - _version = "1.5" - _schema = {'definitions': {}, 'properties': {}, 'type': 'object'} - - -class PingResponse(Response): - """ - Response of debug.ping endpoint. - - :param msg: A friendly message - :type msg: str - """ - _service = "debug" - _action = "ping" - _version = "1.5" - - _schema = { - 'definitions': {}, - 'properties': { - 'msg': { - 'description': 'A friendly message', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, msg=None, **kwargs): - super(PingResponse, self).__init__(**kwargs) - self.msg = msg - - @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 PingAuthRequest(Request): - """ - Return a message. Requires authorization. - - """ - - _service = "debug" - _action = "ping_auth" - _version = "1.5" - _schema = {'definitions': {}, 'properties': {}, 'type': 'object'} - - -class PingAuthResponse(Response): - """ - Response of debug.ping_auth endpoint. - - :param msg: A friendly message - :type msg: str - """ - _service = "debug" - _action = "ping_auth" - _version = "1.5" - - _schema = { - 'definitions': {}, - 'properties': { - 'msg': { - 'description': 'A friendly message', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, msg=None, **kwargs): - super(PingAuthResponse, self).__init__(**kwargs) - self.msg = msg - - @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 - - -response_mapping = { - EchoRequest: EchoResponse, - PingRequest: PingResponse, - PingAuthRequest: PingAuthResponse, - ApiexRequest: ApiexResponse, - ExRequest: ExResponse, -} diff --git a/trains/backend_api/services/v2_1/news.py b/trains/backend_api/services/v2_1/news.py deleted file mode 100644 index 34c22136..00000000 --- a/trains/backend_api/services/v2_1/news.py +++ /dev/null @@ -1,70 +0,0 @@ -""" -news service - -This service provides platform news. -""" -import six -import types -from datetime import datetime -import enum - -from dateutil.parser import parse as parse_datetime - -from ....backend_api.session import Request, BatchRequest, Response, DataModel, NonStrictDataModel, CompoundRequest, schema_property, StringEnum - - -class GetRequest(Request): - """ - Gets latest news link - - """ - - _service = "news" - _action = "get" - _version = "1.5" - _schema = {'definitions': {}, 'properties': {}, 'type': 'object'} - - -class GetResponse(Response): - """ - Response of news.get endpoint. - - :param url: URL to news html file - :type url: str - """ - _service = "news" - _action = "get" - _version = "1.5" - - _schema = { - 'definitions': {}, - 'properties': { - 'url': { - 'description': 'URL to news html file', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, url=None, **kwargs): - super(GetResponse, self).__init__(**kwargs) - self.url = url - - @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 - - -response_mapping = { - GetRequest: GetResponse, -} diff --git a/trains/backend_api/services/v2_1/storage.py b/trains/backend_api/services/v2_1/storage.py deleted file mode 100644 index 6a63da23..00000000 --- a/trains/backend_api/services/v2_1/storage.py +++ /dev/null @@ -1,681 +0,0 @@ -""" -storage service - -Provides a management API for customer-associated storage locations -""" -import six -import types -from datetime import datetime -import enum - -from dateutil.parser import parse as parse_datetime - -from ....backend_api.session import Request, BatchRequest, Response, DataModel, NonStrictDataModel, CompoundRequest, schema_property, StringEnum - - -class Credentials(NonStrictDataModel): - """ - :param access_key: Credentials access key - :type access_key: str - :param secret_key: Credentials secret key - :type secret_key: str - """ - _schema = { - 'properties': { - 'access_key': { - 'description': 'Credentials access key', - 'type': ['string', 'null'], - }, - 'secret_key': { - 'description': 'Credentials secret key', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, access_key=None, secret_key=None, **kwargs): - super(Credentials, self).__init__(**kwargs) - self.access_key = access_key - self.secret_key = secret_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 - - @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 - - -class Storage(NonStrictDataModel): - """ - :param id: Entry ID - :type id: str - :param name: Entry name - :type name: str - :param company: Company ID - :type company: str - :param created: Entry creation time - :type created: datetime.datetime - :param uri: Storage URI - :type uri: str - :param credentials: Credentials required for accessing the storage - :type credentials: Credentials - """ - _schema = { - 'properties': { - 'company': {'description': 'Company ID', 'type': ['string', 'null']}, - 'created': { - 'description': 'Entry creation time', - 'format': 'date-time', - 'type': ['string', 'null'], - }, - 'credentials': { - 'description': 'Credentials required for accessing the storage', - 'oneOf': [{'$ref': '#/definitions/credentials'}, {'type': 'null'}], - }, - 'id': {'description': 'Entry ID', 'type': ['string', 'null']}, - 'name': {'description': 'Entry name', 'type': ['string', 'null']}, - 'uri': {'description': 'Storage URI', 'type': ['string', 'null']}, - }, - 'type': 'object', - } - def __init__( - self, id=None, name=None, company=None, created=None, uri=None, credentials=None, **kwargs): - super(Storage, self).__init__(**kwargs) - self.id = id - self.name = name - self.company = company - self.created = created - self.uri = uri - self.credentials = credentials - - @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('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('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('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 CreateRequest(Request): - """ - Create a new storage entry - - :param name: Storage name - :type name: str - :param uri: Storage URI - :type uri: str - :param credentials: Credentials required for accessing the storage - :type credentials: Credentials - :param company: Company under which to add this storage. Only valid for users - with the root or system role, otherwise the calling user's company will be - used. - :type company: str - """ - - _service = "storage" - _action = "create" - _version = "1.5" - _schema = { - 'definitions': { - 'credentials': { - 'properties': { - 'access_key': { - 'description': 'Credentials access key', - 'type': ['string', 'null'], - }, - 'secret_key': { - 'description': 'Credentials secret key', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - }, - 'properties': { - 'company': { - 'description': "Company under which to add this storage. Only valid for users with the root or system role, otherwise the calling user's company will be used.", - 'type': 'string', - }, - 'credentials': { - '$ref': '#/definitions/credentials', - 'description': 'Credentials required for accessing the storage', - }, - 'name': {'description': 'Storage name', 'type': ['string', 'null']}, - 'uri': {'description': 'Storage URI', 'type': 'string'}, - }, - 'required': ['uri'], - 'type': 'object', - } - def __init__( - self, uri, name=None, credentials=None, company=None, **kwargs): - super(CreateRequest, self).__init__(**kwargs) - self.name = name - self.uri = uri - self.credentials = credentials - self.company = company - - @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('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('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 - - @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 - - -class CreateResponse(Response): - """ - Response of storage.create endpoint. - - :param id: New storage ID - :type id: str - """ - _service = "storage" - _action = "create" - _version = "1.5" - - _schema = { - 'definitions': {}, - 'properties': { - 'id': {'description': 'New storage 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 storage entry - - :param storage: Storage entry ID - :type storage: str - """ - - _service = "storage" - _action = "delete" - _version = "1.5" - _schema = { - 'definitions': {}, - 'properties': { - 'storage': {'description': 'Storage entry ID', 'type': 'string'}, - }, - 'required': ['storage'], - 'type': 'object', - } - def __init__( - self, storage, **kwargs): - super(DeleteRequest, self).__init__(**kwargs) - self.storage = storage - - @schema_property('storage') - def storage(self): - return self._property_storage - - @storage.setter - def storage(self, value): - if value is None: - self._property_storage = None - return - - self.assert_isinstance(value, "storage", six.string_types) - self._property_storage = value - - -class DeleteResponse(Response): - """ - Response of storage.delete endpoint. - - :param deleted: Number of storage entries deleted (0 or 1) - :type deleted: int - """ - _service = "storage" - _action = "delete" - _version = "1.5" - - _schema = { - 'definitions': {}, - 'properties': { - 'deleted': { - 'description': 'Number of storage entries deleted (0 or 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 GetAllRequest(Request): - """ - Get all storage entries - - :param name: Get only storage entries whose name matches this pattern (python - regular expression syntax) - :type name: str - :param id: List of Storage IDs used to filter results - :type id: 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 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] - """ - - _service = "storage" - _action = "get_all" - _version = "1.5" - _schema = { - 'definitions': {}, - 'properties': { - 'id': { - 'description': 'List of Storage IDs used to filter results', - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - 'name': { - 'description': 'Get only storage entries 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'], - }, - }, - 'type': 'object', - } - def __init__( - self, name=None, id=None, page=None, page_size=None, order_by=None, only_fields=None, **kwargs): - super(GetAllRequest, self).__init__(**kwargs) - self.name = name - self.id = id - self.page = page - self.page_size = page_size - self.order_by = order_by - self.only_fields = only_fields - - @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('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('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 - - -class GetAllResponse(Response): - """ - Response of storage.get_all endpoint. - - :param results: Storage entries list - :type results: Sequence[Storage] - """ - _service = "storage" - _action = "get_all" - _version = "1.5" - - _schema = { - 'definitions': { - 'credentials': { - 'properties': { - 'access_key': { - 'description': 'Credentials access key', - 'type': ['string', 'null'], - }, - 'secret_key': { - 'description': 'Credentials secret key', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'storage': { - 'properties': { - 'company': { - 'description': 'Company ID', - 'type': ['string', 'null'], - }, - 'created': { - 'description': 'Entry creation time', - 'format': 'date-time', - 'type': ['string', 'null'], - }, - 'credentials': { - 'description': 'Credentials required for accessing the storage', - 'oneOf': [ - {'$ref': '#/definitions/credentials'}, - {'type': 'null'}, - ], - }, - 'id': {'description': 'Entry ID', 'type': ['string', 'null']}, - 'name': { - 'description': 'Entry name', - 'type': ['string', 'null'], - }, - 'uri': { - 'description': 'Storage URI', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - }, - 'properties': { - 'results': { - 'description': 'Storage entries list', - 'items': {'$ref': '#/definitions/storage'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, results=None, **kwargs): - super(GetAllResponse, self).__init__(**kwargs) - self.results = results - - @schema_property('results') - def results(self): - return self._property_results - - @results.setter - def results(self, value): - if value is None: - self._property_results = None - return - - self.assert_isinstance(value, "results", (list, tuple)) - if any(isinstance(v, dict) for v in value): - value = [Storage.from_dict(v) if isinstance(v, dict) else v for v in value] - else: - self.assert_isinstance(value, "results", Storage, is_array=True) - self._property_results = value - - -response_mapping = { - GetAllRequest: GetAllResponse, - CreateRequest: CreateResponse, - DeleteRequest: DeleteResponse, -} diff --git a/trains/backend_api/services/v2_1/tasks.py b/trains/backend_api/services/v2_1/tasks.py index 287681dc..0efd6e41 100644 --- a/trains/backend_api/services/v2_1/tasks.py +++ b/trains/backend_api/services/v2_1/tasks.py @@ -12,277 +12,6 @@ from dateutil.parser import parse as parse_datetime from ....backend_api.session import Request, BatchRequest, Response, NonStrictDataModel, schema_property, StringEnum -class FilterByRoiEnum(StringEnum): - disabled = "disabled" - no_rois = "no_rois" - label_rules = "label_rules" - - -class FilterLabelRule(NonStrictDataModel): - """ - :param label: Lucene format query (see lucene query syntax). Default search - field is label.keyword and default operator is AND, so searching for: - 'Bus Stop' Blue - is equivalent to: - Label.keyword:'Bus Stop' AND label.keyword:'Blue' - :type label: str - :param count_range: Range of times ROI appears in the frame (min, max). -1 for - not applicable. Both integers must be larger than or equal to -1. 2nd integer - (max) must be either -1 or larger than or equal to the 1st integer (min) - :type count_range: Sequence[int] - :param conf_range: Range of ROI confidence level in the frame (min, max). -1 - for not applicable Both min and max can be either -1 or positive. 2nd number - (max) must be either -1 or larger than or equal to the 1st number (min) - :type conf_range: Sequence[float] - """ - _schema = { - 'properties': { - 'conf_range': { - 'description': 'Range of ROI confidence level in the frame (min, max). -1 for not applicable\n Both min and max can be either -1 or positive.\n 2nd number (max) must be either -1 or larger than or equal to the 1st number (min)', - 'items': {'type': 'number'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'count_range': { - 'description': 'Range of times ROI appears in the frame (min, max). -1 for not applicable.\n Both integers must be larger than or equal to -1.\n 2nd integer (max) must be either -1 or larger than or equal to the 1st integer (min)', - 'items': {'type': 'integer'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'label': { - 'description': "Lucene format query (see lucene query syntax).\nDefault search field is label.keyword and default operator is AND, so searching for:\n\n'Bus Stop' Blue\n\nis equivalent to:\n\nLabel.keyword:'Bus Stop' AND label.keyword:'Blue'", - 'type': 'string', - }, - }, - 'required': ['label'], - 'type': 'object', - } - def __init__( - self, label, count_range=None, conf_range=None, **kwargs): - super(FilterLabelRule, self).__init__(**kwargs) - self.label = label - self.count_range = count_range - self.conf_range = conf_range - - @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('count_range') - def count_range(self): - return self._property_count_range - - @count_range.setter - def count_range(self, value): - if value is None: - self._property_count_range = None - return - - self.assert_isinstance(value, "count_range", (list, tuple)) - value = [int(v) if isinstance(v, float) and v.is_integer() else v for v in value] - - self.assert_isinstance(value, "count_range", six.integer_types, is_array=True) - self._property_count_range = value - - @schema_property('conf_range') - def conf_range(self): - return self._property_conf_range - - @conf_range.setter - def conf_range(self, value): - if value is None: - self._property_conf_range = None - return - - self.assert_isinstance(value, "conf_range", (list, tuple)) - - self.assert_isinstance(value, "conf_range", six.integer_types + (float,), is_array=True) - self._property_conf_range = value - - -class FilterRule(NonStrictDataModel): - """ - :param label_rules: List of FilterLabelRule ('AND' connection) - disabled - No filtering by ROIs. Select all frames, even if they don't have - ROIs (all frames) - no_rois - Select only frames without ROIs (empty frames) - label_rules - Select frames according to label rules - :type label_rules: Sequence[FilterLabelRule] - :param filter_by_roi: Type of filter - :type filter_by_roi: FilterByRoiEnum - :param frame_query: Frame filter, in Lucene query syntax - :type frame_query: str - :param sources_query: Sources filter, in Lucene query syntax. Filters sources - in each frame. - :type sources_query: str - :param dataset: Dataset ID. Must be a dataset which is in the task's view. If - set to '*' all datasets in View are used. - :type dataset: str - :param version: Dataset version to apply rule to. Must belong to the dataset - and be in the task's view. If set to '*' all version of the datasets in View - are used. - :type version: str - :param weight: Rule weight. Default is 1 - :type weight: float - """ - _schema = { - 'properties': { - 'dataset': { - 'description': "Dataset ID. Must be a dataset which is in the task's view. If set to '*' all datasets in View are used.", - 'type': 'string', - }, - 'filter_by_roi': { - '$ref': '#/definitions/filter_by_roi_enum', - 'description': 'Type of filter', - }, - 'frame_query': { - 'description': 'Frame filter, in Lucene query syntax', - 'type': 'string', - }, - 'label_rules': { - 'description': "List of FilterLabelRule ('AND' connection)\n\ndisabled - No filtering by ROIs. Select all frames, even if they don't have ROIs (all frames)\n\nno_rois - Select only frames without ROIs (empty frames)\n\nlabel_rules - Select frames according to label rules", - 'items': {'$ref': '#/definitions/filter_label_rule'}, - 'type': ['array', 'null'], - }, - 'sources_query': { - 'description': 'Sources filter, in Lucene query syntax. Filters sources in each frame.', - 'type': 'string', - }, - 'version': { - 'description': "Dataset version to apply rule to. Must belong to the dataset and be in the task's view. If set to '*' all version of the datasets in View are used.", - 'type': 'string', - }, - 'weight': { - 'description': 'Rule weight. Default is 1', - 'type': 'number', - }, - }, - 'required': ['filter_by_roi'], - 'type': 'object', - } - def __init__( - self, filter_by_roi, label_rules=None, frame_query=None, sources_query=None, dataset=None, version=None, weight=None, **kwargs): - super(FilterRule, self).__init__(**kwargs) - self.label_rules = label_rules - self.filter_by_roi = filter_by_roi - self.frame_query = frame_query - self.sources_query = sources_query - self.dataset = dataset - self.version = version - self.weight = weight - - @schema_property('label_rules') - def label_rules(self): - return self._property_label_rules - - @label_rules.setter - def label_rules(self, value): - if value is None: - self._property_label_rules = None - return - - self.assert_isinstance(value, "label_rules", (list, tuple)) - if any(isinstance(v, dict) for v in value): - value = [FilterLabelRule.from_dict(v) if isinstance(v, dict) else v for v in value] - else: - self.assert_isinstance(value, "label_rules", FilterLabelRule, is_array=True) - self._property_label_rules = value - - @schema_property('filter_by_roi') - def filter_by_roi(self): - return self._property_filter_by_roi - - @filter_by_roi.setter - def filter_by_roi(self, value): - if value is None: - self._property_filter_by_roi = None - return - if isinstance(value, six.string_types): - try: - value = FilterByRoiEnum(value) - except ValueError: - pass - else: - self.assert_isinstance(value, "filter_by_roi", enum.Enum) - self._property_filter_by_roi = value - - @schema_property('frame_query') - def frame_query(self): - return self._property_frame_query - - @frame_query.setter - def frame_query(self, value): - if value is None: - self._property_frame_query = None - return - - self.assert_isinstance(value, "frame_query", six.string_types) - self._property_frame_query = value - - @schema_property('sources_query') - def sources_query(self): - return self._property_sources_query - - @sources_query.setter - def sources_query(self, value): - if value is None: - self._property_sources_query = None - return - - self.assert_isinstance(value, "sources_query", six.string_types) - self._property_sources_query = value - - @schema_property('dataset') - def dataset(self): - return self._property_dataset - - @dataset.setter - def dataset(self, value): - if value is None: - self._property_dataset = None - return - - self.assert_isinstance(value, "dataset", six.string_types) - self._property_dataset = value - - @schema_property('version') - def version(self): - return self._property_version - - @version.setter - def version(self, value): - if value is None: - self._property_version = None - return - - self.assert_isinstance(value, "version", six.string_types) - self._property_version = value - - @schema_property('weight') - def weight(self): - return self._property_weight - - @weight.setter - def weight(self, value): - if value is None: - self._property_weight = None - return - - self.assert_isinstance(value, "weight", six.integer_types + (float,)) - self._property_weight = value - - class MultiFieldPatternData(NonStrictDataModel): """ :param pattern: Pattern string (regex) @@ -356,7 +85,7 @@ class Script(NonStrictDataModel): :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[f] + root folder of repository :type working_dir: str :param requirements: A JSON object containing requirements strings by key :type requirements: dict @@ -390,7 +119,7 @@ class Script(NonStrictDataModel): 'type': ['string', 'null'], }, 'working_dir': { - 'description': 'Path to the folder from which to run the script Default - root folder of repository[f]', + 'description': 'Path to the folder from which to run the script Default - root folder of repository', 'type': ['string', 'null'], }, }, @@ -513,854 +242,8 @@ class Script(NonStrictDataModel): self._property_requirements = value -class LabelSource(NonStrictDataModel): - """ - :param labels: List of source labels (AND connection). '*' indicates any label. - Labels must exist in at least one of the dataset versions in the task's view - :type labels: Sequence[str] - :param dataset: Source dataset id. '*' for all datasets in view - :type dataset: str - :param version: Source dataset version id. Default is '*' (for all versions in - dataset in the view) Version must belong to the selected dataset, and must be - in the task's view[i] - :type version: str - """ - _schema = { - 'properties': { - 'dataset': { - 'description': "Source dataset id. '*' for all datasets in view", - 'type': ['string', 'null'], - }, - 'labels': { - 'description': "List of source labels (AND connection). '*' indicates any label. Labels must exist in at least one of the dataset versions in the task's view", - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - 'version': { - 'description': "Source dataset version id. Default is '*' (for all versions in dataset in the view) Version must belong to the selected dataset, and must be in the task's view[i]", - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, labels=None, dataset=None, version=None, **kwargs): - super(LabelSource, self).__init__(**kwargs) - self.labels = labels - self.dataset = dataset - self.version = version - - @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", (list, tuple)) - - self.assert_isinstance(value, "labels", six.string_types, is_array=True) - self._property_labels = value - - @schema_property('dataset') - def dataset(self): - return self._property_dataset - - @dataset.setter - def dataset(self, value): - if value is None: - self._property_dataset = None - return - - self.assert_isinstance(value, "dataset", six.string_types) - self._property_dataset = value - - @schema_property('version') - def version(self): - return self._property_version - - @version.setter - def version(self, value): - if value is None: - self._property_version = None - return - - self.assert_isinstance(value, "version", six.string_types) - self._property_version = value - - -class MappingRule(NonStrictDataModel): - """ - :param source: Source label info - :type source: LabelSource - :param target: Target label name - :type target: str - """ - _schema = { - 'properties': { - 'source': { - 'description': 'Source label info', - 'oneOf': [{'$ref': '#/definitions/label_source'}, {'type': 'null'}], - }, - 'target': { - 'description': 'Target label name', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, source=None, target=None, **kwargs): - super(MappingRule, self).__init__(**kwargs) - self.source = source - self.target = target - - @schema_property('source') - def source(self): - return self._property_source - - @source.setter - def source(self, value): - if value is None: - self._property_source = None - return - if isinstance(value, dict): - value = LabelSource.from_dict(value) - else: - self.assert_isinstance(value, "source", LabelSource) - self._property_source = value - - @schema_property('target') - def target(self): - return self._property_target - - @target.setter - def target(self, value): - if value is None: - self._property_target = None - return - - self.assert_isinstance(value, "target", six.string_types) - self._property_target = value - - -class Mapping(NonStrictDataModel): - """ - :param rules: Rules list - :type rules: Sequence[MappingRule] - """ - _schema = { - 'properties': { - 'rules': { - 'description': 'Rules list', - 'items': {'$ref': '#/definitions/mapping_rule'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, rules=None, **kwargs): - super(Mapping, self).__init__(**kwargs) - self.rules = rules - - @schema_property('rules') - def rules(self): - return self._property_rules - - @rules.setter - def rules(self, value): - if value is None: - self._property_rules = None - return - - self.assert_isinstance(value, "rules", (list, tuple)) - if any(isinstance(v, dict) for v in value): - value = [MappingRule.from_dict(v) if isinstance(v, dict) else v for v in value] - else: - self.assert_isinstance(value, "rules", MappingRule, is_array=True) - self._property_rules = value - - -class Filtering(NonStrictDataModel): - """ - :param filtering_rules: List of FilterRule ('OR' connection) - :type filtering_rules: Sequence[FilterRule] - :param output_rois: 'all_in_frame' - all rois for a frame are returned - 'only_filtered' - only rois which led this frame to be selected - 'frame_per_roi' - single roi per frame. Frame can be returned multiple times - with a different roi each time. - Note: this should be used for Training tasks only - Note: frame_per_roi implies that only filtered rois will be returned - :type output_rois: OutputRoisEnum - """ - _schema = { - 'properties': { - 'filtering_rules': { - 'description': "List of FilterRule ('OR' connection)", - 'items': {'$ref': '#/definitions/filter_rule'}, - 'type': ['array', 'null'], - }, - 'output_rois': { - 'description': "'all_in_frame' - all rois for a frame are returned\n\n'only_filtered' - only rois which led this frame to be selected\n\n'frame_per_roi' - single roi per frame. Frame can be returned multiple times with a different roi each time.\n\nNote: this should be used for Training tasks only\n\nNote: frame_per_roi implies that only filtered rois will be returned\n ", - 'oneOf': [ - {'$ref': '#/definitions/output_rois_enum'}, - {'type': 'null'}, - ], - }, - }, - 'type': 'object', - } - def __init__( - self, filtering_rules=None, output_rois=None, **kwargs): - super(Filtering, self).__init__(**kwargs) - self.filtering_rules = filtering_rules - self.output_rois = output_rois - - @schema_property('filtering_rules') - def filtering_rules(self): - return self._property_filtering_rules - - @filtering_rules.setter - def filtering_rules(self, value): - if value is None: - self._property_filtering_rules = None - return - - self.assert_isinstance(value, "filtering_rules", (list, tuple)) - if any(isinstance(v, dict) for v in value): - value = [FilterRule.from_dict(v) if isinstance(v, dict) else v for v in value] - else: - self.assert_isinstance(value, "filtering_rules", FilterRule, is_array=True) - self._property_filtering_rules = value - - @schema_property('output_rois') - def output_rois(self): - return self._property_output_rois - - @output_rois.setter - def output_rois(self, value): - if value is None: - self._property_output_rois = None - return - if isinstance(value, six.string_types): - try: - value = OutputRoisEnum(value) - except ValueError: - pass - else: - self.assert_isinstance(value, "output_rois", enum.Enum) - self._property_output_rois = value - - -class Jump(NonStrictDataModel): - """ - :param time: Max time in milliseconds between frames - :type time: int - """ - _schema = { - 'properties': { - 'time': { - 'description': 'Max time in milliseconds between frames', - 'type': ['integer', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, time=None, **kwargs): - super(Jump, self).__init__(**kwargs) - self.time = time - - @schema_property('time') - def time(self): - return self._property_time - - @time.setter - def time(self, value): - if value is None: - self._property_time = None - return - if isinstance(value, float) and value.is_integer(): - value = int(value) - - self.assert_isinstance(value, "time", six.integer_types) - self._property_time = value - - -class AugmentationSet(NonStrictDataModel): - """ - :param cls: Augmentation class - :type cls: str - :param types: Augmentation type - :type types: Sequence[str] - :param strength: Augmentation strength. Range [0,). - :type strength: float - :param arguments: Arguments dictionary per custom augmentation type. - :type arguments: dict - """ - _schema = { - 'properties': { - 'arguments': { - 'additionalProperties': { - 'additionalProperties': True, - 'type': 'object', - }, - 'description': 'Arguments dictionary per custom augmentation type.', - 'type': ['object', 'null'], - }, - 'cls': { - 'description': 'Augmentation class', - 'type': ['string', 'null'], - }, - 'strength': { - 'description': 'Augmentation strength. Range [0,).', - 'minimum': 0, - 'type': ['number', 'null'], - }, - 'types': { - 'description': 'Augmentation type', - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, cls=None, types=None, strength=None, arguments=None, **kwargs): - super(AugmentationSet, self).__init__(**kwargs) - self.cls = cls - self.types = types - self.strength = strength - self.arguments = arguments - - @schema_property('cls') - def cls(self): - return self._property_cls - - @cls.setter - def cls(self, value): - if value is None: - self._property_cls = None - return - - self.assert_isinstance(value, "cls", six.string_types) - self._property_cls = value - - @schema_property('types') - 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 - - @schema_property('strength') - def strength(self): - return self._property_strength - - @strength.setter - def strength(self, value): - if value is None: - self._property_strength = None - return - - self.assert_isinstance(value, "strength", six.integer_types + (float,)) - self._property_strength = value - - @schema_property('arguments') - def arguments(self): - return self._property_arguments - - @arguments.setter - def arguments(self, value): - if value is None: - self._property_arguments = None - return - - self.assert_isinstance(value, "arguments", (dict,)) - self._property_arguments = value - - -class Augmentation(NonStrictDataModel): - """ - :param sets: List of augmentation sets - :type sets: Sequence[AugmentationSet] - :param crop_around_rois: Crop image data around all frame ROIs - :type crop_around_rois: bool - """ - _schema = { - 'properties': { - 'crop_around_rois': { - 'description': 'Crop image data around all frame ROIs', - 'type': ['boolean', 'null'], - }, - 'sets': { - 'description': 'List of augmentation sets', - 'items': {'$ref': '#/definitions/augmentation_set'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, sets=None, crop_around_rois=None, **kwargs): - super(Augmentation, self).__init__(**kwargs) - self.sets = sets - self.crop_around_rois = crop_around_rois - - @schema_property('sets') - def sets(self): - return self._property_sets - - @sets.setter - def sets(self, value): - if value is None: - self._property_sets = None - return - - self.assert_isinstance(value, "sets", (list, tuple)) - if any(isinstance(v, dict) for v in value): - value = [AugmentationSet.from_dict(v) if isinstance(v, dict) else v for v in value] - else: - self.assert_isinstance(value, "sets", AugmentationSet, is_array=True) - self._property_sets = value - - @schema_property('crop_around_rois') - def crop_around_rois(self): - return self._property_crop_around_rois - - @crop_around_rois.setter - def crop_around_rois(self, value): - if value is None: - self._property_crop_around_rois = None - return - - self.assert_isinstance(value, "crop_around_rois", (bool,)) - self._property_crop_around_rois = value - - -class Iteration(NonStrictDataModel): - """ - Sequential Iteration API configuration - - :param order: Input frames order. Values: 'sequential', 'random' In Sequential - mode frames will be returned according to the order in which the frames were - added to the dataset. - :type order: str - :param jump: Jump entry - :type jump: Jump - :param min_sequence: Length (in ms) of video clips to return. This is used in - random order, and in sequential order only if jumping is provided and only for - video frames - :type min_sequence: int - :param infinite: Infinite iteration - :type infinite: bool - :param limit: Maximum frames per task. If not passed, frames will end when no - more matching frames are found, unless infinite is True. - :type limit: int - :param random_seed: Random seed used during iteration - :type random_seed: int - """ - _schema = { - 'description': 'Sequential Iteration API configuration', - 'properties': { - 'infinite': { - 'description': 'Infinite iteration', - 'type': ['boolean', 'null'], - }, - 'jump': { - 'description': 'Jump entry', - 'oneOf': [{'$ref': '#/definitions/jump'}, {'type': 'null'}], - }, - 'limit': { - 'description': 'Maximum frames per task. If not passed, frames will end when no more matching frames are found, unless infinite is True.', - 'type': ['integer', 'null'], - }, - 'min_sequence': { - 'description': 'Length (in ms) of video clips to return. This is used in random order, and in sequential order only if jumping is provided and only for video frames', - 'type': ['integer', 'null'], - }, - 'order': { - 'description': "\n Input frames order. Values: 'sequential', 'random'\n In Sequential mode frames will be returned according to the order in which the frames were added to the dataset.", - 'type': ['string', 'null'], - }, - 'random_seed': { - 'description': 'Random seed used during iteration', - 'type': 'integer', - }, - }, - 'required': ['random_seed'], - 'type': 'object', - } - def __init__( - self, random_seed, order=None, jump=None, min_sequence=None, infinite=None, limit=None, **kwargs): - super(Iteration, self).__init__(**kwargs) - self.order = order - self.jump = jump - self.min_sequence = min_sequence - self.infinite = infinite - self.limit = limit - self.random_seed = random_seed - - @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('jump') - def jump(self): - return self._property_jump - - @jump.setter - def jump(self, value): - if value is None: - self._property_jump = None - return - if isinstance(value, dict): - value = Jump.from_dict(value) - else: - self.assert_isinstance(value, "jump", Jump) - self._property_jump = value - - @schema_property('min_sequence') - def min_sequence(self): - return self._property_min_sequence - - @min_sequence.setter - def min_sequence(self, value): - if value is None: - self._property_min_sequence = None - return - if isinstance(value, float) and value.is_integer(): - value = int(value) - - self.assert_isinstance(value, "min_sequence", six.integer_types) - self._property_min_sequence = value - - @schema_property('infinite') - def infinite(self): - return self._property_infinite - - @infinite.setter - def infinite(self, value): - if value is None: - self._property_infinite = None - return - - self.assert_isinstance(value, "infinite", (bool,)) - self._property_infinite = value - - @schema_property('limit') - def limit(self): - return self._property_limit - - @limit.setter - def limit(self, value): - if value is None: - self._property_limit = None - return - if isinstance(value, float) and value.is_integer(): - value = int(value) - - self.assert_isinstance(value, "limit", six.integer_types) - self._property_limit = value - - @schema_property('random_seed') - def random_seed(self): - return self._property_random_seed - - @random_seed.setter - def random_seed(self, value): - if value is None: - self._property_random_seed = None - return - if isinstance(value, float) and value.is_integer(): - value = int(value) - - self.assert_isinstance(value, "random_seed", six.integer_types) - self._property_random_seed = value - - -class ViewEntry(NonStrictDataModel): - """ - :param version: Version id of a version belonging to the dataset - :type version: str - :param dataset: Existing Dataset id - :type dataset: str - :param merge_with: Version ID to merge with - :type merge_with: str - """ - _schema = { - 'properties': { - 'dataset': { - 'description': 'Existing Dataset id', - 'type': ['string', 'null'], - }, - 'merge_with': { - 'description': 'Version ID to merge with', - 'type': ['string', 'null'], - }, - 'version': { - 'description': 'Version id of a version belonging to the dataset', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, version=None, dataset=None, merge_with=None, **kwargs): - super(ViewEntry, self).__init__(**kwargs) - self.version = version - self.dataset = dataset - self.merge_with = merge_with - - @schema_property('version') - def version(self): - return self._property_version - - @version.setter - def version(self, value): - if value is None: - self._property_version = None - return - - self.assert_isinstance(value, "version", six.string_types) - self._property_version = value - - @schema_property('dataset') - def dataset(self): - return self._property_dataset - - @dataset.setter - def dataset(self, value): - if value is None: - self._property_dataset = None - return - - self.assert_isinstance(value, "dataset", six.string_types) - self._property_dataset = value - - @schema_property('merge_with') - def merge_with(self): - return self._property_merge_with - - @merge_with.setter - def merge_with(self, value): - if value is None: - self._property_merge_with = None - return - - self.assert_isinstance(value, "merge_with", six.string_types) - self._property_merge_with = value - - -class View(NonStrictDataModel): - """ - :param entries: List of view entries. All tasks must have at least one view. - :type entries: Sequence[ViewEntry] - """ - _schema = { - 'properties': { - 'entries': { - 'description': 'List of view entries. All tasks must have at least one view.', - 'items': {'$ref': '#/definitions/view_entry'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - } - def __init__( - self, entries=None, **kwargs): - super(View, self).__init__(**kwargs) - self.entries = entries - - @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 = [ViewEntry.from_dict(v) if isinstance(v, dict) else v for v in value] - else: - self.assert_isinstance(value, "entries", ViewEntry, is_array=True) - self._property_entries = value - - -class Input(NonStrictDataModel): - """ - :param view: View params - :type view: View - :param frames_filter: Filtering params - :type frames_filter: Filtering - :param mapping: Mapping params (see common definitions section) - :type mapping: Mapping - :param augmentation: Augmentation parameters. Only for training and testing - tasks. - :type augmentation: Augmentation - :param iteration: Iteration parameters. Not applicable for register (import) - tasks. - :type iteration: Iteration - :param dataviews: Key to DataView ID Mapping - :type dataviews: dict - """ - _schema = { - 'properties': { - 'augmentation': { - 'description': 'Augmentation parameters. Only for training and testing tasks.', - 'oneOf': [{'$ref': '#/definitions/augmentation'}, {'type': 'null'}], - }, - 'dataviews': { - 'additionalProperties': {'type': 'string'}, - 'description': 'Key to DataView ID Mapping', - 'type': ['object', 'null'], - }, - 'frames_filter': { - 'description': 'Filtering params', - 'oneOf': [{'$ref': '#/definitions/filtering'}, {'type': 'null'}], - }, - 'iteration': { - 'description': 'Iteration parameters. Not applicable for register (import) tasks.', - 'oneOf': [{'$ref': '#/definitions/iteration'}, {'type': 'null'}], - }, - 'mapping': { - 'description': 'Mapping params (see common definitions section)', - 'oneOf': [{'$ref': '#/definitions/mapping'}, {'type': 'null'}], - }, - 'view': { - 'description': 'View params', - 'oneOf': [{'$ref': '#/definitions/view'}, {'type': 'null'}], - }, - }, - 'type': 'object', - } - def __init__( - self, view=None, frames_filter=None, mapping=None, augmentation=None, iteration=None, dataviews=None, **kwargs): - super(Input, self).__init__(**kwargs) - self.view = view - self.frames_filter = frames_filter - self.mapping = mapping - self.augmentation = augmentation - self.iteration = iteration - self.dataviews = dataviews - - @schema_property('view') - def view(self): - return self._property_view - - @view.setter - def view(self, value): - if value is None: - self._property_view = None - return - if isinstance(value, dict): - value = View.from_dict(value) - else: - self.assert_isinstance(value, "view", View) - self._property_view = value - - @schema_property('frames_filter') - def frames_filter(self): - return self._property_frames_filter - - @frames_filter.setter - def frames_filter(self, value): - if value is None: - self._property_frames_filter = None - return - if isinstance(value, dict): - value = Filtering.from_dict(value) - else: - self.assert_isinstance(value, "frames_filter", Filtering) - self._property_frames_filter = value - - @schema_property('mapping') - def mapping(self): - return self._property_mapping - - @mapping.setter - def mapping(self, value): - if value is None: - self._property_mapping = None - return - if isinstance(value, dict): - value = Mapping.from_dict(value) - else: - self.assert_isinstance(value, "mapping", Mapping) - self._property_mapping = value - - @schema_property('augmentation') - def augmentation(self): - return self._property_augmentation - - @augmentation.setter - def augmentation(self, value): - if value is None: - self._property_augmentation = None - return - if isinstance(value, dict): - value = Augmentation.from_dict(value) - else: - self.assert_isinstance(value, "augmentation", Augmentation) - self._property_augmentation = 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, dict): - value = Iteration.from_dict(value) - else: - self.assert_isinstance(value, "iteration", Iteration) - self._property_iteration = value - - @schema_property('dataviews') - def dataviews(self): - return self._property_dataviews - - @dataviews.setter - def dataviews(self, value): - if value is None: - self._property_dataviews = None - return - - self.assert_isinstance(value, "dataviews", (dict,)) - self._property_dataviews = value - - class Output(NonStrictDataModel): """ - :param view: View params - :type view: View :param destination: Storage id. This is where output files will be stored. :type destination: str :param model: Model id. @@ -1382,37 +265,17 @@ class Output(NonStrictDataModel): 'description': "Task result. Values: 'success', 'failure'", 'type': ['string', 'null'], }, - 'view': { - 'description': 'View params', - 'oneOf': [{'$ref': '#/definitions/view'}, {'type': 'null'}], - }, }, 'type': 'object', } def __init__( - self, view=None, destination=None, model=None, result=None, error=None, **kwargs): + self, destination=None, model=None, result=None, error=None, **kwargs): super(Output, self).__init__(**kwargs) - self.view = view self.destination = destination self.model = model self.result = result self.error = error - @schema_property('view') - def view(self): - return self._property_view - - @view.setter - def view(self, value): - if value is None: - self._property_view = None - return - if isinstance(value, dict): - value = View.from_dict(value) - else: - self.assert_isinstance(value, "view", View) - self._property_view = value - @schema_property('destination') def destination(self): return self._property_destination @@ -1466,18 +329,8 @@ class Output(NonStrictDataModel): self._property_error = value -class OutputRoisEnum(StringEnum): - all_in_frame = "all_in_frame" - only_filtered = "only_filtered" - frame_per_roi = "frame_per_roi" - - class Execution(NonStrictDataModel): """ - :param queue: Queue ID where task was queued. - :type queue: str - :param test_split: Percentage of frames to use for testing only - :type test_split: int :param parameters: Json object containing the Task parameters :type parameters: dict :param model: Execution input model ID Not applicable for Register (Import) @@ -1487,21 +340,14 @@ class Execution(NonStrictDataModel): :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[z] + 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 dataviews: Additional dataviews for the task - :type dataviews: Sequence[dict] """ _schema = { 'properties': { - 'dataviews': { - 'description': 'Additional dataviews for the task', - 'items': {'additionalProperties': True, 'type': 'object'}, - 'type': ['array', 'null'], - }, 'framework': { 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', 'type': ['string', 'null'], @@ -1517,7 +363,7 @@ class Execution(NonStrictDataModel): }, '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[z]", + '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': { @@ -1525,56 +371,17 @@ class Execution(NonStrictDataModel): 'description': 'Json object containing the Task parameters', 'type': ['object', 'null'], }, - 'queue': { - 'description': 'Queue ID where task was queued.', - 'type': ['string', 'null'], - }, - 'test_split': { - 'description': 'Percentage of frames to use for testing only', - 'type': ['integer', 'null'], - }, }, 'type': 'object', } def __init__( - self, queue=None, test_split=None, parameters=None, model=None, model_desc=None, model_labels=None, framework=None, dataviews=None, **kwargs): + self, parameters=None, model=None, model_desc=None, model_labels=None, framework=None, **kwargs): super(Execution, self).__init__(**kwargs) - self.queue = queue - self.test_split = test_split self.parameters = parameters self.model = model self.model_desc = model_desc self.model_labels = model_labels self.framework = framework - self.dataviews = dataviews - - @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('test_split') - def test_split(self): - return self._property_test_split - - @test_split.setter - def test_split(self, value): - if value is None: - self._property_test_split = None - return - if isinstance(value, float) and value.is_integer(): - value = int(value) - - self.assert_isinstance(value, "test_split", six.integer_types) - self._property_test_split = value @schema_property('parameters') def parameters(self): @@ -1641,27 +448,13 @@ class Execution(NonStrictDataModel): self.assert_isinstance(value, "framework", six.string_types) self._property_framework = value - @schema_property('dataviews') - def dataviews(self): - return self._property_dataviews - - @dataviews.setter - def dataviews(self, value): - if value is None: - self._property_dataviews = None - return - - self.assert_isinstance(value, "dataviews", (list, tuple)) - - self.assert_isinstance(value, "dataviews", (dict,), is_array=True) - self._property_dataviews = value - class TaskStatusEnum(StringEnum): created = "created" queued = "queued" in_progress = "in_progress" stopped = "stopped" + completed = "completed" published = "published" publishing = "publishing" closed = "closed" @@ -1822,8 +615,7 @@ class Task(NonStrictDataModel): :type user: str :param company: Company ID :type company: str - :param type: Type of task. Values: 'dataset_import', 'annotation', 'training', - 'testing' + :param type: Type of task. Values: 'training', 'testing' :type type: TaskTypeEnum :param status: :type status: TaskStatusEnum @@ -1839,8 +631,6 @@ class Task(NonStrictDataModel): :type parent: str :param project: Project ID of the project to which this task is assigned :type project: str - :param input: Task input params - :type input: Input :param output: Task output params :type output: Output :param execution: Task execution params @@ -1857,11 +647,6 @@ class Task(NonStrictDataModel): :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 @@ -1893,10 +678,6 @@ class Task(NonStrictDataModel): 'oneOf': [{'$ref': '#/definitions/execution'}, {'type': 'null'}], }, 'id': {'description': 'Task id', 'type': ['string', 'null']}, - 'input': { - 'description': 'Task input params', - 'oneOf': [{'$ref': '#/definitions/input'}, {'type': 'null'}], - }, 'last_iteration': { 'description': 'Last iteration reported for this task', 'type': ['integer', 'null'], @@ -1913,15 +694,6 @@ class Task(NonStrictDataModel): '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'], - }, 'name': {'description': 'Task Name', 'type': ['string', 'null']}, 'output': { 'description': 'Task output params', @@ -1972,7 +744,7 @@ class Task(NonStrictDataModel): 'type': ['array', 'null'], }, 'type': { - 'description': "Type of task. Values: 'dataset_import', 'annotation', 'training', 'testing'", + 'description': "Type of task. Values: 'training', 'testing'", 'oneOf': [ {'$ref': '#/definitions/task_type_enum'}, {'type': 'null'}, @@ -1986,7 +758,7 @@ class Task(NonStrictDataModel): '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, parent=None, project=None, input=None, output=None, execution=None, script=None, tags=None, status_changed=None, status_message=None, status_reason=None, published=None, last_worker=None, last_worker_report=None, last_update=None, last_iteration=None, last_metrics=None, **kwargs): + self, id=None, name=None, user=None, company=None, type=None, status=None, comment=None, created=None, started=None, completed=None, parent=None, project=None, output=None, execution=None, script=None, tags=None, status_changed=None, status_message=None, status_reason=None, published=None, last_update=None, last_iteration=None, last_metrics=None, **kwargs): super(Task, self).__init__(**kwargs) self.id = id self.name = name @@ -2000,7 +772,6 @@ class Task(NonStrictDataModel): self.completed = completed self.parent = parent self.project = project - self.input = input self.output = output self.execution = execution self.script = script @@ -2009,8 +780,6 @@ class Task(NonStrictDataModel): 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_iteration = last_iteration self.last_metrics = last_metrics @@ -2187,21 +956,6 @@ class Task(NonStrictDataModel): 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): - if value is None: - self._property_input = None - return - if isinstance(value, dict): - value = Input.from_dict(value) - else: - self.assert_isinstance(value, "input", Input) - self._property_input = value - @schema_property('output') def output(self): return self._property_output @@ -2318,34 +1072,6 @@ class Task(NonStrictDataModel): 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 @@ -2586,54 +1312,8 @@ class CreateRequest(Request): _version = "1.9" _schema = { 'definitions': { - 'augmentation': { - 'properties': { - 'crop_around_rois': { - 'description': 'Crop image data around all frame ROIs', - 'type': ['boolean', 'null'], - }, - 'sets': { - 'description': 'List of augmentation sets', - 'items': {'$ref': '#/definitions/augmentation_set'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'augmentation_set': { - 'properties': { - 'arguments': { - 'additionalProperties': { - 'additionalProperties': True, - 'type': 'object', - }, - 'description': 'Arguments dictionary per custom augmentation type.', - 'type': ['object', 'null'], - }, - 'cls': { - 'description': 'Augmentation class', - 'type': ['string', 'null'], - }, - 'strength': { - 'description': 'Augmentation strength. Range [0,).', - 'minimum': 0, - 'type': ['number', 'null'], - }, - 'types': { - 'description': 'Augmentation type', - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, 'execution': { 'properties': { - 'dataviews': { - 'description': 'Additional dataviews for the task', - 'items': {'additionalProperties': True, 'type': 'object'}, - 'type': ['array', 'null'], - }, 'framework': { 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', 'type': ['string', 'null'], @@ -2649,7 +1329,7 @@ class CreateRequest(Request): }, '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[z]", + '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': { @@ -2657,228 +1337,9 @@ class CreateRequest(Request): 'description': 'Json object containing the Task parameters', 'type': ['object', 'null'], }, - 'queue': { - 'description': 'Queue ID where task was queued.', - 'type': ['string', 'null'], - }, - 'test_split': { - 'description': 'Percentage of frames to use for testing only', - 'type': ['integer', 'null'], - }, }, 'type': 'object', }, - 'filter_by_roi_enum': { - 'default': 'label_rules', - 'enum': ['disabled', 'no_rois', 'label_rules'], - 'type': 'string', - }, - 'filter_label_rule': { - 'properties': { - 'conf_range': { - 'description': 'Range of ROI confidence level in the frame (min, max). -1 for not applicable\n Both min and max can be either -1 or positive.\n 2nd number (max) must be either -1 or larger than or equal to the 1st number (min)', - 'items': {'type': 'number'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'count_range': { - 'description': 'Range of times ROI appears in the frame (min, max). -1 for not applicable.\n Both integers must be larger than or equal to -1.\n 2nd integer (max) must be either -1 or larger than or equal to the 1st integer (min)', - 'items': {'type': 'integer'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'label': { - 'description': "Lucene format query (see lucene query syntax).\nDefault search field is label.keyword and default operator is AND, so searching for:\n\n'Bus Stop' Blue\n\nis equivalent to:\n\nLabel.keyword:'Bus Stop' AND label.keyword:'Blue'", - 'type': 'string', - }, - }, - 'required': ['label'], - 'type': 'object', - }, - 'filter_rule': { - 'properties': { - 'dataset': { - 'description': "Dataset ID. Must be a dataset which is in the task's view. If set to '*' all datasets in View are used.", - 'type': 'string', - }, - 'filter_by_roi': { - '$ref': '#/definitions/filter_by_roi_enum', - 'description': 'Type of filter', - }, - 'frame_query': { - 'description': 'Frame filter, in Lucene query syntax', - 'type': 'string', - }, - 'label_rules': { - 'description': "List of FilterLabelRule ('AND' connection)\n\ndisabled - No filtering by ROIs. Select all frames, even if they don't have ROIs (all frames)\n\nno_rois - Select only frames without ROIs (empty frames)\n\nlabel_rules - Select frames according to label rules", - 'items': {'$ref': '#/definitions/filter_label_rule'}, - 'type': ['array', 'null'], - }, - 'sources_query': { - 'description': 'Sources filter, in Lucene query syntax. Filters sources in each frame.', - 'type': 'string', - }, - 'version': { - 'description': "Dataset version to apply rule to. Must belong to the dataset and be in the task's view. If set to '*' all version of the datasets in View are used.", - 'type': 'string', - }, - 'weight': { - 'description': 'Rule weight. Default is 1', - 'type': 'number', - }, - }, - 'required': ['filter_by_roi'], - 'type': 'object', - }, - 'filtering': { - 'properties': { - 'filtering_rules': { - 'description': "List of FilterRule ('OR' connection)", - 'items': {'$ref': '#/definitions/filter_rule'}, - 'type': ['array', 'null'], - }, - 'output_rois': { - 'description': "'all_in_frame' - all rois for a frame are returned\n\n'only_filtered' - only rois which led this frame to be selected\n\n'frame_per_roi' - single roi per frame. Frame can be returned multiple times with a different roi each time.\n\nNote: this should be used for Training tasks only\n\nNote: frame_per_roi implies that only filtered rois will be returned\n ", - 'oneOf': [ - {'$ref': '#/definitions/output_rois_enum'}, - {'type': 'null'}, - ], - }, - }, - 'type': 'object', - }, - 'input': { - 'properties': { - 'augmentation': { - 'description': 'Augmentation parameters. Only for training and testing tasks.', - 'oneOf': [ - {'$ref': '#/definitions/augmentation'}, - {'type': 'null'}, - ], - }, - 'dataviews': { - 'additionalProperties': {'type': 'string'}, - 'description': 'Key to DataView ID Mapping', - 'type': ['object', 'null'], - }, - 'frames_filter': { - 'description': 'Filtering params', - 'oneOf': [ - {'$ref': '#/definitions/filtering'}, - {'type': 'null'}, - ], - }, - 'iteration': { - 'description': 'Iteration parameters. Not applicable for register (import) tasks.', - 'oneOf': [ - {'$ref': '#/definitions/iteration'}, - {'type': 'null'}, - ], - }, - 'mapping': { - 'description': 'Mapping params (see common definitions section)', - 'oneOf': [ - {'$ref': '#/definitions/mapping'}, - {'type': 'null'}, - ], - }, - 'view': { - 'description': 'View params', - 'oneOf': [{'$ref': '#/definitions/view'}, {'type': 'null'}], - }, - }, - 'type': 'object', - }, - 'iteration': { - 'description': 'Sequential Iteration API configuration', - 'properties': { - 'infinite': { - 'description': 'Infinite iteration', - 'type': ['boolean', 'null'], - }, - 'jump': { - 'description': 'Jump entry', - 'oneOf': [{'$ref': '#/definitions/jump'}, {'type': 'null'}], - }, - 'limit': { - 'description': 'Maximum frames per task. If not passed, frames will end when no more matching frames are found, unless infinite is True.', - 'type': ['integer', 'null'], - }, - 'min_sequence': { - 'description': 'Length (in ms) of video clips to return. This is used in random order, and in sequential order only if jumping is provided and only for video frames', - 'type': ['integer', 'null'], - }, - 'order': { - 'description': "\n Input frames order. Values: 'sequential', 'random'\n In Sequential mode frames will be returned according to the order in which the frames were added to the dataset.", - 'type': ['string', 'null'], - }, - 'random_seed': { - 'description': 'Random seed used during iteration', - 'type': 'integer', - }, - }, - 'required': ['random_seed'], - 'type': 'object', - }, - 'jump': { - 'properties': { - 'time': { - 'description': 'Max time in milliseconds between frames', - 'type': ['integer', 'null'], - }, - }, - 'type': 'object', - }, - 'label_source': { - 'properties': { - 'dataset': { - 'description': "Source dataset id. '*' for all datasets in view", - 'type': ['string', 'null'], - }, - 'labels': { - 'description': "List of source labels (AND connection). '*' indicates any label. Labels must exist in at least one of the dataset versions in the task's view", - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - 'version': { - 'description': "Source dataset version id. Default is '*' (for all versions in dataset in the view) Version must belong to the selected dataset, and must be in the task's view[i]", - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'mapping': { - 'properties': { - 'rules': { - 'description': 'Rules list', - 'items': {'$ref': '#/definitions/mapping_rule'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'mapping_rule': { - 'properties': { - 'source': { - 'description': 'Source label info', - 'oneOf': [ - {'$ref': '#/definitions/label_source'}, - {'type': 'null'}, - ], - }, - 'target': { - 'description': 'Target label name', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'output_rois_enum': { - 'enum': ['all_in_frame', 'only_filtered', 'frame_per_roi'], - 'type': 'string', - }, 'script': { 'properties': { 'binary': { @@ -2911,49 +1372,13 @@ class CreateRequest(Request): 'type': ['string', 'null'], }, 'working_dir': { - 'description': 'Path to the folder from which to run the script Default - root folder of repository[f]', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'task_type_enum': { - 'enum': [ - 'dataset_import', - 'annotation', - 'annotation_manual', - 'training', - 'testing', - ], - 'type': 'string', - }, - 'view': { - 'properties': { - 'entries': { - 'description': 'List of view entries. All tasks must have at least one view.', - 'items': {'$ref': '#/definitions/view_entry'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'view_entry': { - 'properties': { - 'dataset': { - 'description': 'Existing Dataset id', - 'type': ['string', 'null'], - }, - 'merge_with': { - 'description': 'Version ID to merge with', - 'type': ['string', 'null'], - }, - 'version': { - 'description': 'Version id of a version belonging to the dataset', + 'description': 'Path to the folder from which to run the script Default - root folder of repository', 'type': ['string', 'null'], }, }, 'type': 'object', }, + 'task_type_enum': {'enum': ['training', 'testing'], 'type': 'string'}, }, 'properties': { 'comment': {'description': 'Free text comment ', 'type': 'string'}, @@ -2962,7 +1387,7 @@ class CreateRequest(Request): 'description': 'Task execution params', }, 'input': { - '$ref': '#/definitions/input', + # '$ref': '#/definitions/input', 'description': 'Task input params. (input view must be provided).', }, 'name': { @@ -3099,13 +1524,6 @@ class CreateRequest(Request): @input.setter def input(self, value): - if value is None: - self._property_input = None - return - if isinstance(value, dict): - value = Input.from_dict(value) - else: - self.assert_isinstance(value, "input", Input) self._property_input = value @schema_property('output_dest') @@ -3192,7 +1610,7 @@ class CreateResponse(Response): 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, projects or datasets. + 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. @@ -3464,172 +1882,6 @@ class DeleteResponse(Response): self._property_events = 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 = "1.5" - _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 dequeued: Number of tasks dequeued (0 or 1) - :type dequeued: int - :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 = "dequeue" - _version = "1.5" - - _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, dequeued=None, updated=None, fields=None, **kwargs): - super(DequeueResponse, self).__init__(**kwargs) - self.dequeued = dequeued - self.updated = updated - self.fields = fields - - @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 - - @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 EditRequest(Request): """ Edit task's details. @@ -3651,8 +1903,6 @@ class EditRequest(Request): :param project: Project ID of the project to which this task is assigned Must exist[ab] :type project: str - :param input: Task input params. (input view must be provided). - :type input: Input :param output_dest: Output storage id Must be a reference to an existing storage. :type output_dest: str @@ -3667,54 +1917,8 @@ class EditRequest(Request): _version = "1.9" _schema = { 'definitions': { - 'augmentation': { - 'properties': { - 'crop_around_rois': { - 'description': 'Crop image data around all frame ROIs', - 'type': ['boolean', 'null'], - }, - 'sets': { - 'description': 'List of augmentation sets', - 'items': {'$ref': '#/definitions/augmentation_set'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'augmentation_set': { - 'properties': { - 'arguments': { - 'additionalProperties': { - 'additionalProperties': True, - 'type': 'object', - }, - 'description': 'Arguments dictionary per custom augmentation type.', - 'type': ['object', 'null'], - }, - 'cls': { - 'description': 'Augmentation class', - 'type': ['string', 'null'], - }, - 'strength': { - 'description': 'Augmentation strength. Range [0,).', - 'minimum': 0, - 'type': ['number', 'null'], - }, - 'types': { - 'description': 'Augmentation type', - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, 'execution': { 'properties': { - 'dataviews': { - 'description': 'Additional dataviews for the task', - 'items': {'additionalProperties': True, 'type': 'object'}, - 'type': ['array', 'null'], - }, 'framework': { 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', 'type': ['string', 'null'], @@ -3730,7 +1934,7 @@ class EditRequest(Request): }, '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[z]", + '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': { @@ -3738,228 +1942,9 @@ class EditRequest(Request): 'description': 'Json object containing the Task parameters', 'type': ['object', 'null'], }, - 'queue': { - 'description': 'Queue ID where task was queued.', - 'type': ['string', 'null'], - }, - 'test_split': { - 'description': 'Percentage of frames to use for testing only', - 'type': ['integer', 'null'], - }, }, 'type': 'object', }, - 'filter_by_roi_enum': { - 'default': 'label_rules', - 'enum': ['disabled', 'no_rois', 'label_rules'], - 'type': 'string', - }, - 'filter_label_rule': { - 'properties': { - 'conf_range': { - 'description': 'Range of ROI confidence level in the frame (min, max). -1 for not applicable\n Both min and max can be either -1 or positive.\n 2nd number (max) must be either -1 or larger than or equal to the 1st number (min)', - 'items': {'type': 'number'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'count_range': { - 'description': 'Range of times ROI appears in the frame (min, max). -1 for not applicable.\n Both integers must be larger than or equal to -1.\n 2nd integer (max) must be either -1 or larger than or equal to the 1st integer (min)', - 'items': {'type': 'integer'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'label': { - 'description': "Lucene format query (see lucene query syntax).\nDefault search field is label.keyword and default operator is AND, so searching for:\n\n'Bus Stop' Blue\n\nis equivalent to:\n\nLabel.keyword:'Bus Stop' AND label.keyword:'Blue'", - 'type': 'string', - }, - }, - 'required': ['label'], - 'type': 'object', - }, - 'filter_rule': { - 'properties': { - 'dataset': { - 'description': "Dataset ID. Must be a dataset which is in the task's view. If set to '*' all datasets in View are used.", - 'type': 'string', - }, - 'filter_by_roi': { - '$ref': '#/definitions/filter_by_roi_enum', - 'description': 'Type of filter', - }, - 'frame_query': { - 'description': 'Frame filter, in Lucene query syntax', - 'type': 'string', - }, - 'label_rules': { - 'description': "List of FilterLabelRule ('AND' connection)\n\ndisabled - No filtering by ROIs. Select all frames, even if they don't have ROIs (all frames)\n\nno_rois - Select only frames without ROIs (empty frames)\n\nlabel_rules - Select frames according to label rules", - 'items': {'$ref': '#/definitions/filter_label_rule'}, - 'type': ['array', 'null'], - }, - 'sources_query': { - 'description': 'Sources filter, in Lucene query syntax. Filters sources in each frame.', - 'type': 'string', - }, - 'version': { - 'description': "Dataset version to apply rule to. Must belong to the dataset and be in the task's view. If set to '*' all version of the datasets in View are used.", - 'type': 'string', - }, - 'weight': { - 'description': 'Rule weight. Default is 1', - 'type': 'number', - }, - }, - 'required': ['filter_by_roi'], - 'type': 'object', - }, - 'filtering': { - 'properties': { - 'filtering_rules': { - 'description': "List of FilterRule ('OR' connection)", - 'items': {'$ref': '#/definitions/filter_rule'}, - 'type': ['array', 'null'], - }, - 'output_rois': { - 'description': "'all_in_frame' - all rois for a frame are returned\n\n'only_filtered' - only rois which led this frame to be selected\n\n'frame_per_roi' - single roi per frame. Frame can be returned multiple times with a different roi each time.\n\nNote: this should be used for Training tasks only\n\nNote: frame_per_roi implies that only filtered rois will be returned\n ", - 'oneOf': [ - {'$ref': '#/definitions/output_rois_enum'}, - {'type': 'null'}, - ], - }, - }, - 'type': 'object', - }, - 'input': { - 'properties': { - 'augmentation': { - 'description': 'Augmentation parameters. Only for training and testing tasks.', - 'oneOf': [ - {'$ref': '#/definitions/augmentation'}, - {'type': 'null'}, - ], - }, - 'dataviews': { - 'additionalProperties': {'type': 'string'}, - 'description': 'Key to DataView ID Mapping', - 'type': ['object', 'null'], - }, - 'frames_filter': { - 'description': 'Filtering params', - 'oneOf': [ - {'$ref': '#/definitions/filtering'}, - {'type': 'null'}, - ], - }, - 'iteration': { - 'description': 'Iteration parameters. Not applicable for register (import) tasks.', - 'oneOf': [ - {'$ref': '#/definitions/iteration'}, - {'type': 'null'}, - ], - }, - 'mapping': { - 'description': 'Mapping params (see common definitions section)', - 'oneOf': [ - {'$ref': '#/definitions/mapping'}, - {'type': 'null'}, - ], - }, - 'view': { - 'description': 'View params', - 'oneOf': [{'$ref': '#/definitions/view'}, {'type': 'null'}], - }, - }, - 'type': 'object', - }, - 'iteration': { - 'description': 'Sequential Iteration API configuration', - 'properties': { - 'infinite': { - 'description': 'Infinite iteration', - 'type': ['boolean', 'null'], - }, - 'jump': { - 'description': 'Jump entry', - 'oneOf': [{'$ref': '#/definitions/jump'}, {'type': 'null'}], - }, - 'limit': { - 'description': 'Maximum frames per task. If not passed, frames will end when no more matching frames are found, unless infinite is True.', - 'type': ['integer', 'null'], - }, - 'min_sequence': { - 'description': 'Length (in ms) of video clips to return. This is used in random order, and in sequential order only if jumping is provided and only for video frames', - 'type': ['integer', 'null'], - }, - 'order': { - 'description': "\n Input frames order. Values: 'sequential', 'random'\n In Sequential mode frames will be returned according to the order in which the frames were added to the dataset.", - 'type': ['string', 'null'], - }, - 'random_seed': { - 'description': 'Random seed used during iteration', - 'type': 'integer', - }, - }, - 'required': ['random_seed'], - 'type': 'object', - }, - 'jump': { - 'properties': { - 'time': { - 'description': 'Max time in milliseconds between frames', - 'type': ['integer', 'null'], - }, - }, - 'type': 'object', - }, - 'label_source': { - 'properties': { - 'dataset': { - 'description': "Source dataset id. '*' for all datasets in view", - 'type': ['string', 'null'], - }, - 'labels': { - 'description': "List of source labels (AND connection). '*' indicates any label. Labels must exist in at least one of the dataset versions in the task's view", - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - 'version': { - 'description': "Source dataset version id. Default is '*' (for all versions in dataset in the view) Version must belong to the selected dataset, and must be in the task's view[i]", - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'mapping': { - 'properties': { - 'rules': { - 'description': 'Rules list', - 'items': {'$ref': '#/definitions/mapping_rule'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'mapping_rule': { - 'properties': { - 'source': { - 'description': 'Source label info', - 'oneOf': [ - {'$ref': '#/definitions/label_source'}, - {'type': 'null'}, - ], - }, - 'target': { - 'description': 'Target label name', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'output_rois_enum': { - 'enum': ['all_in_frame', 'only_filtered', 'frame_per_roi'], - 'type': 'string', - }, 'script': { 'properties': { 'binary': { @@ -3992,49 +1977,13 @@ class EditRequest(Request): 'type': ['string', 'null'], }, 'working_dir': { - 'description': 'Path to the folder from which to run the script Default - root folder of repository[f]', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'task_type_enum': { - 'enum': [ - 'dataset_import', - 'annotation', - 'annotation_manual', - 'training', - 'testing', - ], - 'type': 'string', - }, - 'view': { - 'properties': { - 'entries': { - 'description': 'List of view entries. All tasks must have at least one view.', - 'items': {'$ref': '#/definitions/view_entry'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'view_entry': { - 'properties': { - 'dataset': { - 'description': 'Existing Dataset id', - 'type': ['string', 'null'], - }, - 'merge_with': { - 'description': 'Version ID to merge with', - 'type': ['string', 'null'], - }, - 'version': { - 'description': 'Version id of a version belonging to the dataset', + 'description': 'Path to the folder from which to run the script Default - root folder of repository', 'type': ['string', 'null'], }, }, 'type': 'object', }, + 'task_type_enum': {'enum': ['training', 'testing'], 'type': 'string'}, }, 'properties': { 'comment': {'description': 'Free text comment ', 'type': 'string'}, @@ -4047,10 +1996,6 @@ class EditRequest(Request): 'description': "If not true, call fails if the task status is not 'created'", 'type': 'boolean', }, - 'input': { - '$ref': '#/definitions/input', - 'description': 'Task input params. (input view must be provided).', - }, 'name': { 'description': 'Task name Unique within the company.', 'type': 'string', @@ -4082,7 +2027,7 @@ class EditRequest(Request): 'type': 'object', } def __init__( - self, task, force=False, name=None, tags=None, type=None, comment=None, parent=None, project=None, input=None, output_dest=None, execution=None, script=None, **kwargs): + self, task, force=False, name=None, tags=None, type=None, comment=None, parent=None, project=None, output_dest=None, execution=None, script=None, **kwargs): super(EditRequest, self).__init__(**kwargs) self.task = task self.force = force @@ -4092,7 +2037,6 @@ class EditRequest(Request): self.comment = comment self.parent = parent self.project = project - self.input = input self.output_dest = output_dest self.execution = execution self.script = script @@ -4208,21 +2152,6 @@ class EditRequest(Request): 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): - if value is None: - self._property_input = None - return - if isinstance(value, dict): - value = Input.from_dict(value) - else: - self.assert_isinstance(value, "input", Input) - self._property_input = value - @schema_property('output_dest') def output_dest(self): return self._property_output_dest @@ -4331,200 +2260,6 @@ class EditResponse(Response): self._property_fields = 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, 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 - """ - - _service = "tasks" - _action = "enqueue" - _version = "1.5" - _schema = { - 'definitions': {}, - 'properties': { - 'queue': { - 'description': 'Queue id. If not provided, task is added to the default queue.', - 'type': ['string', '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, queue=None, status_reason=None, status_message=None, **kwargs): - super(EnqueueRequest, self).__init__(**kwargs) - self.queue = queue - self.task = task - self.status_reason = status_reason - self.status_message = status_message - - @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 - - -class EnqueueResponse(Response): - """ - Response of tasks.enqueue endpoint. - - :param queued: Number of tasks queued (0 or 1) - :type queued: int - :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 = "enqueue" - _version = "1.5" - - _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, queued=None, updated=None, fields=None, **kwargs): - super(EnqueueResponse, self).__init__(**kwargs) - self.queued = queued - self.updated = updated - self.fields = fields - - @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 - - @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 FailedRequest(Request): """ Indicates that task has failed @@ -4735,10 +2470,6 @@ class GetAllRequest(Request): :type _all_: MultiFieldPatternData :param _any_: Multi-field pattern condition (any field matches pattern) :type _any_: MultiFieldPatternData - :param input.view.entries.dataset: List of input dataset IDs - :type input.view.entries.dataset: Sequence[str] - :param input.view.entries.version: List of input dataset version IDs - :type input.view.entries.version: Sequence[str] """ _service = "tasks" @@ -4763,7 +2494,6 @@ class GetAllRequest(Request): 'task_status_enum': { 'enum': [ 'created', - 'queued', 'in_progress', 'stopped', 'published', @@ -4796,16 +2526,6 @@ class GetAllRequest(Request): 'items': {'type': 'string'}, 'type': ['array', 'null'], }, - 'input.view.entries.dataset': { - 'description': 'List of input dataset IDs', - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - 'input.view.entries.version': { - 'description': 'List of input dataset version IDs', - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, 'name': { 'description': 'Get only tasks whose name matches this pattern (python regular expression syntax)', 'type': ['string', 'null'], @@ -4869,7 +2589,7 @@ class GetAllRequest(Request): '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, status=None, only_fields=None, parent=None, status_changed=None, search_text=None, _all_=None, _any_=None, input__view__entries__dataset=None, input__view__entries__version=None, **kwargs): + self, id=None, name=None, user=None, project=None, page=None, page_size=None, order_by=None, type=None, tags=None, status=None, only_fields=None, parent=None, status_changed=None, search_text=None, _all_=None, _any_=None, **kwargs): super(GetAllRequest, self).__init__(**kwargs) self.id = id self.name = name @@ -4887,8 +2607,6 @@ class GetAllRequest(Request): self.search_text = search_text self._all_ = _all_ self._any_ = _any_ - self.input__view__entries__dataset = input__view__entries__dataset - self.input__view__entries__version = input__view__entries__version @schema_property('id') def id(self): @@ -5126,36 +2844,6 @@ class GetAllRequest(Request): self.assert_isinstance(value, "_any_", MultiFieldPatternData) self._property__any_ = value - @schema_property('input.view.entries.dataset') - def input__view__entries__dataset(self): - return self._property_input__view__entries__dataset - - @input__view__entries__dataset.setter - def input__view__entries__dataset(self, value): - if value is None: - self._property_input__view__entries__dataset = None - return - - self.assert_isinstance(value, "input__view__entries__dataset", (list, tuple)) - - self.assert_isinstance(value, "input__view__entries__dataset", six.string_types, is_array=True) - self._property_input__view__entries__dataset = value - - @schema_property('input.view.entries.version') - def input__view__entries__version(self): - return self._property_input__view__entries__version - - @input__view__entries__version.setter - def input__view__entries__version(self, value): - if value is None: - self._property_input__view__entries__version = None - return - - self.assert_isinstance(value, "input__view__entries__version", (list, tuple)) - - self.assert_isinstance(value, "input__view__entries__version", six.string_types, is_array=True) - self._property_input__view__entries__version = value - class GetAllResponse(Response): """ @@ -5170,54 +2858,8 @@ class GetAllResponse(Response): _schema = { 'definitions': { - 'augmentation': { - 'properties': { - 'crop_around_rois': { - 'description': 'Crop image data around all frame ROIs', - 'type': ['boolean', 'null'], - }, - 'sets': { - 'description': 'List of augmentation sets', - 'items': {'$ref': '#/definitions/augmentation_set'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'augmentation_set': { - 'properties': { - 'arguments': { - 'additionalProperties': { - 'additionalProperties': True, - 'type': 'object', - }, - 'description': 'Arguments dictionary per custom augmentation type.', - 'type': ['object', 'null'], - }, - 'cls': { - 'description': 'Augmentation class', - 'type': ['string', 'null'], - }, - 'strength': { - 'description': 'Augmentation strength. Range [0,).', - 'minimum': 0, - 'type': ['number', 'null'], - }, - 'types': { - 'description': 'Augmentation type', - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, 'execution': { 'properties': { - 'dataviews': { - 'description': 'Additional dataviews for the task', - 'items': {'additionalProperties': True, 'type': 'object'}, - 'type': ['array', 'null'], - }, 'framework': { 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', 'type': ['string', 'null'], @@ -5233,7 +2875,7 @@ class GetAllResponse(Response): }, '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[z]", + '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': { @@ -5241,195 +2883,6 @@ class GetAllResponse(Response): 'description': 'Json object containing the Task parameters', 'type': ['object', 'null'], }, - 'queue': { - 'description': 'Queue ID where task was queued.', - 'type': ['string', 'null'], - }, - 'test_split': { - 'description': 'Percentage of frames to use for testing only', - 'type': ['integer', 'null'], - }, - }, - 'type': 'object', - }, - 'filter_by_roi_enum': { - 'default': 'label_rules', - 'enum': ['disabled', 'no_rois', 'label_rules'], - 'type': 'string', - }, - 'filter_label_rule': { - 'properties': { - 'conf_range': { - 'description': 'Range of ROI confidence level in the frame (min, max). -1 for not applicable\n Both min and max can be either -1 or positive.\n 2nd number (max) must be either -1 or larger than or equal to the 1st number (min)', - 'items': {'type': 'number'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'count_range': { - 'description': 'Range of times ROI appears in the frame (min, max). -1 for not applicable.\n Both integers must be larger than or equal to -1.\n 2nd integer (max) must be either -1 or larger than or equal to the 1st integer (min)', - 'items': {'type': 'integer'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'label': { - 'description': "Lucene format query (see lucene query syntax).\nDefault search field is label.keyword and default operator is AND, so searching for:\n\n'Bus Stop' Blue\n\nis equivalent to:\n\nLabel.keyword:'Bus Stop' AND label.keyword:'Blue'", - 'type': 'string', - }, - }, - 'required': ['label'], - 'type': 'object', - }, - 'filter_rule': { - 'properties': { - 'dataset': { - 'description': "Dataset ID. Must be a dataset which is in the task's view. If set to '*' all datasets in View are used.", - 'type': 'string', - }, - 'filter_by_roi': { - '$ref': '#/definitions/filter_by_roi_enum', - 'description': 'Type of filter', - }, - 'frame_query': { - 'description': 'Frame filter, in Lucene query syntax', - 'type': 'string', - }, - 'label_rules': { - 'description': "List of FilterLabelRule ('AND' connection)\n\ndisabled - No filtering by ROIs. Select all frames, even if they don't have ROIs (all frames)\n\nno_rois - Select only frames without ROIs (empty frames)\n\nlabel_rules - Select frames according to label rules", - 'items': {'$ref': '#/definitions/filter_label_rule'}, - 'type': ['array', 'null'], - }, - 'sources_query': { - 'description': 'Sources filter, in Lucene query syntax. Filters sources in each frame.', - 'type': 'string', - }, - 'version': { - 'description': "Dataset version to apply rule to. Must belong to the dataset and be in the task's view. If set to '*' all version of the datasets in View are used.", - 'type': 'string', - }, - 'weight': { - 'description': 'Rule weight. Default is 1', - 'type': 'number', - }, - }, - 'required': ['filter_by_roi'], - 'type': 'object', - }, - 'filtering': { - 'properties': { - 'filtering_rules': { - 'description': "List of FilterRule ('OR' connection)", - 'items': {'$ref': '#/definitions/filter_rule'}, - 'type': ['array', 'null'], - }, - 'output_rois': { - 'description': "'all_in_frame' - all rois for a frame are returned\n\n'only_filtered' - only rois which led this frame to be selected\n\n'frame_per_roi' - single roi per frame. Frame can be returned multiple times with a different roi each time.\n\nNote: this should be used for Training tasks only\n\nNote: frame_per_roi implies that only filtered rois will be returned\n ", - 'oneOf': [ - {'$ref': '#/definitions/output_rois_enum'}, - {'type': 'null'}, - ], - }, - }, - 'type': 'object', - }, - 'input': { - 'properties': { - 'augmentation': { - 'description': 'Augmentation parameters. Only for training and testing tasks.', - 'oneOf': [ - {'$ref': '#/definitions/augmentation'}, - {'type': 'null'}, - ], - }, - 'dataviews': { - 'additionalProperties': {'type': 'string'}, - 'description': 'Key to DataView ID Mapping', - 'type': ['object', 'null'], - }, - 'frames_filter': { - 'description': 'Filtering params', - 'oneOf': [ - {'$ref': '#/definitions/filtering'}, - {'type': 'null'}, - ], - }, - 'iteration': { - 'description': 'Iteration parameters. Not applicable for register (import) tasks.', - 'oneOf': [ - {'$ref': '#/definitions/iteration'}, - {'type': 'null'}, - ], - }, - 'mapping': { - 'description': 'Mapping params (see common definitions section)', - 'oneOf': [ - {'$ref': '#/definitions/mapping'}, - {'type': 'null'}, - ], - }, - 'view': { - 'description': 'View params', - 'oneOf': [{'$ref': '#/definitions/view'}, {'type': 'null'}], - }, - }, - 'type': 'object', - }, - 'iteration': { - 'description': 'Sequential Iteration API configuration', - 'properties': { - 'infinite': { - 'description': 'Infinite iteration', - 'type': ['boolean', 'null'], - }, - 'jump': { - 'description': 'Jump entry', - 'oneOf': [{'$ref': '#/definitions/jump'}, {'type': 'null'}], - }, - 'limit': { - 'description': 'Maximum frames per task. If not passed, frames will end when no more matching frames are found, unless infinite is True.', - 'type': ['integer', 'null'], - }, - 'min_sequence': { - 'description': 'Length (in ms) of video clips to return. This is used in random order, and in sequential order only if jumping is provided and only for video frames', - 'type': ['integer', 'null'], - }, - 'order': { - 'description': "\n Input frames order. Values: 'sequential', 'random'\n In Sequential mode frames will be returned according to the order in which the frames were added to the dataset.", - 'type': ['string', 'null'], - }, - 'random_seed': { - 'description': 'Random seed used during iteration', - 'type': 'integer', - }, - }, - 'required': ['random_seed'], - 'type': 'object', - }, - 'jump': { - 'properties': { - 'time': { - 'description': 'Max time in milliseconds between frames', - 'type': ['integer', 'null'], - }, - }, - 'type': 'object', - }, - 'label_source': { - 'properties': { - 'dataset': { - 'description': "Source dataset id. '*' for all datasets in view", - 'type': ['string', 'null'], - }, - 'labels': { - 'description': "List of source labels (AND connection). '*' indicates any label. Labels must exist in at least one of the dataset versions in the task's view", - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - 'version': { - 'description': "Source dataset version id. Default is '*' (for all versions in dataset in the view) Version must belong to the selected dataset, and must be in the task's view[i]", - 'type': ['string', 'null'], - }, }, 'type': 'object', }, @@ -5467,32 +2920,6 @@ class GetAllResponse(Response): 'description': 'Last metric events, one for each variant hash', 'type': 'object', }, - 'mapping': { - 'properties': { - 'rules': { - 'description': 'Rules list', - 'items': {'$ref': '#/definitions/mapping_rule'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'mapping_rule': { - 'properties': { - 'source': { - 'description': 'Source label info', - 'oneOf': [ - {'$ref': '#/definitions/label_source'}, - {'type': 'null'}, - ], - }, - 'target': { - 'description': 'Target label name', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, 'output': { 'properties': { 'destination': { @@ -5511,17 +2938,9 @@ class GetAllResponse(Response): 'description': "Task result. Values: 'success', 'failure'", 'type': ['string', 'null'], }, - 'view': { - 'description': 'View params', - 'oneOf': [{'$ref': '#/definitions/view'}, {'type': 'null'}], - }, }, 'type': 'object', }, - 'output_rois_enum': { - 'enum': ['all_in_frame', 'only_filtered', 'frame_per_roi'], - 'type': 'string', - }, 'script': { 'properties': { 'binary': { @@ -5554,7 +2973,7 @@ class GetAllResponse(Response): 'type': ['string', 'null'], }, 'working_dir': { - 'description': 'Path to the folder from which to run the script Default - root folder of repository[f]', + 'description': 'Path to the folder from which to run the script Default - root folder of repository', 'type': ['string', 'null'], }, }, @@ -5588,13 +3007,6 @@ class GetAllResponse(Response): ], }, 'id': {'description': 'Task id', 'type': ['string', 'null']}, - 'input': { - 'description': 'Task input params', - 'oneOf': [ - {'$ref': '#/definitions/input'}, - {'type': 'null'}, - ], - }, 'last_iteration': { 'description': 'Last iteration reported for this task', 'type': ['integer', 'null'], @@ -5611,15 +3023,6 @@ class GetAllResponse(Response): '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'], - }, 'name': { 'description': 'Task Name', 'type': ['string', 'null'], @@ -5682,7 +3085,7 @@ class GetAllResponse(Response): 'type': ['array', 'null'], }, 'type': { - 'description': "Type of task. Values: 'dataset_import', 'annotation', 'training', 'testing'", + 'description': "Type of task. Values: 'training', 'testing'", 'oneOf': [ {'$ref': '#/definitions/task_type_enum'}, {'type': 'null'}, @@ -5698,7 +3101,6 @@ class GetAllResponse(Response): 'task_status_enum': { 'enum': [ 'created', - 'queued', 'in_progress', 'stopped', 'published', @@ -5709,43 +3111,7 @@ class GetAllResponse(Response): ], 'type': 'string', }, - 'task_type_enum': { - 'enum': [ - 'dataset_import', - 'annotation', - 'annotation_manual', - 'training', - 'testing', - ], - 'type': 'string', - }, - 'view': { - 'properties': { - 'entries': { - 'description': 'List of view entries. All tasks must have at least one view.', - 'items': {'$ref': '#/definitions/view_entry'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'view_entry': { - 'properties': { - 'dataset': { - 'description': 'Existing Dataset id', - 'type': ['string', 'null'], - }, - 'merge_with': { - 'description': 'Version ID to merge with', - 'type': ['string', 'null'], - }, - 'version': { - 'description': 'Version id of a version belonging to the dataset', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, + 'task_type_enum': {'enum': ['training', 'testing'], 'type': 'string'}, }, 'properties': { 'tasks': { @@ -5828,54 +3194,8 @@ class GetByIdResponse(Response): _schema = { 'definitions': { - 'augmentation': { - 'properties': { - 'crop_around_rois': { - 'description': 'Crop image data around all frame ROIs', - 'type': ['boolean', 'null'], - }, - 'sets': { - 'description': 'List of augmentation sets', - 'items': {'$ref': '#/definitions/augmentation_set'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'augmentation_set': { - 'properties': { - 'arguments': { - 'additionalProperties': { - 'additionalProperties': True, - 'type': 'object', - }, - 'description': 'Arguments dictionary per custom augmentation type.', - 'type': ['object', 'null'], - }, - 'cls': { - 'description': 'Augmentation class', - 'type': ['string', 'null'], - }, - 'strength': { - 'description': 'Augmentation strength. Range [0,).', - 'minimum': 0, - 'type': ['number', 'null'], - }, - 'types': { - 'description': 'Augmentation type', - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, 'execution': { 'properties': { - 'dataviews': { - 'description': 'Additional dataviews for the task', - 'items': {'additionalProperties': True, 'type': 'object'}, - 'type': ['array', 'null'], - }, 'framework': { 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', 'type': ['string', 'null'], @@ -5891,7 +3211,7 @@ class GetByIdResponse(Response): }, '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[z]", + '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': { @@ -5899,195 +3219,6 @@ class GetByIdResponse(Response): 'description': 'Json object containing the Task parameters', 'type': ['object', 'null'], }, - 'queue': { - 'description': 'Queue ID where task was queued.', - 'type': ['string', 'null'], - }, - 'test_split': { - 'description': 'Percentage of frames to use for testing only', - 'type': ['integer', 'null'], - }, - }, - 'type': 'object', - }, - 'filter_by_roi_enum': { - 'default': 'label_rules', - 'enum': ['disabled', 'no_rois', 'label_rules'], - 'type': 'string', - }, - 'filter_label_rule': { - 'properties': { - 'conf_range': { - 'description': 'Range of ROI confidence level in the frame (min, max). -1 for not applicable\n Both min and max can be either -1 or positive.\n 2nd number (max) must be either -1 or larger than or equal to the 1st number (min)', - 'items': {'type': 'number'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'count_range': { - 'description': 'Range of times ROI appears in the frame (min, max). -1 for not applicable.\n Both integers must be larger than or equal to -1.\n 2nd integer (max) must be either -1 or larger than or equal to the 1st integer (min)', - 'items': {'type': 'integer'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'label': { - 'description': "Lucene format query (see lucene query syntax).\nDefault search field is label.keyword and default operator is AND, so searching for:\n\n'Bus Stop' Blue\n\nis equivalent to:\n\nLabel.keyword:'Bus Stop' AND label.keyword:'Blue'", - 'type': 'string', - }, - }, - 'required': ['label'], - 'type': 'object', - }, - 'filter_rule': { - 'properties': { - 'dataset': { - 'description': "Dataset ID. Must be a dataset which is in the task's view. If set to '*' all datasets in View are used.", - 'type': 'string', - }, - 'filter_by_roi': { - '$ref': '#/definitions/filter_by_roi_enum', - 'description': 'Type of filter', - }, - 'frame_query': { - 'description': 'Frame filter, in Lucene query syntax', - 'type': 'string', - }, - 'label_rules': { - 'description': "List of FilterLabelRule ('AND' connection)\n\ndisabled - No filtering by ROIs. Select all frames, even if they don't have ROIs (all frames)\n\nno_rois - Select only frames without ROIs (empty frames)\n\nlabel_rules - Select frames according to label rules", - 'items': {'$ref': '#/definitions/filter_label_rule'}, - 'type': ['array', 'null'], - }, - 'sources_query': { - 'description': 'Sources filter, in Lucene query syntax. Filters sources in each frame.', - 'type': 'string', - }, - 'version': { - 'description': "Dataset version to apply rule to. Must belong to the dataset and be in the task's view. If set to '*' all version of the datasets in View are used.", - 'type': 'string', - }, - 'weight': { - 'description': 'Rule weight. Default is 1', - 'type': 'number', - }, - }, - 'required': ['filter_by_roi'], - 'type': 'object', - }, - 'filtering': { - 'properties': { - 'filtering_rules': { - 'description': "List of FilterRule ('OR' connection)", - 'items': {'$ref': '#/definitions/filter_rule'}, - 'type': ['array', 'null'], - }, - 'output_rois': { - 'description': "'all_in_frame' - all rois for a frame are returned\n\n'only_filtered' - only rois which led this frame to be selected\n\n'frame_per_roi' - single roi per frame. Frame can be returned multiple times with a different roi each time.\n\nNote: this should be used for Training tasks only\n\nNote: frame_per_roi implies that only filtered rois will be returned\n ", - 'oneOf': [ - {'$ref': '#/definitions/output_rois_enum'}, - {'type': 'null'}, - ], - }, - }, - 'type': 'object', - }, - 'input': { - 'properties': { - 'augmentation': { - 'description': 'Augmentation parameters. Only for training and testing tasks.', - 'oneOf': [ - {'$ref': '#/definitions/augmentation'}, - {'type': 'null'}, - ], - }, - 'dataviews': { - 'additionalProperties': {'type': 'string'}, - 'description': 'Key to DataView ID Mapping', - 'type': ['object', 'null'], - }, - 'frames_filter': { - 'description': 'Filtering params', - 'oneOf': [ - {'$ref': '#/definitions/filtering'}, - {'type': 'null'}, - ], - }, - 'iteration': { - 'description': 'Iteration parameters. Not applicable for register (import) tasks.', - 'oneOf': [ - {'$ref': '#/definitions/iteration'}, - {'type': 'null'}, - ], - }, - 'mapping': { - 'description': 'Mapping params (see common definitions section)', - 'oneOf': [ - {'$ref': '#/definitions/mapping'}, - {'type': 'null'}, - ], - }, - 'view': { - 'description': 'View params', - 'oneOf': [{'$ref': '#/definitions/view'}, {'type': 'null'}], - }, - }, - 'type': 'object', - }, - 'iteration': { - 'description': 'Sequential Iteration API configuration', - 'properties': { - 'infinite': { - 'description': 'Infinite iteration', - 'type': ['boolean', 'null'], - }, - 'jump': { - 'description': 'Jump entry', - 'oneOf': [{'$ref': '#/definitions/jump'}, {'type': 'null'}], - }, - 'limit': { - 'description': 'Maximum frames per task. If not passed, frames will end when no more matching frames are found, unless infinite is True.', - 'type': ['integer', 'null'], - }, - 'min_sequence': { - 'description': 'Length (in ms) of video clips to return. This is used in random order, and in sequential order only if jumping is provided and only for video frames', - 'type': ['integer', 'null'], - }, - 'order': { - 'description': "\n Input frames order. Values: 'sequential', 'random'\n In Sequential mode frames will be returned according to the order in which the frames were added to the dataset.", - 'type': ['string', 'null'], - }, - 'random_seed': { - 'description': 'Random seed used during iteration', - 'type': 'integer', - }, - }, - 'required': ['random_seed'], - 'type': 'object', - }, - 'jump': { - 'properties': { - 'time': { - 'description': 'Max time in milliseconds between frames', - 'type': ['integer', 'null'], - }, - }, - 'type': 'object', - }, - 'label_source': { - 'properties': { - 'dataset': { - 'description': "Source dataset id. '*' for all datasets in view", - 'type': ['string', 'null'], - }, - 'labels': { - 'description': "List of source labels (AND connection). '*' indicates any label. Labels must exist in at least one of the dataset versions in the task's view", - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - 'version': { - 'description': "Source dataset version id. Default is '*' (for all versions in dataset in the view) Version must belong to the selected dataset, and must be in the task's view[i]", - 'type': ['string', 'null'], - }, }, 'type': 'object', }, @@ -6125,32 +3256,6 @@ class GetByIdResponse(Response): 'description': 'Last metric events, one for each variant hash', 'type': 'object', }, - 'mapping': { - 'properties': { - 'rules': { - 'description': 'Rules list', - 'items': {'$ref': '#/definitions/mapping_rule'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'mapping_rule': { - 'properties': { - 'source': { - 'description': 'Source label info', - 'oneOf': [ - {'$ref': '#/definitions/label_source'}, - {'type': 'null'}, - ], - }, - 'target': { - 'description': 'Target label name', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, 'output': { 'properties': { 'destination': { @@ -6169,17 +3274,9 @@ class GetByIdResponse(Response): 'description': "Task result. Values: 'success', 'failure'", 'type': ['string', 'null'], }, - 'view': { - 'description': 'View params', - 'oneOf': [{'$ref': '#/definitions/view'}, {'type': 'null'}], - }, }, 'type': 'object', }, - 'output_rois_enum': { - 'enum': ['all_in_frame', 'only_filtered', 'frame_per_roi'], - 'type': 'string', - }, 'script': { 'properties': { 'binary': { @@ -6212,7 +3309,7 @@ class GetByIdResponse(Response): 'type': ['string', 'null'], }, 'working_dir': { - 'description': 'Path to the folder from which to run the script Default - root folder of repository[f]', + 'description': 'Path to the folder from which to run the script Default - root folder of repository', 'type': ['string', 'null'], }, }, @@ -6246,13 +3343,6 @@ class GetByIdResponse(Response): ], }, 'id': {'description': 'Task id', 'type': ['string', 'null']}, - 'input': { - 'description': 'Task input params', - 'oneOf': [ - {'$ref': '#/definitions/input'}, - {'type': 'null'}, - ], - }, 'last_iteration': { 'description': 'Last iteration reported for this task', 'type': ['integer', 'null'], @@ -6269,15 +3359,6 @@ class GetByIdResponse(Response): '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'], - }, 'name': { 'description': 'Task Name', 'type': ['string', 'null'], @@ -6340,7 +3421,7 @@ class GetByIdResponse(Response): 'type': ['array', 'null'], }, 'type': { - 'description': "Type of task. Values: 'dataset_import', 'annotation', 'training', 'testing'", + 'description': "Type of task. Values: 'training', 'testing'", 'oneOf': [ {'$ref': '#/definitions/task_type_enum'}, {'type': 'null'}, @@ -6356,7 +3437,6 @@ class GetByIdResponse(Response): 'task_status_enum': { 'enum': [ 'created', - 'queued', 'in_progress', 'stopped', 'published', @@ -6367,43 +3447,7 @@ class GetByIdResponse(Response): ], 'type': 'string', }, - 'task_type_enum': { - 'enum': [ - 'dataset_import', - 'annotation', - 'annotation_manual', - 'training', - 'testing', - ], - 'type': 'string', - }, - 'view': { - 'properties': { - 'entries': { - 'description': 'List of view entries. All tasks must have at least one view.', - 'items': {'$ref': '#/definitions/view_entry'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'view_entry': { - 'properties': { - 'dataset': { - 'description': 'Existing Dataset id', - 'type': ['string', 'null'], - }, - 'merge_with': { - 'description': 'Version ID to merge with', - 'type': ['string', 'null'], - }, - 'version': { - 'description': 'Version id of a version belonging to the dataset', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, + 'task_type_enum': {'enum': ['training', 'testing'], 'type': 'string'}, }, 'properties': { 'task': { @@ -6751,8 +3795,6 @@ class ResetResponse(Response): :param deleted_indices: List of deleted ES indices that were removed as part of the reset process :type deleted_indices: Sequence[str] - :param dequeued: Response from queues.remove_task - :type dequeued: dict :param frames: Response from frames.rollback :type frames: dict :param events: Response from events.delete_for_task @@ -6780,11 +3822,6 @@ class ResetResponse(Response): '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', @@ -6809,10 +3846,9 @@ class ResetResponse(Response): 'type': 'object', } def __init__( - self, deleted_indices=None, dequeued=None, frames=None, events=None, deleted_models=None, updated=None, fields=None, **kwargs): + self, deleted_indices=None, frames=None, events=None, deleted_models=None, updated=None, fields=None, **kwargs): super(ResetResponse, self).__init__(**kwargs) self.deleted_indices = deleted_indices - self.dequeued = dequeued self.frames = frames self.events = events self.deleted_models = deleted_models @@ -6834,19 +3870,6 @@ class ResetResponse(Response): self.assert_isinstance(value, "deleted_indices", six.string_types, is_array=True) self._property_deleted_indices = 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('frames') def frames(self): return self._property_frames @@ -7843,8 +4866,6 @@ class ValidateRequest(Request): :param project: Project ID of the project to which this task is assigned Must exist[ab] :type project: str - :param input: Task input params. (input view must be provided). - :type input: Input :param output_dest: Output storage id Must be a reference to an existing storage. :type output_dest: str @@ -7859,54 +4880,8 @@ class ValidateRequest(Request): _version = "1.9" _schema = { 'definitions': { - 'augmentation': { - 'properties': { - 'crop_around_rois': { - 'description': 'Crop image data around all frame ROIs', - 'type': ['boolean', 'null'], - }, - 'sets': { - 'description': 'List of augmentation sets', - 'items': {'$ref': '#/definitions/augmentation_set'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'augmentation_set': { - 'properties': { - 'arguments': { - 'additionalProperties': { - 'additionalProperties': True, - 'type': 'object', - }, - 'description': 'Arguments dictionary per custom augmentation type.', - 'type': ['object', 'null'], - }, - 'cls': { - 'description': 'Augmentation class', - 'type': ['string', 'null'], - }, - 'strength': { - 'description': 'Augmentation strength. Range [0,).', - 'minimum': 0, - 'type': ['number', 'null'], - }, - 'types': { - 'description': 'Augmentation type', - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, 'execution': { 'properties': { - 'dataviews': { - 'description': 'Additional dataviews for the task', - 'items': {'additionalProperties': True, 'type': 'object'}, - 'type': ['array', 'null'], - }, 'framework': { 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', 'type': ['string', 'null'], @@ -7922,7 +4897,7 @@ class ValidateRequest(Request): }, '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[z]", + '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': { @@ -7930,228 +4905,9 @@ class ValidateRequest(Request): 'description': 'Json object containing the Task parameters', 'type': ['object', 'null'], }, - 'queue': { - 'description': 'Queue ID where task was queued.', - 'type': ['string', 'null'], - }, - 'test_split': { - 'description': 'Percentage of frames to use for testing only', - 'type': ['integer', 'null'], - }, }, 'type': 'object', }, - 'filter_by_roi_enum': { - 'default': 'label_rules', - 'enum': ['disabled', 'no_rois', 'label_rules'], - 'type': 'string', - }, - 'filter_label_rule': { - 'properties': { - 'conf_range': { - 'description': 'Range of ROI confidence level in the frame (min, max). -1 for not applicable\n Both min and max can be either -1 or positive.\n 2nd number (max) must be either -1 or larger than or equal to the 1st number (min)', - 'items': {'type': 'number'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'count_range': { - 'description': 'Range of times ROI appears in the frame (min, max). -1 for not applicable.\n Both integers must be larger than or equal to -1.\n 2nd integer (max) must be either -1 or larger than or equal to the 1st integer (min)', - 'items': {'type': 'integer'}, - 'maxItems': 2, - 'minItems': 1, - 'type': 'array', - }, - 'label': { - 'description': "Lucene format query (see lucene query syntax).\nDefault search field is label.keyword and default operator is AND, so searching for:\n\n'Bus Stop' Blue\n\nis equivalent to:\n\nLabel.keyword:'Bus Stop' AND label.keyword:'Blue'", - 'type': 'string', - }, - }, - 'required': ['label'], - 'type': 'object', - }, - 'filter_rule': { - 'properties': { - 'dataset': { - 'description': "Dataset ID. Must be a dataset which is in the task's view. If set to '*' all datasets in View are used.", - 'type': 'string', - }, - 'filter_by_roi': { - '$ref': '#/definitions/filter_by_roi_enum', - 'description': 'Type of filter', - }, - 'frame_query': { - 'description': 'Frame filter, in Lucene query syntax', - 'type': 'string', - }, - 'label_rules': { - 'description': "List of FilterLabelRule ('AND' connection)\n\ndisabled - No filtering by ROIs. Select all frames, even if they don't have ROIs (all frames)\n\nno_rois - Select only frames without ROIs (empty frames)\n\nlabel_rules - Select frames according to label rules", - 'items': {'$ref': '#/definitions/filter_label_rule'}, - 'type': ['array', 'null'], - }, - 'sources_query': { - 'description': 'Sources filter, in Lucene query syntax. Filters sources in each frame.', - 'type': 'string', - }, - 'version': { - 'description': "Dataset version to apply rule to. Must belong to the dataset and be in the task's view. If set to '*' all version of the datasets in View are used.", - 'type': 'string', - }, - 'weight': { - 'description': 'Rule weight. Default is 1', - 'type': 'number', - }, - }, - 'required': ['filter_by_roi'], - 'type': 'object', - }, - 'filtering': { - 'properties': { - 'filtering_rules': { - 'description': "List of FilterRule ('OR' connection)", - 'items': {'$ref': '#/definitions/filter_rule'}, - 'type': ['array', 'null'], - }, - 'output_rois': { - 'description': "'all_in_frame' - all rois for a frame are returned\n\n'only_filtered' - only rois which led this frame to be selected\n\n'frame_per_roi' - single roi per frame. Frame can be returned multiple times with a different roi each time.\n\nNote: this should be used for Training tasks only\n\nNote: frame_per_roi implies that only filtered rois will be returned\n ", - 'oneOf': [ - {'$ref': '#/definitions/output_rois_enum'}, - {'type': 'null'}, - ], - }, - }, - 'type': 'object', - }, - 'input': { - 'properties': { - 'augmentation': { - 'description': 'Augmentation parameters. Only for training and testing tasks.', - 'oneOf': [ - {'$ref': '#/definitions/augmentation'}, - {'type': 'null'}, - ], - }, - 'dataviews': { - 'additionalProperties': {'type': 'string'}, - 'description': 'Key to DataView ID Mapping', - 'type': ['object', 'null'], - }, - 'frames_filter': { - 'description': 'Filtering params', - 'oneOf': [ - {'$ref': '#/definitions/filtering'}, - {'type': 'null'}, - ], - }, - 'iteration': { - 'description': 'Iteration parameters. Not applicable for register (import) tasks.', - 'oneOf': [ - {'$ref': '#/definitions/iteration'}, - {'type': 'null'}, - ], - }, - 'mapping': { - 'description': 'Mapping params (see common definitions section)', - 'oneOf': [ - {'$ref': '#/definitions/mapping'}, - {'type': 'null'}, - ], - }, - 'view': { - 'description': 'View params', - 'oneOf': [{'$ref': '#/definitions/view'}, {'type': 'null'}], - }, - }, - 'type': 'object', - }, - 'iteration': { - 'description': 'Sequential Iteration API configuration', - 'properties': { - 'infinite': { - 'description': 'Infinite iteration', - 'type': ['boolean', 'null'], - }, - 'jump': { - 'description': 'Jump entry', - 'oneOf': [{'$ref': '#/definitions/jump'}, {'type': 'null'}], - }, - 'limit': { - 'description': 'Maximum frames per task. If not passed, frames will end when no more matching frames are found, unless infinite is True.', - 'type': ['integer', 'null'], - }, - 'min_sequence': { - 'description': 'Length (in ms) of video clips to return. This is used in random order, and in sequential order only if jumping is provided and only for video frames', - 'type': ['integer', 'null'], - }, - 'order': { - 'description': "\n Input frames order. Values: 'sequential', 'random'\n In Sequential mode frames will be returned according to the order in which the frames were added to the dataset.", - 'type': ['string', 'null'], - }, - 'random_seed': { - 'description': 'Random seed used during iteration', - 'type': 'integer', - }, - }, - 'required': ['random_seed'], - 'type': 'object', - }, - 'jump': { - 'properties': { - 'time': { - 'description': 'Max time in milliseconds between frames', - 'type': ['integer', 'null'], - }, - }, - 'type': 'object', - }, - 'label_source': { - 'properties': { - 'dataset': { - 'description': "Source dataset id. '*' for all datasets in view", - 'type': ['string', 'null'], - }, - 'labels': { - 'description': "List of source labels (AND connection). '*' indicates any label. Labels must exist in at least one of the dataset versions in the task's view", - 'items': {'type': 'string'}, - 'type': ['array', 'null'], - }, - 'version': { - 'description': "Source dataset version id. Default is '*' (for all versions in dataset in the view) Version must belong to the selected dataset, and must be in the task's view[i]", - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'mapping': { - 'properties': { - 'rules': { - 'description': 'Rules list', - 'items': {'$ref': '#/definitions/mapping_rule'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'mapping_rule': { - 'properties': { - 'source': { - 'description': 'Source label info', - 'oneOf': [ - {'$ref': '#/definitions/label_source'}, - {'type': 'null'}, - ], - }, - 'target': { - 'description': 'Target label name', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'output_rois_enum': { - 'enum': ['all_in_frame', 'only_filtered', 'frame_per_roi'], - 'type': 'string', - }, 'script': { 'properties': { 'binary': { @@ -8184,49 +4940,13 @@ class ValidateRequest(Request): 'type': ['string', 'null'], }, 'working_dir': { - 'description': 'Path to the folder from which to run the script Default - root folder of repository[f]', - 'type': ['string', 'null'], - }, - }, - 'type': 'object', - }, - 'task_type_enum': { - 'enum': [ - 'dataset_import', - 'annotation', - 'annotation_manual', - 'training', - 'testing', - ], - 'type': 'string', - }, - 'view': { - 'properties': { - 'entries': { - 'description': 'List of view entries. All tasks must have at least one view.', - 'items': {'$ref': '#/definitions/view_entry'}, - 'type': ['array', 'null'], - }, - }, - 'type': 'object', - }, - 'view_entry': { - 'properties': { - 'dataset': { - 'description': 'Existing Dataset id', - 'type': ['string', 'null'], - }, - 'merge_with': { - 'description': 'Version ID to merge with', - 'type': ['string', 'null'], - }, - 'version': { - 'description': 'Version id of a version belonging to the dataset', + 'description': 'Path to the folder from which to run the script Default - root folder of repository', 'type': ['string', 'null'], }, }, 'type': 'object', }, + 'task_type_enum': {'enum': ['training', 'testing'], 'type': 'string'}, }, 'properties': { 'comment': {'description': 'Free text comment ', 'type': 'string'}, @@ -8234,10 +4954,6 @@ class ValidateRequest(Request): '$ref': '#/definitions/execution', 'description': 'Task execution params', }, - 'input': { - '$ref': '#/definitions/input', - 'description': 'Task input params. (input view must be provided).', - }, 'name': { 'description': 'Task name. Unique within the company.', 'type': 'string', @@ -8268,7 +4984,7 @@ class ValidateRequest(Request): 'type': 'object', } def __init__( - self, name, type, tags=None, comment=None, parent=None, project=None, input=None, output_dest=None, execution=None, script=None, **kwargs): + self, name, type, tags=None, comment=None, parent=None, project=None, output_dest=None, execution=None, script=None, **kwargs): super(ValidateRequest, self).__init__(**kwargs) self.name = name self.tags = tags @@ -8276,7 +4992,6 @@ class ValidateRequest(Request): self.comment = comment self.parent = parent self.project = project - self.input = input self.output_dest = output_dest self.execution = execution self.script = script @@ -8366,21 +5081,6 @@ class ValidateRequest(Request): 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): - if value is None: - self._property_input = None - return - if isinstance(value, dict): - value = Input.from_dict(value) - else: - self.assert_isinstance(value, "input", Input) - self._property_input = value - @schema_property('output_dest') def output_dest(self): return self._property_output_dest @@ -8453,7 +5153,5 @@ response_mapping = { FailedRequest: FailedResponse, CloseRequest: CloseResponse, PublishRequest: PublishResponse, - EnqueueRequest: EnqueueResponse, - DequeueRequest: DequeueResponse, SetRequirementsRequest: SetRequirementsResponse, } diff --git a/trains/backend_api/services/v2_2/__init__.py b/trains/backend_api/services/v2_2/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/trains/backend_api/services/v2_2/auth.py b/trains/backend_api/services/v2_2/auth.py new file mode 100644 index 00000000..c715e1e6 --- /dev/null +++ b/trains/backend_api/services/v2_2/auth.py @@ -0,0 +1,621 @@ +""" +auth service + +This service provides authentication management and authorization +validation for the entire system. +""" +import six +import types +from datetime import datetime +import enum + +from dateutil.parser import parse as parse_datetime + +from ....backend_api.session import Request, BatchRequest, Response, DataModel, NonStrictDataModel, CompoundRequest, schema_property, StringEnum + + +class Credentials(NonStrictDataModel): + """ + :param access_key: Credentials access key + :type access_key: str + :param secret_key: Credentials secret key + :type secret_key: str + """ + _schema = { + 'properties': { + 'access_key': { + 'description': 'Credentials access key', + 'type': ['string', 'null'], + }, + 'secret_key': { + 'description': 'Credentials secret key', + 'type': ['string', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, access_key=None, secret_key=None, **kwargs): + super(Credentials, self).__init__(**kwargs) + self.access_key = access_key + self.secret_key = secret_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 + + @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 + + +class CredentialKey(NonStrictDataModel): + """ + :param access_key: + :type access_key: str + """ + _schema = {'properties': {'access_key': {'description': '', 'type': ['string', 'null']}}, 'type': 'object'} + def __init__( + self, access_key=None, **kwargs): + super(CredentialKey, 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 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. + + """ + + _service = "auth" + _action = "create_credentials" + _version = "1.5" + _schema = { + 'additionalProperties': False, + 'definitions': {}, + 'properties': {}, + 'type': 'object', + } + + +class CreateCredentialsResponse(Response): + """ + Response of auth.create_credentials endpoint. + + :param credentials: Created credentials + :type credentials: Credentials + """ + _service = "auth" + _action = "create_credentials" + _version = "1.5" + + _schema = { + 'definitions': { + 'credentials': { + 'properties': { + 'access_key': { + 'description': 'Credentials access key', + '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 DeleteUserRequest(Request): + """ + Delete a new user manually. Only supported in on-premises deployments. This only removes the user's auth entry so that any references to the deleted user's ID will still have valid user information + + :param user: User ID + :type user: str + """ + + _service = "auth" + _action = "delete_user" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': {'user': {'description': 'User ID', 'type': 'string'}}, + 'required': ['user'], + 'type': 'object', + } + def __init__( + self, user, **kwargs): + super(DeleteUserRequest, self).__init__(**kwargs) + self.user = user + + @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 + + +class DeleteUserResponse(Response): + """ + Response of auth.delete_user endpoint. + + :param deleted: True if user was successfully deleted, False otherwise + :type deleted: bool + """ + _service = "auth" + _action = "delete_user" + _version = "1.5" + + _schema = { + 'definitions': {}, + 'properties': { + 'deleted': { + 'description': 'True if user was successfully deleted, False otherwise', + 'type': ['boolean', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, deleted=None, **kwargs): + super(DeleteUserResponse, 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 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 = "1.9" + _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 = "1.9" + + _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 = "1.5" + _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] + """ + _service = "auth" + _action = "get_credentials" + _version = "1.5" + + _schema = { + 'definitions': { + 'credential_key': { + 'properties': { + 'access_key': {'description': '', 'type': ['string', 'null']}, + }, + 'type': 'object', + }, + }, + 'properties': { + '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, **kwargs): + super(GetCredentialsResponse, 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 + + 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 + + + + +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. Token will be limited by the same permissions that + exist for the credentials used in this call. + + :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 = "1.5" + _schema = { + 'definitions': {}, + 'properties': { + 'expiration_sec': { + 'description': 'Requested token expiration time in seconds. \n 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 = "1.5" + + _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 = "1.5" + _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 = "1.5" + + _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, + RevokeCredentialsRequest: RevokeCredentialsResponse, + DeleteUserRequest: DeleteUserResponse, + EditUserRequest: EditUserResponse, +} diff --git a/trains/backend_api/services/v2_2/events.py b/trains/backend_api/services/v2_2/events.py new file mode 100644 index 00000000..a466281a --- /dev/null +++ b/trains/backend_api/services/v2_2/events.py @@ -0,0 +1,2846 @@ +""" +events service + +Provides an API for running tasks to report events collected by the system. +""" +import six +import types +from datetime import datetime +import enum + +from dateutil.parser import parse as parse_datetime + +from ....backend_api.session import Request, BatchRequest, Response, DataModel, NonStrictDataModel, CompoundRequest, schema_property, StringEnum + + +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 + """ + _schema = { + 'description': " An entire plot (not single datapoint) and it's layout.\n 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.\n Used for plotting ROC curves, confidence matrices, etc. when evaluating the net.\n ", + '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': '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, **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 + + @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 + + +class LogLevelEnum(StringEnum): + notset = "notset" + debug = "debug" + verbose = "verbose" + info = "info" + warn = "warn" + warning = "warning" + error = "error" + fatal = "fatal" + critical = "critical" + + +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 AddRequest(CompoundRequest): + """ + Adds a single event + + """ + + _service = "events" + _action = "add" + _version = "1.5" + _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.\n 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.\n Used for plotting ROC curves, confidence matrices, etc. when evaluating the net.\n ", + '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': '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 = "1.5" + + _schema = {'additionalProperties': True, 'definitions': {}, 'type': 'object'} + + +class AddBatchRequest(BatchRequest): + """ + Adds a batch of events in a single call. + + """ + + _service = "events" + _action = "add_batch" + _version = "1.5" + _batched_request_cls = AddRequest + + +class AddBatchResponse(Response): + """ + Response of events.add_batch endpoint. + + :param added: + :type added: int + :param errors: + :type errors: int + """ + _service = "events" + _action = "add_batch" + _version = "1.5" + + _schema = { + 'definitions': {}, + 'properties': { + 'added': {'type': ['integer', 'null']}, + 'errors': {'type': ['integer', 'null']}, + }, + 'type': 'object', + } + def __init__( + self, added=None, errors=None, **kwargs): + super(AddBatchResponse, self).__init__(**kwargs) + self.added = added + self.errors = errors + + @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 + + +class DebugImagesRequest(Request): + """ + Get all debug images of a 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 + """ + + _service = "events" + _action = "debug_images" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': { + 'iters': { + 'description': 'Max number of latest iterations for which to return debug images', + 'type': 'integer', + }, + '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, **kwargs): + super(DebugImagesRequest, self).__init__(**kwargs) + self.task = task + self.iters = iters + 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('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 + + +class DebugImagesResponse(Response): + """ + Response of events.debug_images endpoint. + + :param task: Task ID + :type task: str + :param images: Images list + :type images: 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 = "debug_images" + _version = "1.5" + + _schema = { + 'definitions': {}, + 'properties': { + 'images': { + 'description': 'Images 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'], + }, + 'task': {'description': 'Task ID', 'type': ['string', 'null']}, + 'total': { + 'description': 'Total number of results available for this query', + 'type': ['number', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, task=None, images=None, returned=None, total=None, scroll_id=None, **kwargs): + super(DebugImagesResponse, self).__init__(**kwargs) + self.task = task + self.images = images + self.returned = returned + self.total = 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('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 + + @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 DeleteForTaskRequest(Request): + """ + Delete all task event. *This cannot be undone!* + + :param task: Task ID + :type task: str + """ + + _service = "events" + _action = "delete_for_task" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': {'task': {'description': 'Task ID', 'type': 'string'}}, + 'required': ['task'], + 'type': 'object', + } + def __init__( + self, task, **kwargs): + super(DeleteForTaskRequest, 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 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 = "1.5" + + _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 = "1.5" + _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 = "1.5" + + _schema = {'definitions': {}, 'type': 'string'} + + +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 + """ + + _service = "events" + _action = "get_multi_task_plots" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': { + 'iters': { + 'description': 'Max number of latest iterations for which to return debug images', + 'type': 'integer', + }, + '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, **kwargs): + super(GetMultiTaskPlotsRequest, self).__init__(**kwargs) + self.tasks = tasks + self.iters = iters + 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)) + + 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 + + +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 = "1.5" + + _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 GetScalarMetricDataRequest(Request): + """ + get scalar metric data for task + + :param task: task ID + :type task: str + :param metric: type of metric + :type metric: str + """ + + _service = "events" + _action = "get_scalar_metric_data" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': { + 'metric': {'description': 'type of metric', 'type': ['string', 'null']}, + 'task': {'description': 'task ID', 'type': ['string', 'null']}, + }, + 'type': 'object', + } + def __init__( + self, task=None, metric=None, **kwargs): + super(GetScalarMetricDataRequest, self).__init__(**kwargs) + self.task = task + self.metric = 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 + + +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 = "1.5" + + _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 = "1.5" + _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 = "1.5" + + _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 + :type batch_size: int + """ + + _service = "events" + _action = "get_task_events" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': { + 'batch_size': { + 'description': 'Number of events to return each time', + 'type': 'integer', + }, + '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, **kwargs): + super(GetTaskEventsRequest, self).__init__(**kwargs) + self.task = task + self.order = order + self.scroll_id = scroll_id + self.batch_size = batch_size + + @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 + + +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 = "1.5" + + _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 = "1.5" + _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 = "1.5" + + _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 all 'log' events for this task + + :param task: Task ID + :type task: str + :param order: Timestamp order in which log events will be returned (defaults to + ascending) + :type order: str + :param from: Where will the log entries be taken from (default to the head of + the log) + :type from: str + :param scroll_id: + :type scroll_id: str + :param batch_size: + :type batch_size: int + """ + + _service = "events" + _action = "get_task_log" + _version = "1.7" + _schema = { + 'definitions': {}, + 'properties': { + 'batch_size': {'description': '', 'type': 'integer'}, + 'from': { + 'description': 'Where will the log entries be taken from (default to the head of the log)', + 'enum': ['head', 'tail'], + 'type': 'string', + }, + 'order': { + 'description': 'Timestamp order in which log events will be returned (defaults to ascending)', + 'enum': ['asc', 'desc'], + 'type': 'string', + }, + 'scroll_id': {'description': '', 'type': 'string'}, + 'task': {'description': 'Task ID', 'type': 'string'}, + }, + 'required': ['task'], + 'type': 'object', + } + def __init__( + self, task, order=None, from_=None, scroll_id=None, batch_size=None, **kwargs): + super(GetTaskLogRequest, self).__init__(**kwargs) + self.task = task + self.order = order + self.from_ = from_ + self.scroll_id = scroll_id + self.batch_size = batch_size + + @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('from') + def from_(self): + return self._property_from_ + + @from_.setter + def from_(self, value): + if value is None: + self._property_from_ = None + return + + self.assert_isinstance(value, "from_", six.string_types) + self._property_from_ = 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 + + +class GetTaskLogResponse(Response): + """ + Response of events.get_task_log endpoint. + + :param events: Log items 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_log" + _version = "1.7" + + _schema = { + 'definitions': {}, + 'properties': { + 'events': { + 'description': 'Log items 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(GetTaskLogResponse, 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 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 + """ + + _service = "events" + _action = "get_task_plots" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': { + 'iters': { + 'description': 'Max number of latest iterations for which to return debug images', + 'type': 'integer', + }, + '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, **kwargs): + super(GetTaskPlotsRequest, self).__init__(**kwargs) + self.task = task + self.iters = iters + 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('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 + + +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 = "1.5" + + _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 GetVectorMetricsAndVariantsRequest(Request): + """ + :param task: Task ID + :type task: str + """ + + _service = "events" + _action = "get_vector_metrics_and_variants" + _version = "1.5" + _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 = "1.5" + + _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 + :type tasks: Sequence[str] + """ + + _service = "events" + _action = "multi_task_scalar_metrics_iter_histogram" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': { + 'tasks': { + 'description': 'List of task Task IDs', + 'items': { + 'description': 'List of task Task IDs', + 'type': 'string', + }, + 'type': 'array', + }, + }, + 'required': ['tasks'], + 'type': 'object', + } + def __init__( + self, tasks, **kwargs): + super(MultiTaskScalarMetricsIterHistogramRequest, 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 MultiTaskScalarMetricsIterHistogramResponse(Response): + """ + Response of events.multi_task_scalar_metrics_iter_histogram endpoint. + + """ + _service = "events" + _action = "multi_task_scalar_metrics_iter_histogram" + _version = "1.5" + + _schema = {'additionalProperties': True, 'definitions': {}, 'type': 'object'} + + +class ScalarMetricsIterHistogramRequest(Request): + """ + Get histogram data of all the vector metrics and variants in the task + + :param task: Task ID + :type task: str + """ + + _service = "events" + _action = "scalar_metrics_iter_histogram" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': {'task': {'description': 'Task ID', 'type': 'string'}}, + 'required': ['task'], + 'type': 'object', + } + def __init__( + self, task, **kwargs): + super(ScalarMetricsIterHistogramRequest, 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 ScalarMetricsIterHistogramResponse(Response): + """ + Response of events.scalar_metrics_iter_histogram endpoint. + + :param images: + :type images: Sequence[dict] + """ + _service = "events" + _action = "scalar_metrics_iter_histogram" + _version = "1.5" + + _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 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 = "1.5" + _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 = "1.5" + + _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, + GetTaskLogRequest: GetTaskLogResponse, + GetTaskEventsRequest: GetTaskEventsResponse, + DownloadTaskLogRequest: DownloadTaskLogResponse, + GetTaskPlotsRequest: GetTaskPlotsResponse, + GetMultiTaskPlotsRequest: GetMultiTaskPlotsResponse, + GetVectorMetricsAndVariantsRequest: GetVectorMetricsAndVariantsResponse, + VectorMetricsIterHistogramRequest: VectorMetricsIterHistogramResponse, + ScalarMetricsIterHistogramRequest: ScalarMetricsIterHistogramResponse, + MultiTaskScalarMetricsIterHistogramRequest: MultiTaskScalarMetricsIterHistogramResponse, + GetTaskLatestScalarValuesRequest: GetTaskLatestScalarValuesResponse, + GetScalarMetricsAndVariantsRequest: GetScalarMetricsAndVariantsResponse, + GetScalarMetricDataRequest: GetScalarMetricDataResponse, +} diff --git a/trains/backend_api/services/v2_2/models.py b/trains/backend_api/services/v2_2/models.py new file mode 100644 index 00000000..fb1479f6 --- /dev/null +++ b/trains/backend_api/services/v2_2/models.py @@ -0,0 +1,2675 @@ +""" +models service + +This service provides a management interface for models (results of training tasks) stored in the system. +""" +import six +import types +from datetime import datetime +import enum + +from dateutil.parser import parse as parse_datetime + +from ....backend_api.session import Request, BatchRequest, Response, DataModel, NonStrictDataModel, CompoundRequest, 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 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 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: Tags + :type 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 + """ + _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'], + }, + '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'], + }, + 'tags': { + 'description': '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', + } + def __init__( + self, id=None, name=None, user=None, company=None, created=None, task=None, parent=None, project=None, comment=None, tags=None, framework=None, design=None, labels=None, uri=None, ready=None, ui_cache=None, **kwargs): + super(Model, self).__init__(**kwargs) + self.id = id + self.name = name + self.user = user + self.company = company + self.created = created + self.task = task + self.parent = parent + self.project = project + self.comment = comment + self.tags = tags + self.framework = framework + self.design = design + self.labels = labels + self.uri = uri + self.ready = ready + self.ui_cache = ui_cache + + @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('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('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 + + +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: Tags list + :type 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 = "1.5" + _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', + }, + 'tags': {'description': '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', 'labels'], + 'type': 'object', + } + def __init__( + self, uri, name, labels, comment=None, tags=None, framework=None, design=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.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('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 = "1.5" + + _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 = "1.5" + _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.\n ", + '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 + """ + _service = "models" + _action = "delete" + _version = "1.5" + + _schema = { + 'definitions': {}, + 'properties': { + 'deleted': { + 'description': 'Indicates whether the model was deleted', + 'type': ['boolean', '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 + + self.assert_isinstance(value, "deleted", (bool,)) + self._property_deleted = 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: Tags list + :type 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 + """ + + _service = "models" + _action = "edit" + _version = "1.5" + _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', + }, + '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', + }, + 'tags': {'description': 'Tags list', 'items': {'type': 'string'}, 'type': 'array'}, + 'task': {'description': 'Associated task ID', 'type': 'string'}, + 'uri': {'description': 'URI for the model', 'type': 'string'}, + }, + 'required': ['model'], + 'type': 'object', + } + def __init__( + self, model, uri=None, name=None, comment=None, tags=None, framework=None, design=None, labels=None, ready=None, project=None, parent=None, task=None, iteration=None, **kwargs): + super(EditRequest, self).__init__(**kwargs) + self.model = model + self.uri = uri + self.name = name + self.comment = comment + self.tags = 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 + + @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('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 + + +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 = "1.5" + + _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 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: Tags list used to filter results. Prepend '-' to tag name to + indicate exclusion + :type 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 + """ + + _service = "models" + _action = "get_all" + _version = "1.5" + _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'], + }, + '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'], + }, + 'search_text': { + 'description': 'Free text search query', + 'type': ['string', 'null'], + }, + 'tags': { + 'description': "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'], + }, + }, + 'type': 'object', + } + def __init__( + self, name=None, ready=None, 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, **kwargs): + super(GetAllRequest, self).__init__(**kwargs) + self.name = name + self.ready = ready + self.tags = 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_ + + @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('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('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 + + +class GetAllResponse(Response): + """ + Response of models.get_all endpoint. + + :param models: Models list + :type models: Sequence[Model] + """ + _service = "models" + _action = "get_all" + _version = "1.5" + + _schema = { + 'definitions': { + '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'], + }, + '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'], + }, + 'tags': { + 'description': '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'], + }, + }, + 'type': 'object', + } + def __init__( + self, models=None, **kwargs): + super(GetAllResponse, self).__init__(**kwargs) + self.models = models + + @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 + + +class GetByIdRequest(Request): + """ + Gets model information + + :param model: Model id + :type model: str + """ + + _service = "models" + _action = "get_by_id" + _version = "1.5" + _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 = "1.5" + + _schema = { + 'definitions': { + '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'], + }, + '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'], + }, + 'tags': { + 'description': '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 = "1.5" + _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 = "1.5" + + _schema = { + 'definitions': { + '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'], + }, + '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'], + }, + 'tags': { + 'description': '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 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 = "1.9" + _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 = "1.9" + + _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': { + 'committed_versions_results': { + 'description': 'Committed versions results', + 'items': { + 'additionalProperties': True, + 'type': 'object', + }, + 'type': 'array', + }, + '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 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: Tags list + :type 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 = "1.5" + _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', + }, + 'tags': {'description': '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, 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.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('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 = "1.5" + + _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 + :type uri: str + :param name: Model name Unique within the company. + :type name: str + :param comment: Model comment + :type comment: str + :param tags: Tags list + :type tags: Sequence[str] + :param override_model_id: Override model ID. If provided, this model is updated + in the task. + :type override_model_id: str + :param iteration: Iteration (used to update task statistics) + :type iteration: int + """ + + _service = "models" + _action = "update_for_task" + _version = "1.5" + _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.', + 'type': 'string', + }, + 'tags': {'description': 'Tags list', 'items': {'type': 'string'}, 'type': 'array'}, + 'task': {'description': 'Task id', 'type': 'string'}, + 'uri': {'description': 'URI for the model', 'type': 'string'}, + }, + 'required': ['task'], + 'type': 'object', + } + def __init__( + self, task, uri=None, name=None, comment=None, 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.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('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 = "1.5" + + _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, + UpdateForTaskRequest: UpdateForTaskResponse, + CreateRequest: CreateResponse, + EditRequest: EditResponse, + UpdateRequest: UpdateResponse, + SetReadyRequest: SetReadyResponse, + DeleteRequest: DeleteResponse, +} diff --git a/trains/backend_api/services/v2_2/projects.py b/trains/backend_api/services/v2_2/projects.py new file mode 100644 index 00000000..be2e4081 --- /dev/null +++ b/trains/backend_api/services/v2_2/projects.py @@ -0,0 +1,1845 @@ +""" +projects service + +Provides support for defining Projects containing Tasks, Models and Dataset Versions. +""" +from datetime import datetime + +import six +from dateutil.parser import parse as parse_datetime + +from ....backend_api.session import Request, 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 ProjectTagsEnum(StringEnum): + archived = "archived" + public = "public" + default = "default" + + +class Project(NonStrictDataModel): + """ + :param id: Project id + :type id: str + :param name: Project name + :type name: 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 tags: Tags + :type tags: Sequence[ProjectTagsEnum] + :param default_output_destination: The default output destination URL for new + tasks under this project + :type default_output_destination: str + :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 + """ + _schema = { + 'properties': { + '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']}, + 'tags': { + 'description': 'Tags', + 'items': {'$ref': '#/definitions/project_tags_enum'}, + 'type': ['array', 'null'], + }, + 'user': { + 'description': 'Associated user id', + 'type': ['string', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, id=None, name=None, description=None, user=None, company=None, created=None, tags=None, default_output_destination=None, last_update=None, **kwargs): + super(Project, self).__init__(**kwargs) + self.id = id + self.name = name + self.description = description + self.user = user + self.company = company + self.created = created + self.tags = tags + self.default_output_destination = default_output_destination + self.last_update = last_update + + @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('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('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)) + if any(isinstance(v, six.string_types) for v in value): + value = [ProjectTagsEnum(v) if isinstance(v, six.string_types) else v for v in value] + else: + self.assert_isinstance(value, "tags", ProjectTagsEnum, is_array=True) + self._property_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('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 + + +class StatsStatusCount(NonStrictDataModel): + """ + :param total_runtime: Total run time of all tasks in project (in seconds) + :type total_runtime: int + :param status_count: Status counts + :type status_count: dict + """ + _schema = { + 'properties': { + 'status_count': { + 'description': 'Status counts', + 'properties': { + 'closed': { + 'description': "Number of 'closed' 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'], + }, + }, + 'type': 'object', + } + def __init__( + self, total_runtime=None, status_count=None, **kwargs): + super(StatsStatusCount, self).__init__(**kwargs) + self.total_runtime = total_runtime + 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('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 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 tags: Tags + :type tags: Sequence[ProjectTagsEnum] + :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 + """ + _schema = { + 'properties': { + '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']}, + 'name': {'description': 'Project name', 'type': ['string', 'null']}, + 'stats': { + 'description': 'Additional project stats', + 'oneOf': [{'$ref': '#/definitions/stats'}, {'type': 'null'}], + }, + 'tags': { + 'description': 'Tags', + 'items': {'$ref': '#/definitions/project_tags_enum'}, + 'type': ['array', 'null'], + }, + 'user': { + 'description': 'Associated user id', + 'type': ['string', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, id=None, name=None, description=None, user=None, company=None, created=None, tags=None, default_output_destination=None, stats=None, **kwargs): + super(ProjectsGetAllResponseSingle, self).__init__(**kwargs) + self.id = id + self.name = name + self.description = description + self.user = user + self.company = company + self.created = created + self.tags = tags + self.default_output_destination = default_output_destination + 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('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('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)) + if any(isinstance(v, six.string_types) for v in value): + value = [ProjectTagsEnum(v) if isinstance(v, six.string_types) else v for v in value] + else: + self.assert_isinstance(value, "tags", ProjectTagsEnum, is_array=True) + self._property_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 + + +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\n 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\n 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 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: Tags + :type tags: Sequence[ProjectTagsEnum] + :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 = "1.5" + _schema = { + 'definitions': { + 'project_tags_enum': {'enum': ['archived', 'public', 'default'], 'type': 'string'}, + }, + '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', + }, + 'tags': { + 'description': 'Tags', + 'items': {'$ref': '#/definitions/project_tags_enum'}, + 'type': 'array', + }, + }, + 'required': ['name', 'description'], + 'type': 'object', + } + def __init__( + self, name, description, tags=None, default_output_destination=None, **kwargs): + super(CreateRequest, self).__init__(**kwargs) + self.name = name + self.description = description + self.tags = 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)) + if any(isinstance(v, six.string_types) for v in value): + value = [ProjectTagsEnum(v) if isinstance(v, six.string_types) else v for v in value] + else: + self.assert_isinstance(value, "tags", ProjectTagsEnum, is_array=True) + self._property_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 = "1.5" + + _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 + """ + + _service = "projects" + _action = "delete" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': { + 'force': { + 'default': False, + 'description': 'If not true, fails if project has tasks.\n 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, **kwargs): + super(DeleteRequest, self).__init__(**kwargs) + self.project = project + self.force = force + + @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 + + +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 + """ + _service = "projects" + _action = "delete" + _version = "1.5" + + _schema = { + 'definitions': {}, + 'properties': { + 'deleted': { + 'description': 'Number of projects deleted (0 or 1)', + 'type': ['integer', 'null'], + }, + 'disassociated_tasks': { + 'description': 'Number of tasks disassociated from the deleted project', + 'type': ['integer', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, deleted=None, disassociated_tasks=None, **kwargs): + super(DeleteResponse, self).__init__(**kwargs) + self.deleted = deleted + self.disassociated_tasks = disassociated_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 + + +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 description: Get only projects whose description matches this pattern + (python regular expression syntax) + :type description: str + :param tags: Tags list used to filter results. Prepend '-' to tag name to + indicate exclusion + :type 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 + dataviews + :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 + """ + + _service = "projects" + _action = "get_all" + _version = "1.5" + _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'}, + ], + }, + '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'], + }, + 'search_text': { + 'description': 'Free text search query', + 'type': ['string', 'null'], + }, + 'tags': { + 'description': "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, description=None, tags=None, order_by=None, page=None, page_size=None, search_text=None, only_fields=None, _all_=None, _any_=None, **kwargs): + super(GetAllRequest, self).__init__(**kwargs) + self.id = id + self.name = name + self.description = description + self.tags = 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_ + + @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('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('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 + + +class GetAllResponse(Response): + """ + Response of projects.get_all endpoint. + + :param projects: Projects list + :type projects: Sequence[ProjectsGetAllResponseSingle] + """ + _service = "projects" + _action = "get_all" + _version = "1.5" + + _schema = { + 'definitions': { + 'project_tags_enum': {'enum': ['archived', 'public', 'default'], 'type': 'string'}, + 'projects_get_all_response_single': { + 'properties': { + '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']}, + 'name': { + 'description': 'Project name', + 'type': ['string', 'null'], + }, + 'stats': { + 'description': 'Additional project stats', + 'oneOf': [ + {'$ref': '#/definitions/stats'}, + {'type': 'null'}, + ], + }, + 'tags': { + 'description': 'Tags', + 'items': {'$ref': '#/definitions/project_tags_enum'}, + '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': { + 'status_count': { + 'description': 'Status counts', + 'properties': { + 'closed': { + 'description': "Number of 'closed' 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'], + }, + }, + 'type': 'object', + }, + }, + 'properties': { + 'projects': { + 'description': 'Projects list', + 'items': { + '$ref': '#/definitions/projects_get_all_response_single', + }, + 'type': ['array', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, projects=None, **kwargs): + super(GetAllResponse, 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)) + 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 + + +class GetByIdRequest(Request): + """ + :param project: Project id + :type project: str + """ + + _service = "projects" + _action = "get_by_id" + _version = "1.5" + _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 = "1.5" + + _schema = { + 'definitions': { + 'project': { + 'properties': { + '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'], + }, + 'tags': { + 'description': 'Tags', + 'items': {'$ref': '#/definitions/project_tags_enum'}, + 'type': ['array', 'null'], + }, + 'user': { + 'description': 'Associated user id', + 'type': ['string', 'null'], + }, + }, + 'type': 'object', + }, + 'project_tags_enum': {'enum': ['archived', 'public', 'default'], 'type': 'string'}, + }, + '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 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 + """ + + _service = "projects" + _action = "get_unique_metric_variants" + _version = "1.6" + _schema = { + 'definitions': {}, + 'properties': { + 'project': {'description': 'Project ID', 'type': ['string', 'null']}, + }, + 'type': 'object', + } + def __init__( + self, project=None, **kwargs): + super(GetUniqueMetricVariantsRequest, 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 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 = "1.6" + + _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\n 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\n 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 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: Tags list + :type 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 = "1.5" + _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'}, + 'tags': {'description': 'Tags list', 'items': {'type': 'string'}, 'type': 'array'}, + }, + 'required': ['project'], + 'type': 'object', + } + def __init__( + self, project, name=None, description=None, 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.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('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 = "1.5" + + _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 + + +response_mapping = { + CreateRequest: CreateResponse, + GetByIdRequest: GetByIdResponse, + GetAllRequest: GetAllResponse, + UpdateRequest: UpdateResponse, + DeleteRequest: DeleteResponse, + GetUniqueMetricVariantsRequest: GetUniqueMetricVariantsResponse, +} diff --git a/trains/backend_api/services/v2_2/tasks.py b/trains/backend_api/services/v2_2/tasks.py new file mode 100644 index 00000000..d2d5df77 --- /dev/null +++ b/trains/backend_api/services/v2_2/tasks.py @@ -0,0 +1,5410 @@ +""" +tasks service + +Provides a management API for tasks in the system. +""" +import enum +from datetime import datetime + +import six +from dateutil.parser import parse as parse_datetime + +from ....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 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 Execution(NonStrictDataModel): + """ + :param parameters: Json object containing the Task parameters + :type parameters: dict + :param model: Execution input model ID Not applicable for Register (Import) + tasks + :type model: str + :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 + """ + _schema = { + 'properties': { + 'framework': { + 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', + 'type': ['string', 'null'], + }, + 'model': { + 'description': 'Execution input model ID Not applicable for Register (Import) 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'], + }, + }, + 'type': 'object', + } + def __init__( + self, parameters=None, model=None, model_desc=None, model_labels=None, framework=None, **kwargs): + super(Execution, self).__init__(**kwargs) + self.parameters = parameters + self.model = model + self.model_desc = model_desc + self.model_labels = model_labels + self.framework = framework + + @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') + 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('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 + + +class TaskStatusEnum(StringEnum): + created = "created" + queued = "queued" + in_progress = "in_progress" + stopped = "stopped" + completed = "completed" + published = "published" + publishing = "publishing" + closed = "closed" + failed = "failed" + unknown = "unknown" + + +class TaskTypeEnum(StringEnum): + training = "training" + testing = "testing" + + +class LastMetricsEvent(NonStrictDataModel): + """ + :param metric: Metric name + :type metric: str + :param variant: Variant name + :type variant: str + :param type: Event type + :type type: str + :param timestamp: Event report time (UTC) + :type timestamp: datetime.datetime + :param iter: Iteration number + :type iter: int + :param value: Value + :type value: float + """ + _schema = { + 'properties': { + 'iter': { + 'description': 'Iteration number', + 'type': ['integer', 'null'], + }, + 'metric': {'description': 'Metric name', 'type': ['string', 'null']}, + 'timestamp': { + 'description': 'Event report time (UTC)', + 'format': 'date-time', + 'type': ['string', 'null'], + }, + 'type': {'description': 'Event type', 'type': ['string', 'null']}, + 'value': {'description': 'Value', 'type': ['number', 'null']}, + 'variant': {'description': 'Variant name', 'type': ['string', 'null']}, + }, + 'type': 'object', + } + def __init__( + self, metric=None, variant=None, type=None, timestamp=None, iter=None, value=None, **kwargs): + super(LastMetricsEvent, self).__init__(**kwargs) + self.metric = metric + self.variant = variant + self.type = type + self.timestamp = timestamp + self.iter = iter + self.value = 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('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('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.string_types + (datetime,)) + if not isinstance(value, datetime): + value = parse_datetime(value) + self._property_timestamp = 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('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 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 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 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 script: Script info + :type script: Script + :param tags: Tags list + :type 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_update: Last time this task was created, updated, changed or events + for this task were reported + :type last_update: 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 + """ + _schema = { + 'properties': { + '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'], + }, + 'created': { + 'description': 'Task creation time (UTC) ', + 'format': 'date-time', + 'type': ['string', 'null'], + }, + 'execution': { + 'description': 'Task execution params', + 'oneOf': [{'$ref': '#/definitions/execution'}, {'type': 'null'}], + }, + 'id': {'description': 'Task id', '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, updated, changed or events for this task were reported', + 'format': 'date-time', + 'type': ['string', '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'], + }, + 'tags': { + 'description': '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, parent=None, project=None, output=None, execution=None, script=None, tags=None, status_changed=None, status_message=None, status_reason=None, published=None, last_update=None, last_iteration=None, last_metrics=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.parent = parent + self.project = project + self.output = output + self.execution = execution + self.script = script + self.tags = tags + self.status_changed = status_changed + self.status_message = status_message + self.status_reason = status_reason + self.published = published + self.last_update = last_update + self.last_iteration = last_iteration + self.last_metrics = last_metrics + + @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('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('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('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_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_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 + + +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 = "1.5" + _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 = "1.5" + + _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 + created/in_progress/published + :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 = "completed" + _version = "2.2" + _schema = { + 'definitions': {}, + 'properties': { + 'force': { + 'default': False, + 'description': 'If not true, call fails if the task status is not created/in_progress/published', + '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(CompletedRequest, 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 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 + """ + _service = "tasks" + _action = "completed" + _version = "2.2" + + _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(CompletedResponse, 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 CreateRequest(Request): + """ + Create a new task + + :param name: Task name. Unique within the company. + :type name: str + :param tags: Tags list + :type 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 input: Task input params. (input view must be provided). + :type input: Input + :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 + """ + + _service = "tasks" + _action = "create" + _version = "1.9" + _schema = { + 'definitions': { + 'execution': { + 'properties': { + 'framework': { + 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', + 'type': ['string', 'null'], + }, + 'model': { + 'description': 'Execution input model ID Not applicable for Register (Import) 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'], + }, + }, + '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', + }, + 'task_type_enum': {'enum': ['training', 'testing'], 'type': 'string'}, + }, + 'properties': { + 'comment': {'description': 'Free text comment ', 'type': 'string'}, + 'execution': { + '$ref': '#/definitions/execution', + 'description': 'Task execution params', + }, + 'input': { + # '$ref': '#/definitions/input', + 'description': 'Task input params. (input view must be provided).', + }, + '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', + }, + 'tags': {'description': '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, comment=None, parent=None, project=None, input=None, output_dest=None, execution=None, script=None, **kwargs): + super(CreateRequest, self).__init__(**kwargs) + self.name = name + self.tags = 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 + + @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('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 + + +class CreateResponse(Response): + """ + Response of tasks.create endpoint. + + :param id: ID of the task + :type id: str + """ + _service = "tasks" + _action = "create" + _version = "1.9" + + _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 + """ + + _service = "tasks" + _action = "delete" + _version = "1.5" + _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'], + }, + '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, **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 + + @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 + + +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 updated_versions: Number of dataset versions whose task property was + updated + :type updated_versions: int + :param frames: Response from frames.rollback + :type frames: dict + :param events: Response from events.delete_for_task + :type events: dict + """ + _service = "tasks" + _action = "delete" + _version = "1.5" + + _schema = { + 'definitions': {}, + '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'], + }, + 'frames': { + 'additionalProperties': True, + 'description': 'Response from frames.rollback', + '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'], + }, + 'updated_versions': { + 'description': 'Number of dataset versions whose task property was updated', + 'type': ['integer', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, deleted=None, updated_children=None, updated_models=None, updated_versions=None, frames=None, events=None, **kwargs): + super(DeleteResponse, self).__init__(**kwargs) + self.deleted = deleted + self.updated_children = updated_children + self.updated_models = updated_models + self.updated_versions = updated_versions + self.frames = frames + self.events = events + + @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('updated_versions') + def updated_versions(self): + return self._property_updated_versions + + @updated_versions.setter + def updated_versions(self, value): + if value is None: + self._property_updated_versions = None + return + if isinstance(value, float) and value.is_integer(): + value = int(value) + + self.assert_isinstance(value, "updated_versions", six.integer_types) + self._property_updated_versions = value + + @schema_property('frames') + def frames(self): + return self._property_frames + + @frames.setter + def frames(self, value): + if value is None: + self._property_frames = None + return + + self.assert_isinstance(value, "frames", (dict,)) + self._property_frames = 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 + + +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: Tags list + :type 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 + """ + + _service = "tasks" + _action = "edit" + _version = "1.9" + _schema = { + 'definitions': { + 'execution': { + 'properties': { + 'framework': { + 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', + 'type': ['string', 'null'], + }, + 'model': { + 'description': 'Execution input model ID Not applicable for Register (Import) 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'], + }, + }, + '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', + }, + 'task_type_enum': {'enum': ['training', 'testing'], 'type': 'string'}, + }, + 'properties': { + 'comment': {'description': 'Free text comment ', 'type': 'string'}, + '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', + }, + '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', + }, + 'tags': {'description': '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, type=None, comment=None, parent=None, project=None, output_dest=None, execution=None, script=None, **kwargs): + super(EditRequest, self).__init__(**kwargs) + self.task = task + self.force = force + self.name = name + self.tags = tags + self.type = type + self.comment = comment + self.parent = parent + self.project = project + self.output_dest = output_dest + self.execution = execution + self.script = script + + @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('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('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 + + +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 = "1.9" + + _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 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 = "1.5" + _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 = "1.5" + + _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 + :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 tags. Use '-' prefix to exclude tags + :type 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 + """ + + _service = "tasks" + _action = "get_all" + _version = "1.9" + _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', + 'in_progress', + 'stopped', + 'published', + 'publishing', + 'closed', + 'failed', + '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'], + }, + 'search_text': { + 'description': 'Free text search query', + 'type': ['string', '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'], + }, + 'tags': { + 'description': "List of task tags. Use '-' prefix to exclude tags", + 'items': {'type': 'string'}, + 'type': ['array', 'null'], + }, + 'type': { + 'description': "List of task types. One or more of: 'import', 'annotation', 'training' or 'testing' (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, status=None, only_fields=None, parent=None, status_changed=None, search_text=None, _all_=None, _any_=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.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_ + + @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('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 + + +class GetAllResponse(Response): + """ + Response of tasks.get_all endpoint. + + :param tasks: List of tasks + :type tasks: Sequence[Task] + """ + _service = "tasks" + _action = "get_all" + _version = "1.9" + + _schema = { + 'definitions': { + 'execution': { + 'properties': { + 'framework': { + 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', + 'type': ['string', 'null'], + }, + 'model': { + 'description': 'Execution input model ID Not applicable for Register (Import) 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'], + }, + }, + 'type': 'object', + }, + 'last_metrics_event': { + 'properties': { + 'iter': { + 'description': 'Iteration number', + 'type': ['integer', 'null'], + }, + 'metric': { + 'description': 'Metric name', + 'type': ['string', 'null'], + }, + 'timestamp': { + 'description': 'Event report time (UTC)', + 'format': 'date-time', + 'type': ['string', 'null'], + }, + 'type': { + 'description': 'Event type', + 'type': ['string', 'null'], + }, + 'value': {'description': 'Value', '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', + }, + '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', + }, + 'task': { + 'properties': { + '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'], + }, + 'created': { + 'description': 'Task creation time (UTC) ', + 'format': 'date-time', + 'type': ['string', 'null'], + }, + 'execution': { + 'description': 'Task execution params', + 'oneOf': [ + {'$ref': '#/definitions/execution'}, + {'type': 'null'}, + ], + }, + 'id': {'description': 'Task id', '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, updated, changed or events for this task were reported', + 'format': 'date-time', + 'type': ['string', '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'], + }, + 'tags': { + 'description': '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_status_enum': { + 'enum': [ + 'created', + 'in_progress', + 'stopped', + 'published', + 'publishing', + 'closed', + 'failed', + 'unknown', + ], + 'type': 'string', + }, + 'task_type_enum': {'enum': ['training', 'testing'], 'type': 'string'}, + }, + 'properties': { + 'tasks': { + 'description': 'List of tasks', + 'items': {'$ref': '#/definitions/task'}, + 'type': ['array', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, tasks=None, **kwargs): + super(GetAllResponse, 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)) + 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 + + +class GetByIdRequest(Request): + """ + Gets task information + + :param task: Task ID + :type task: str + """ + + _service = "tasks" + _action = "get_by_id" + _version = "1.9" + _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 = "1.9" + + _schema = { + 'definitions': { + 'execution': { + 'properties': { + 'framework': { + 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', + 'type': ['string', 'null'], + }, + 'model': { + 'description': 'Execution input model ID Not applicable for Register (Import) 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'], + }, + }, + 'type': 'object', + }, + 'last_metrics_event': { + 'properties': { + 'iter': { + 'description': 'Iteration number', + 'type': ['integer', 'null'], + }, + 'metric': { + 'description': 'Metric name', + 'type': ['string', 'null'], + }, + 'timestamp': { + 'description': 'Event report time (UTC)', + 'format': 'date-time', + 'type': ['string', 'null'], + }, + 'type': { + 'description': 'Event type', + 'type': ['string', 'null'], + }, + 'value': {'description': 'Value', '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', + }, + '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', + }, + 'task': { + 'properties': { + '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'], + }, + 'created': { + 'description': 'Task creation time (UTC) ', + 'format': 'date-time', + 'type': ['string', 'null'], + }, + 'execution': { + 'description': 'Task execution params', + 'oneOf': [ + {'$ref': '#/definitions/execution'}, + {'type': 'null'}, + ], + }, + 'id': {'description': 'Task id', '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, updated, changed or events for this task were reported', + 'format': 'date-time', + 'type': ['string', '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'], + }, + 'tags': { + 'description': '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_status_enum': { + 'enum': [ + 'created', + 'in_progress', + 'stopped', + 'published', + 'publishing', + 'closed', + 'failed', + 'unknown', + ], + 'type': 'string', + }, + 'task_type_enum': {'enum': ['training', 'testing'], '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 PingRequest(Request): + """ + Refresh the task's last update time + + :param task: Task ID + :type task: str + """ + + _service = "tasks" + _action = "ping" + _version = "2.1" + _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.1" + + _schema = {'additionalProperties': False, 'definitions': {}, 'type': 'object'} + + +class PublishRequest(Request): + """ + Mark a task status as published. + + For Annotation tasks - if any changes were committed by this task, a new version in the dataset together with an output view are created. + + For Training tasks - 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 = "1.5" + _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 committed_versions_results: Committed versions results + :type committed_versions_results: Sequence[dict] + :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 = "1.5" + + _schema = { + 'definitions': {}, + 'properties': { + 'committed_versions_results': { + 'description': 'Committed versions results', + 'items': {'additionalProperties': True, 'type': 'object'}, + 'type': ['array', '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, committed_versions_results=None, updated=None, fields=None, **kwargs): + super(PublishResponse, self).__init__(**kwargs) + self.committed_versions_results = committed_versions_results + self.updated = updated + self.fields = fields + + @schema_property('committed_versions_results') + def committed_versions_results(self): + return self._property_committed_versions_results + + @committed_versions_results.setter + def committed_versions_results(self, value): + if value is None: + self._property_committed_versions_results = None + return + + self.assert_isinstance(value, "committed_versions_results", (list, tuple)) + + self.assert_isinstance(value, "committed_versions_results", (dict,), is_array=True) + self._property_committed_versions_results = 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 + + +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 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 = "reset" + _version = "1.5" + _schema = { + 'definitions': {}, + 'properties': { + 'force': { + 'default': False, + 'description': "If not true, call fails if the task status is 'completed'", + '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(ResetRequest, 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 ResetResponse(Response): + """ + Response of tasks.reset endpoint. + + :param deleted_indices: List of deleted ES indices that were removed as part of + the reset process + :type deleted_indices: Sequence[str] + :param frames: Response from frames.rollback + :type frames: 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 updated: Number of tasks updated (0 or 1) + :type updated: int + :param fields: Updated fields names and values + :type fields: dict + """ + _service = "tasks" + _action = "reset" + _version = "1.5" + + _schema = { + 'definitions': {}, + 'properties': { + 'deleted_indices': { + 'description': 'List of deleted ES indices that were removed as part of the reset process', + 'items': {'type': 'string'}, + 'type': ['array', 'null'], + }, + 'deleted_models': { + 'description': 'Number of output models deleted by the reset', + 'type': ['integer', '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'], + }, + 'frames': { + 'additionalProperties': True, + 'description': 'Response from frames.rollback', + 'type': ['object', 'null'], + }, + 'updated': { + 'description': 'Number of tasks updated (0 or 1)', + 'enum': [0, 1], + 'type': ['integer', 'null'], + }, + }, + 'type': 'object', + } + def __init__( + self, deleted_indices=None, frames=None, events=None, deleted_models=None, updated=None, fields=None, **kwargs): + super(ResetResponse, self).__init__(**kwargs) + self.deleted_indices = deleted_indices + self.frames = frames + self.events = events + self.deleted_models = deleted_models + self.updated = updated + self.fields = fields + + @schema_property('deleted_indices') + def deleted_indices(self): + return self._property_deleted_indices + + @deleted_indices.setter + def deleted_indices(self, value): + if value is None: + self._property_deleted_indices = None + return + + self.assert_isinstance(value, "deleted_indices", (list, tuple)) + + self.assert_isinstance(value, "deleted_indices", six.string_types, is_array=True) + self._property_deleted_indices = value + + @schema_property('frames') + def frames(self): + return self._property_frames + + @frames.setter + def frames(self, value): + if value is None: + self._property_frames = None + return + + self.assert_isinstance(value, "frames", (dict,)) + self._property_frames = 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('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 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 = "1.6" + _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 = "1.6" + + _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 = "1.5" + _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 started: Number of tasks started (0 or 1) + :type started: int + :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 = "started" + _version = "1.5" + + _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, started=None, updated=None, fields=None, **kwargs): + super(StartedResponse, self).__init__(**kwargs) + self.started = started + self.updated = updated + self.fields = fields + + @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 + + @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 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 = "1.5" + _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 = "1.5" + + _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 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 = "1.5" + _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 = "1.5" + + _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 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: Tags list + :type 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 = "1.5" + _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', + }, + 'tags': {'description': '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, 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.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('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 = "1.5" + + _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 = "1.5" + _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 = "1.5" + + _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: Tags list + :type 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 + """ + + _service = "tasks" + _action = "validate" + _version = "1.9" + _schema = { + 'definitions': { + 'execution': { + 'properties': { + 'framework': { + 'description': 'Framework related to the task. Case insensitive. Mandatory for Training tasks. ', + 'type': ['string', 'null'], + }, + 'model': { + 'description': 'Execution input model ID Not applicable for Register (Import) 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'], + }, + }, + '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', + }, + 'task_type_enum': {'enum': ['training', 'testing'], 'type': 'string'}, + }, + 'properties': { + 'comment': {'description': 'Free text comment ', 'type': 'string'}, + 'execution': { + '$ref': '#/definitions/execution', + 'description': 'Task execution params', + }, + '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', + }, + 'tags': {'description': '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, comment=None, parent=None, project=None, output_dest=None, execution=None, script=None, **kwargs): + super(ValidateRequest, self).__init__(**kwargs) + self.name = name + self.tags = tags + self.type = type + self.comment = comment + self.parent = parent + self.project = project + self.output_dest = output_dest + self.execution = execution + self.script = script + + @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('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('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 + + +class ValidateResponse(Response): + """ + Response of tasks.validate endpoint. + + """ + _service = "tasks" + _action = "validate" + _version = "1.9" + + _schema = {'additionalProperties': False, 'definitions': {}, 'type': 'object'} + + +response_mapping = { + GetByIdRequest: GetByIdResponse, + GetAllRequest: GetAllResponse, + CreateRequest: CreateResponse, + ValidateRequest: ValidateResponse, + UpdateRequest: UpdateResponse, + UpdateBatchRequest: UpdateBatchResponse, + EditRequest: EditResponse, + ResetRequest: ResetResponse, + DeleteRequest: DeleteResponse, + StartedRequest: StartedResponse, + StopRequest: StopResponse, + StoppedRequest: StoppedResponse, + FailedRequest: FailedResponse, + CloseRequest: CloseResponse, + PublishRequest: PublishResponse, + SetRequirementsRequest: SetRequirementsResponse, + CompletedRequest: CompletedResponse, + PingRequest: PingResponse, +}