From 77c624c1917601f1fd79f85846a020eb76c5cfac Mon Sep 17 00:00:00 2001 From: "Jeremy A. Prescott" Date: Fri, 1 Nov 2024 16:51:03 +0100 Subject: [PATCH] update specs for autoTasks (#1715) update specs for autoTasks --- .../swagger_client/__init__.py | 9 + .../swagger_client/api/teams_api.py | 151 +++++++++++++++ .../swagger_client/models/__init__.py | 9 + .../swagger_client/models/auto_task.py | 177 ++++++++++++++++++ .../swagger_client/models/auto_task_base.py | 104 ++++++++++ .../swagger_client/models/auto_task_crop.py | 86 +++++++++ .../models/auto_task_crop_all_of.py | 83 ++++++++ .../swagger_client/models/auto_task_tiling.py | 90 +++++++++ .../models/auto_task_tiling_all_of.py | 87 +++++++++ .../swagger_client/models/consent.py | 92 +++++++++ .../models/docker_worker_config_v4_docker.py | 8 +- .../docker_worker_config_v4_docker_crops.py | 90 +++++++++ .../models/questionnaire_data.py | 18 +- .../models/selection_config_v4.py | 14 +- .../models/selection_config_v4_all_of.py | 14 +- .../swagger_client/models/usage.py | 47 +++++ 16 files changed, 1070 insertions(+), 9 deletions(-) create mode 100644 lightly/openapi_generated/swagger_client/models/auto_task.py create mode 100644 lightly/openapi_generated/swagger_client/models/auto_task_base.py create mode 100644 lightly/openapi_generated/swagger_client/models/auto_task_crop.py create mode 100644 lightly/openapi_generated/swagger_client/models/auto_task_crop_all_of.py create mode 100644 lightly/openapi_generated/swagger_client/models/auto_task_tiling.py create mode 100644 lightly/openapi_generated/swagger_client/models/auto_task_tiling_all_of.py create mode 100644 lightly/openapi_generated/swagger_client/models/consent.py create mode 100644 lightly/openapi_generated/swagger_client/models/docker_worker_config_v4_docker_crops.py create mode 100644 lightly/openapi_generated/swagger_client/models/usage.py diff --git a/lightly/openapi_generated/swagger_client/__init__.py b/lightly/openapi_generated/swagger_client/__init__.py index b7e6c3ed8..65e0b8994 100644 --- a/lightly/openapi_generated/swagger_client/__init__.py +++ b/lightly/openapi_generated/swagger_client/__init__.py @@ -56,6 +56,12 @@ from lightly.openapi_generated.swagger_client.models.api_error_code import ApiErrorCode from lightly.openapi_generated.swagger_client.models.api_error_response import ApiErrorResponse from lightly.openapi_generated.swagger_client.models.async_task_data import AsyncTaskData +from lightly.openapi_generated.swagger_client.models.auto_task import AutoTask +from lightly.openapi_generated.swagger_client.models.auto_task_base import AutoTaskBase +from lightly.openapi_generated.swagger_client.models.auto_task_crop import AutoTaskCrop +from lightly.openapi_generated.swagger_client.models.auto_task_crop_all_of import AutoTaskCropAllOf +from lightly.openapi_generated.swagger_client.models.auto_task_tiling import AutoTaskTiling +from lightly.openapi_generated.swagger_client.models.auto_task_tiling_all_of import AutoTaskTilingAllOf from lightly.openapi_generated.swagger_client.models.categorical_distribution import CategoricalDistribution from lightly.openapi_generated.swagger_client.models.categorical_distribution_metrics import CategoricalDistributionMetrics from lightly.openapi_generated.swagger_client.models.categorical_distribution_per_set import CategoricalDistributionPerSet @@ -63,6 +69,7 @@ from lightly.openapi_generated.swagger_client.models.configuration_entry import ConfigurationEntry from lightly.openapi_generated.swagger_client.models.configuration_set_request import ConfigurationSetRequest from lightly.openapi_generated.swagger_client.models.configuration_value_data_type import ConfigurationValueDataType +from lightly.openapi_generated.swagger_client.models.consent import Consent from lightly.openapi_generated.swagger_client.models.create_cf_bucket_activity_request import CreateCFBucketActivityRequest from lightly.openapi_generated.swagger_client.models.create_docker_worker_registry_entry_request import CreateDockerWorkerRegistryEntryRequest from lightly.openapi_generated.swagger_client.models.create_entity_response import CreateEntityResponse @@ -179,6 +186,7 @@ from lightly.openapi_generated.swagger_client.models.docker_worker_config_v4_data import DockerWorkerConfigV4Data from lightly.openapi_generated.swagger_client.models.docker_worker_config_v4_data_all_of import DockerWorkerConfigV4DataAllOf from lightly.openapi_generated.swagger_client.models.docker_worker_config_v4_docker import DockerWorkerConfigV4Docker +from lightly.openapi_generated.swagger_client.models.docker_worker_config_v4_docker_crops import DockerWorkerConfigV4DockerCrops from lightly.openapi_generated.swagger_client.models.docker_worker_config_vx_data import DockerWorkerConfigVXData from lightly.openapi_generated.swagger_client.models.docker_worker_config_vx_data_base import DockerWorkerConfigVXDataBase from lightly.openapi_generated.swagger_client.models.docker_worker_registry_entry_data import DockerWorkerRegistryEntryData @@ -321,6 +329,7 @@ from lightly.openapi_generated.swagger_client.models.trigger2d_embedding_job_request import Trigger2dEmbeddingJobRequest from lightly.openapi_generated.swagger_client.models.update_docker_worker_registry_entry_request import UpdateDockerWorkerRegistryEntryRequest from lightly.openapi_generated.swagger_client.models.update_team_membership_request import UpdateTeamMembershipRequest +from lightly.openapi_generated.swagger_client.models.usage import Usage from lightly.openapi_generated.swagger_client.models.user_type import UserType from lightly.openapi_generated.swagger_client.models.video_frame_data import VideoFrameData from lightly.openapi_generated.swagger_client.models.worker_information import WorkerInformation diff --git a/lightly/openapi_generated/swagger_client/api/teams_api.py b/lightly/openapi_generated/swagger_client/api/teams_api.py index 6302460e2..d68975058 100644 --- a/lightly/openapi_generated/swagger_client/api/teams_api.py +++ b/lightly/openapi_generated/swagger_client/api/teams_api.py @@ -791,6 +791,157 @@ def get_team_members_by_id_with_http_info(self, team_id : Annotated[constr(stric collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def service_account_reset_token(self, team_id : Annotated[constr(strict=True), Field(..., description="id of the team")], service_account_id : Annotated[StrictStr, Field(..., description="id of the serviceAccount")], **kwargs) -> str: # noqa: E501 + """service_account_reset_token # noqa: E501 + + Reset token of service account and generate a new one. This is not ideal because the user does not have a transition time between the old and new token (e.g for this pipelines). Also, the token should be a JWT or similar. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.service_account_reset_token(team_id, service_account_id, async_req=True) + >>> result = thread.get() + + :param team_id: id of the team (required) + :type team_id: str + :param service_account_id: id of the serviceAccount (required) + :type service_account_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: str + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the service_account_reset_token_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + return self.service_account_reset_token_with_http_info(team_id, service_account_id, **kwargs) # noqa: E501 + + @validate_arguments + def service_account_reset_token_with_http_info(self, team_id : Annotated[constr(strict=True), Field(..., description="id of the team")], service_account_id : Annotated[StrictStr, Field(..., description="id of the serviceAccount")], **kwargs) -> ApiResponse: # noqa: E501 + """service_account_reset_token # noqa: E501 + + Reset token of service account and generate a new one. This is not ideal because the user does not have a transition time between the old and new token (e.g for this pipelines). Also, the token should be a JWT or similar. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.service_account_reset_token_with_http_info(team_id, service_account_id, async_req=True) + >>> result = thread.get() + + :param team_id: id of the team (required) + :type team_id: str + :param service_account_id: id of the serviceAccount (required) + :type service_account_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(str, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'team_id', + 'service_account_id' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method service_account_reset_token" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['team_id']: + _path_params['teamId'] = _params['team_id'] + + if _params['service_account_id']: + _path_params['serviceAccountId'] = _params['service_account_id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['auth0Bearer', 'ApiKeyAuth'] # noqa: E501 + + _response_types_map = { + '200': "str", + '400': "ApiErrorResponse", + '401': "ApiErrorResponse", + '403': "ApiErrorResponse", + '404': "ApiErrorResponse", + } + + return self.api_client.call_api( + '/v1/teams/{teamId}/serviceaccounts/{serviceAccountId}/token', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments def update_team_member_by_id(self, team_id : Annotated[constr(strict=True), Field(..., description="id of the team")], user_id : Annotated[StrictStr, Field(..., description="id of the user")], update_team_membership_request : UpdateTeamMembershipRequest, **kwargs) -> None: # noqa: E501 """update_team_member_by_id # noqa: E501 diff --git a/lightly/openapi_generated/swagger_client/models/__init__.py b/lightly/openapi_generated/swagger_client/models/__init__.py index 9f8015b83..e1e0ace03 100644 --- a/lightly/openapi_generated/swagger_client/models/__init__.py +++ b/lightly/openapi_generated/swagger_client/models/__init__.py @@ -23,6 +23,12 @@ from lightly.openapi_generated.swagger_client.models.api_error_code import ApiErrorCode from lightly.openapi_generated.swagger_client.models.api_error_response import ApiErrorResponse from lightly.openapi_generated.swagger_client.models.async_task_data import AsyncTaskData +from lightly.openapi_generated.swagger_client.models.auto_task import AutoTask +from lightly.openapi_generated.swagger_client.models.auto_task_base import AutoTaskBase +from lightly.openapi_generated.swagger_client.models.auto_task_crop import AutoTaskCrop +from lightly.openapi_generated.swagger_client.models.auto_task_crop_all_of import AutoTaskCropAllOf +from lightly.openapi_generated.swagger_client.models.auto_task_tiling import AutoTaskTiling +from lightly.openapi_generated.swagger_client.models.auto_task_tiling_all_of import AutoTaskTilingAllOf from lightly.openapi_generated.swagger_client.models.categorical_distribution import CategoricalDistribution from lightly.openapi_generated.swagger_client.models.categorical_distribution_metrics import CategoricalDistributionMetrics from lightly.openapi_generated.swagger_client.models.categorical_distribution_per_set import CategoricalDistributionPerSet @@ -30,6 +36,7 @@ from lightly.openapi_generated.swagger_client.models.configuration_entry import ConfigurationEntry from lightly.openapi_generated.swagger_client.models.configuration_set_request import ConfigurationSetRequest from lightly.openapi_generated.swagger_client.models.configuration_value_data_type import ConfigurationValueDataType +from lightly.openapi_generated.swagger_client.models.consent import Consent from lightly.openapi_generated.swagger_client.models.create_cf_bucket_activity_request import CreateCFBucketActivityRequest from lightly.openapi_generated.swagger_client.models.create_docker_worker_registry_entry_request import CreateDockerWorkerRegistryEntryRequest from lightly.openapi_generated.swagger_client.models.create_entity_response import CreateEntityResponse @@ -146,6 +153,7 @@ from lightly.openapi_generated.swagger_client.models.docker_worker_config_v4_data import DockerWorkerConfigV4Data from lightly.openapi_generated.swagger_client.models.docker_worker_config_v4_data_all_of import DockerWorkerConfigV4DataAllOf from lightly.openapi_generated.swagger_client.models.docker_worker_config_v4_docker import DockerWorkerConfigV4Docker +from lightly.openapi_generated.swagger_client.models.docker_worker_config_v4_docker_crops import DockerWorkerConfigV4DockerCrops from lightly.openapi_generated.swagger_client.models.docker_worker_config_vx_data import DockerWorkerConfigVXData from lightly.openapi_generated.swagger_client.models.docker_worker_config_vx_data_base import DockerWorkerConfigVXDataBase from lightly.openapi_generated.swagger_client.models.docker_worker_registry_entry_data import DockerWorkerRegistryEntryData @@ -288,6 +296,7 @@ from lightly.openapi_generated.swagger_client.models.trigger2d_embedding_job_request import Trigger2dEmbeddingJobRequest from lightly.openapi_generated.swagger_client.models.update_docker_worker_registry_entry_request import UpdateDockerWorkerRegistryEntryRequest from lightly.openapi_generated.swagger_client.models.update_team_membership_request import UpdateTeamMembershipRequest +from lightly.openapi_generated.swagger_client.models.usage import Usage from lightly.openapi_generated.swagger_client.models.user_type import UserType from lightly.openapi_generated.swagger_client.models.video_frame_data import VideoFrameData from lightly.openapi_generated.swagger_client.models.worker_information import WorkerInformation diff --git a/lightly/openapi_generated/swagger_client/models/auto_task.py b/lightly/openapi_generated/swagger_client/models/auto_task.py new file mode 100644 index 000000000..10457f460 --- /dev/null +++ b/lightly/openapi_generated/swagger_client/models/auto_task.py @@ -0,0 +1,177 @@ +# coding: utf-8 + +""" + Lightly API + + Lightly.ai enables you to do self-supervised learning in an easy and intuitive way. The lightly.ai OpenAPI spec defines how one can interact with our REST API to unleash the full potential of lightly.ai # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: support@lightly.ai + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import Any, List, Optional +try: + # Pydantic >=v1.10.17 + from pydantic.v1 import BaseModel, Field, StrictStr, ValidationError, validator +except ImportError: + # Pydantic v1 + from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from lightly.openapi_generated.swagger_client.models.auto_task_crop import AutoTaskCrop +from lightly.openapi_generated.swagger_client.models.auto_task_tiling import AutoTaskTiling +try: + # Pydantic >=v1.10.17 + from pydantic.v1 import StrictStr, Field +except ImportError: + # Pydantic v1 + from pydantic import StrictStr, Field + +AUTOTASK_ONE_OF_SCHEMAS = ["AutoTaskCrop", "AutoTaskTiling"] + +class AutoTask(BaseModel): + """ + AutoTask + """ + # data type: AutoTaskTiling + oneof_schema_1_validator: Optional[AutoTaskTiling] = None + # data type: AutoTaskCrop + oneof_schema_2_validator: Optional[AutoTaskCrop] = None + actual_instance: Any + one_of_schemas: List[str] = Field(AUTOTASK_ONE_OF_SCHEMAS, const=True) + + class Config: + validate_assignment = True + use_enum_values = True + extra = "forbid" + + discriminator_value_class_map = { + } + + def __init__(self, *args, **kwargs): + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = AutoTask.construct() + error_messages = [] + match = 0 + # validate data type: AutoTaskTiling + if not isinstance(v, AutoTaskTiling): + error_messages.append(f"Error! Input type `{type(v)}` is not `AutoTaskTiling`") + else: + match += 1 + # validate data type: AutoTaskCrop + if not isinstance(v, AutoTaskCrop): + error_messages.append(f"Error! Input type `{type(v)}` is not `AutoTaskCrop`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in AutoTask with oneOf schemas: AutoTaskCrop, AutoTaskTiling. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in AutoTask with oneOf schemas: AutoTaskCrop, AutoTaskTiling. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> AutoTask: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> AutoTask: + """Returns the object represented by the json string""" + instance = AutoTask.construct() + error_messages = [] + match = 0 + + # use oneOf discriminator to lookup the data type + _data_type = json.loads(json_str).get("type") + if not _data_type: + raise ValueError("Failed to lookup data type from the field `type` in the input.") + + # check if data type is `AutoTaskCrop` + if _data_type == "AutoTaskCrop": + instance.actual_instance = AutoTaskCrop.from_json(json_str) + return instance + + # check if data type is `AutoTaskTiling` + if _data_type == "AutoTaskTiling": + instance.actual_instance = AutoTaskTiling.from_json(json_str) + return instance + + # check if data type is `AutoTaskCrop` + if _data_type == "CROP": + instance.actual_instance = AutoTaskCrop.from_json(json_str) + return instance + + # check if data type is `AutoTaskTiling` + if _data_type == "TILING": + instance.actual_instance = AutoTaskTiling.from_json(json_str) + return instance + + # deserialize data into AutoTaskTiling + try: + instance.actual_instance = AutoTaskTiling.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into AutoTaskCrop + try: + instance.actual_instance = AutoTaskCrop.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into AutoTask with oneOf schemas: AutoTaskCrop, AutoTaskTiling. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into AutoTask with oneOf schemas: AutoTaskCrop, AutoTaskTiling. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self, by_alias: bool = False) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json(by_alias=by_alias) + else: + return json.dumps(self.actual_instance) + + def to_dict(self, by_alias: bool = False) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + to_dict = getattr(self.actual_instance, "to_dict", None) + if callable(to_dict): + return self.actual_instance.to_dict(by_alias=by_alias) + else: + # primitive type + return self.actual_instance + + def to_str(self, by_alias: bool = False) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict(by_alias=by_alias)) + diff --git a/lightly/openapi_generated/swagger_client/models/auto_task_base.py b/lightly/openapi_generated/swagger_client/models/auto_task_base.py new file mode 100644 index 000000000..858e38328 --- /dev/null +++ b/lightly/openapi_generated/swagger_client/models/auto_task_base.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + Lightly API + + Lightly.ai enables you to do self-supervised learning in an easy and intuitive way. The lightly.ai OpenAPI spec defines how one can interact with our REST API to unleash the full potential of lightly.ai # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: support@lightly.ai + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json +import lightly.openapi_generated.swagger_client.models + + + +try: + # Pydantic >=v1.10.17 + from pydantic.v1 import BaseModel, Field, StrictStr, constr, validator +except ImportError: + # Pydantic v1 + from pydantic import BaseModel, Field, StrictStr, constr, validator + +class AutoTaskBase(BaseModel): + """ + AutoTaskBase + """ + type: StrictStr = Field(..., description="The type of the auto task") + name: constr(strict=True) = Field(..., description="Since we sometimes stitch together SelectionInputTask+ActiveLearningScoreType, they need to follow the same specs of ActiveLearningScoreType. However, this can be an empty string due to internal logic (no minLength). Also v2config.filespecs.ts has this pattern for predictionTaskJSONSchema as well. ") + __properties = ["type", "name"] + + @validator('name') + def name_validate_regular_expression(cls, value): + """Validates the regular expression""" + if not re.match(r"^[a-zA-Z0-9_+=,.@:\/-]*$", value): + raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9_+=,.@:\/-]*$/") + return value + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + use_enum_values = True + extra = "forbid" + + # JSON field name that stores the object type + __discriminator_property_name = 'type' + + # discriminator mappings + __discriminator_value_class_map = { + 'AutoTaskCrop': 'AutoTaskCrop', + 'AutoTaskTiling': 'AutoTaskTiling' + } + + @classmethod + def get_discriminator_value(cls, obj: dict) -> str: + """Returns the discriminator value (object type) of the data""" + discriminator_value = obj[cls.__discriminator_property_name] + if discriminator_value: + return cls.__discriminator_value_class_map.get(discriminator_value) + else: + return None + + def to_str(self, by_alias: bool = False) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.dict(by_alias=by_alias)) + + def to_json(self, by_alias: bool = False) -> str: + """Returns the JSON representation of the model""" + return json.dumps(self.to_dict(by_alias=by_alias)) + + @classmethod + def from_json(cls, json_str: str) -> Union(AutoTaskCrop, AutoTaskTiling): + """Create an instance of AutoTaskBase from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self, by_alias: bool = False): + """Returns the dictionary representation of the model""" + _dict = self.dict(by_alias=by_alias, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Union(AutoTaskCrop, AutoTaskTiling): + """Create an instance of AutoTaskBase from a dict""" + # look up the object type based on discriminator mapping + object_type = cls.get_discriminator_value(obj) + if object_type: + klass = getattr(lightly.openapi_generated.swagger_client.models, object_type) + return klass.from_dict(obj) + else: + raise ValueError("AutoTaskBase failed to lookup discriminator value from " + + json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + + ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) + diff --git a/lightly/openapi_generated/swagger_client/models/auto_task_crop.py b/lightly/openapi_generated/swagger_client/models/auto_task_crop.py new file mode 100644 index 000000000..10ba0b73c --- /dev/null +++ b/lightly/openapi_generated/swagger_client/models/auto_task_crop.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + Lightly API + + Lightly.ai enables you to do self-supervised learning in an easy and intuitive way. The lightly.ai OpenAPI spec defines how one can interact with our REST API to unleash the full potential of lightly.ai # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: support@lightly.ai + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import List, Optional, Union +try: + # Pydantic >=v1.10.17 + from pydantic.v1 import BaseModel, Field, confloat, conint, conlist +except ImportError: + # Pydantic v1 + from pydantic import BaseModel, Field, confloat, conint, conlist +from lightly.openapi_generated.swagger_client.models.auto_task_base import AutoTaskBase + +class AutoTaskCrop(AutoTaskBase): + """ + Create a prediction which crops and focuses on a specific part of the image + """ + bboxs: Optional[conlist(conlist(Union[confloat(le=1, ge=0, strict=True), conint(le=1, ge=0, strict=True)], max_items=4, min_items=4), min_items=1)] = Field(None, description="The bounding boxes to focus on.") + __properties = ["type", "name", "bboxs"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + use_enum_values = True + extra = "forbid" + + def to_str(self, by_alias: bool = False) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.dict(by_alias=by_alias)) + + def to_json(self, by_alias: bool = False) -> str: + """Returns the JSON representation of the model""" + return json.dumps(self.to_dict(by_alias=by_alias)) + + @classmethod + def from_json(cls, json_str: str) -> AutoTaskCrop: + """Create an instance of AutoTaskCrop from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self, by_alias: bool = False): + """Returns the dictionary representation of the model""" + _dict = self.dict(by_alias=by_alias, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AutoTaskCrop: + """Create an instance of AutoTaskCrop from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AutoTaskCrop.parse_obj(obj) + + # raise errors for additional fields in the input + for _key in obj.keys(): + if _key not in cls.__properties: + raise ValueError("Error due to additional fields (not defined in AutoTaskCrop) in the input: " + str(obj)) + + _obj = AutoTaskCrop.parse_obj({ + "type": obj.get("type"), + "name": obj.get("name"), + "bboxs": obj.get("bboxs") + }) + return _obj + diff --git a/lightly/openapi_generated/swagger_client/models/auto_task_crop_all_of.py b/lightly/openapi_generated/swagger_client/models/auto_task_crop_all_of.py new file mode 100644 index 000000000..3d79b8654 --- /dev/null +++ b/lightly/openapi_generated/swagger_client/models/auto_task_crop_all_of.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + Lightly API + + Lightly.ai enables you to do self-supervised learning in an easy and intuitive way. The lightly.ai OpenAPI spec defines how one can interact with our REST API to unleash the full potential of lightly.ai # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: support@lightly.ai + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import List, Optional, Union +try: + # Pydantic >=v1.10.17 + from pydantic.v1 import BaseModel, Field, confloat, conint, conlist +except ImportError: + # Pydantic v1 + from pydantic import BaseModel, Field, confloat, conint, conlist + +class AutoTaskCropAllOf(BaseModel): + """ + AutoTaskCropAllOf + """ + bboxs: Optional[conlist(conlist(Union[confloat(le=1, ge=0, strict=True), conint(le=1, ge=0, strict=True)], max_items=4, min_items=4), min_items=1)] = Field(None, description="The bounding boxes to focus on.") + __properties = ["bboxs"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + use_enum_values = True + extra = "forbid" + + def to_str(self, by_alias: bool = False) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.dict(by_alias=by_alias)) + + def to_json(self, by_alias: bool = False) -> str: + """Returns the JSON representation of the model""" + return json.dumps(self.to_dict(by_alias=by_alias)) + + @classmethod + def from_json(cls, json_str: str) -> AutoTaskCropAllOf: + """Create an instance of AutoTaskCropAllOf from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self, by_alias: bool = False): + """Returns the dictionary representation of the model""" + _dict = self.dict(by_alias=by_alias, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AutoTaskCropAllOf: + """Create an instance of AutoTaskCropAllOf from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AutoTaskCropAllOf.parse_obj(obj) + + # raise errors for additional fields in the input + for _key in obj.keys(): + if _key not in cls.__properties: + raise ValueError("Error due to additional fields (not defined in AutoTaskCropAllOf) in the input: " + str(obj)) + + _obj = AutoTaskCropAllOf.parse_obj({ + "bboxs": obj.get("bboxs") + }) + return _obj + diff --git a/lightly/openapi_generated/swagger_client/models/auto_task_tiling.py b/lightly/openapi_generated/swagger_client/models/auto_task_tiling.py new file mode 100644 index 000000000..7a3430509 --- /dev/null +++ b/lightly/openapi_generated/swagger_client/models/auto_task_tiling.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + Lightly API + + Lightly.ai enables you to do self-supervised learning in an easy and intuitive way. The lightly.ai OpenAPI spec defines how one can interact with our REST API to unleash the full potential of lightly.ai # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: support@lightly.ai + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional, Union +try: + # Pydantic >=v1.10.17 + from pydantic.v1 import BaseModel, Field, confloat, conint +except ImportError: + # Pydantic v1 + from pydantic import BaseModel, Field, confloat, conint +from lightly.openapi_generated.swagger_client.models.auto_task_base import AutoTaskBase + +class AutoTaskTiling(AutoTaskBase): + """ + Create multiple predictions which equally split the image into tiles + """ + num_rows: conint(strict=True, ge=1) = Field(..., alias="numRows", description="The number of rows the image should be split into") + num_cols: conint(strict=True, ge=1) = Field(..., alias="numCols", description="The number of column the image should be split into") + overlap: Optional[Union[confloat(ge=0.0, strict=True), conint(ge=0, strict=True)]] = Field(0.0, description="The relative overlap between tiles. The overlap is a fraction of the tile size. For example, if the overlap is 0.1 and the tile size is 100, the overlap is 10 pixels. ") + __properties = ["type", "name", "numRows", "numCols", "overlap"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + use_enum_values = True + extra = "forbid" + + def to_str(self, by_alias: bool = False) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.dict(by_alias=by_alias)) + + def to_json(self, by_alias: bool = False) -> str: + """Returns the JSON representation of the model""" + return json.dumps(self.to_dict(by_alias=by_alias)) + + @classmethod + def from_json(cls, json_str: str) -> AutoTaskTiling: + """Create an instance of AutoTaskTiling from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self, by_alias: bool = False): + """Returns the dictionary representation of the model""" + _dict = self.dict(by_alias=by_alias, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AutoTaskTiling: + """Create an instance of AutoTaskTiling from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AutoTaskTiling.parse_obj(obj) + + # raise errors for additional fields in the input + for _key in obj.keys(): + if _key not in cls.__properties: + raise ValueError("Error due to additional fields (not defined in AutoTaskTiling) in the input: " + str(obj)) + + _obj = AutoTaskTiling.parse_obj({ + "type": obj.get("type"), + "name": obj.get("name"), + "num_rows": obj.get("numRows"), + "num_cols": obj.get("numCols"), + "overlap": obj.get("overlap") if obj.get("overlap") is not None else 0.0 + }) + return _obj + diff --git a/lightly/openapi_generated/swagger_client/models/auto_task_tiling_all_of.py b/lightly/openapi_generated/swagger_client/models/auto_task_tiling_all_of.py new file mode 100644 index 000000000..5df676445 --- /dev/null +++ b/lightly/openapi_generated/swagger_client/models/auto_task_tiling_all_of.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + Lightly API + + Lightly.ai enables you to do self-supervised learning in an easy and intuitive way. The lightly.ai OpenAPI spec defines how one can interact with our REST API to unleash the full potential of lightly.ai # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: support@lightly.ai + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional, Union +try: + # Pydantic >=v1.10.17 + from pydantic.v1 import BaseModel, Field, confloat, conint +except ImportError: + # Pydantic v1 + from pydantic import BaseModel, Field, confloat, conint + +class AutoTaskTilingAllOf(BaseModel): + """ + AutoTaskTilingAllOf + """ + num_rows: conint(strict=True, ge=1) = Field(..., alias="numRows", description="The number of rows the image should be split into") + num_cols: conint(strict=True, ge=1) = Field(..., alias="numCols", description="The number of column the image should be split into") + overlap: Optional[Union[confloat(ge=0.0, strict=True), conint(ge=0, strict=True)]] = Field(0.0, description="The relative overlap between tiles. The overlap is a fraction of the tile size. For example, if the overlap is 0.1 and the tile size is 100, the overlap is 10 pixels. ") + __properties = ["numRows", "numCols", "overlap"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + use_enum_values = True + extra = "forbid" + + def to_str(self, by_alias: bool = False) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.dict(by_alias=by_alias)) + + def to_json(self, by_alias: bool = False) -> str: + """Returns the JSON representation of the model""" + return json.dumps(self.to_dict(by_alias=by_alias)) + + @classmethod + def from_json(cls, json_str: str) -> AutoTaskTilingAllOf: + """Create an instance of AutoTaskTilingAllOf from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self, by_alias: bool = False): + """Returns the dictionary representation of the model""" + _dict = self.dict(by_alias=by_alias, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AutoTaskTilingAllOf: + """Create an instance of AutoTaskTilingAllOf from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AutoTaskTilingAllOf.parse_obj(obj) + + # raise errors for additional fields in the input + for _key in obj.keys(): + if _key not in cls.__properties: + raise ValueError("Error due to additional fields (not defined in AutoTaskTilingAllOf) in the input: " + str(obj)) + + _obj = AutoTaskTilingAllOf.parse_obj({ + "num_rows": obj.get("numRows"), + "num_cols": obj.get("numCols"), + "overlap": obj.get("overlap") if obj.get("overlap") is not None else 0.0 + }) + return _obj + diff --git a/lightly/openapi_generated/swagger_client/models/consent.py b/lightly/openapi_generated/swagger_client/models/consent.py new file mode 100644 index 000000000..0b31ae63e --- /dev/null +++ b/lightly/openapi_generated/swagger_client/models/consent.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + Lightly API + + Lightly.ai enables you to do self-supervised learning in an easy and intuitive way. The lightly.ai OpenAPI spec defines how one can interact with our REST API to unleash the full potential of lightly.ai # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: support@lightly.ai + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional +try: + # Pydantic >=v1.10.17 + from pydantic.v1 import BaseModel, Field, StrictBool, conint +except ImportError: + # Pydantic v1 + from pydantic import BaseModel, Field, StrictBool, conint + +class Consent(BaseModel): + """ + Consent + """ + accepted_newsletter: Optional[StrictBool] = Field(None, alias="acceptedNewsletter") + accepted_terms_date: Optional[conint(strict=True, ge=0)] = Field(None, alias="acceptedTermsDate", description="unix timestamp in milliseconds") + additional_properties: Dict[str, Any] = {} + __properties = ["acceptedNewsletter", "acceptedTermsDate"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + use_enum_values = True + extra = "forbid" + + def to_str(self, by_alias: bool = False) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.dict(by_alias=by_alias)) + + def to_json(self, by_alias: bool = False) -> str: + """Returns the JSON representation of the model""" + return json.dumps(self.to_dict(by_alias=by_alias)) + + @classmethod + def from_json(cls, json_str: str) -> Consent: + """Create an instance of Consent from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self, by_alias: bool = False): + """Returns the dictionary representation of the model""" + _dict = self.dict(by_alias=by_alias, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Consent: + """Create an instance of Consent from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Consent.parse_obj(obj) + + _obj = Consent.parse_obj({ + "accepted_newsletter": obj.get("acceptedNewsletter"), + "accepted_terms_date": obj.get("acceptedTermsDate") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + diff --git a/lightly/openapi_generated/swagger_client/models/docker_worker_config_v4_docker.py b/lightly/openapi_generated/swagger_client/models/docker_worker_config_v4_docker.py index 30164cfd6..7967d3141 100644 --- a/lightly/openapi_generated/swagger_client/models/docker_worker_config_v4_docker.py +++ b/lightly/openapi_generated/swagger_client/models/docker_worker_config_v4_docker.py @@ -29,6 +29,7 @@ from lightly.openapi_generated.swagger_client.models.docker_worker_config_v3_docker_corruptness_check import DockerWorkerConfigV3DockerCorruptnessCheck from lightly.openapi_generated.swagger_client.models.docker_worker_config_v3_docker_datasource import DockerWorkerConfigV3DockerDatasource from lightly.openapi_generated.swagger_client.models.docker_worker_config_v3_docker_training import DockerWorkerConfigV3DockerTraining +from lightly.openapi_generated.swagger_client.models.docker_worker_config_v4_docker_crops import DockerWorkerConfigV4DockerCrops class DockerWorkerConfigV4Docker(BaseModel): """ @@ -38,6 +39,7 @@ class DockerWorkerConfigV4Docker(BaseModel): checkpoint_run_id: Optional[constr(strict=True)] = Field(None, alias="checkpointRunId", description="MongoDB ObjectId") corruptness_check: Optional[DockerWorkerConfigV3DockerCorruptnessCheck] = Field(None, alias="corruptnessCheck") datasource: Optional[DockerWorkerConfigV3DockerDatasource] = None + crops: Optional[DockerWorkerConfigV4DockerCrops] = None embeddings: Optional[StrictStr] = None enable_training: Optional[StrictBool] = Field(None, alias="enableTraining") training: Optional[DockerWorkerConfigV3DockerTraining] = None @@ -53,7 +55,7 @@ class DockerWorkerConfigV4Docker(BaseModel): use_datapool: Optional[StrictBool] = Field(None, alias="useDatapool") shutdown_when_job_finished: Optional[StrictBool] = Field(None, alias="shutdownWhenJobFinished") cache_size: Optional[conint(strict=True, ge=-1)] = Field(None, alias="cacheSize", description="Maximum number of bytes stored in the disk cache. Setting it to <=0 disables the cache.") - __properties = ["checkpoint", "checkpointRunId", "corruptnessCheck", "datasource", "embeddings", "enableTraining", "training", "normalizeEmbeddings", "numProcesses", "numThreads", "outputImageFormat", "pretagging", "pretaggingUpload", "relevantFilenamesFile", "selectedSequenceLength", "uploadReport", "useDatapool", "shutdownWhenJobFinished", "cacheSize"] + __properties = ["checkpoint", "checkpointRunId", "corruptnessCheck", "datasource", "crops", "embeddings", "enableTraining", "training", "normalizeEmbeddings", "numProcesses", "numThreads", "outputImageFormat", "pretagging", "pretaggingUpload", "relevantFilenamesFile", "selectedSequenceLength", "uploadReport", "useDatapool", "shutdownWhenJobFinished", "cacheSize"] @validator('checkpoint_run_id') def checkpoint_run_id_validate_regular_expression(cls, value): @@ -97,6 +99,9 @@ def to_dict(self, by_alias: bool = False): # override the default output from pydantic by calling `to_dict()` of datasource if self.datasource: _dict['datasource' if by_alias else 'datasource'] = self.datasource.to_dict(by_alias=by_alias) + # override the default output from pydantic by calling `to_dict()` of crops + if self.crops: + _dict['crops' if by_alias else 'crops'] = self.crops.to_dict(by_alias=by_alias) # override the default output from pydantic by calling `to_dict()` of training if self.training: _dict['training' if by_alias else 'training'] = self.training.to_dict(by_alias=by_alias) @@ -121,6 +126,7 @@ def from_dict(cls, obj: dict) -> DockerWorkerConfigV4Docker: "checkpoint_run_id": obj.get("checkpointRunId"), "corruptness_check": DockerWorkerConfigV3DockerCorruptnessCheck.from_dict(obj.get("corruptnessCheck")) if obj.get("corruptnessCheck") is not None else None, "datasource": DockerWorkerConfigV3DockerDatasource.from_dict(obj.get("datasource")) if obj.get("datasource") is not None else None, + "crops": DockerWorkerConfigV4DockerCrops.from_dict(obj.get("crops")) if obj.get("crops") is not None else None, "embeddings": obj.get("embeddings"), "enable_training": obj.get("enableTraining"), "training": DockerWorkerConfigV3DockerTraining.from_dict(obj.get("training")) if obj.get("training") is not None else None, diff --git a/lightly/openapi_generated/swagger_client/models/docker_worker_config_v4_docker_crops.py b/lightly/openapi_generated/swagger_client/models/docker_worker_config_v4_docker_crops.py new file mode 100644 index 000000000..f1f1bf73f --- /dev/null +++ b/lightly/openapi_generated/swagger_client/models/docker_worker_config_v4_docker_crops.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + Lightly API + + Lightly.ai enables you to do self-supervised learning in an easy and intuitive way. The lightly.ai OpenAPI spec defines how one can interact with our REST API to unleash the full potential of lightly.ai # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: support@lightly.ai + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import List, Optional +try: + # Pydantic >=v1.10.17 + from pydantic.v1 import BaseModel, Field, StrictBool, conlist, constr, validator +except ImportError: + # Pydantic v1 + from pydantic import BaseModel, Field, StrictBool, conlist, constr, validator + +class DockerWorkerConfigV4DockerCrops(BaseModel): + """ + DockerWorkerConfigV4DockerCrops + """ + enable_upload: Optional[StrictBool] = Field(True, alias="enableUpload", description="If false, no crop dataset is created nor are the crops uploaded to the bucket. Predictions (e.g bounding boxes) will be created on the main dataset regardless. ") + enable_upload_for_tasks: Optional[conlist(constr(strict=True))] = Field(None, alias="enableUploadForTasks", description="Array of tasks (prediction tasks and autoTasks) for which the crop dataset creation and upload is enabled. If unset, all tasks are uploaded by default. ") + __properties = ["enableUpload", "enableUploadForTasks"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + use_enum_values = True + extra = "forbid" + + def to_str(self, by_alias: bool = False) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.dict(by_alias=by_alias)) + + def to_json(self, by_alias: bool = False) -> str: + """Returns the JSON representation of the model""" + return json.dumps(self.to_dict(by_alias=by_alias)) + + @classmethod + def from_json(cls, json_str: str) -> DockerWorkerConfigV4DockerCrops: + """Create an instance of DockerWorkerConfigV4DockerCrops from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self, by_alias: bool = False): + """Returns the dictionary representation of the model""" + _dict = self.dict(by_alias=by_alias, + exclude={ + }, + exclude_none=True) + # set to None if enable_upload_for_tasks (nullable) is None + # and __fields_set__ contains the field + if self.enable_upload_for_tasks is None and "enable_upload_for_tasks" in self.__fields_set__: + _dict['enableUploadForTasks' if by_alias else 'enable_upload_for_tasks'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> DockerWorkerConfigV4DockerCrops: + """Create an instance of DockerWorkerConfigV4DockerCrops from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return DockerWorkerConfigV4DockerCrops.parse_obj(obj) + + # raise errors for additional fields in the input + for _key in obj.keys(): + if _key not in cls.__properties: + raise ValueError("Error due to additional fields (not defined in DockerWorkerConfigV4DockerCrops) in the input: " + str(obj)) + + _obj = DockerWorkerConfigV4DockerCrops.parse_obj({ + "enable_upload": obj.get("enableUpload") if obj.get("enableUpload") is not None else True, + "enable_upload_for_tasks": obj.get("enableUploadForTasks") + }) + return _obj + diff --git a/lightly/openapi_generated/swagger_client/models/questionnaire_data.py b/lightly/openapi_generated/swagger_client/models/questionnaire_data.py index 011b85e32..49f256158 100644 --- a/lightly/openapi_generated/swagger_client/models/questionnaire_data.py +++ b/lightly/openapi_generated/swagger_client/models/questionnaire_data.py @@ -22,11 +22,12 @@ from typing import Optional try: # Pydantic >=v1.10.17 - from pydantic.v1 import BaseModel, constr + from pydantic.v1 import BaseModel, Field, StrictStr, constr except ImportError: # Pydantic v1 - from pydantic import BaseModel, constr + from pydantic import BaseModel, Field, StrictStr, constr from lightly.openapi_generated.swagger_client.models.sector import Sector +from lightly.openapi_generated.swagger_client.models.usage import Usage class QuestionnaireData(BaseModel): """ @@ -34,7 +35,9 @@ class QuestionnaireData(BaseModel): """ company: Optional[constr(strict=True, min_length=3)] = None sector: Optional[Sector] = None - __properties = ["company", "sector"] + usage: Optional[Usage] = None + usage_custom_reason: Optional[StrictStr] = Field(None, alias="usageCustomReason") + __properties = ["company", "sector", "usage", "usageCustomReason"] class Config: """Pydantic configuration""" @@ -62,6 +65,11 @@ def to_dict(self, by_alias: bool = False): exclude={ }, exclude_none=True) + # set to None if usage_custom_reason (nullable) is None + # and __fields_set__ contains the field + if self.usage_custom_reason is None and "usage_custom_reason" in self.__fields_set__: + _dict['usageCustomReason' if by_alias else 'usage_custom_reason'] = None + return _dict @classmethod @@ -80,7 +88,9 @@ def from_dict(cls, obj: dict) -> QuestionnaireData: _obj = QuestionnaireData.parse_obj({ "company": obj.get("company"), - "sector": obj.get("sector") + "sector": obj.get("sector"), + "usage": obj.get("usage"), + "usage_custom_reason": obj.get("usageCustomReason") }) return _obj diff --git a/lightly/openapi_generated/swagger_client/models/selection_config_v4.py b/lightly/openapi_generated/swagger_client/models/selection_config_v4.py index ba02c67a7..d1dae6b67 100644 --- a/lightly/openapi_generated/swagger_client/models/selection_config_v4.py +++ b/lightly/openapi_generated/swagger_client/models/selection_config_v4.py @@ -26,6 +26,7 @@ except ImportError: # Pydantic v1 from pydantic import BaseModel, Field, confloat, conint, conlist, constr +from lightly.openapi_generated.swagger_client.models.auto_task import AutoTask from lightly.openapi_generated.swagger_client.models.selection_config_v4_entry import SelectionConfigV4Entry class SelectionConfigV4(BaseModel): @@ -36,7 +37,8 @@ class SelectionConfigV4(BaseModel): proportion_samples: Optional[Union[confloat(le=1.0, ge=0.0, strict=True), conint(le=1, ge=0, strict=True)]] = Field(None, alias="proportionSamples") strategies: conlist(SelectionConfigV4Entry, min_items=1) = Field(...) lightly_path_regex: Optional[constr(strict=True, min_length=1)] = Field(None, alias="lightlyPathRegex", description="The Lightly Path Regex to extract information from filenames for metadata balancing and more. Docs are coming soon.") - __properties = ["nSamples", "proportionSamples", "strategies", "lightlyPathRegex"] + auto_tasks: Optional[conlist(AutoTask)] = Field(None, alias="autoTasks", description="Array of tasks we automatically apply to images create fake prediction for. These can then be used with the selection strategies.") + __properties = ["nSamples", "proportionSamples", "strategies", "lightlyPathRegex", "autoTasks"] class Config: """Pydantic configuration""" @@ -71,6 +73,13 @@ def to_dict(self, by_alias: bool = False): if _item: _items.append(_item.to_dict(by_alias=by_alias)) _dict['strategies' if by_alias else 'strategies'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in auto_tasks (list) + _items = [] + if self.auto_tasks: + for _item in self.auto_tasks: + if _item: + _items.append(_item.to_dict(by_alias=by_alias)) + _dict['autoTasks' if by_alias else 'auto_tasks'] = _items return _dict @classmethod @@ -91,7 +100,8 @@ def from_dict(cls, obj: dict) -> SelectionConfigV4: "n_samples": obj.get("nSamples"), "proportion_samples": obj.get("proportionSamples"), "strategies": [SelectionConfigV4Entry.from_dict(_item) for _item in obj.get("strategies")] if obj.get("strategies") is not None else None, - "lightly_path_regex": obj.get("lightlyPathRegex") + "lightly_path_regex": obj.get("lightlyPathRegex"), + "auto_tasks": [AutoTask.from_dict(_item) for _item in obj.get("autoTasks")] if obj.get("autoTasks") is not None else None }) return _obj diff --git a/lightly/openapi_generated/swagger_client/models/selection_config_v4_all_of.py b/lightly/openapi_generated/swagger_client/models/selection_config_v4_all_of.py index 889a0fcf6..85b9a4abe 100644 --- a/lightly/openapi_generated/swagger_client/models/selection_config_v4_all_of.py +++ b/lightly/openapi_generated/swagger_client/models/selection_config_v4_all_of.py @@ -26,6 +26,7 @@ except ImportError: # Pydantic v1 from pydantic import BaseModel, Field, conlist, constr +from lightly.openapi_generated.swagger_client.models.auto_task import AutoTask from lightly.openapi_generated.swagger_client.models.selection_config_v4_entry import SelectionConfigV4Entry class SelectionConfigV4AllOf(BaseModel): @@ -34,7 +35,8 @@ class SelectionConfigV4AllOf(BaseModel): """ strategies: conlist(SelectionConfigV4Entry, min_items=1) = Field(...) lightly_path_regex: Optional[constr(strict=True, min_length=1)] = Field(None, alias="lightlyPathRegex", description="The Lightly Path Regex to extract information from filenames for metadata balancing and more. Docs are coming soon.") - __properties = ["strategies", "lightlyPathRegex"] + auto_tasks: Optional[conlist(AutoTask)] = Field(None, alias="autoTasks", description="Array of tasks we automatically apply to images create fake prediction for. These can then be used with the selection strategies.") + __properties = ["strategies", "lightlyPathRegex", "autoTasks"] class Config: """Pydantic configuration""" @@ -69,6 +71,13 @@ def to_dict(self, by_alias: bool = False): if _item: _items.append(_item.to_dict(by_alias=by_alias)) _dict['strategies' if by_alias else 'strategies'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in auto_tasks (list) + _items = [] + if self.auto_tasks: + for _item in self.auto_tasks: + if _item: + _items.append(_item.to_dict(by_alias=by_alias)) + _dict['autoTasks' if by_alias else 'auto_tasks'] = _items return _dict @classmethod @@ -87,7 +96,8 @@ def from_dict(cls, obj: dict) -> SelectionConfigV4AllOf: _obj = SelectionConfigV4AllOf.parse_obj({ "strategies": [SelectionConfigV4Entry.from_dict(_item) for _item in obj.get("strategies")] if obj.get("strategies") is not None else None, - "lightly_path_regex": obj.get("lightlyPathRegex") + "lightly_path_regex": obj.get("lightlyPathRegex"), + "auto_tasks": [AutoTask.from_dict(_item) for _item in obj.get("autoTasks")] if obj.get("autoTasks") is not None else None }) return _obj diff --git a/lightly/openapi_generated/swagger_client/models/usage.py b/lightly/openapi_generated/swagger_client/models/usage.py new file mode 100644 index 000000000..77de56e32 --- /dev/null +++ b/lightly/openapi_generated/swagger_client/models/usage.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + Lightly API + + Lightly.ai enables you to do self-supervised learning in an easy and intuitive way. The lightly.ai OpenAPI spec defines how one can interact with our REST API to unleash the full potential of lightly.ai # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: support@lightly.ai + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import json +import pprint +import re # noqa: F401 +from enum import Enum +from aenum import no_arg # type: ignore + + + + + +class Usage(str, Enum): + """ + Usage + """ + + """ + allowed enum values + """ + LABELING = 'LABELING' + SELECTING = 'SELECTING' + VISUALIZATION = 'VISUALIZATION' + MODEL_TRAINING = 'MODEL_TRAINING' + DATASET_MANAGING = 'DATASET_MANAGING' + CHECKING_THE_TOOL = 'CHECKING_THE_TOOL' + OTHER = 'OTHER' + + @classmethod + def from_json(cls, json_str: str) -> 'Usage': + """Create an instance of Usage from a JSON string""" + return Usage(json.loads(json_str)) + +