diff --git a/.gitignore b/.gitignore index d4551a9..a640b8a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ learning_orchestra_client/transform/__pycache__ learning_orchestra_client/main.py learning_orchestra_client/explore/__pycache__ learning_orchestra_client/builder/__pycache__ -docs sentiment_analysis_output.py mnist_output.py mnist_treatment.py \ No newline at end of file diff --git a/html/learning_orchestra_client/builder/builder.html b/docs/builder/builder.html similarity index 100% rename from html/learning_orchestra_client/builder/builder.html rename to docs/builder/builder.html diff --git a/html/learning_orchestra_client/builder/builder_horovod.html b/docs/builder/builder_horovod.html similarity index 100% rename from html/learning_orchestra_client/builder/builder_horovod.html rename to docs/builder/builder_horovod.html diff --git a/html/learning_orchestra_client/builder/index.html b/docs/builder/index.html similarity index 100% rename from html/learning_orchestra_client/builder/index.html rename to docs/builder/index.html diff --git a/html/learning_orchestra_client/dataset/csv.html b/docs/dataset/csv.html similarity index 100% rename from html/learning_orchestra_client/dataset/csv.html rename to docs/dataset/csv.html diff --git a/html/learning_orchestra_client/dataset/generic.html b/docs/dataset/generic.html similarity index 100% rename from html/learning_orchestra_client/dataset/generic.html rename to docs/dataset/generic.html diff --git a/html/learning_orchestra_client/dataset/index.html b/docs/dataset/index.html similarity index 100% rename from html/learning_orchestra_client/dataset/index.html rename to docs/dataset/index.html diff --git a/html/learning_orchestra_client/evaluate/index.html b/docs/evaluate/index.html similarity index 100% rename from html/learning_orchestra_client/evaluate/index.html rename to docs/evaluate/index.html diff --git a/html/learning_orchestra_client/evaluate/scikitlearn.html b/docs/evaluate/scikitlearn.html similarity index 100% rename from html/learning_orchestra_client/evaluate/scikitlearn.html rename to docs/evaluate/scikitlearn.html diff --git a/html/learning_orchestra_client/evaluate/tensorflow.html b/docs/evaluate/tensorflow.html similarity index 100% rename from html/learning_orchestra_client/evaluate/tensorflow.html rename to docs/evaluate/tensorflow.html diff --git a/html/learning_orchestra_client/explore/histogram.html b/docs/explore/histogram.html similarity index 100% rename from html/learning_orchestra_client/explore/histogram.html rename to docs/explore/histogram.html diff --git a/html/learning_orchestra_client/explore/index.html b/docs/explore/index.html similarity index 100% rename from html/learning_orchestra_client/explore/index.html rename to docs/explore/index.html diff --git a/html/learning_orchestra_client/explore/scikitlearn.html b/docs/explore/scikitlearn.html similarity index 100% rename from html/learning_orchestra_client/explore/scikitlearn.html rename to docs/explore/scikitlearn.html diff --git a/html/learning_orchestra_client/explore/tensorflow.html b/docs/explore/tensorflow.html similarity index 100% rename from html/learning_orchestra_client/explore/tensorflow.html rename to docs/explore/tensorflow.html diff --git a/html/learning_orchestra_client/function/index.html b/docs/function/index.html similarity index 100% rename from html/learning_orchestra_client/function/index.html rename to docs/function/index.html diff --git a/html/learning_orchestra_client/function/python.html b/docs/function/python.html similarity index 100% rename from html/learning_orchestra_client/function/python.html rename to docs/function/python.html diff --git a/html/learning_orchestra_client/index.html b/docs/index.html similarity index 100% rename from html/learning_orchestra_client/index.html rename to docs/index.html diff --git a/html/learning_orchestra_client/model/index.html b/docs/model/index.html similarity index 100% rename from html/learning_orchestra_client/model/index.html rename to docs/model/index.html diff --git a/html/learning_orchestra_client/model/scikitlearn.html b/docs/model/scikitlearn.html similarity index 100% rename from html/learning_orchestra_client/model/scikitlearn.html rename to docs/model/scikitlearn.html diff --git a/html/learning_orchestra_client/model/tensorflow.html b/docs/model/tensorflow.html similarity index 100% rename from html/learning_orchestra_client/model/tensorflow.html rename to docs/model/tensorflow.html diff --git a/html/learning_orchestra_client/observe/index.html b/docs/observe/index.html similarity index 100% rename from html/learning_orchestra_client/observe/index.html rename to docs/observe/index.html diff --git a/html/learning_orchestra_client/observe/observe.html b/docs/observe/observe.html similarity index 100% rename from html/learning_orchestra_client/observe/observe.html rename to docs/observe/observe.html diff --git a/docs/old/.nojekyll b/docs/old/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/docs/old/index.html b/docs/old/index.html new file mode 100644 index 0000000..0b7bc20 --- /dev/null +++ b/docs/old/index.html @@ -0,0 +1,279 @@ + + +
+ + + +from ._response_treat import ResponseTreat +import requests +from requests import Response + + +class EntityReader: + def __init__(self, entity_url: str): + self.__response_treat = ResponseTreat() + self.__entity_url = entity_url + + def read_all_instances_from_entity(self) -> Response: + request_url = self.__entity_url + + response = requests.get(request_url) + return response + + def read_entity_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0) \ + -> Response: + request_url = f'{self.__entity_url}/{name}' \ + f'?query={query}&limit={limit}&skip={skip}' + + response = requests.get(request_url) + return response + + def read_explore_image_metadata(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0 + ) -> Response: + request_url = f'{self.__entity_url}/{name}/metadata' \ + f'?query={query}&limit={limit}&skip={skip}' + + response = requests.get(request_url) + return response +
class EntityReader: + def __init__(self, entity_url: str): + self.__response_treat = ResponseTreat() + self.__entity_url = entity_url + + def read_all_instances_from_entity(self) -> Response: + request_url = self.__entity_url + + response = requests.get(request_url) + return response + + def read_entity_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0) \ + -> Response: + request_url = f'{self.__entity_url}/{name}' \ + f'?query={query}&limit={limit}&skip={skip}' + + response = requests.get(request_url) + return response + + def read_explore_image_metadata(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0 + ) -> Response: + request_url = f'{self.__entity_url}/{name}/metadata' \ + f'?query={query}&limit={limit}&skip={skip}' + + response = requests.get(request_url) + return response +
def __init__(self, entity_url: str): + self.__response_treat = ResponseTreat() + self.__entity_url = entity_url +
def read_all_instances_from_entity(self) -> Response: + request_url = self.__entity_url + + response = requests.get(request_url) + return response +
def read_entity_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0) \ + -> Response: + request_url = f'{self.__entity_url}/{name}' \ + f'?query={query}&limit={limit}&skip={skip}' + + response = requests.get(request_url) + return response +
def read_explore_image_metadata(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0 + ) -> Response: + request_url = f'{self.__entity_url}/{name}/metadata' \ + f'?query={query}&limit={limit}&skip={skip}' + + response = requests.get(request_url) + return response +
import json +from requests import Response +import logging +from typing import Union + + +class ResponseTreat: + HTTP_CREATED = 201 + HTTP_SUCCESS = 200 + HTTP_ERROR = 500 + + def treatment(self, response: Response, + pretty_response: bool = True) -> Union[dict, str]: + """ + description: This method is responsible to return an indented json file + or a dict. + + response: file that will be indented. + + return: Indented json file or a dict. + """ + if response.status_code >= self.HTTP_ERROR: + logging.error(response.text) + elif ( + response.status_code != self.HTTP_SUCCESS + and response.status_code != self.HTTP_CREATED + ): + logging.warning(response.json()["result"]) + return {} + else: + if pretty_response: + return json.dumps(response.json(), indent=4, sort_keys=True) + else: + return response.json() +
class ResponseTreat: + HTTP_CREATED = 201 + HTTP_SUCCESS = 200 + HTTP_ERROR = 500 + + def treatment(self, response: Response, + pretty_response: bool = True) -> Union[dict, str]: + """ + description: This method is responsible to return an indented json file + or a dict. + + response: file that will be indented. + + return: Indented json file or a dict. + """ + if response.status_code >= self.HTTP_ERROR: + logging.error(response.text) + elif ( + response.status_code != self.HTTP_SUCCESS + and response.status_code != self.HTTP_CREATED + ): + logging.warning(response.json()["result"]) + return {} + else: + if pretty_response: + return json.dumps(response.json(), indent=4, sort_keys=True) + else: + return response.json() +
def treatment(self, response: Response, + pretty_response: bool = True) -> Union[dict, str]: + """ + description: This method is responsible to return an indented json file + or a dict. + + response: file that will be indented. + + return: Indented json file or a dict. + """ + if response.status_code >= self.HTTP_ERROR: + logging.error(response.text) + elif ( + response.status_code != self.HTTP_SUCCESS + and response.status_code != self.HTTP_CREATED + ): + logging.warning(response.json()["result"]) + return {} + else: + if pretty_response: + return json.dumps(response.json(), indent=4, sort_keys=True) + else: + return response.json() +
description: This method is responsible to return an indented json file +or a dict.
+ +response: file that will be indented.
+ +return: Indented json file or a dict.
+from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class BuilderSparkMl: + __TRAIN_FIELD = "trainDatasetName" + __TEST_FIELD = "testDatasetName" + __CODE_FIELD = "modelingCode" + __CLASSIFIERS_LIST_FIELD = "classifiersList" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/builder/sparkml" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def run_spark_ml_sync(self, + train_dataset_name: str, + test_dataset_name: str, + modeling_code: str, + model_classifiers: list, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method call runs several steps of a machine + learning pipeline (transform, tune, train and evaluate, for instance) + using a model code and several classifiers. It represents a way to run + an entire pipeline. The caller waits until the method execution ends, + since it is a synchronous method. + + train_dataset_name: Represent final train dataset. + test_dataset_name: Represent final test dataset. + modeling_code: Represent Python3 code for pyspark pre-processing model + model_classifiers: list of initial classifiers to be used in the model + pretty_response: if True it represents a result useful for visualization + + return: The set of predictions (URIs of them). + """ + + request_body_content = { + self.__TRAIN_FIELD: train_dataset_name, + self.__TEST_FIELD: test_dataset_name, + self.__CODE_FIELD: modeling_code, + self.__CLASSIFIERS_LIST_FIELD: model_classifiers, + } + response = requests.post(url=self.__service_url, + json=request_body_content) + + for classifier in model_classifiers: + self.__observer.wait(f'{test_dataset_name}{classifier}') + + return self.__response_treat.treatment(response, pretty_response) + + def run_spark_ml_async(self, + train_dataset_name: str, + test_dataset_name: str, + modeling_code: str, + model_classifiers: list, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method call runs several steps of a machine + learning pipeline (transform, tune, train and evaluate, for instance) + using a model code and several classifiers. It represents a way to run + an entire pipeline. The caller does not wait until the method execution + ends, since it is an asynchronous method. + + train_dataset_name: Represent final train dataset. + test_dataset_name: Represent final test dataset. + modeling_code: Represent Python3 code for pyspark pre-processing model + model_classifiers: list of initial classifiers to be used in the model + pretty_response: if True it represents a result useful for visualization + + return: the URL to retrieve the Spark pipeline result + """ + + request_body_content = { + self.__TRAIN_FIELD: train_dataset_name, + self.__TEST_FIELD: test_dataset_name, + self.__CODE_FIELD: modeling_code, + self.__CLASSIFIERS_LIST_FIELD: model_classifiers, + } + response = requests.post(url=self.__service_url, + json=request_body_content) + + return self.__response_treat.treatment(response, pretty_response) + + def search_all_builders(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all model predictions metadata. It + does not retrieve the model predictions content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A list with all model predictions metadata stored in Learning + Orchestra or an empty result. + """ + + response = self.__entity_reader.read_all_instances_from_entity() + + return self.__response_treat.treatment(response, pretty_response) + + def search_builder_register_predictions(self, + builder_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the model + predictions content. + + pretty_response: If true it returns a string, otherwise a dictionary. + builder_name: Represents the model predictions name. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if the + pipeline runs incorrectly. The current page is also returned to be used + in future content requests. + """ + + response = self.__entity_reader.read_entity_content( + builder_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def search_builder(self, builder_name: str, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving a specific + model metadata. + + pretty_response: If true return indented string, else return dict. + builder_name: Represents the model predictions name. + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: Specific model prediction metadata stored in Learning Orchestra + or an error if there is no such projections. + """ + response = self.search_builder_register_predictions( + builder_name, limit=1, + pretty_response=pretty_response) + + return response + + def delete_builder(self, builder_name: str, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting a model prediction. + The delete operation is always asynchronous, + since the deletion is performed in background. + + pretty_response: If true it returns a string, otherwise a dictionary. + builder_name: Represents the pipeline name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + cluster_url_dataset = f'{self.__service_url}/{builder_name}' + + response = requests.delete(cluster_url_dataset) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the run_spark_ml_async method. + + dataset_name: Represents the pipeline name. + timeout: Represents the time in seconds to wait for a builder to + finish its run. + + return: JSON object with an error message, a warning message or a + correct execution of a pipeline + """ + return self.__observer.wait(dataset_name, timeout) +
class BuilderSparkMl: + __TRAIN_FIELD = "trainDatasetName" + __TEST_FIELD = "testDatasetName" + __CODE_FIELD = "modelingCode" + __CLASSIFIERS_LIST_FIELD = "classifiersList" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/builder/sparkml" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def run_spark_ml_sync(self, + train_dataset_name: str, + test_dataset_name: str, + modeling_code: str, + model_classifiers: list, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method call runs several steps of a machine + learning pipeline (transform, tune, train and evaluate, for instance) + using a model code and several classifiers. It represents a way to run + an entire pipeline. The caller waits until the method execution ends, + since it is a synchronous method. + + train_dataset_name: Represent final train dataset. + test_dataset_name: Represent final test dataset. + modeling_code: Represent Python3 code for pyspark pre-processing model + model_classifiers: list of initial classifiers to be used in the model + pretty_response: if True it represents a result useful for visualization + + return: The set of predictions (URIs of them). + """ + + request_body_content = { + self.__TRAIN_FIELD: train_dataset_name, + self.__TEST_FIELD: test_dataset_name, + self.__CODE_FIELD: modeling_code, + self.__CLASSIFIERS_LIST_FIELD: model_classifiers, + } + response = requests.post(url=self.__service_url, + json=request_body_content) + + for classifier in model_classifiers: + self.__observer.wait(f'{test_dataset_name}{classifier}') + + return self.__response_treat.treatment(response, pretty_response) + + def run_spark_ml_async(self, + train_dataset_name: str, + test_dataset_name: str, + modeling_code: str, + model_classifiers: list, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method call runs several steps of a machine + learning pipeline (transform, tune, train and evaluate, for instance) + using a model code and several classifiers. It represents a way to run + an entire pipeline. The caller does not wait until the method execution + ends, since it is an asynchronous method. + + train_dataset_name: Represent final train dataset. + test_dataset_name: Represent final test dataset. + modeling_code: Represent Python3 code for pyspark pre-processing model + model_classifiers: list of initial classifiers to be used in the model + pretty_response: if True it represents a result useful for visualization + + return: the URL to retrieve the Spark pipeline result + """ + + request_body_content = { + self.__TRAIN_FIELD: train_dataset_name, + self.__TEST_FIELD: test_dataset_name, + self.__CODE_FIELD: modeling_code, + self.__CLASSIFIERS_LIST_FIELD: model_classifiers, + } + response = requests.post(url=self.__service_url, + json=request_body_content) + + return self.__response_treat.treatment(response, pretty_response) + + def search_all_builders(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all model predictions metadata. It + does not retrieve the model predictions content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A list with all model predictions metadata stored in Learning + Orchestra or an empty result. + """ + + response = self.__entity_reader.read_all_instances_from_entity() + + return self.__response_treat.treatment(response, pretty_response) + + def search_builder_register_predictions(self, + builder_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the model + predictions content. + + pretty_response: If true it returns a string, otherwise a dictionary. + builder_name: Represents the model predictions name. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if the + pipeline runs incorrectly. The current page is also returned to be used + in future content requests. + """ + + response = self.__entity_reader.read_entity_content( + builder_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def search_builder(self, builder_name: str, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving a specific + model metadata. + + pretty_response: If true return indented string, else return dict. + builder_name: Represents the model predictions name. + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: Specific model prediction metadata stored in Learning Orchestra + or an error if there is no such projections. + """ + response = self.search_builder_register_predictions( + builder_name, limit=1, + pretty_response=pretty_response) + + return response + + def delete_builder(self, builder_name: str, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting a model prediction. + The delete operation is always asynchronous, + since the deletion is performed in background. + + pretty_response: If true it returns a string, otherwise a dictionary. + builder_name: Represents the pipeline name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + cluster_url_dataset = f'{self.__service_url}/{builder_name}' + + response = requests.delete(cluster_url_dataset) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the run_spark_ml_async method. + + dataset_name: Represents the pipeline name. + timeout: Represents the time in seconds to wait for a builder to + finish its run. + + return: JSON object with an error message, a warning message or a + correct execution of a pipeline + """ + return self.__observer.wait(dataset_name, timeout) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/builder/sparkml" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def run_spark_ml_sync(self, + train_dataset_name: str, + test_dataset_name: str, + modeling_code: str, + model_classifiers: list, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method call runs several steps of a machine + learning pipeline (transform, tune, train and evaluate, for instance) + using a model code and several classifiers. It represents a way to run + an entire pipeline. The caller waits until the method execution ends, + since it is a synchronous method. + + train_dataset_name: Represent final train dataset. + test_dataset_name: Represent final test dataset. + modeling_code: Represent Python3 code for pyspark pre-processing model + model_classifiers: list of initial classifiers to be used in the model + pretty_response: if True it represents a result useful for visualization + + return: The set of predictions (URIs of them). + """ + + request_body_content = { + self.__TRAIN_FIELD: train_dataset_name, + self.__TEST_FIELD: test_dataset_name, + self.__CODE_FIELD: modeling_code, + self.__CLASSIFIERS_LIST_FIELD: model_classifiers, + } + response = requests.post(url=self.__service_url, + json=request_body_content) + + for classifier in model_classifiers: + self.__observer.wait(f'{test_dataset_name}{classifier}') + + return self.__response_treat.treatment(response, pretty_response) +
description: This method call runs several steps of a machine +learning pipeline (transform, tune, train and evaluate, for instance) +using a model code and several classifiers. It represents a way to run +an entire pipeline. The caller waits until the method execution ends, +since it is a synchronous method.
+ +train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark pre-processing model +model_classifiers: list of initial classifiers to be used in the model +pretty_response: if True it represents a result useful for visualization
+ +return: The set of predictions (URIs of them).
+def run_spark_ml_async(self, + train_dataset_name: str, + test_dataset_name: str, + modeling_code: str, + model_classifiers: list, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method call runs several steps of a machine + learning pipeline (transform, tune, train and evaluate, for instance) + using a model code and several classifiers. It represents a way to run + an entire pipeline. The caller does not wait until the method execution + ends, since it is an asynchronous method. + + train_dataset_name: Represent final train dataset. + test_dataset_name: Represent final test dataset. + modeling_code: Represent Python3 code for pyspark pre-processing model + model_classifiers: list of initial classifiers to be used in the model + pretty_response: if True it represents a result useful for visualization + + return: the URL to retrieve the Spark pipeline result + """ + + request_body_content = { + self.__TRAIN_FIELD: train_dataset_name, + self.__TEST_FIELD: test_dataset_name, + self.__CODE_FIELD: modeling_code, + self.__CLASSIFIERS_LIST_FIELD: model_classifiers, + } + response = requests.post(url=self.__service_url, + json=request_body_content) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method call runs several steps of a machine +learning pipeline (transform, tune, train and evaluate, for instance) +using a model code and several classifiers. It represents a way to run +an entire pipeline. The caller does not wait until the method execution +ends, since it is an asynchronous method.
+ +train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark pre-processing model +model_classifiers: list of initial classifiers to be used in the model +pretty_response: if True it represents a result useful for visualization
+ +return: the URL to retrieve the Spark pipeline result
+def search_all_builders(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all model predictions metadata. It + does not retrieve the model predictions content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A list with all model predictions metadata stored in Learning + Orchestra or an empty result. + """ + + response = self.__entity_reader.read_all_instances_from_entity() + + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all model predictions metadata. It +does not retrieve the model predictions content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: A list with all model predictions metadata stored in Learning +Orchestra or an empty result.
+def search_builder_register_predictions(self, + builder_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the model + predictions content. + + pretty_response: If true it returns a string, otherwise a dictionary. + builder_name: Represents the model predictions name. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if the + pipeline runs incorrectly. The current page is also returned to be used + in future content requests. + """ + + response = self.__entity_reader.read_entity_content( + builder_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving the model +predictions content.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +builder_name: Represents the model predictions name. +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: A page with some tuples or registers inside or an error if the +pipeline runs incorrectly. The current page is also returned to be used +in future content requests.
+def search_builder(self, builder_name: str, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving a specific + model metadata. + + pretty_response: If true return indented string, else return dict. + builder_name: Represents the model predictions name. + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: Specific model prediction metadata stored in Learning Orchestra + or an error if there is no such projections. + """ + response = self.search_builder_register_predictions( + builder_name, limit=1, + pretty_response=pretty_response) + + return response +
description: This method is responsible for retrieving a specific +model metadata.
+ +pretty_response: If true return indented string, else return dict. +builder_name: Represents the model predictions name. +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: Specific model prediction metadata stored in Learning Orchestra +or an error if there is no such projections.
+def delete_builder(self, builder_name: str, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting a model prediction. + The delete operation is always asynchronous, + since the deletion is performed in background. + + pretty_response: If true it returns a string, otherwise a dictionary. + builder_name: Represents the pipeline name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + cluster_url_dataset = f'{self.__service_url}/{builder_name}' + + response = requests.delete(cluster_url_dataset) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting a model prediction. +The delete operation is always asynchronous, +since the deletion is performed in background.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +builder_name: Represents the pipeline name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the run_spark_ml_async method. + + dataset_name: Represents the pipeline name. + timeout: Represents the time in seconds to wait for a builder to + finish its run. + + return: JSON object with an error message, a warning message or a + correct execution of a pipeline + """ + return self.__observer.wait(dataset_name, timeout) +
description: This method is responsible to create a synchronization +barrier for the run_spark_ml_async method.
+ +dataset_name: Represents the pipeline name. +timeout: Represents the time in seconds to wait for a builder to +finish its run.
+ +return: JSON object with an error message, a warning message or a +correct execution of a pipeline
+from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class Dataset: + __DATASET_NAME = "datasetName" + __URL = "datasetURI" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def insert_dataset_sync(self, + dataset_name: str, + url: str, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method is responsible to insert a dataset from a URI + synchronously, i.e., the caller waits until the dataset is inserted into + the Learning Orchestra storage mechanism. + + pretty_response: If true it returns a string, otherwise a dictionary. + dataset_name: Is the name of the dataset file that will be created. + url: Url to CSV file. + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = {self.__DATASET_NAME: dataset_name, + self.__URL: url} + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) + + def insert_dataset_async(self, + dataset_name: str, + url: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible to insert a dataset from a URI + asynchronously, i.e., the caller does not wait until the dataset is + inserted into the Learning Orchestra storage mechanism. Instead, the + caller receives a JSON object with a URL to proceed future calls to + verify if the dataset is inserted. + + pretty_response: If true return indented string, else return dict. + dataset_name: Is the name of the dataset file that will be created. + url: Url to CSV file. + + return: A JSON object with an error or warning message or a URL + indicating the correct operation (the caller must use such an URL to + proceed future checks to verify if the dataset is inserted - using wait + method). + """ + request_body = {self.__DATASET_NAME: dataset_name, + self.__URL: url} + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_datasets(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all datasets metadata, i.e., it does + not retrieve the dataset content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All datasets metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_dataset(self, dataset_name, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the dataset. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. If a + dataset was used by another task (Ex. projection, histogram, pca, tune + and so forth), it cannot be deleted. + + pretty_response: If true it returns a string, otherwise a dictionary. + dataset_name: Represents the dataset name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{dataset_name}' + response = requests.delete(request_url) + + return self.__response_treat.treatment(response, pretty_response) + + def search_dataset_content(self, + dataset_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the dataset + content + + pretty_response: If true it returns a string, otherwise a dictionary. + dataset_name: Is the name of the dataset file. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if there + is no such dataset. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + dataset_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the insert_dataset_async method. + + dataset_name: Represents the dataset name. + timeout: Represents the time in seconds to wait for a dataset + download to finish its run. + + return: JSON object with an error message, a warning message or a + correct execution of a pipeline + """ + return self.__observer.wait(dataset_name, timeout) +
class Dataset: + __DATASET_NAME = "datasetName" + __URL = "datasetURI" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def insert_dataset_sync(self, + dataset_name: str, + url: str, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method is responsible to insert a dataset from a URI + synchronously, i.e., the caller waits until the dataset is inserted into + the Learning Orchestra storage mechanism. + + pretty_response: If true it returns a string, otherwise a dictionary. + dataset_name: Is the name of the dataset file that will be created. + url: Url to CSV file. + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = {self.__DATASET_NAME: dataset_name, + self.__URL: url} + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) + + def insert_dataset_async(self, + dataset_name: str, + url: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible to insert a dataset from a URI + asynchronously, i.e., the caller does not wait until the dataset is + inserted into the Learning Orchestra storage mechanism. Instead, the + caller receives a JSON object with a URL to proceed future calls to + verify if the dataset is inserted. + + pretty_response: If true return indented string, else return dict. + dataset_name: Is the name of the dataset file that will be created. + url: Url to CSV file. + + return: A JSON object with an error or warning message or a URL + indicating the correct operation (the caller must use such an URL to + proceed future checks to verify if the dataset is inserted - using wait + method). + """ + request_body = {self.__DATASET_NAME: dataset_name, + self.__URL: url} + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_datasets(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all datasets metadata, i.e., it does + not retrieve the dataset content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All datasets metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_dataset(self, dataset_name, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the dataset. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. If a + dataset was used by another task (Ex. projection, histogram, pca, tune + and so forth), it cannot be deleted. + + pretty_response: If true it returns a string, otherwise a dictionary. + dataset_name: Represents the dataset name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{dataset_name}' + response = requests.delete(request_url) + + return self.__response_treat.treatment(response, pretty_response) + + def search_dataset_content(self, + dataset_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the dataset + content + + pretty_response: If true it returns a string, otherwise a dictionary. + dataset_name: Is the name of the dataset file. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if there + is no such dataset. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + dataset_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the insert_dataset_async method. + + dataset_name: Represents the dataset name. + timeout: Represents the time in seconds to wait for a dataset + download to finish its run. + + return: JSON object with an error message, a warning message or a + correct execution of a pipeline + """ + return self.__observer.wait(dataset_name, timeout) +
def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def insert_dataset_sync(self, + dataset_name: str, + url: str, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method is responsible to insert a dataset from a URI + synchronously, i.e., the caller waits until the dataset is inserted into + the Learning Orchestra storage mechanism. + + pretty_response: If true it returns a string, otherwise a dictionary. + dataset_name: Is the name of the dataset file that will be created. + url: Url to CSV file. + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = {self.__DATASET_NAME: dataset_name, + self.__URL: url} + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible to insert a dataset from a URI +synchronously, i.e., the caller waits until the dataset is inserted into +the Learning Orchestra storage mechanism.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +dataset_name: Is the name of the dataset file that will be created. +url: Url to CSV file.
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def insert_dataset_async(self, + dataset_name: str, + url: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible to insert a dataset from a URI + asynchronously, i.e., the caller does not wait until the dataset is + inserted into the Learning Orchestra storage mechanism. Instead, the + caller receives a JSON object with a URL to proceed future calls to + verify if the dataset is inserted. + + pretty_response: If true return indented string, else return dict. + dataset_name: Is the name of the dataset file that will be created. + url: Url to CSV file. + + return: A JSON object with an error or warning message or a URL + indicating the correct operation (the caller must use such an URL to + proceed future checks to verify if the dataset is inserted - using wait + method). + """ + request_body = {self.__DATASET_NAME: dataset_name, + self.__URL: url} + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible to insert a dataset from a URI +asynchronously, i.e., the caller does not wait until the dataset is +inserted into the Learning Orchestra storage mechanism. Instead, the +caller receives a JSON object with a URL to proceed future calls to +verify if the dataset is inserted.
+ +pretty_response: If true return indented string, else return dict. +dataset_name: Is the name of the dataset file that will be created. +url: Url to CSV file.
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation (the caller must use such an URL to +proceed future checks to verify if the dataset is inserted - using wait +method).
+def search_all_datasets(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all datasets metadata, i.e., it does + not retrieve the dataset content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All datasets metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all datasets metadata, i.e., it does +not retrieve the dataset content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: All datasets metadata stored in Learning Orchestra or an empty +result.
+def delete_dataset(self, dataset_name, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the dataset. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. If a + dataset was used by another task (Ex. projection, histogram, pca, tune + and so forth), it cannot be deleted. + + pretty_response: If true it returns a string, otherwise a dictionary. + dataset_name: Represents the dataset name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{dataset_name}' + response = requests.delete(request_url) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting the dataset. +This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. If a + dataset was used by another task (Ex. projection, histogram, pca, tune + and so forth), it cannot be deleted.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +dataset_name: Represents the dataset name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def search_dataset_content(self, + dataset_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the dataset + content + + pretty_response: If true it returns a string, otherwise a dictionary. + dataset_name: Is the name of the dataset file. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if there + is no such dataset. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + dataset_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving the dataset +content
+ +pretty_response: If true it returns a string, otherwise a dictionary. +dataset_name: Is the name of the dataset file. +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: A page with some tuples or registers inside or an error if there +is no such dataset. The current page is also returned to be used in +future content requests.
+def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the insert_dataset_async method. + + dataset_name: Represents the dataset name. + timeout: Represents the time in seconds to wait for a dataset + download to finish its run. + + return: JSON object with an error message, a warning message or a + correct execution of a pipeline + """ + return self.__observer.wait(dataset_name, timeout) +
description: This method is responsible to create a synchronization +barrier for the insert_dataset_async method.
+ +dataset_name: Represents the dataset name. +timeout: Represents the time in seconds to wait for a dataset +download to finish its run.
+ +return: JSON object with an error message, a warning message or a +correct execution of a pipeline
+from ._dataset import Dataset + + +class DatasetCsv(Dataset): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/dataset/csv" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class DatasetCsv(Dataset): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/dataset/csv" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/dataset/csv" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from ._dataset import Dataset + + +class DatasetGeneric(Dataset): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/dataset/generic" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class DatasetGeneric(Dataset): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/dataset/generic" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/dataset/generic" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class Evaluate: + __PARENT_NAME_FIELD = "parentName" + __MODEL_NAME_FIELD = "modelName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_evaluate_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an evaluation about a model in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be evaluated. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to evaluate a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_evaluate_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an evaluation about a model in async mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be evaluated. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to evaluate a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_evaluates(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all created evaluations, i.e., it + does not retrieve the specific evaluation content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All datasets metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_evaluate(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting an evaluation + result. This delete operation is asynchronous, so it does not lock the + caller until the deletion finished. Instead, it returns a JSON object + with a URL for a future use. The caller uses the wait method for delete + checks. If a dataset was used by another task (Ex. projection, + histogram, tune, and so forth), it cannot be deleted. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the model name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_evaluate_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the evaluation + content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some metadata inside or an error if there + is no such dataset. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_evaluate_async method and + delete_evaluate_async method. + + name: Represents the model name. + timeout: Represents the time in seconds to wait for an evaluation to + finish its run. + + return: JSON object with an error message, a warning message or a + correct evaluation result + """ + return self.__observer.wait(name, timeout) +
class Evaluate: + __PARENT_NAME_FIELD = "parentName" + __MODEL_NAME_FIELD = "modelName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_evaluate_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an evaluation about a model in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be evaluated. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to evaluate a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_evaluate_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an evaluation about a model in async mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be evaluated. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to evaluate a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_evaluates(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all created evaluations, i.e., it + does not retrieve the specific evaluation content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All datasets metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_evaluate(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting an evaluation + result. This delete operation is asynchronous, so it does not lock the + caller until the deletion finished. Instead, it returns a JSON object + with a URL for a future use. The caller uses the wait method for delete + checks. If a dataset was used by another task (Ex. projection, + histogram, tune, and so forth), it cannot be deleted. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the model name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_evaluate_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the evaluation + content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some metadata inside or an error if there + is no such dataset. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_evaluate_async method and + delete_evaluate_async method. + + name: Represents the model name. + timeout: Represents the time in seconds to wait for an evaluation to + finish its run. + + return: JSON object with an error message, a warning message or a + correct evaluation result + """ + return self.__observer.wait(name, timeout) +
def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def create_evaluate_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an evaluation about a model in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be evaluated. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to evaluate a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method runs an evaluation about a model in sync mode
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the model that will be evaluated. +parent_name: The name of the previous pipe in the pipeline +method_name: the name of the ML tool method used to evaluate a model +parameters: the set of parameters of the ML method defined previously
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def create_evaluate_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an evaluation about a model in async mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be evaluated. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to evaluate a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) +
description: This method runs an evaluation about a model in async mode
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the model that will be evaluated. +parent_name: The name of the previous pipe in the pipeline +method_name: the name of the ML tool method used to evaluate a model +parameters: the set of parameters of the ML method defined previously
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def search_all_evaluates(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all created evaluations, i.e., it + does not retrieve the specific evaluation content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All datasets metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all created evaluations, i.e., it +does not retrieve the specific evaluation content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: All datasets metadata stored in Learning Orchestra or an empty +result.
+def delete_evaluate(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting an evaluation + result. This delete operation is asynchronous, so it does not lock the + caller until the deletion finished. Instead, it returns a JSON object + with a URL for a future use. The caller uses the wait method for delete + checks. If a dataset was used by another task (Ex. projection, + histogram, tune, and so forth), it cannot be deleted. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the model name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting an evaluation +result. This delete operation is asynchronous, so it does not lock the +caller until the deletion finished. Instead, it returns a JSON object +with a URL for a future use. The caller uses the wait method for delete +checks. If a dataset was used by another task (Ex. projection, +histogram, tune, and so forth), it cannot be deleted.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Represents the model name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def search_evaluate_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the evaluation + content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some metadata inside or an error if there + is no such dataset. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving the evaluation +content
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the model. +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: A page with some metadata inside or an error if there +is no such dataset. The current page is also returned to be used in +future content requests.
+def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_evaluate_async method and + delete_evaluate_async method. + + name: Represents the model name. + timeout: Represents the time in seconds to wait for an evaluation to + finish its run. + + return: JSON object with an error message, a warning message or a + correct evaluation result + """ + return self.__observer.wait(name, timeout) +
description: This method is responsible to create a synchronization +barrier for the create_evaluate_async method and +delete_evaluate_async method.
+ +name: Represents the model name. +timeout: Represents the time in seconds to wait for an evaluation to +finish its run.
+ +return: JSON object with an error message, a warning message or a +correct evaluation result
+from ._evaluate import Evaluate + + +class EvaluateScikitLearn(Evaluate): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/evaluate/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class EvaluateScikitLearn(Evaluate): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/evaluate/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/evaluate/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from ._evaluate import Evaluate + + +class EvaluateTensorflow(Evaluate): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/evaluate/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class EvaluateTensorflow(Evaluate): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/evaluate/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/evaluate/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class Explore: + __PARENT_NAME_FIELD = "parentName" + __MODEL_NAME_FIELD = "modelName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_explore_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an evaluation about a model in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be explored. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to explore a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_explore_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an explore service about a model in async + mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be explored. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to explore a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_explores(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all created explorations, i.e., it + does not retrieve the specific explore content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All datasets metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_explore(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting an explore result. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the wait method for delete + checks. If a dataset was used by another task (Ex. projection, + histogram, tune and so forth), it cannot be deleted. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the model name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_explore_image(self, + name: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the explore + image to be plotted + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the explore instance. + + return: An URL with a link for an image or an error if there + is no such result. + """ + + response = self.__entity_reader.read_entity_content( + name) + + return self.__response_treat.treatment(response, pretty_response) + + def search_explore_metadata(self, + name: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the explore + metadata image. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the explore instance. + + return: A page with some metadata inside or an error if there + is no such dataset. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_explore_image_metadata(name) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_explore_async method, delete_explore_async + method. + + name: Represents the model name. + timeout: Represents the time in seconds to wait for an explore to + finish its run. + + return: JSON object with an error message, a warning message or a + correct explore result (the image URL as an explore result) + """ + return self.__observer.wait(name, timeout) +
class Explore: + __PARENT_NAME_FIELD = "parentName" + __MODEL_NAME_FIELD = "modelName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_explore_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an evaluation about a model in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be explored. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to explore a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_explore_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an explore service about a model in async + mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be explored. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to explore a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_explores(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all created explorations, i.e., it + does not retrieve the specific explore content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All datasets metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_explore(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting an explore result. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the wait method for delete + checks. If a dataset was used by another task (Ex. projection, + histogram, tune and so forth), it cannot be deleted. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the model name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_explore_image(self, + name: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the explore + image to be plotted + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the explore instance. + + return: An URL with a link for an image or an error if there + is no such result. + """ + + response = self.__entity_reader.read_entity_content( + name) + + return self.__response_treat.treatment(response, pretty_response) + + def search_explore_metadata(self, + name: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the explore + metadata image. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the explore instance. + + return: A page with some metadata inside or an error if there + is no such dataset. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_explore_image_metadata(name) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_explore_async method, delete_explore_async + method. + + name: Represents the model name. + timeout: Represents the time in seconds to wait for an explore to + finish its run. + + return: JSON object with an error message, a warning message or a + correct explore result (the image URL as an explore result) + """ + return self.__observer.wait(name, timeout) +
def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def create_explore_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an evaluation about a model in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be explored. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to explore a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method runs an evaluation about a model in sync mode
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the model that will be explored. +parent_name: The name of the previous pipe in the pipeline +method_name: the name of the ML tool method used to explore a model +parameters: the set of parameters of the ML method defined previously
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def create_explore_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method runs an explore service about a model in async + mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be explored. + parent_name: The name of the previous pipe in the pipeline + method_name: the name of the ML tool method used to explore a model + parameters: the set of parameters of the ML method defined previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) +
description: This method runs an explore service about a model in async +mode
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the model that will be explored. +parent_name: The name of the previous pipe in the pipeline +method_name: the name of the ML tool method used to explore a model +parameters: the set of parameters of the ML method defined previously
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def search_all_explores(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all created explorations, i.e., it + does not retrieve the specific explore content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All datasets metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all created explorations, i.e., it +does not retrieve the specific explore content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: All datasets metadata stored in Learning Orchestra or an empty +result.
+def delete_explore(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting an explore result. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the wait method for delete + checks. If a dataset was used by another task (Ex. projection, + histogram, tune and so forth), it cannot be deleted. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the model name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting an explore result. +This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the wait method for delete + checks. If a dataset was used by another task (Ex. projection, + histogram, tune and so forth), it cannot be deleted.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Represents the model name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def search_explore_image(self, + name: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the explore + image to be plotted + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the explore instance. + + return: An URL with a link for an image or an error if there + is no such result. + """ + + response = self.__entity_reader.read_entity_content( + name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving the explore +image to be plotted
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the explore instance.
+ +return: An URL with a link for an image or an error if there +is no such result.
+def search_explore_metadata(self, + name: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the explore + metadata image. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the explore instance. + + return: A page with some metadata inside or an error if there + is no such dataset. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_explore_image_metadata(name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving the explore +metadata image.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the explore instance.
+ +return: A page with some metadata inside or an error if there +is no such dataset. The current page is also returned to be used in +future content requests.
+def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_explore_async method, delete_explore_async + method. + + name: Represents the model name. + timeout: Represents the time in seconds to wait for an explore to + finish its run. + + return: JSON object with an error message, a warning message or a + correct explore result (the image URL as an explore result) + """ + return self.__observer.wait(name, timeout) +
description: This method is responsible to create a synchronization +barrier for the create_explore_async method, delete_explore_async +method.
+ +name: Represents the model name. +timeout: Represents the time in seconds to wait for an explore to +finish its run.
+ +return: JSON object with an error message, a warning message or a +correct explore result (the image URL as an explore result)
+from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +import requests +from typing import Union +from learning_orchestra_client._util._entity_reader import EntityReader + + +class ExploreHistogram: + __INPUT_NAME = "inputDatasetName" + __OUTPUT_NAME = "outputDatasetName" + __FIELDS = "names" + + def __init__(self, cluster_ip: str): + self.__cluster_ip = cluster_ip + self.__api_path = "/api/learningOrchestra/v1/explore/histogram" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__observer = Observer(self.__cluster_ip) + self.__entity_reader = EntityReader(self.__service_url) + + def run_histogram_sync(self, + dataset_name: str, + histogram_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method creates a histogram + synchronously, so the caller waits until the histogram is inserted into + the Learning Orchestra storage mechanism. + + dataset_name: Represents the name of dataset. + histogram_name: Represents the name of histogram. + fields: Represents a list of attributes. + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A JSON object with error or warning messages. In case of + success, it returns a histogram. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: histogram_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) + + def run_histogram_async(self, + dataset_name: str, + histogram_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method creates a histogram + asynchronously, so the caller does not wait until the histogram is + inserted into the Learning Orchestra storage mechanism. + + dataset_name: Represents the name of dataset. + histogram_name: Represents the name of histogram. + fields: Represents a list of attributes. + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A JSON object with error or warning messages. In case of + success, it returns a histogram. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: histogram_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + + return self.__response_treat.treatment(response, pretty_response) + + def search_all_histograms(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all histogram metadata, it does not + retrieve the histogram content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A list with all histogram metadata stored in Learning Orchestra + or an empty result. + """ + + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def search_histogram_content(self, + histogram_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the histogram + content. + + pretty_response: If true it returns a string, otherwise a dictionary. + histogram_name: Represents the histogram name. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if there + is no such projection. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + histogram_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def delete_histogram(self, histogram_name: str, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method is responsible for deleting a histogram. + The delete operation is always asynchronous, + since the deletion is performed in background. + + pretty_response: If true it returns a string, otherwise a dictionary. + histogram_name: Represents the histogram name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + cluster_url_histogram = f'{self.__service_url}/{histogram_name}' + response = requests.delete(cluster_url_histogram) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the run_histogram_async method or delete_histogram + method. + + name: Represents the histogram name. + timeout: Represents the time in seconds to wait for a histogram to + finish its run. + + return: JSON object with an error message, a warning message or a + correct histogram result + """ + return self.__observer.wait(name, timeout) +
class ExploreHistogram: + __INPUT_NAME = "inputDatasetName" + __OUTPUT_NAME = "outputDatasetName" + __FIELDS = "names" + + def __init__(self, cluster_ip: str): + self.__cluster_ip = cluster_ip + self.__api_path = "/api/learningOrchestra/v1/explore/histogram" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__observer = Observer(self.__cluster_ip) + self.__entity_reader = EntityReader(self.__service_url) + + def run_histogram_sync(self, + dataset_name: str, + histogram_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method creates a histogram + synchronously, so the caller waits until the histogram is inserted into + the Learning Orchestra storage mechanism. + + dataset_name: Represents the name of dataset. + histogram_name: Represents the name of histogram. + fields: Represents a list of attributes. + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A JSON object with error or warning messages. In case of + success, it returns a histogram. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: histogram_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) + + def run_histogram_async(self, + dataset_name: str, + histogram_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method creates a histogram + asynchronously, so the caller does not wait until the histogram is + inserted into the Learning Orchestra storage mechanism. + + dataset_name: Represents the name of dataset. + histogram_name: Represents the name of histogram. + fields: Represents a list of attributes. + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A JSON object with error or warning messages. In case of + success, it returns a histogram. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: histogram_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + + return self.__response_treat.treatment(response, pretty_response) + + def search_all_histograms(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all histogram metadata, it does not + retrieve the histogram content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A list with all histogram metadata stored in Learning Orchestra + or an empty result. + """ + + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def search_histogram_content(self, + histogram_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the histogram + content. + + pretty_response: If true it returns a string, otherwise a dictionary. + histogram_name: Represents the histogram name. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if there + is no such projection. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + histogram_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def delete_histogram(self, histogram_name: str, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method is responsible for deleting a histogram. + The delete operation is always asynchronous, + since the deletion is performed in background. + + pretty_response: If true it returns a string, otherwise a dictionary. + histogram_name: Represents the histogram name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + cluster_url_histogram = f'{self.__service_url}/{histogram_name}' + response = requests.delete(cluster_url_histogram) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the run_histogram_async method or delete_histogram + method. + + name: Represents the histogram name. + timeout: Represents the time in seconds to wait for a histogram to + finish its run. + + return: JSON object with an error message, a warning message or a + correct histogram result + """ + return self.__observer.wait(name, timeout) +
def __init__(self, cluster_ip: str): + self.__cluster_ip = cluster_ip + self.__api_path = "/api/learningOrchestra/v1/explore/histogram" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__observer = Observer(self.__cluster_ip) + self.__entity_reader = EntityReader(self.__service_url) +
def run_histogram_sync(self, + dataset_name: str, + histogram_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method creates a histogram + synchronously, so the caller waits until the histogram is inserted into + the Learning Orchestra storage mechanism. + + dataset_name: Represents the name of dataset. + histogram_name: Represents the name of histogram. + fields: Represents a list of attributes. + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A JSON object with error or warning messages. In case of + success, it returns a histogram. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: histogram_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method creates a histogram +synchronously, so the caller waits until the histogram is inserted into +the Learning Orchestra storage mechanism.
+ +dataset_name: Represents the name of dataset. +histogram_name: Represents the name of histogram. +fields: Represents a list of attributes. +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: A JSON object with error or warning messages. In case of +success, it returns a histogram.
+def run_histogram_async(self, + dataset_name: str, + histogram_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method creates a histogram + asynchronously, so the caller does not wait until the histogram is + inserted into the Learning Orchestra storage mechanism. + + dataset_name: Represents the name of dataset. + histogram_name: Represents the name of histogram. + fields: Represents a list of attributes. + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A JSON object with error or warning messages. In case of + success, it returns a histogram. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: histogram_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method creates a histogram +asynchronously, so the caller does not wait until the histogram is +inserted into the Learning Orchestra storage mechanism.
+ +dataset_name: Represents the name of dataset. +histogram_name: Represents the name of histogram. +fields: Represents a list of attributes. +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: A JSON object with error or warning messages. In case of +success, it returns a histogram.
+def search_all_histograms(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all histogram metadata, it does not + retrieve the histogram content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A list with all histogram metadata stored in Learning Orchestra + or an empty result. + """ + + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all histogram metadata, it does not +retrieve the histogram content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: A list with all histogram metadata stored in Learning Orchestra +or an empty result.
+def search_histogram_content(self, + histogram_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the histogram + content. + + pretty_response: If true it returns a string, otherwise a dictionary. + histogram_name: Represents the histogram name. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if there + is no such projection. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + histogram_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving the histogram +content.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +histogram_name: Represents the histogram name. +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: A page with some tuples or registers inside or an error if there +is no such projection. The current page is also returned to be used in +future content requests.
+def delete_histogram(self, histogram_name: str, + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method is responsible for deleting a histogram. + The delete operation is always asynchronous, + since the deletion is performed in background. + + pretty_response: If true it returns a string, otherwise a dictionary. + histogram_name: Represents the histogram name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + cluster_url_histogram = f'{self.__service_url}/{histogram_name}' + response = requests.delete(cluster_url_histogram) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting a histogram. +The delete operation is always asynchronous, +since the deletion is performed in background.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +histogram_name: Represents the histogram name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the run_histogram_async method or delete_histogram + method. + + name: Represents the histogram name. + timeout: Represents the time in seconds to wait for a histogram to + finish its run. + + return: JSON object with an error message, a warning message or a + correct histogram result + """ + return self.__observer.wait(name, timeout) +
description: This method is responsible to create a synchronization +barrier for the run_histogram_async method or delete_histogram +method.
+ +name: Represents the histogram name. +timeout: Represents the time in seconds to wait for a histogram to +finish its run.
+ +return: JSON object with an error message, a warning message or a +correct histogram result
+from ._explore import Explore + + +class ExploreScikitLearn(Explore): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/explore/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class ExploreScikitLearn(Explore): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/explore/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/explore/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from ._explore import Explore + + +class ExploreTensorflow(Explore): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/explore/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class ExploreTensorflow(Explore): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/explore/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/explore/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class FunctionPython: + __CODE_FIELD = "function" + __PARAMETERS_FIELD = "functionParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/function/python" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def run_function_sync(self, + name: str, + parameters: dict, + code: str, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a python 3 code in sync mode, so it + represents a wildcard for the data scientist. It can be used when + train, predict, tune, explore or any other pipe must be customized. The + function is also useful for new pipes. pretty_response: If true it + returns a string, otherwise a dictionary. + + name: Is the name of the object stored in Learning Orchestra storage + system (volume or mongoDB). + url: Url to CSV file. + + return: A JSON object with an error or warning message or the correct + operation result. + """ + request_body = { + self.__NAME_FIELD: name, + self.__PARAMETERS_FIELD: parameters, + self.__CODE_FIELD: code, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def run_function_async(self, + name: str, + parameters: dict, + code: str, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a python 3 code in async mode, so it + represents a wildcard for the data scientist. It does not lock the + caller, so a wait method must be used. It can be used when train, + predict, tune, explore or any other pipe must be customized. The + function is also useful for new pipes. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the function to be called + code: the Python code + parameters: the parameters of the function being called + + return: A JSON object with an error or warning message or the correct + operation result. + """ + request_body = { + self.__NAME_FIELD: name, + self.__PARAMETERS_FIELD: parameters, + self.__CODE_FIELD: code, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_executions(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all created functions metadata, + i.e., it does not retrieve the function result content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All function executions metadata stored in Learning Orchestra + or an empty result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_execution(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the function. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the function name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_execution_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the function + results, including metadata. A function is executed many times, using + different parameters, + thus many results are stored + in Learning Orchestra. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the function. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: + A page with some function results inside or an error if there + is no such function. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the run_function_async method or delete_function method. + + name: Represents the function name. + timeout: Represents the time in seconds to wait for a function to + finish its run. + + return: JSON object with an error message, a warning message or a + correct function result + """ + return self.__observer.wait(dataset_name, timeout) +
class FunctionPython: + __CODE_FIELD = "function" + __PARAMETERS_FIELD = "functionParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/function/python" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def run_function_sync(self, + name: str, + parameters: dict, + code: str, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a python 3 code in sync mode, so it + represents a wildcard for the data scientist. It can be used when + train, predict, tune, explore or any other pipe must be customized. The + function is also useful for new pipes. pretty_response: If true it + returns a string, otherwise a dictionary. + + name: Is the name of the object stored in Learning Orchestra storage + system (volume or mongoDB). + url: Url to CSV file. + + return: A JSON object with an error or warning message or the correct + operation result. + """ + request_body = { + self.__NAME_FIELD: name, + self.__PARAMETERS_FIELD: parameters, + self.__CODE_FIELD: code, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def run_function_async(self, + name: str, + parameters: dict, + code: str, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a python 3 code in async mode, so it + represents a wildcard for the data scientist. It does not lock the + caller, so a wait method must be used. It can be used when train, + predict, tune, explore or any other pipe must be customized. The + function is also useful for new pipes. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the function to be called + code: the Python code + parameters: the parameters of the function being called + + return: A JSON object with an error or warning message or the correct + operation result. + """ + request_body = { + self.__NAME_FIELD: name, + self.__PARAMETERS_FIELD: parameters, + self.__CODE_FIELD: code, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_executions(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all created functions metadata, + i.e., it does not retrieve the function result content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All function executions metadata stored in Learning Orchestra + or an empty result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_execution(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the function. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the function name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_execution_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the function + results, including metadata. A function is executed many times, using + different parameters, + thus many results are stored + in Learning Orchestra. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the function. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: + A page with some function results inside or an error if there + is no such function. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the run_function_async method or delete_function method. + + name: Represents the function name. + timeout: Represents the time in seconds to wait for a function to + finish its run. + + return: JSON object with an error message, a warning message or a + correct function result + """ + return self.__observer.wait(dataset_name, timeout) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/function/python" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def run_function_sync(self, + name: str, + parameters: dict, + code: str, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a python 3 code in sync mode, so it + represents a wildcard for the data scientist. It can be used when + train, predict, tune, explore or any other pipe must be customized. The + function is also useful for new pipes. pretty_response: If true it + returns a string, otherwise a dictionary. + + name: Is the name of the object stored in Learning Orchestra storage + system (volume or mongoDB). + url: Url to CSV file. + + return: A JSON object with an error or warning message or the correct + operation result. + """ + request_body = { + self.__NAME_FIELD: name, + self.__PARAMETERS_FIELD: parameters, + self.__CODE_FIELD: code, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method runs a python 3 code in sync mode, so it +represents a wildcard for the data scientist. It can be used when +train, predict, tune, explore or any other pipe must be customized. The +function is also useful for new pipes. pretty_response: If true it +returns a string, otherwise a dictionary.
+ +name: Is the name of the object stored in Learning Orchestra storage +system (volume or mongoDB). +url: Url to CSV file.
+ +return: A JSON object with an error or warning message or the correct +operation result.
+def run_function_async(self, + name: str, + parameters: dict, + code: str, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a python 3 code in async mode, so it + represents a wildcard for the data scientist. It does not lock the + caller, so a wait method must be used. It can be used when train, + predict, tune, explore or any other pipe must be customized. The + function is also useful for new pipes. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the function to be called + code: the Python code + parameters: the parameters of the function being called + + return: A JSON object with an error or warning message or the correct + operation result. + """ + request_body = { + self.__NAME_FIELD: name, + self.__PARAMETERS_FIELD: parameters, + self.__CODE_FIELD: code, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) +
description: This method runs a python 3 code in async mode, so it +represents a wildcard for the data scientist. It does not lock the +caller, so a wait method must be used. It can be used when train, +predict, tune, explore or any other pipe must be customized. The +function is also useful for new pipes.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the function to be called +code: the Python code +parameters: the parameters of the function being called
+ +return: A JSON object with an error or warning message or the correct +operation result.
+def search_all_executions(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all created functions metadata, + i.e., it does not retrieve the function result content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All function executions metadata stored in Learning Orchestra + or an empty result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all created functions metadata, +i.e., it does not retrieve the function result content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: All function executions metadata stored in Learning Orchestra +or an empty result.
+def delete_execution(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the function. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the function name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting the function. +This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Represents the function name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def search_execution_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the function + results, including metadata. A function is executed many times, using + different parameters, + thus many results are stored + in Learning Orchestra. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the function. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: + A page with some function results inside or an error if there + is no such function. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving the function +results, including metadata. A function is executed many times, using +different parameters, +thus many results are stored +in Learning Orchestra.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the function. +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: + A page with some function results inside or an error if there +is no such function. The current page is also returned to be used in +future content requests.
+def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the run_function_async method or delete_function method. + + name: Represents the function name. + timeout: Represents the time in seconds to wait for a function to + finish its run. + + return: JSON object with an error message, a warning message or a + correct function result + """ + return self.__observer.wait(dataset_name, timeout) +
description: This method is responsible to create a synchronization +barrier for the run_function_async method or delete_function method.
+ +name: Represents the function name. +timeout: Represents the time in seconds to wait for a function to +finish its run.
+ +return: JSON object with an error message, a warning message or a +correct function result
+from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class Model: + __CLASS_FIELD = "class" + __MODULE_PATH_FIELD = "modulePath" + __ClASS_PARAMETERS_FIELD = "classParameters" + __NAME_FIELD = "modelName" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_model_sync(self, + name: str, + module_path: str, + class_name: str, + class_parameters: dict, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a model creation in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be created. + class_name: is the name of the class to be executed + module_path: The name of the package of the ML tool used + (Ex. Scikit-learn or TensorFlow) + class_parameters: the set of parameters of the ML class defined + previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__CLASS_FIELD: class_name, + self.__MODULE_PATH_FIELD: module_path, + self.__ClASS_PARAMETERS_FIELD: class_parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_model_async(self, + name: str, + module_path: str, + class_name: str, + class_parameters: dict, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a model creation in async mode, thus it + requires a wait method call + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be created. + class_name: is the name of the class to be executed + module_path: The name of the package of the ML tool used + (Ex. Scikit-learn or TensorFlow) + class_parameters: the set of parameters of the ML class defined + previously + + return: A JSON object with an error or warning message or a URL + indicating the future correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__CLASS_FIELD: class_name, + self.__MODULE_PATH_FIELD: module_path, + self.__ClASS_PARAMETERS_FIELD: class_parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + + return self.__response_treat.treatment(response, pretty_response) + + def search_all_models(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all models metadata, i.e., it does + not retrieve the model content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All models metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_model(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the model. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the model name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_model(self, name: str, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves a model metadata, i.e., it does + not retrieve the model content. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the model name + + return: A model metadata stored in Learning Orchestra or an empty + result. + """ + + response = self.__entity_reader.read_entity_content( + name) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_model_async method, delete_model method. + + name: Represents the model name. + timeout: Represents the time in seconds to wait for a model creation + to finish its run. + + return: JSON object with an error message, a warning message or a + correct model result + """ + return self.__observer.wait(name, timeout) +
class Model: + __CLASS_FIELD = "class" + __MODULE_PATH_FIELD = "modulePath" + __ClASS_PARAMETERS_FIELD = "classParameters" + __NAME_FIELD = "modelName" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_model_sync(self, + name: str, + module_path: str, + class_name: str, + class_parameters: dict, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a model creation in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be created. + class_name: is the name of the class to be executed + module_path: The name of the package of the ML tool used + (Ex. Scikit-learn or TensorFlow) + class_parameters: the set of parameters of the ML class defined + previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__CLASS_FIELD: class_name, + self.__MODULE_PATH_FIELD: module_path, + self.__ClASS_PARAMETERS_FIELD: class_parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_model_async(self, + name: str, + module_path: str, + class_name: str, + class_parameters: dict, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a model creation in async mode, thus it + requires a wait method call + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be created. + class_name: is the name of the class to be executed + module_path: The name of the package of the ML tool used + (Ex. Scikit-learn or TensorFlow) + class_parameters: the set of parameters of the ML class defined + previously + + return: A JSON object with an error or warning message or a URL + indicating the future correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__CLASS_FIELD: class_name, + self.__MODULE_PATH_FIELD: module_path, + self.__ClASS_PARAMETERS_FIELD: class_parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + + return self.__response_treat.treatment(response, pretty_response) + + def search_all_models(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all models metadata, i.e., it does + not retrieve the model content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All models metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_model(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the model. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the model name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_model(self, name: str, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves a model metadata, i.e., it does + not retrieve the model content. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the model name + + return: A model metadata stored in Learning Orchestra or an empty + result. + """ + + response = self.__entity_reader.read_entity_content( + name) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_model_async method, delete_model method. + + name: Represents the model name. + timeout: Represents the time in seconds to wait for a model creation + to finish its run. + + return: JSON object with an error message, a warning message or a + correct model result + """ + return self.__observer.wait(name, timeout) +
def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def create_model_sync(self, + name: str, + module_path: str, + class_name: str, + class_parameters: dict, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a model creation in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be created. + class_name: is the name of the class to be executed + module_path: The name of the package of the ML tool used + (Ex. Scikit-learn or TensorFlow) + class_parameters: the set of parameters of the ML class defined + previously + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__CLASS_FIELD: class_name, + self.__MODULE_PATH_FIELD: module_path, + self.__ClASS_PARAMETERS_FIELD: class_parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method runs a model creation in sync mode
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the model that will be created. +class_name: is the name of the class to be executed +module_path: The name of the package of the ML tool used +(Ex. Scikit-learn or TensorFlow) +class_parameters: the set of parameters of the ML class defined +previously
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def create_model_async(self, + name: str, + module_path: str, + class_name: str, + class_parameters: dict, + description: str = "", + pretty_response: bool = False) -> Union[dict, str]: + """ + description: This method runs a model creation in async mode, thus it + requires a wait method call + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the model that will be created. + class_name: is the name of the class to be executed + module_path: The name of the package of the ML tool used + (Ex. Scikit-learn or TensorFlow) + class_parameters: the set of parameters of the ML class defined + previously + + return: A JSON object with an error or warning message or a URL + indicating the future correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__CLASS_FIELD: class_name, + self.__MODULE_PATH_FIELD: module_path, + self.__ClASS_PARAMETERS_FIELD: class_parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method runs a model creation in async mode, thus it +requires a wait method call
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the model that will be created. +class_name: is the name of the class to be executed +module_path: The name of the package of the ML tool used +(Ex. Scikit-learn or TensorFlow) +class_parameters: the set of parameters of the ML class defined +previously
+ +return: A JSON object with an error or warning message or a URL +indicating the future correct operation.
+def search_all_models(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all models metadata, i.e., it does + not retrieve the model content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All models metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all models metadata, i.e., it does +not retrieve the model content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: All models metadata stored in Learning Orchestra or an empty +result.
+def delete_model(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the model. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the model name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting the model. +This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Represents the model name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def search_model(self, name: str, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves a model metadata, i.e., it does + not retrieve the model content. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the model name + + return: A model metadata stored in Learning Orchestra or an empty + result. + """ + + response = self.__entity_reader.read_entity_content( + name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves a model metadata, i.e., it does +not retrieve the model content.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the model name
+ +return: A model metadata stored in Learning Orchestra or an empty +result.
+def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_model_async method, delete_model method. + + name: Represents the model name. + timeout: Represents the time in seconds to wait for a model creation + to finish its run. + + return: JSON object with an error message, a warning message or a + correct model result + """ + return self.__observer.wait(name, timeout) +
description: This method is responsible to create a synchronization +barrier for the create_model_async method, delete_model method.
+ +name: Represents the model name. +timeout: Represents the time in seconds to wait for a model creation +to finish its run.
+ +return: JSON object with an error message, a warning message or a +correct model result
+from ._model import Model + + +class ModelScikitLearn(Model): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/model/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class ModelScikitLearn(Model): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/model/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/model/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from ._model import Model + + +class ModelTensorflow(Model): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/model/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class ModelTensorflow(Model): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/model/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/model/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from pymongo import MongoClient, change_stream + + +class Observer: + __TIMEOUT_TIME_MULTIPLICATION = 1000 + + def __init__(self, cluster_ip: str): + cluster_ip = cluster_ip.replace("http://", "") + mongo_url = f'mongodb://root:owl45%2321@{cluster_ip}' + mongo_client = MongoClient( + mongo_url + ) + + self.__database = mongo_client.database + + def wait(self, name: str, timeout: int = None) -> dict: + """ + :description: Observe the end of a pipe for a timeout seconds or + until the pipe finishes its execution. + + name: Represents the pipe name. Any tune, train, predict service can + wait its finish with a + wait method call. + timeout: the maximum time to wait the observed step, in seconds. + + :return: If True it returns a String. Otherwise, it returns + a dictionary with the content of a mongo collection, representing + any pipe result + """ + + dataset_collection = self.__database[name] + metadata_query = {"_id": 0} + dataset_metadata = dataset_collection.find_one(metadata_query) + + if dataset_metadata["finished"]: + return dataset_metadata + + observer_query = [ + {'$match': { + '$and': + [ + {'operationType': 'update'}, + {'fullDocument.finished': {'$eq': True}} + ] + }} + ] + return dataset_collection.watch( + observer_query, + full_document='updateLookup', + max_await_time_ms=timeout * self.__TIMEOUT_TIME_MULTIPLICATION + ).next()['fullDocument'] + + def observe_pipe(self, name: str, timeout: int = None) -> \ + change_stream.CollectionChangeStream: + """ + :description: It waits until a pipe change its content + (replace, insert, update and delete mongoDB collection operation + types), so it is a bit different + from wait method with a timeout and a finish explicit condition. + + :name: the name of the pipe to be observed. A train, predict, explore, + transform or any + other pipe can be observed. + timeout: the maximum time to wait the observed step, in milliseconds. + + :return: A pymongo CollectionChangeStream object. You must use the + builtin next() method to iterate over changes. + """ + + observer_query = [ + {'$match': { + '$or': [ + {'operationType': 'replace'}, + {'operationType': 'insert'}, + {'operationType': 'update'}, + {'operationType': 'delete'} + + ] + }} + ] + return self.__database[name].watch( + observer_query, + max_await_time_ms=timeout * self.__TIMEOUT_TIME_MULTIPLICATION, + full_document='updateLookup') +
class Observer: + __TIMEOUT_TIME_MULTIPLICATION = 1000 + + def __init__(self, cluster_ip: str): + cluster_ip = cluster_ip.replace("http://", "") + mongo_url = f'mongodb://root:owl45%2321@{cluster_ip}' + mongo_client = MongoClient( + mongo_url + ) + + self.__database = mongo_client.database + + def wait(self, name: str, timeout: int = None) -> dict: + """ + :description: Observe the end of a pipe for a timeout seconds or + until the pipe finishes its execution. + + name: Represents the pipe name. Any tune, train, predict service can + wait its finish with a + wait method call. + timeout: the maximum time to wait the observed step, in seconds. + + :return: If True it returns a String. Otherwise, it returns + a dictionary with the content of a mongo collection, representing + any pipe result + """ + + dataset_collection = self.__database[name] + metadata_query = {"_id": 0} + dataset_metadata = dataset_collection.find_one(metadata_query) + + if dataset_metadata["finished"]: + return dataset_metadata + + observer_query = [ + {'$match': { + '$and': + [ + {'operationType': 'update'}, + {'fullDocument.finished': {'$eq': True}} + ] + }} + ] + return dataset_collection.watch( + observer_query, + full_document='updateLookup', + max_await_time_ms=timeout * self.__TIMEOUT_TIME_MULTIPLICATION + ).next()['fullDocument'] + + def observe_pipe(self, name: str, timeout: int = None) -> \ + change_stream.CollectionChangeStream: + """ + :description: It waits until a pipe change its content + (replace, insert, update and delete mongoDB collection operation + types), so it is a bit different + from wait method with a timeout and a finish explicit condition. + + :name: the name of the pipe to be observed. A train, predict, explore, + transform or any + other pipe can be observed. + timeout: the maximum time to wait the observed step, in milliseconds. + + :return: A pymongo CollectionChangeStream object. You must use the + builtin next() method to iterate over changes. + """ + + observer_query = [ + {'$match': { + '$or': [ + {'operationType': 'replace'}, + {'operationType': 'insert'}, + {'operationType': 'update'}, + {'operationType': 'delete'} + + ] + }} + ] + return self.__database[name].watch( + observer_query, + max_await_time_ms=timeout * self.__TIMEOUT_TIME_MULTIPLICATION, + full_document='updateLookup') +
def __init__(self, cluster_ip: str): + cluster_ip = cluster_ip.replace("http://", "") + mongo_url = f'mongodb://root:owl45%2321@{cluster_ip}' + mongo_client = MongoClient( + mongo_url + ) + + self.__database = mongo_client.database +
def wait(self, name: str, timeout: int = None) -> dict: + """ + :description: Observe the end of a pipe for a timeout seconds or + until the pipe finishes its execution. + + name: Represents the pipe name. Any tune, train, predict service can + wait its finish with a + wait method call. + timeout: the maximum time to wait the observed step, in seconds. + + :return: If True it returns a String. Otherwise, it returns + a dictionary with the content of a mongo collection, representing + any pipe result + """ + + dataset_collection = self.__database[name] + metadata_query = {"_id": 0} + dataset_metadata = dataset_collection.find_one(metadata_query) + + if dataset_metadata["finished"]: + return dataset_metadata + + observer_query = [ + {'$match': { + '$and': + [ + {'operationType': 'update'}, + {'fullDocument.finished': {'$eq': True}} + ] + }} + ] + return dataset_collection.watch( + observer_query, + full_document='updateLookup', + max_await_time_ms=timeout * self.__TIMEOUT_TIME_MULTIPLICATION + ).next()['fullDocument'] +
:description: Observe the end of a pipe for a timeout seconds or +until the pipe finishes its execution.
+ +name: Represents the pipe name. Any tune, train, predict service can +wait its finish with a +wait method call. +timeout: the maximum time to wait the observed step, in seconds.
+ +:return: If True it returns a String. Otherwise, it returns +a dictionary with the content of a mongo collection, representing +any pipe result
+def observe_pipe(self, name: str, timeout: int = None) -> \ + change_stream.CollectionChangeStream: + """ + :description: It waits until a pipe change its content + (replace, insert, update and delete mongoDB collection operation + types), so it is a bit different + from wait method with a timeout and a finish explicit condition. + + :name: the name of the pipe to be observed. A train, predict, explore, + transform or any + other pipe can be observed. + timeout: the maximum time to wait the observed step, in milliseconds. + + :return: A pymongo CollectionChangeStream object. You must use the + builtin next() method to iterate over changes. + """ + + observer_query = [ + {'$match': { + '$or': [ + {'operationType': 'replace'}, + {'operationType': 'insert'}, + {'operationType': 'update'}, + {'operationType': 'delete'} + + ] + }} + ] + return self.__database[name].watch( + observer_query, + max_await_time_ms=timeout * self.__TIMEOUT_TIME_MULTIPLICATION, + full_document='updateLookup') +
:description: It waits until a pipe change its content +(replace, insert, update and delete mongoDB collection operation +types), so it is a bit different +from wait method with a timeout and a finish explicit condition.
+ +:name: the name of the pipe to be observed. A train, predict, explore, +transform or any +other pipe can be observed. +timeout: the maximum time to wait the observed step, in milliseconds.
+ +:return: A pymongo CollectionChangeStream object. You must use the +builtin next() method to iterate over changes.
+from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class Predict: + __MODEL_NAME_FIELD = "modelName" + __PARENT_NAME_FIELD = "parentName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_prediction_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to predict models in sync mode + + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the prediction output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to predict models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_prediction_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to predict models in async mode. + A wait method call is mandatory due to the asynchronous aspect. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the prediction output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to predict models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_predictions(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all predictions metadata, i.e., it + does not retrieve the prediction content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All predict metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_prediction(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the prediction. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the prediction name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_prediction_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving all the + prediction tuples or registers, as well as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the prediction object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some predictions inside or an error if there + is no such prediction object. The current page is also returned to be + used in future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_prediction_async method, delete_prediction + method. + + name: Represents the prediction name. + timeout: Represents the time in seconds to wait for a prediction to + finish its run. + + return: JSON object with an error message, a warning message or a + correct prediction result + """ + return self.__observer.wait(name, timeout) +
class Predict: + __MODEL_NAME_FIELD = "modelName" + __PARENT_NAME_FIELD = "parentName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_prediction_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to predict models in sync mode + + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the prediction output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to predict models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_prediction_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to predict models in async mode. + A wait method call is mandatory due to the asynchronous aspect. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the prediction output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to predict models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_predictions(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all predictions metadata, i.e., it + does not retrieve the prediction content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All predict metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_prediction(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the prediction. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the prediction name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_prediction_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving all the + prediction tuples or registers, as well as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the prediction object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some predictions inside or an error if there + is no such prediction object. The current page is also returned to be + used in future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_prediction_async method, delete_prediction + method. + + name: Represents the prediction name. + timeout: Represents the time in seconds to wait for a prediction to + finish its run. + + return: JSON object with an error message, a warning message or a + correct prediction result + """ + return self.__observer.wait(name, timeout) +
def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def create_prediction_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to predict models in sync mode + + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the prediction output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to predict models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible to predict models in sync mode
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the prediction output object that will be created. +parent_name: Is the name of the previous ML step of the pipeline +method_name: is the name of the method to be executed (the ML tool way +to predict models) +parameters: Is the set of parameters used by the method
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def create_prediction_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to predict models in async mode. + A wait method call is mandatory due to the asynchronous aspect. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the prediction output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to predict models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible to predict models in async mode. +A wait method call is mandatory due to the asynchronous aspect.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the prediction output object that will be created. +parent_name: Is the name of the previous ML step of the pipeline +method_name: is the name of the method to be executed (the ML tool way +to predict models) +parameters: Is the set of parameters used by the method
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def search_all_predictions(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all predictions metadata, i.e., it + does not retrieve the prediction content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All predict metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all predictions metadata, i.e., it +does not retrieve the prediction content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: All predict metadata stored in Learning Orchestra or an empty +result.
+def delete_prediction(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the prediction. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the prediction name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting the prediction. +This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Represents the prediction name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def search_prediction_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving all the + prediction tuples or registers, as well as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the prediction object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some predictions inside or an error if there + is no such prediction object. The current page is also returned to be + used in future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving all the +prediction tuples or registers, as well as the metadata content
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the prediction object +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: A page with some predictions inside or an error if there +is no such prediction object. The current page is also returned to be +used in future content requests.
+def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_prediction_async method, delete_prediction + method. + + name: Represents the prediction name. + timeout: Represents the time in seconds to wait for a prediction to + finish its run. + + return: JSON object with an error message, a warning message or a + correct prediction result + """ + return self.__observer.wait(name, timeout) +
description: This method is responsible to create a synchronization +barrier for the create_prediction_async method, delete_prediction +method.
+ +name: Represents the prediction name. +timeout: Represents the time in seconds to wait for a prediction to +finish its run.
+ +return: JSON object with an error message, a warning message or a +correct prediction result
+from ._predict import Predict + + +class PredictScikitLearn(Predict): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/predict/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class PredictScikitLearn(Predict): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/predict/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/predict/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from ._predict import Predict + + +class PredictTensorflow(Predict): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/predict/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class PredictTensorflow(Predict): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/predict/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/predict/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class Train: + __PARENT_NAME_FIELD = "parentName" + __MODEL_NAME_FIELD = "modelName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_training_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to train models in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the train output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to train models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_training_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to train models in async mode. + A wait method call is mandatory due to the asynchronous aspect. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the train output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to train models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_trainings(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all train metadata, i.e., it does + not retrieve the train content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All predict metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_training(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the train step. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the train name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_training_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving all the train + tuples or registers, as well as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the train object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some trains inside or an error if there + is no such train object. The current page is also returned to be used in + future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_train_async method, delete_train method. + + name: Represents the train name. + timeout: Represents the time in seconds to wait for a train to + finish its run. + + return: JSON object with an error message, a warning message or a + correct train result + """ + return self.__observer.wait(name, timeout) +
class Train: + __PARENT_NAME_FIELD = "parentName" + __MODEL_NAME_FIELD = "modelName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_training_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to train models in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the train output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to train models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_training_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to train models in async mode. + A wait method call is mandatory due to the asynchronous aspect. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the train output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to train models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_trainings(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all train metadata, i.e., it does + not retrieve the train content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All predict metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_training(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the train step. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the train name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_training_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving all the train + tuples or registers, as well as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the train object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some trains inside or an error if there + is no such train object. The current page is also returned to be used in + future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_train_async method, delete_train method. + + name: Represents the train name. + timeout: Represents the time in seconds to wait for a train to + finish its run. + + return: JSON object with an error message, a warning message or a + correct train result + """ + return self.__observer.wait(name, timeout) +
def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def create_training_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to train models in sync mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the train output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to train models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible to train models in sync mode
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the train output object that will be created. +parent_name: Is the name of the previous ML step of the pipeline +method_name: is the name of the method to be executed (the ML tool way +to train models) +parameters: Is the set of parameters used by the method
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def create_training_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to train models in async mode. + A wait method call is mandatory due to the asynchronous aspect. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the train output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to train models) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible to train models in async mode. +A wait method call is mandatory due to the asynchronous aspect.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the train output object that will be created. +parent_name: Is the name of the previous ML step of the pipeline +method_name: is the name of the method to be executed (the ML tool way +to train models) +parameters: Is the set of parameters used by the method
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def search_all_trainings(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all train metadata, i.e., it does + not retrieve the train content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All predict metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all train metadata, i.e., it does +not retrieve the train content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: All predict metadata stored in Learning Orchestra or an empty +result.
+def delete_training(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the train step. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the train name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting the train step. +This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Represents the train name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def search_training_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving all the train + tuples or registers, as well as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the train object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some trains inside or an error if there + is no such train object. The current page is also returned to be used in + future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving all the train +tuples or registers, as well as the metadata content
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the train object +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: A page with some trains inside or an error if there +is no such train object. The current page is also returned to be used in +future content requests.
+def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_train_async method, delete_train method. + + name: Represents the train name. + timeout: Represents the time in seconds to wait for a train to + finish its run. + + return: JSON object with an error message, a warning message or a + correct train result + """ + return self.__observer.wait(name, timeout) +
description: This method is responsible to create a synchronization +barrier for the create_train_async method, delete_train method.
+ +name: Represents the train name. +timeout: Represents the time in seconds to wait for a train to +finish its run.
+ +return: JSON object with an error message, a warning message or a +correct train result
+from ._train import Train + + +class TrainScikitLearn(Train): + __PARENT_NAME_FIELD = "parentName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/train/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class TrainScikitLearn(Train): + __PARENT_NAME_FIELD = "parentName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/train/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/train/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from ._train import Train + + +class TrainTensorflow(Train): + __PARENT_NAME_FIELD = "parentName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/train/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class TrainTensorflow(Train): + __PARENT_NAME_FIELD = "parentName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/train/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/train/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class Transform: + __PARENT_NAME_FIELD = "parentName" + __MODEL_NAME_FIELD = "modelName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_transform_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to transform datasets in sync + mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the transform output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed + (the ML tool way to transform datasets) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_transform_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to transform datasets in async + mode. The wait method must be called to guarantee a synchronization + barrier. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the transform output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to transform datasets) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_transformations(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all transform metadata, i.e., it does + not retrieve the transform content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All transform metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_transform(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting a transform step. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the transform name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_transform_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving a transform + URL, which is useful to obtain the transform plottable content, as well + as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the transform object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return A page with transform content and metadata inside or an error if + there is no such train object. The current page is also returned to be + used in future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_transform_async method, delete_transform + method. + + name: Represents the transform name. + timeout: Represents the time in seconds to wait for a transform step + to finish its run. + + return: JSON object with an error message, a warning message or a + correct transform result + """ + return self.__observer.wait(name, timeout) +
class Transform: + __PARENT_NAME_FIELD = "parentName" + __MODEL_NAME_FIELD = "modelName" + __METHOD_NAME_FIELD = "method" + __ClASS_PARAMETERS_FIELD = "methodParameters" + __NAME_FIELD = "name" + __DESCRIPTION_FIELD = "description" + + def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def create_transform_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to transform datasets in sync + mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the transform output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed + (the ML tool way to transform datasets) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) + + def create_transform_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to transform datasets in async + mode. The wait method must be called to guarantee a synchronization + barrier. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the transform output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to transform datasets) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_transformations(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all transform metadata, i.e., it does + not retrieve the transform content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All transform metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_transform(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting a transform step. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the transform name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_transform_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving a transform + URL, which is useful to obtain the transform plottable content, as well + as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the transform object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return A page with transform content and metadata inside or an error if + there is no such train object. The current page is also returned to be + used in future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_transform_async method, delete_transform + method. + + name: Represents the transform name. + timeout: Represents the time in seconds to wait for a transform step + to finish its run. + + return: JSON object with an error message, a warning message or a + correct transform result + """ + return self.__observer.wait(name, timeout) +
def __init__(self, cluster_ip: str, api_path: str): + self.__service_url = f'{cluster_ip}{api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def create_transform_sync(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to transform datasets in sync + mode + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the transform output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed + (the ML tool way to transform datasets) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible to transform datasets in sync +mode
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the transform output object that will be created. +parent_name: Is the name of the previous ML step of the pipeline +method_name: is the name of the method to be executed +(the ML tool way to transform datasets) +parameters: Is the set of parameters used by the method
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def create_transform_async(self, + name: str, + model_name: str, + parent_name: str, + method_name: str, + parameters: dict, + description: str = "", + pretty_response: bool = False) -> \ + Union[dict, str]: + """ + description: This method is responsible to transform datasets in async + mode. The wait method must be called to guarantee a synchronization + barrier. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the transform output object that will be created. + parent_name: Is the name of the previous ML step of the pipeline + method_name: is the name of the method to be executed (the ML tool way + to transform datasets) + parameters: Is the set of parameters used by the method + + return: A JSON object with an error or warning message or a URL + indicating the correct operation. + """ + request_body = { + self.__NAME_FIELD: name, + self.__MODEL_NAME_FIELD: model_name, + self.__PARENT_NAME_FIELD: parent_name, + self.__METHOD_NAME_FIELD: method_name, + self.__ClASS_PARAMETERS_FIELD: parameters, + self.__DESCRIPTION_FIELD: description} + + request_url = self.__service_url + + response = requests.post(url=request_url, json=request_body) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible to transform datasets in async +mode. The wait method must be called to guarantee a synchronization +barrier.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the transform output object that will be created. +parent_name: Is the name of the previous ML step of the pipeline +method_name: is the name of the method to be executed (the ML tool way +to transform datasets) +parameters: Is the set of parameters used by the method
+ +return: A JSON object with an error or warning message or a URL +indicating the correct operation.
+def search_all_transformations(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all transform metadata, i.e., it does + not retrieve the transform content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All transform metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all transform metadata, i.e., it does +not retrieve the transform content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: All transform metadata stored in Learning Orchestra or an empty +result.
+def delete_transform(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting a transform step. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the transform name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting a transform step. +This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Represents the transform name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def search_transform_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving a transform + URL, which is useful to obtain the transform plottable content, as well + as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the transform object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return A page with transform content and metadata inside or an error if + there is no such train object. The current page is also returned to be + used in future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving a transform +URL, which is useful to obtain the transform plottable content, as well +as the metadata content
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the transform object +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return A page with transform content and metadata inside or an error if +there is no such train object. The current page is also returned to be +used in future content requests.
+def wait(self, name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the create_transform_async method, delete_transform + method. + + name: Represents the transform name. + timeout: Represents the time in seconds to wait for a transform step + to finish its run. + + return: JSON object with an error message, a warning message or a + correct transform result + """ + return self.__observer.wait(name, timeout) +
description: This method is responsible to create a synchronization +barrier for the create_transform_async method, delete_transform +method.
+ +name: Represents the transform name. +timeout: Represents the time in seconds to wait for a transform step +to finish its run.
+ +return: JSON object with an error message, a warning message or a +correct transform result
+from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader +from learning_orchestra_client.observe.observe import Observer +import requests +from typing import Union + + +class TransformDataType: + __INPUT_NAME = "inputDatasetName" + __TYPES = "types" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/dataType" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def update_dataset_type_sync(self, + dataset_name: str, + types: dict, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: Change dataset field types (from number to string and + vice-versa). Many type modifications can be performed in one method + call. + + dataset_name: Represents the dataset name. + types: Represents a map, where the pair key:value is a field:type + + return: A JSON object with error or warning messages or a correct + datatype result. + """ + url_request = self.__service_url + body_request = { + self.__INPUT_NAME: dataset_name, + self.__TYPES: types + } + + response = requests.patch(url=url_request, json=body_request) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) + + def update_dataset_type_async(self, + dataset_name: str, + types: dict, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: Change dataset field types (from number to string and + vice-versa). Many type modifications can be performed in one method + call. Is is an asynchronous call, thus a wait method must be also + called to guarantee a synchronization barrier. + + dataset_name: Represents the dataset name. + types: Represents a map, where the pair key:value is a field:type + + return: A JSON object with error or warning messages or a correct + datatype result. + """ + url_request = self.__service_url + body_request = { + self.__INPUT_NAME: dataset_name, + self.__TYPES: types + } + + response = requests.patch(url=url_request, json=body_request) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_datatype(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all datatype metadata, i.e., it does + not retrieve the datatype content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All predict metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_datatype(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the datatype step. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the datatype name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_datatype_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving all the datatype + tuples or registers, as well as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the datatype object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some registers or tuples inside or an error if there + is no such datatype object. The current page is also returned to be + used in future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the update_dataset_type_async method, delete_datatype + method. + + name: Represents the datatype name. + timeout: Represents the time in seconds to wait for a datatype to + finish its run. + + return: JSON object with an error message, a warning message or a + correct datatype result + """ + return self.__observer.wait(dataset_name, timeout) +
class TransformDataType: + __INPUT_NAME = "inputDatasetName" + __TYPES = "types" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/dataType" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def update_dataset_type_sync(self, + dataset_name: str, + types: dict, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: Change dataset field types (from number to string and + vice-versa). Many type modifications can be performed in one method + call. + + dataset_name: Represents the dataset name. + types: Represents a map, where the pair key:value is a field:type + + return: A JSON object with error or warning messages or a correct + datatype result. + """ + url_request = self.__service_url + body_request = { + self.__INPUT_NAME: dataset_name, + self.__TYPES: types + } + + response = requests.patch(url=url_request, json=body_request) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) + + def update_dataset_type_async(self, + dataset_name: str, + types: dict, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: Change dataset field types (from number to string and + vice-versa). Many type modifications can be performed in one method + call. Is is an asynchronous call, thus a wait method must be also + called to guarantee a synchronization barrier. + + dataset_name: Represents the dataset name. + types: Represents a map, where the pair key:value is a field:type + + return: A JSON object with error or warning messages or a correct + datatype result. + """ + url_request = self.__service_url + body_request = { + self.__INPUT_NAME: dataset_name, + self.__TYPES: types + } + + response = requests.patch(url=url_request, json=body_request) + return self.__response_treat.treatment(response, pretty_response) + + def search_all_datatype(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all datatype metadata, i.e., it does + not retrieve the datatype content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All predict metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def delete_datatype(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the datatype step. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the datatype name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) + + def search_datatype_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving all the datatype + tuples or registers, as well as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the datatype object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some registers or tuples inside or an error if there + is no such datatype object. The current page is also returned to be + used in future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the update_dataset_type_async method, delete_datatype + method. + + name: Represents the datatype name. + timeout: Represents the time in seconds to wait for a datatype to + finish its run. + + return: JSON object with an error message, a warning message or a + correct datatype result + """ + return self.__observer.wait(dataset_name, timeout) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/dataType" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def update_dataset_type_sync(self, + dataset_name: str, + types: dict, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: Change dataset field types (from number to string and + vice-versa). Many type modifications can be performed in one method + call. + + dataset_name: Represents the dataset name. + types: Represents a map, where the pair key:value is a field:type + + return: A JSON object with error or warning messages or a correct + datatype result. + """ + url_request = self.__service_url + body_request = { + self.__INPUT_NAME: dataset_name, + self.__TYPES: types + } + + response = requests.patch(url=url_request, json=body_request) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) +
description: Change dataset field types (from number to string and +vice-versa). Many type modifications can be performed in one method +call.
+ +dataset_name: Represents the dataset name. +types: Represents a map, where the pair key:value is a field:type
+ +return: A JSON object with error or warning messages or a correct +datatype result.
+def update_dataset_type_async(self, + dataset_name: str, + types: dict, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: Change dataset field types (from number to string and + vice-versa). Many type modifications can be performed in one method + call. Is is an asynchronous call, thus a wait method must be also + called to guarantee a synchronization barrier. + + dataset_name: Represents the dataset name. + types: Represents a map, where the pair key:value is a field:type + + return: A JSON object with error or warning messages or a correct + datatype result. + """ + url_request = self.__service_url + body_request = { + self.__INPUT_NAME: dataset_name, + self.__TYPES: types + } + + response = requests.patch(url=url_request, json=body_request) + return self.__response_treat.treatment(response, pretty_response) +
description: Change dataset field types (from number to string and +vice-versa). Many type modifications can be performed in one method +call. Is is an asynchronous call, thus a wait method must be also +called to guarantee a synchronization barrier.
+ +dataset_name: Represents the dataset name. +types: Represents a map, where the pair key:value is a field:type
+ +return: A JSON object with error or warning messages or a correct +datatype result.
+def search_all_datatype(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all datatype metadata, i.e., it does + not retrieve the datatype content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: All predict metadata stored in Learning Orchestra or an empty + result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all datatype metadata, i.e., it does +not retrieve the datatype content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: All predict metadata stored in Learning Orchestra or an empty +result.
+def delete_datatype(self, name: str, pretty_response=False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting the datatype step. + This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks. + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Represents the datatype name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + request_url = f'{self.__service_url}/{name}' + + response = requests.delete(request_url) + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting the datatype step. +This delete operation is asynchronous, so it does not lock the caller + until the deletion finished. Instead, it returns a JSON object with a + URL for a future use. The caller uses the URL for delete checks.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Represents the datatype name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def search_datatype_content(self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving all the datatype + tuples or registers, as well as the metadata content + + pretty_response: If true it returns a string, otherwise a dictionary. + name: Is the name of the datatype object + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some registers or tuples inside or an error if there + is no such datatype object. The current page is also returned to be + used in future content requests. + """ + response = self.__entity_reader.read_entity_content( + name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving all the datatype +tuples or registers, as well as the metadata content
+ +pretty_response: If true it returns a string, otherwise a dictionary. +name: Is the name of the datatype object +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: A page with some registers or tuples inside or an error if there +is no such datatype object. The current page is also returned to be +used in future content requests.
+def wait(self, dataset_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the update_dataset_type_async method, delete_datatype + method. + + name: Represents the datatype name. + timeout: Represents the time in seconds to wait for a datatype to + finish its run. + + return: JSON object with an error message, a warning message or a + correct datatype result + """ + return self.__observer.wait(dataset_name, timeout) +
description: This method is responsible to create a synchronization +barrier for the update_dataset_type_async method, delete_datatype +method.
+ +name: Represents the datatype name. +timeout: Represents the time in seconds to wait for a datatype to +finish its run.
+ +return: JSON object with an error message, a warning message or a +correct datatype result
+from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client.observe.observe import Observer +from learning_orchestra_client._util._entity_reader import EntityReader +import requests +from typing import Union + + +class TransformProjection: + __INPUT_NAME = "inputDatasetName" + __OUTPUT_NAME = "outputDatasetName" + __FIELDS = "names" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/projection" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def remove_dataset_attributes_sync(self, + dataset_name: str, + projection_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method removes a set of attributes of a dataset + synchronously, the caller waits until the projection is inserted into + the Learning Orchestra storage mechanism. + + pretty_response: If returns true a string, otherwise a dictionary. + projection_name: Represents the projection name. + dataset_name: Represents the dataset name. + fields: Represents the set of attributes to be removed. This is list + with some attributes. + + return: A JSON object with error or warning messages. In case of + success, it returns the projection metadata. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: projection_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) + + def remove_dataset_attributes_async(self, + dataset_name: str, + projection_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method removes a set of attributes of a dataset + asynchronously; this way, the caller does not wait until the projection + is inserted into the Learning Orchestra storage mechanism. A wait + method call must occur to guarantee a synchronization barrier. + + pretty_response: If returns true a string, otherwise a dictionary. + projection_name: Represents the projection name. + dataset_name: Represents the dataset name. + fields: Represents the set of attributes to be removed. This is list + with some attributes. + + return: A JSON object with error or warning messages. In case of + success, it returns the projection URL to be obtained latter with a + wait method call. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: projection_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + response = requests.post(url=request_url, json=request_body) + + return self.__response_treat.treatment(response, pretty_response) + + def search_all_projections(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all projection metadata, i.e., it + does not retrieve the projection content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A list with all projections metadata stored in Learning + Orchestra or an empty result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def search_projection_content(self, + projection_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the projection + content. + + pretty_response: If true it returns a string, otherwise a dictionary. + projection_name: Represents the projection name. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if there + is no such projection. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + projection_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def delete_projection(self, projection_name: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting a projection. + The delete operation is always asynchronous and performed in background. + + + pretty_response: If true it returns a string, otherwise a dictionary. + projection_name: Represents the projection name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + cluster_url_projection = f'{self.__service_url}/{projection_name}' + + response = requests.delete(cluster_url_projection) + response.raise_for_status() + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, projection_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the remove_dataset_attributes_async method, + delete_projection method. + + name: Represents the projection name. + timeout: Represents the time in seconds to wait for a projection to + finish its run. + + return: JSON object with an error message, a warning message or a + correct projection result + """ + return self.__observer.wait(projection_name, timeout) +
class TransformProjection: + __INPUT_NAME = "inputDatasetName" + __OUTPUT_NAME = "outputDatasetName" + __FIELDS = "names" + + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/projection" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) + + def remove_dataset_attributes_sync(self, + dataset_name: str, + projection_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method removes a set of attributes of a dataset + synchronously, the caller waits until the projection is inserted into + the Learning Orchestra storage mechanism. + + pretty_response: If returns true a string, otherwise a dictionary. + projection_name: Represents the projection name. + dataset_name: Represents the dataset name. + fields: Represents the set of attributes to be removed. This is list + with some attributes. + + return: A JSON object with error or warning messages. In case of + success, it returns the projection metadata. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: projection_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) + + def remove_dataset_attributes_async(self, + dataset_name: str, + projection_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method removes a set of attributes of a dataset + asynchronously; this way, the caller does not wait until the projection + is inserted into the Learning Orchestra storage mechanism. A wait + method call must occur to guarantee a synchronization barrier. + + pretty_response: If returns true a string, otherwise a dictionary. + projection_name: Represents the projection name. + dataset_name: Represents the dataset name. + fields: Represents the set of attributes to be removed. This is list + with some attributes. + + return: A JSON object with error or warning messages. In case of + success, it returns the projection URL to be obtained latter with a + wait method call. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: projection_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + response = requests.post(url=request_url, json=request_body) + + return self.__response_treat.treatment(response, pretty_response) + + def search_all_projections(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all projection metadata, i.e., it + does not retrieve the projection content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A list with all projections metadata stored in Learning + Orchestra or an empty result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) + + def search_projection_content(self, + projection_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the projection + content. + + pretty_response: If true it returns a string, otherwise a dictionary. + projection_name: Represents the projection name. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if there + is no such projection. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + projection_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) + + def delete_projection(self, projection_name: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting a projection. + The delete operation is always asynchronous and performed in background. + + + pretty_response: If true it returns a string, otherwise a dictionary. + projection_name: Represents the projection name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + cluster_url_projection = f'{self.__service_url}/{projection_name}' + + response = requests.delete(cluster_url_projection) + response.raise_for_status() + + return self.__response_treat.treatment(response, pretty_response) + + def wait(self, projection_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the remove_dataset_attributes_async method, + delete_projection method. + + name: Represents the projection name. + timeout: Represents the time in seconds to wait for a projection to + finish its run. + + return: JSON object with an error message, a warning message or a + correct projection result + """ + return self.__observer.wait(projection_name, timeout) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/projection" + self.__service_url = f'{cluster_ip}{self.__api_path}' + self.__response_treat = ResponseTreat() + self.__cluster_ip = cluster_ip + self.__entity_reader = EntityReader(self.__service_url) + self.__observer = Observer(self.__cluster_ip) +
def remove_dataset_attributes_sync(self, + dataset_name: str, + projection_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method removes a set of attributes of a dataset + synchronously, the caller waits until the projection is inserted into + the Learning Orchestra storage mechanism. + + pretty_response: If returns true a string, otherwise a dictionary. + projection_name: Represents the projection name. + dataset_name: Represents the dataset name. + fields: Represents the set of attributes to be removed. This is list + with some attributes. + + return: A JSON object with error or warning messages. In case of + success, it returns the projection metadata. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: projection_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + response = requests.post(url=request_url, json=request_body) + self.__observer.wait(dataset_name) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method removes a set of attributes of a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.
+ +pretty_response: If returns true a string, otherwise a dictionary. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be removed. This is list +with some attributes.
+ +return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.
+def remove_dataset_attributes_async(self, + dataset_name: str, + projection_name: str, + fields: list, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method removes a set of attributes of a dataset + asynchronously; this way, the caller does not wait until the projection + is inserted into the Learning Orchestra storage mechanism. A wait + method call must occur to guarantee a synchronization barrier. + + pretty_response: If returns true a string, otherwise a dictionary. + projection_name: Represents the projection name. + dataset_name: Represents the dataset name. + fields: Represents the set of attributes to be removed. This is list + with some attributes. + + return: A JSON object with error or warning messages. In case of + success, it returns the projection URL to be obtained latter with a + wait method call. + """ + + request_body = { + self.__INPUT_NAME: dataset_name, + self.__OUTPUT_NAME: projection_name, + self.__FIELDS: fields, + } + request_url = self.__service_url + response = requests.post(url=request_url, json=request_body) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method removes a set of attributes of a dataset +asynchronously; this way, the caller does not wait until the projection +is inserted into the Learning Orchestra storage mechanism. A wait +method call must occur to guarantee a synchronization barrier.
+ +pretty_response: If returns true a string, otherwise a dictionary. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be removed. This is list +with some attributes.
+ +return: A JSON object with error or warning messages. In case of +success, it returns the projection URL to be obtained latter with a +wait method call.
+def search_all_projections(self, pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method retrieves all projection metadata, i.e., it + does not retrieve the projection content. + + pretty_response: If true it returns a string, otherwise a dictionary. + + return: A list with all projections metadata stored in Learning + Orchestra or an empty result. + """ + response = self.__entity_reader.read_all_instances_from_entity() + return self.__response_treat.treatment(response, pretty_response) +
description: This method retrieves all projection metadata, i.e., it +does not retrieve the projection content.
+ +pretty_response: If true it returns a string, otherwise a dictionary.
+ +return: A list with all projections metadata stored in Learning +Orchestra or an empty result.
+def search_projection_content(self, + projection_name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for retrieving the projection + content. + + pretty_response: If true it returns a string, otherwise a dictionary. + projection_name: Represents the projection name. + query: Query to make in MongoDB(default: empty query) + limit: Number of rows to return in pagination(default: 10) (maximum is + set at 20 rows per request) + skip: Number of rows to skip in pagination(default: 0) + + return: A page with some tuples or registers inside or an error if there + is no such projection. The current page is also returned to be used in + future content requests. + """ + + response = self.__entity_reader.read_entity_content( + projection_name, query, limit, skip) + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for retrieving the projection +content.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +projection_name: Represents the projection name. +query: Query to make in MongoDB(default: empty query) +limit: Number of rows to return in pagination(default: 10) (maximum is +set at 20 rows per request) +skip: Number of rows to skip in pagination(default: 0)
+ +return: A page with some tuples or registers inside or an error if there +is no such projection. The current page is also returned to be used in +future content requests.
+def delete_projection(self, projection_name: str, + pretty_response: bool = False) \ + -> Union[dict, str]: + """ + description: This method is responsible for deleting a projection. + The delete operation is always asynchronous and performed in background. + + + pretty_response: If true it returns a string, otherwise a dictionary. + projection_name: Represents the projection name. + + return: JSON object with an error message, a warning message or a + correct delete message + """ + cluster_url_projection = f'{self.__service_url}/{projection_name}' + + response = requests.delete(cluster_url_projection) + response.raise_for_status() + + return self.__response_treat.treatment(response, pretty_response) +
description: This method is responsible for deleting a projection. +The delete operation is always asynchronous and performed in background.
+ +pretty_response: If true it returns a string, otherwise a dictionary. +projection_name: Represents the projection name.
+ +return: JSON object with an error message, a warning message or a +correct delete message
+def wait(self, projection_name: str, timeout: int = None) -> dict: + """ + description: This method is responsible to create a synchronization + barrier for the remove_dataset_attributes_async method, + delete_projection method. + + name: Represents the projection name. + timeout: Represents the time in seconds to wait for a projection to + finish its run. + + return: JSON object with an error message, a warning message or a + correct projection result + """ + return self.__observer.wait(projection_name, timeout) +
description: This method is responsible to create a synchronization +barrier for the remove_dataset_attributes_async method, +delete_projection method.
+ +name: Represents the projection name. +timeout: Represents the time in seconds to wait for a projection to +finish its run.
+ +return: JSON object with an error message, a warning message or a +correct projection result
+from ._transform import Transform + + +class TransformScikitLearn(Transform): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class TransformScikitLearn(Transform): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
from ._transform import Transform + + +class TransformTensorflow(Transform): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
class TransformTensorflow(Transform): + def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
def __init__(self, cluster_ip: str): + self.__api_path = "/api/learningOrchestra/v1/transform/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) +
description: This method call runs several steps of a machine\nlearning pipeline (transform, tune, train and evaluate, for instance)\nusing a model code and several classifiers. It represents a way to run\nan entire pipeline. The caller waits until the method execution ends,\nsince it is a synchronous method.
\n\ntrain_dataset_name: Represent final train dataset.\ntest_dataset_name: Represent final test dataset.\nmodeling_code: Represent Python3 code for pyspark pre-processing model\nmodel_classifiers: list of initial classifiers to be used in the model\npretty_response: if True it represents a result useful for visualization
\n\nreturn: The set of predictions (URIs of them).
\n", "parameters": ["self", "train_dataset_name", "test_dataset_name", "modeling_code", "model_classifiers", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.builder.builder.BuilderSparkMl.run_spark_ml_async", "modulename": "learning_orchestra_client.builder.builder", "qualname": "BuilderSparkMl.run_spark_ml_async", "type": "function", "doc": "description: This method call runs several steps of a machine\nlearning pipeline (transform, tune, train and evaluate, for instance)\nusing a model code and several classifiers. It represents a way to run\nan entire pipeline. The caller does not wait until the method execution\nends, since it is an asynchronous method.
\n\ntrain_dataset_name: Represent final train dataset.\ntest_dataset_name: Represent final test dataset.\nmodeling_code: Represent Python3 code for pyspark pre-processing model\nmodel_classifiers: list of initial classifiers to be used in the model\npretty_response: if True it represents a result useful for visualization
\n\nreturn: the URL to retrieve the Spark pipeline result
\n", "parameters": ["self", "train_dataset_name", "test_dataset_name", "modeling_code", "model_classifiers", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.builder.builder.BuilderSparkMl.search_all_builders", "modulename": "learning_orchestra_client.builder.builder", "qualname": "BuilderSparkMl.search_all_builders", "type": "function", "doc": "description: This method retrieves all model predictions metadata. It\ndoes not retrieve the model predictions content.
\n\npretty_response: If true it returns a string, otherwise a dictionary.
\n\nreturn: A list with all model predictions metadata stored in Learning\nOrchestra or an empty result.
\n", "parameters": ["self", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.builder.builder.BuilderSparkMl.search_builder_register_predictions", "modulename": "learning_orchestra_client.builder.builder", "qualname": "BuilderSparkMl.search_builder_register_predictions", "type": "function", "doc": "description: This method is responsible for retrieving the model\npredictions content.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nbuilder_name: Represents the model predictions name.\nquery: Query to make in MongoDB(default: empty query)\nlimit: Number of rows to return in pagination(default: 10) (maximum is\nset at 20 rows per request)\nskip: Number of rows to skip in pagination(default: 0)
\n\nreturn: A page with some tuples or registers inside or an error if the\npipeline runs incorrectly. The current page is also returned to be used\nin future content requests.
\n", "parameters": ["self", "builder_name", "query", "limit", "skip", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.builder.builder.BuilderSparkMl.search_builder", "modulename": "learning_orchestra_client.builder.builder", "qualname": "BuilderSparkMl.search_builder", "type": "function", "doc": "description: This method is responsible for retrieving a specific\nmodel metadata.
\n\npretty_response: If true return indented string, else return dict.\nbuilder_name: Represents the model predictions name.\nlimit: Number of rows to return in pagination(default: 10) (maximum is\nset at 20 rows per request)\nskip: Number of rows to skip in pagination(default: 0)
\n\nreturn: Specific model prediction metadata stored in Learning Orchestra\nor an error if there is no such projections.
\n", "parameters": ["self", "builder_name", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.builder.builder.BuilderSparkMl.delete_builder", "modulename": "learning_orchestra_client.builder.builder", "qualname": "BuilderSparkMl.delete_builder", "type": "function", "doc": "description: This method is responsible for deleting a model prediction.\nThe delete operation is always asynchronous,\nsince the deletion is performed in background.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nbuilder_name: Represents the pipeline name.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect delete message
\n", "parameters": ["self", "builder_name", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.builder.builder.BuilderSparkMl.wait", "modulename": "learning_orchestra_client.builder.builder", "qualname": "BuilderSparkMl.wait", "type": "function", "doc": "description: This method is responsible to create a synchronization\nbarrier for the run_spark_ml_async method.
\n\ndataset_name: Represents the pipeline name.\ntimeout: Represents the time in seconds to wait for a builder to\nfinish its run.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect execution of a pipeline
\n", "parameters": ["self", "dataset_name", "timeout"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.dataset", "modulename": "learning_orchestra_client.dataset", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.dataset.csv", "modulename": "learning_orchestra_client.dataset.csv", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.dataset.csv.DatasetCsv", "modulename": "learning_orchestra_client.dataset.csv", "qualname": "DatasetCsv", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.dataset.csv.DatasetCsv.__init__", "modulename": "learning_orchestra_client.dataset.csv", "qualname": "DatasetCsv.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.dataset.generic", "modulename": "learning_orchestra_client.dataset.generic", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.dataset.generic.DatasetGeneric", "modulename": "learning_orchestra_client.dataset.generic", "qualname": "DatasetGeneric", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.dataset.generic.DatasetGeneric.__init__", "modulename": "learning_orchestra_client.dataset.generic", "qualname": "DatasetGeneric.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.evaluate", "modulename": "learning_orchestra_client.evaluate", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.evaluate.scikitlearn", "modulename": "learning_orchestra_client.evaluate.scikitlearn", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.evaluate.scikitlearn.EvaluateScikitLearn", "modulename": "learning_orchestra_client.evaluate.scikitlearn", "qualname": "EvaluateScikitLearn", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.evaluate.scikitlearn.EvaluateScikitLearn.__init__", "modulename": "learning_orchestra_client.evaluate.scikitlearn", "qualname": "EvaluateScikitLearn.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.evaluate.tensorflow", "modulename": "learning_orchestra_client.evaluate.tensorflow", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.evaluate.tensorflow.EvaluateTensorflow", "modulename": "learning_orchestra_client.evaluate.tensorflow", "qualname": "EvaluateTensorflow", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.evaluate.tensorflow.EvaluateTensorflow.__init__", "modulename": "learning_orchestra_client.evaluate.tensorflow", "qualname": "EvaluateTensorflow.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.explore", "modulename": "learning_orchestra_client.explore", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.explore.histogram", "modulename": "learning_orchestra_client.explore.histogram", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.explore.histogram.ExploreHistogram", "modulename": "learning_orchestra_client.explore.histogram", "qualname": "ExploreHistogram", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.explore.histogram.ExploreHistogram.__init__", "modulename": "learning_orchestra_client.explore.histogram", "qualname": "ExploreHistogram.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.explore.histogram.ExploreHistogram.run_histogram_sync", "modulename": "learning_orchestra_client.explore.histogram", "qualname": "ExploreHistogram.run_histogram_sync", "type": "function", "doc": "description: This method creates a histogram\nsynchronously, so the caller waits until the histogram is inserted into\nthe Learning Orchestra storage mechanism.
\n\ndataset_name: Represents the name of dataset.\nhistogram_name: Represents the name of histogram.\nfields: Represents a list of attributes.\npretty_response: If true it returns a string, otherwise a dictionary.
\n\nreturn: A JSON object with error or warning messages. In case of\nsuccess, it returns a histogram.
\n", "parameters": ["self", "dataset_name", "histogram_name", "fields", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.explore.histogram.ExploreHistogram.run_histogram_async", "modulename": "learning_orchestra_client.explore.histogram", "qualname": "ExploreHistogram.run_histogram_async", "type": "function", "doc": "description: This method creates a histogram\nasynchronously, so the caller does not wait until the histogram is\ninserted into the Learning Orchestra storage mechanism.
\n\ndataset_name: Represents the name of dataset.\nhistogram_name: Represents the name of histogram.\nfields: Represents a list of attributes.\npretty_response: If true it returns a string, otherwise a dictionary.
\n\nreturn: A JSON object with error or warning messages. In case of\nsuccess, it returns a histogram.
\n", "parameters": ["self", "dataset_name", "histogram_name", "fields", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.explore.histogram.ExploreHistogram.search_all_histograms", "modulename": "learning_orchestra_client.explore.histogram", "qualname": "ExploreHistogram.search_all_histograms", "type": "function", "doc": "description: This method retrieves all histogram metadata, it does not\nretrieve the histogram content.
\n\npretty_response: If true it returns a string, otherwise a dictionary.
\n\nreturn: A list with all histogram metadata stored in Learning Orchestra\nor an empty result.
\n", "parameters": ["self", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.explore.histogram.ExploreHistogram.search_histogram_content", "modulename": "learning_orchestra_client.explore.histogram", "qualname": "ExploreHistogram.search_histogram_content", "type": "function", "doc": "description: This method is responsible for retrieving the histogram\ncontent.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nhistogram_name: Represents the histogram name.\nquery: Query to make in MongoDB(default: empty query)\nlimit: Number of rows to return in pagination(default: 10) (maximum is\nset at 20 rows per request)\nskip: Number of rows to skip in pagination(default: 0)
\n\nreturn: A page with some tuples or registers inside or an error if there\nis no such projection. The current page is also returned to be used in\nfuture content requests.
\n", "parameters": ["self", "histogram_name", "query", "limit", "skip", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.explore.histogram.ExploreHistogram.delete_histogram", "modulename": "learning_orchestra_client.explore.histogram", "qualname": "ExploreHistogram.delete_histogram", "type": "function", "doc": "description: This method is responsible for deleting a histogram.\nThe delete operation is always asynchronous,\nsince the deletion is performed in background.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nhistogram_name: Represents the histogram name.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect delete message
\n", "parameters": ["self", "histogram_name", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.explore.histogram.ExploreHistogram.wait", "modulename": "learning_orchestra_client.explore.histogram", "qualname": "ExploreHistogram.wait", "type": "function", "doc": "description: This method is responsible to create a synchronization\nbarrier for the run_histogram_async method or delete_histogram\nmethod.
\n\nname: Represents the histogram name.\ntimeout: Represents the time in seconds to wait for a histogram to\nfinish its run.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect histogram result
\n", "parameters": ["self", "name", "timeout"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.explore.scikitlearn", "modulename": "learning_orchestra_client.explore.scikitlearn", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.explore.scikitlearn.ExploreScikitLearn", "modulename": "learning_orchestra_client.explore.scikitlearn", "qualname": "ExploreScikitLearn", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.explore.scikitlearn.ExploreScikitLearn.__init__", "modulename": "learning_orchestra_client.explore.scikitlearn", "qualname": "ExploreScikitLearn.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.explore.tensorflow", "modulename": "learning_orchestra_client.explore.tensorflow", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.explore.tensorflow.ExploreTensorflow", "modulename": "learning_orchestra_client.explore.tensorflow", "qualname": "ExploreTensorflow", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.explore.tensorflow.ExploreTensorflow.__init__", "modulename": "learning_orchestra_client.explore.tensorflow", "qualname": "ExploreTensorflow.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.function", "modulename": "learning_orchestra_client.function", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.function.python", "modulename": "learning_orchestra_client.function.python", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.function.python.FunctionPython", "modulename": "learning_orchestra_client.function.python", "qualname": "FunctionPython", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.function.python.FunctionPython.__init__", "modulename": "learning_orchestra_client.function.python", "qualname": "FunctionPython.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.function.python.FunctionPython.run_function_sync", "modulename": "learning_orchestra_client.function.python", "qualname": "FunctionPython.run_function_sync", "type": "function", "doc": "description: This method runs a python 3 code in sync mode, so it\nrepresents a wildcard for the data scientist. It can be used when\ntrain, predict, tune, explore or any other pipe must be customized. The\nfunction is also useful for new pipes. pretty_response: If true it\nreturns a string, otherwise a dictionary.
\n\nname: Is the name of the object stored in Learning Orchestra storage\nsystem (volume or mongoDB).\nurl: Url to CSV file.
\n\nreturn: A JSON object with an error or warning message or the correct\noperation result.
\n", "parameters": ["self", "name", "parameters", "code", "description", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.function.python.FunctionPython.run_function_async", "modulename": "learning_orchestra_client.function.python", "qualname": "FunctionPython.run_function_async", "type": "function", "doc": "description: This method runs a python 3 code in async mode, so it\nrepresents a wildcard for the data scientist. It does not lock the\ncaller, so a wait method must be used. It can be used when train,\npredict, tune, explore or any other pipe must be customized. The\nfunction is also useful for new pipes.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nname: Is the name of the function to be called\ncode: the Python code\nparameters: the parameters of the function being called
\n\nreturn: A JSON object with an error or warning message or the correct\noperation result.
\n", "parameters": ["self", "name", "parameters", "code", "description", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.function.python.FunctionPython.search_all_executions", "modulename": "learning_orchestra_client.function.python", "qualname": "FunctionPython.search_all_executions", "type": "function", "doc": "description: This method retrieves all created functions metadata,\ni.e., it does not retrieve the function result content.
\n\npretty_response: If true it returns a string, otherwise a dictionary.
\n\nreturn: All function executions metadata stored in Learning Orchestra\nor an empty result.
\n", "parameters": ["self", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.function.python.FunctionPython.delete_execution", "modulename": "learning_orchestra_client.function.python", "qualname": "FunctionPython.delete_execution", "type": "function", "doc": "description: This method is responsible for deleting the function.\nThis delete operation is asynchronous, so it does not lock the caller\n until the deletion finished. Instead, it returns a JSON object with a\n URL for a future use. The caller uses the URL for delete checks.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nname: Represents the function name.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect delete message
\n", "parameters": ["self", "name", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.function.python.FunctionPython.search_execution_content", "modulename": "learning_orchestra_client.function.python", "qualname": "FunctionPython.search_execution_content", "type": "function", "doc": "description: This method is responsible for retrieving the function\nresults, including metadata. A function is executed many times, using\ndifferent parameters,\nthus many results are stored\nin Learning Orchestra.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nname: Is the name of the function.\nquery: Query to make in MongoDB(default: empty query)\nlimit: Number of rows to return in pagination(default: 10) (maximum is\nset at 20 rows per request)\nskip: Number of rows to skip in pagination(default: 0)
\n\nreturn:\n A page with some function results inside or an error if there\nis no such function. The current page is also returned to be used in\nfuture content requests.
\n", "parameters": ["self", "name", "query", "limit", "skip", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.function.python.FunctionPython.wait", "modulename": "learning_orchestra_client.function.python", "qualname": "FunctionPython.wait", "type": "function", "doc": "description: This method is responsible to create a synchronization\nbarrier for the run_function_async method or delete_function method.
\n\nname: Represents the function name.\ntimeout: Represents the time in seconds to wait for a function to\nfinish its run.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect function result
\n", "parameters": ["self", "dataset_name", "timeout"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.model", "modulename": "learning_orchestra_client.model", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.model.scikitlearn", "modulename": "learning_orchestra_client.model.scikitlearn", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.model.scikitlearn.ModelScikitLearn", "modulename": "learning_orchestra_client.model.scikitlearn", "qualname": "ModelScikitLearn", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.model.scikitlearn.ModelScikitLearn.__init__", "modulename": "learning_orchestra_client.model.scikitlearn", "qualname": "ModelScikitLearn.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.model.tensorflow", "modulename": "learning_orchestra_client.model.tensorflow", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.model.tensorflow.ModelTensorflow", "modulename": "learning_orchestra_client.model.tensorflow", "qualname": "ModelTensorflow", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.model.tensorflow.ModelTensorflow.__init__", "modulename": "learning_orchestra_client.model.tensorflow", "qualname": "ModelTensorflow.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.observe", "modulename": "learning_orchestra_client.observe", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.observe.observe", "modulename": "learning_orchestra_client.observe.observe", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.observe.observe.Observer", "modulename": "learning_orchestra_client.observe.observe", "qualname": "Observer", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.observe.observe.Observer.__init__", "modulename": "learning_orchestra_client.observe.observe", "qualname": "Observer.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.observe.observe.Observer.wait", "modulename": "learning_orchestra_client.observe.observe", "qualname": "Observer.wait", "type": "function", "doc": ":description: Observe the end of a pipe for a timeout seconds or\nuntil the pipe finishes its execution.
\n\nname: Represents the pipe name. Any tune, train, predict service can\nwait its finish with a\nwait method call.\ntimeout: the maximum time to wait the observed step, in seconds.
\n\n:return: If True it returns a String. Otherwise, it returns\na dictionary with the content of a mongo collection, representing\nany pipe result
\n", "parameters": ["self", "name", "timeout"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.observe.observe.Observer.observe_pipe", "modulename": "learning_orchestra_client.observe.observe", "qualname": "Observer.observe_pipe", "type": "function", "doc": ":description: It waits until a pipe change its content\n(replace, insert, update and delete mongoDB collection operation\ntypes), so it is a bit different\nfrom wait method with a timeout and a finish explicit condition.
\n\n:name: the name of the pipe to be observed. A train, predict, explore,\ntransform or any\nother pipe can be observed.\ntimeout: the maximum time to wait the observed step, in milliseconds.
\n\n:return: A pymongo CollectionChangeStream object. You must use the\nbuiltin next() method to iterate over changes.
\n", "parameters": ["self", "name", "timeout"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.predict", "modulename": "learning_orchestra_client.predict", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.predict.scikitlearn", "modulename": "learning_orchestra_client.predict.scikitlearn", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.predict.scikitlearn.PredictScikitLearn", "modulename": "learning_orchestra_client.predict.scikitlearn", "qualname": "PredictScikitLearn", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.predict.scikitlearn.PredictScikitLearn.__init__", "modulename": "learning_orchestra_client.predict.scikitlearn", "qualname": "PredictScikitLearn.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.predict.tensorflow", "modulename": "learning_orchestra_client.predict.tensorflow", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.predict.tensorflow.PredictTensorflow", "modulename": "learning_orchestra_client.predict.tensorflow", "qualname": "PredictTensorflow", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.predict.tensorflow.PredictTensorflow.__init__", "modulename": "learning_orchestra_client.predict.tensorflow", "qualname": "PredictTensorflow.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.train", "modulename": "learning_orchestra_client.train", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.train.scikitlearn", "modulename": "learning_orchestra_client.train.scikitlearn", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.train.scikitlearn.TrainScikitLearn", "modulename": "learning_orchestra_client.train.scikitlearn", "qualname": "TrainScikitLearn", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.train.scikitlearn.TrainScikitLearn.__init__", "modulename": "learning_orchestra_client.train.scikitlearn", "qualname": "TrainScikitLearn.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.train.tensorflow", "modulename": "learning_orchestra_client.train.tensorflow", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.train.tensorflow.TrainTensorflow", "modulename": "learning_orchestra_client.train.tensorflow", "qualname": "TrainTensorflow", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.train.tensorflow.TrainTensorflow.__init__", "modulename": "learning_orchestra_client.train.tensorflow", "qualname": "TrainTensorflow.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform", "modulename": "learning_orchestra_client.transform", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.transform.data_type", "modulename": "learning_orchestra_client.transform.data_type", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.transform.data_type.TransformDataType", "modulename": "learning_orchestra_client.transform.data_type", "qualname": "TransformDataType", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.transform.data_type.TransformDataType.__init__", "modulename": "learning_orchestra_client.transform.data_type", "qualname": "TransformDataType.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.data_type.TransformDataType.update_dataset_type_sync", "modulename": "learning_orchestra_client.transform.data_type", "qualname": "TransformDataType.update_dataset_type_sync", "type": "function", "doc": "description: Change dataset field types (from number to string and\nvice-versa). Many type modifications can be performed in one method\ncall.
\n\ndataset_name: Represents the dataset name.\ntypes: Represents a map, where the pair key:value is a field:type
\n\nreturn: A JSON object with error or warning messages or a correct\ndatatype result.
\n", "parameters": ["self", "dataset_name", "types", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.data_type.TransformDataType.update_dataset_type_async", "modulename": "learning_orchestra_client.transform.data_type", "qualname": "TransformDataType.update_dataset_type_async", "type": "function", "doc": "description: Change dataset field types (from number to string and\nvice-versa). Many type modifications can be performed in one method\ncall. Is is an asynchronous call, thus a wait method must be also\ncalled to guarantee a synchronization barrier.
\n\ndataset_name: Represents the dataset name.\ntypes: Represents a map, where the pair key:value is a field:type
\n\nreturn: A JSON object with error or warning messages or a correct\ndatatype result.
\n", "parameters": ["self", "dataset_name", "types", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.data_type.TransformDataType.search_all_datatype", "modulename": "learning_orchestra_client.transform.data_type", "qualname": "TransformDataType.search_all_datatype", "type": "function", "doc": "description: This method retrieves all datatype metadata, i.e., it does\nnot retrieve the datatype content.
\n\npretty_response: If true it returns a string, otherwise a dictionary.
\n\nreturn: All predict metadata stored in Learning Orchestra or an empty\nresult.
\n", "parameters": ["self", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.data_type.TransformDataType.delete_datatype", "modulename": "learning_orchestra_client.transform.data_type", "qualname": "TransformDataType.delete_datatype", "type": "function", "doc": "description: This method is responsible for deleting the datatype step.\nThis delete operation is asynchronous, so it does not lock the caller\n until the deletion finished. Instead, it returns a JSON object with a\n URL for a future use. The caller uses the URL for delete checks.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nname: Represents the datatype name.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect delete message
\n", "parameters": ["self", "name", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.data_type.TransformDataType.search_datatype_content", "modulename": "learning_orchestra_client.transform.data_type", "qualname": "TransformDataType.search_datatype_content", "type": "function", "doc": "description: This method is responsible for retrieving all the datatype\ntuples or registers, as well as the metadata content
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nname: Is the name of the datatype object\nquery: Query to make in MongoDB(default: empty query)\nlimit: Number of rows to return in pagination(default: 10) (maximum is\nset at 20 rows per request)\nskip: Number of rows to skip in pagination(default: 0)
\n\nreturn: A page with some registers or tuples inside or an error if there\nis no such datatype object. The current page is also returned to be\nused in future content requests.
\n", "parameters": ["self", "name", "query", "limit", "skip", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.data_type.TransformDataType.wait", "modulename": "learning_orchestra_client.transform.data_type", "qualname": "TransformDataType.wait", "type": "function", "doc": "description: This method is responsible to create a synchronization\nbarrier for the update_dataset_type_async method, delete_datatype\nmethod.
\n\nname: Represents the datatype name.\ntimeout: Represents the time in seconds to wait for a datatype to\nfinish its run.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect datatype result
\n", "parameters": ["self", "dataset_name", "timeout"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.projection", "modulename": "learning_orchestra_client.transform.projection", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.transform.projection.TransformProjection", "modulename": "learning_orchestra_client.transform.projection", "qualname": "TransformProjection", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.transform.projection.TransformProjection.__init__", "modulename": "learning_orchestra_client.transform.projection", "qualname": "TransformProjection.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.projection.TransformProjection.remove_dataset_attributes_sync", "modulename": "learning_orchestra_client.transform.projection", "qualname": "TransformProjection.remove_dataset_attributes_sync", "type": "function", "doc": "description: This method removes a set of attributes of a dataset\nsynchronously, the caller waits until the projection is inserted into\nthe Learning Orchestra storage mechanism.
\n\npretty_response: If returns true a string, otherwise a dictionary.\nprojection_name: Represents the projection name.\ndataset_name: Represents the dataset name.\nfields: Represents the set of attributes to be removed. This is list\nwith some attributes.
\n\nreturn: A JSON object with error or warning messages. In case of\nsuccess, it returns the projection metadata.
\n", "parameters": ["self", "dataset_name", "projection_name", "fields", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.projection.TransformProjection.remove_dataset_attributes_async", "modulename": "learning_orchestra_client.transform.projection", "qualname": "TransformProjection.remove_dataset_attributes_async", "type": "function", "doc": "description: This method removes a set of attributes of a dataset\nasynchronously; this way, the caller does not wait until the projection\nis inserted into the Learning Orchestra storage mechanism. A wait\nmethod call must occur to guarantee a synchronization barrier.
\n\npretty_response: If returns true a string, otherwise a dictionary.\nprojection_name: Represents the projection name.\ndataset_name: Represents the dataset name.\nfields: Represents the set of attributes to be removed. This is list\nwith some attributes.
\n\nreturn: A JSON object with error or warning messages. In case of\nsuccess, it returns the projection URL to be obtained latter with a\nwait method call.
\n", "parameters": ["self", "dataset_name", "projection_name", "fields", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.projection.TransformProjection.search_all_projections", "modulename": "learning_orchestra_client.transform.projection", "qualname": "TransformProjection.search_all_projections", "type": "function", "doc": "description: This method retrieves all projection metadata, i.e., it\ndoes not retrieve the projection content.
\n\npretty_response: If true it returns a string, otherwise a dictionary.
\n\nreturn: A list with all projections metadata stored in Learning\nOrchestra or an empty result.
\n", "parameters": ["self", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.projection.TransformProjection.search_projection_content", "modulename": "learning_orchestra_client.transform.projection", "qualname": "TransformProjection.search_projection_content", "type": "function", "doc": "description: This method is responsible for retrieving the projection\ncontent.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nprojection_name: Represents the projection name.\nquery: Query to make in MongoDB(default: empty query)\nlimit: Number of rows to return in pagination(default: 10) (maximum is\nset at 20 rows per request)\nskip: Number of rows to skip in pagination(default: 0)
\n\nreturn: A page with some tuples or registers inside or an error if there\nis no such projection. The current page is also returned to be used in\nfuture content requests.
\n", "parameters": ["self", "projection_name", "query", "limit", "skip", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.projection.TransformProjection.delete_projection", "modulename": "learning_orchestra_client.transform.projection", "qualname": "TransformProjection.delete_projection", "type": "function", "doc": "description: This method is responsible for deleting a projection.\nThe delete operation is always asynchronous and performed in background.
\n\npretty_response: If true it returns a string, otherwise a dictionary.\nprojection_name: Represents the projection name.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect delete message
\n", "parameters": ["self", "projection_name", "pretty_response"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.projection.TransformProjection.wait", "modulename": "learning_orchestra_client.transform.projection", "qualname": "TransformProjection.wait", "type": "function", "doc": "description: This method is responsible to create a synchronization\nbarrier for the remove_dataset_attributes_async method,\ndelete_projection method.
\n\nname: Represents the projection name.\ntimeout: Represents the time in seconds to wait for a projection to\nfinish its run.
\n\nreturn: JSON object with an error message, a warning message or a\ncorrect projection result
\n", "parameters": ["self", "projection_name", "timeout"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.scikitlearn", "modulename": "learning_orchestra_client.transform.scikitlearn", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.transform.scikitlearn.TransformScikitLearn", "modulename": "learning_orchestra_client.transform.scikitlearn", "qualname": "TransformScikitLearn", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.transform.scikitlearn.TransformScikitLearn.__init__", "modulename": "learning_orchestra_client.transform.scikitlearn", "qualname": "TransformScikitLearn.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}, {"fullname": "learning_orchestra_client.transform.tensorflow", "modulename": "learning_orchestra_client.transform.tensorflow", "qualname": "", "type": "module", "doc": "\n"}, {"fullname": "learning_orchestra_client.transform.tensorflow.TransformTensorflow", "modulename": "learning_orchestra_client.transform.tensorflow", "qualname": "TransformTensorflow", "type": "class", "doc": "\n"}, {"fullname": "learning_orchestra_client.transform.tensorflow.TransformTensorflow.__init__", "modulename": "learning_orchestra_client.transform.tensorflow", "qualname": "TransformTensorflow.__init__", "type": "function", "doc": "\n", "parameters": ["self", "cluster_ip"], "funcdef": "def"}] \ No newline at end of file diff --git a/html/learning_orchestra_client/predict/index.html b/docs/predict/index.html similarity index 100% rename from html/learning_orchestra_client/predict/index.html rename to docs/predict/index.html diff --git a/html/learning_orchestra_client/predict/scikitlearn.html b/docs/predict/scikitlearn.html similarity index 100% rename from html/learning_orchestra_client/predict/scikitlearn.html rename to docs/predict/scikitlearn.html diff --git a/html/learning_orchestra_client/predict/tensorflow.html b/docs/predict/tensorflow.html similarity index 100% rename from html/learning_orchestra_client/predict/tensorflow.html rename to docs/predict/tensorflow.html diff --git a/html/learning_orchestra_client/train/horovod.html b/docs/train/horovod.html similarity index 100% rename from html/learning_orchestra_client/train/horovod.html rename to docs/train/horovod.html diff --git a/html/learning_orchestra_client/train/index.html b/docs/train/index.html similarity index 100% rename from html/learning_orchestra_client/train/index.html rename to docs/train/index.html diff --git a/html/learning_orchestra_client/train/scikitlearn.html b/docs/train/scikitlearn.html similarity index 100% rename from html/learning_orchestra_client/train/scikitlearn.html rename to docs/train/scikitlearn.html diff --git a/html/learning_orchestra_client/train/tensorflow.html b/docs/train/tensorflow.html similarity index 100% rename from html/learning_orchestra_client/train/tensorflow.html rename to docs/train/tensorflow.html diff --git a/html/learning_orchestra_client/transform/data_type.html b/docs/transform/data_type.html similarity index 100% rename from html/learning_orchestra_client/transform/data_type.html rename to docs/transform/data_type.html diff --git a/html/learning_orchestra_client/transform/index.html b/docs/transform/index.html similarity index 100% rename from html/learning_orchestra_client/transform/index.html rename to docs/transform/index.html diff --git a/html/learning_orchestra_client/transform/projection.html b/docs/transform/projection.html similarity index 100% rename from html/learning_orchestra_client/transform/projection.html rename to docs/transform/projection.html diff --git a/html/learning_orchestra_client/transform/scikitlearn.html b/docs/transform/scikitlearn.html similarity index 100% rename from html/learning_orchestra_client/transform/scikitlearn.html rename to docs/transform/scikitlearn.html diff --git a/html/learning_orchestra_client/transform/tensorflow.html b/docs/transform/tensorflow.html similarity index 100% rename from html/learning_orchestra_client/transform/tensorflow.html rename to docs/transform/tensorflow.html