From 07b7ec279525123d6a22d460c3e22259b605c1db Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sun, 20 Dec 2020 13:00:36 -0300 Subject: [PATCH 01/28] docs --- .../builder/builder.html | 790 +++++++++++++ .../builder/index.html | 65 ++ .../dataset/dataset.html | 678 +++++++++++ .../dataset/index.html | 65 ++ .../explore/histogram.html | 676 +++++++++++ .../explore/index.html | 75 ++ .../explore/pca.html | 742 ++++++++++++ .../explore/tsne.html | 742 ++++++++++++ html/learning_orchestra_client/index.html | 85 ++ html/learning_orchestra_client/observer.html | 375 ++++++ .../response_treat.html | 197 ++++ .../transform/data_type.html | 199 ++++ .../transform/index.html | 70 ++ .../transform/projection.html | 1035 +++++++++++++++++ 14 files changed, 5794 insertions(+) create mode 100644 html/learning_orchestra_client/builder/builder.html create mode 100644 html/learning_orchestra_client/builder/index.html create mode 100644 html/learning_orchestra_client/dataset/dataset.html create mode 100644 html/learning_orchestra_client/dataset/index.html create mode 100644 html/learning_orchestra_client/explore/histogram.html create mode 100644 html/learning_orchestra_client/explore/index.html create mode 100644 html/learning_orchestra_client/explore/pca.html create mode 100644 html/learning_orchestra_client/explore/tsne.html create mode 100644 html/learning_orchestra_client/index.html create mode 100644 html/learning_orchestra_client/observer.html create mode 100644 html/learning_orchestra_client/response_treat.html create mode 100644 html/learning_orchestra_client/transform/data_type.html create mode 100644 html/learning_orchestra_client/transform/index.html create mode 100644 html/learning_orchestra_client/transform/projection.html diff --git a/html/learning_orchestra_client/builder/builder.html b/html/learning_orchestra_client/builder/builder.html new file mode 100644 index 0000000..f450096 --- /dev/null +++ b/html/learning_orchestra_client/builder/builder.html @@ -0,0 +1,790 @@ + + + + + + +learning_orchestra_client.builder.builder API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.builder.builder

+
+
+
+ +Expand source code + +
from ..observer import Observer
+from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+import requests
+from typing import Union
+
+
+class Builder:
+    def __init__(self, ip_from_cluster: str):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/builder"
+        self.response_treat = ResponseTreat()
+        self.TRAIN_NAME = "trainDatasetName"
+        self.TEST_NAME = "testDatasetName"
+        self.CODE = "modelingCode"
+        self.CLASSIFIERS_LIST = "classifiersList"
+        self.dataset = Dataset(ip_from_cluster)
+        self.METADATA_INDEX = 0
+
+    def run_builder_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 resource join several steps of machine
+        learning workflow (transform, tune, train and evaluate) coupling in
+        a unique resource, builder creates several model predictions using
+        your own modeling code using a defined set of classifiers. This is made
+        synchronously, the caller waits until the model predictions are inserted
+        into the Learning Orchestra storage mechanism.
+
+        train_dataset_name: Represent final train dataset.
+        test_dataset_name: Represent final test dataset.
+        modeling_code: Represent Python3 code for pyspark preprocessing model
+        model_classifiers: list of initial classifiers to be used in model
+        pretty_response: returns indented string for visualization if True
+
+        return: The resulted predictions URIs.
+        """
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE MODEL WITH "
+                + train_dataset_name
+                + " AND "
+                + test_dataset_name
+                + " ----------"
+            )
+
+        request_body_content = {
+            self.TRAIN_NAME: train_dataset_name,
+            self.TEST_NAME: test_dataset_name,
+            self.CODE: modeling_code,
+            self.CLASSIFIERS_LIST: model_classifiers,
+        }
+        response = requests.post(url=self.cluster_url,
+                                 json=request_body_content)
+
+        observer = Observer(test_dataset_name, self.CLUSTER_IP)
+
+        for model in model_classifiers:
+            observer.set_dataset_name(test_dataset_name + model)
+            observer.observe_processing(pretty_response)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_builder_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 resource join several steps of machine
+        learning workflow (transform, tune, train and evaluate) coupling in
+        a unique resource, builder creates several model predictions using
+        your own modeling code using a defined set of classifiers. This is made
+        asynchronously, the caller does not wait until the model predictions are
+        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 model predictions are inserted.
+
+        train_dataset_name: Represent final train dataset.
+        test_dataset_name: Represent final test dataset.
+        modeling_code: Represent Python3 code for pyspark preprocessing model
+        model_classifiers: list of initial classifiers to be used in model
+        pretty_response: returns indented string for visualization if True
+
+        return: The resulted predictions URIs.
+        """
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE MODEL WITH "
+                + train_dataset_name
+                + " AND "
+                + test_dataset_name
+                + " ----------"
+            )
+
+        request_body_content = {
+            self.TRAIN_NAME: train_dataset_name,
+            self.TEST_NAME: test_dataset_name,
+            self.CODE: modeling_code,
+            self.CLASSIFIERS_LIST: model_classifiers,
+        }
+        response = requests.post(url=self.cluster_url,
+                                 json=request_body_content)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_model(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 return indented string, else return dict.
+
+        return: A list with all model predictions metadata stored in Learning
+        Orchestra or an empty result.
+        """
+
+        cluster_url_tsne = self.cluster_url
+
+        response = requests.get(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_model_prediction(self,
+                                model_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 return indented string, else return dict.
+        model_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 there
+        is no such projection. The current page is also returned to be used in
+        future content requests.
+        """
+
+        cluster_url_dataset = self.cluster_url + "/" + model_name + \
+                              "?query=" + str(query) + \
+                              "&limit=" + str(limit) + \
+                              "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_dataset)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_model(self, model_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description:  This method is responsible for retrieving a specific
+        model prediction metadata.
+
+        pretty_response: If true return indented string, else return dict.
+        model_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_model_prediction(model_name, limit=1,
+                                                pretty_response=pretty_response)
+
+        return response
+
+    def delete_model(self, model_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting a model prediction.
+        The delete operation is always synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        model_name: Represents the projection name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        cluster_url_dataset = self.cluster_url + "/" + model_name
+
+        response = requests.delete(cluster_url_dataset)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Builder +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Builder:
+    def __init__(self, ip_from_cluster: str):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/builder"
+        self.response_treat = ResponseTreat()
+        self.TRAIN_NAME = "trainDatasetName"
+        self.TEST_NAME = "testDatasetName"
+        self.CODE = "modelingCode"
+        self.CLASSIFIERS_LIST = "classifiersList"
+        self.dataset = Dataset(ip_from_cluster)
+        self.METADATA_INDEX = 0
+
+    def run_builder_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 resource join several steps of machine
+        learning workflow (transform, tune, train and evaluate) coupling in
+        a unique resource, builder creates several model predictions using
+        your own modeling code using a defined set of classifiers. This is made
+        synchronously, the caller waits until the model predictions are inserted
+        into the Learning Orchestra storage mechanism.
+
+        train_dataset_name: Represent final train dataset.
+        test_dataset_name: Represent final test dataset.
+        modeling_code: Represent Python3 code for pyspark preprocessing model
+        model_classifiers: list of initial classifiers to be used in model
+        pretty_response: returns indented string for visualization if True
+
+        return: The resulted predictions URIs.
+        """
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE MODEL WITH "
+                + train_dataset_name
+                + " AND "
+                + test_dataset_name
+                + " ----------"
+            )
+
+        request_body_content = {
+            self.TRAIN_NAME: train_dataset_name,
+            self.TEST_NAME: test_dataset_name,
+            self.CODE: modeling_code,
+            self.CLASSIFIERS_LIST: model_classifiers,
+        }
+        response = requests.post(url=self.cluster_url,
+                                 json=request_body_content)
+
+        observer = Observer(test_dataset_name, self.CLUSTER_IP)
+
+        for model in model_classifiers:
+            observer.set_dataset_name(test_dataset_name + model)
+            observer.observe_processing(pretty_response)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_builder_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 resource join several steps of machine
+        learning workflow (transform, tune, train and evaluate) coupling in
+        a unique resource, builder creates several model predictions using
+        your own modeling code using a defined set of classifiers. This is made
+        asynchronously, the caller does not wait until the model predictions are
+        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 model predictions are inserted.
+
+        train_dataset_name: Represent final train dataset.
+        test_dataset_name: Represent final test dataset.
+        modeling_code: Represent Python3 code for pyspark preprocessing model
+        model_classifiers: list of initial classifiers to be used in model
+        pretty_response: returns indented string for visualization if True
+
+        return: The resulted predictions URIs.
+        """
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE MODEL WITH "
+                + train_dataset_name
+                + " AND "
+                + test_dataset_name
+                + " ----------"
+            )
+
+        request_body_content = {
+            self.TRAIN_NAME: train_dataset_name,
+            self.TEST_NAME: test_dataset_name,
+            self.CODE: modeling_code,
+            self.CLASSIFIERS_LIST: model_classifiers,
+        }
+        response = requests.post(url=self.cluster_url,
+                                 json=request_body_content)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_model(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 return indented string, else return dict.
+
+        return: A list with all model predictions metadata stored in Learning
+        Orchestra or an empty result.
+        """
+
+        cluster_url_tsne = self.cluster_url
+
+        response = requests.get(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_model_prediction(self,
+                                model_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 return indented string, else return dict.
+        model_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 there
+        is no such projection. The current page is also returned to be used in
+        future content requests.
+        """
+
+        cluster_url_dataset = self.cluster_url + "/" + model_name + \
+                              "?query=" + str(query) + \
+                              "&limit=" + str(limit) + \
+                              "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_dataset)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_model(self, model_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description:  This method is responsible for retrieving a specific
+        model prediction metadata.
+
+        pretty_response: If true return indented string, else return dict.
+        model_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_model_prediction(model_name, limit=1,
+                                                pretty_response=pretty_response)
+
+        return response
+
+    def delete_model(self, model_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting a model prediction.
+        The delete operation is always synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        model_name: Represents the projection name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        cluster_url_dataset = self.cluster_url + "/" + model_name
+
+        response = requests.delete(cluster_url_dataset)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+

Methods

+
+
+def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible for deleting a model prediction. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

+

pretty_response: If true return indented string, else return dict. +model_name: Represents the projection name.

+

return: JSON object with an error message, a warning message or a +correct delete message

+
+ +Expand source code + +
def delete_model(self, model_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for deleting a model prediction.
+    The delete operation is always synchronous because it is very fast,
+    since the deletion is performed in background.
+
+    pretty_response: If true return indented string, else return dict.
+    model_name: Represents the projection name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message
+    """
+
+    cluster_url_dataset = self.cluster_url + "/" + model_name
+
+    response = requests.delete(cluster_url_dataset)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +asynchronously, the caller does not wait until the model predictions are +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 model predictions are inserted.

+

train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

+

return: The resulted predictions URIs.

+
+ +Expand source code + +
def run_builder_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 resource join several steps of machine
+    learning workflow (transform, tune, train and evaluate) coupling in
+    a unique resource, builder creates several model predictions using
+    your own modeling code using a defined set of classifiers. This is made
+    asynchronously, the caller does not wait until the model predictions are
+    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 model predictions are inserted.
+
+    train_dataset_name: Represent final train dataset.
+    test_dataset_name: Represent final test dataset.
+    modeling_code: Represent Python3 code for pyspark preprocessing model
+    model_classifiers: list of initial classifiers to be used in model
+    pretty_response: returns indented string for visualization if True
+
+    return: The resulted predictions URIs.
+    """
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE MODEL WITH "
+            + train_dataset_name
+            + " AND "
+            + test_dataset_name
+            + " ----------"
+        )
+
+    request_body_content = {
+        self.TRAIN_NAME: train_dataset_name,
+        self.TEST_NAME: test_dataset_name,
+        self.CODE: modeling_code,
+        self.CLASSIFIERS_LIST: model_classifiers,
+    }
+    response = requests.post(url=self.cluster_url,
+                             json=request_body_content)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +synchronously, the caller waits until the model predictions are inserted +into the Learning Orchestra storage mechanism.

+

train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

+

return: The resulted predictions URIs.

+
+ +Expand source code + +
def run_builder_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 resource join several steps of machine
+    learning workflow (transform, tune, train and evaluate) coupling in
+    a unique resource, builder creates several model predictions using
+    your own modeling code using a defined set of classifiers. This is made
+    synchronously, the caller waits until the model predictions are inserted
+    into the Learning Orchestra storage mechanism.
+
+    train_dataset_name: Represent final train dataset.
+    test_dataset_name: Represent final test dataset.
+    modeling_code: Represent Python3 code for pyspark preprocessing model
+    model_classifiers: list of initial classifiers to be used in model
+    pretty_response: returns indented string for visualization if True
+
+    return: The resulted predictions URIs.
+    """
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE MODEL WITH "
+            + train_dataset_name
+            + " AND "
+            + test_dataset_name
+            + " ----------"
+        )
+
+    request_body_content = {
+        self.TRAIN_NAME: train_dataset_name,
+        self.TEST_NAME: test_dataset_name,
+        self.CODE: modeling_code,
+        self.CLASSIFIERS_LIST: model_classifiers,
+    }
+    response = requests.post(url=self.cluster_url,
+                             json=request_body_content)
+
+    observer = Observer(test_dataset_name, self.CLUSTER_IP)
+
+    for model in model_classifiers:
+        observer.set_dataset_name(test_dataset_name + model)
+        observer.observe_processing(pretty_response)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_all_model(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 return indented string, else return dict.

+

return: A list with all model predictions metadata stored in Learning +Orchestra or an empty result.

+
+ +Expand source code + +
def search_all_model(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 return indented string, else return dict.
+
+    return: A list with all model predictions metadata stored in Learning
+    Orchestra or an empty result.
+    """
+
+    cluster_url_tsne = self.cluster_url
+
+    response = requests.get(cluster_url_tsne)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: +This method is responsible for retrieving a specific +model prediction metadata.

+

pretty_response: If true return indented string, else return dict. +model_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.

+
+ +Expand source code + +
def search_model(self, model_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description:  This method is responsible for retrieving a specific
+    model prediction metadata.
+
+    pretty_response: If true return indented string, else return dict.
+    model_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_model_prediction(model_name, limit=1,
+                                            pretty_response=pretty_response)
+
+    return response
+
+
+
+def search_model_prediction(self, model_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 return indented string, else return dict. +model_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 there +is no such projection. The current page is also returned to be used in +future content requests.

+
+ +Expand source code + +
def search_model_prediction(self,
+                            model_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 return indented string, else return dict.
+    model_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 there
+    is no such projection. The current page is also returned to be used in
+    future content requests.
+    """
+
+    cluster_url_dataset = self.cluster_url + "/" + model_name + \
+                          "?query=" + str(query) + \
+                          "&limit=" + str(limit) + \
+                          "&skip=" + str(skip)
+
+    response = requests.get(cluster_url_dataset)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/builder/index.html b/html/learning_orchestra_client/builder/index.html new file mode 100644 index 0000000..f6061e5 --- /dev/null +++ b/html/learning_orchestra_client/builder/index.html @@ -0,0 +1,65 @@ + + + + + + +learning_orchestra_client.builder API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/dataset/dataset.html b/html/learning_orchestra_client/dataset/dataset.html new file mode 100644 index 0000000..64e61be --- /dev/null +++ b/html/learning_orchestra_client/dataset/dataset.html @@ -0,0 +1,678 @@ + + + + + + +learning_orchestra_client.dataset.dataset API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.dataset.dataset

+
+
+
+ +Expand source code + +
__author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
+__credits__ = "all free source developers"
+__status__ = "Prototype"
+
+from ..observer import Observer
+from ..response_treat import ResponseTreat
+import requests
+from typing import Union
+
+
+class Dataset:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/dataset"
+        self.response_treat = ResponseTreat()
+        self.OUTPUT_NAME = "datasetName"
+        self.URL = "datasetURI"
+        self.CLUSTER_IP = ip_from_cluster
+
+    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 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.
+        """
+        request_body = {self.OUTPUT_NAME: dataset_name,
+                        self.URL: url}
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
+
+        if pretty_response:
+            print("\n----------" + " CREATED FILE " + 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).
+        """
+        request_body = {self.OUTPUT_NAME: dataset_name,
+                        self.URL: url}
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
+                                                                     "---")
+        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 return indented string, else return dict.
+
+        return: All datasets metadata stored in Learning Orchestra or an empty
+        result.
+        """
+        request_url = self.cluster_url
+
+        response = requests.get(request_url)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for retrieving a specific
+        dataset
+
+        pretty_response: If true return indented string, else return dict.
+        dataset_name: Is the name of the dataset file.
+        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 dataset metadata stored in Learning Orchestra or an
+        error if there is no such dataset.
+        """
+        response = self.search_dataset_content(dataset_name, limit=1,
+                                               pretty_response=pretty_response)
+
+        return 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 return indented string, else return dict.
+        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.
+        """
+
+        request_url = self.cluster_url + "/" + dataset_name + \
+                      "?query=" + str(query) + \
+                      "&limit=" + str(limit) + \
+                      "&skip=" + str(skip)
+
+        response = requests.get(request_url)
+
+        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. The
+        delete operation is always synchronous because it is very fast, since
+        the deletion is performed in background. If a dataset was used by
+        another task (Ex. projection, histogram, pca, tuning and so forth), it
+        cannot be deleted.
+
+        pretty_response: If true return indented string, else return dict.
+        dataset_name: Represents the dataset name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        request_url = self.cluster_url + "/" + dataset_name
+
+        response = requests.delete(request_url)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Dataset +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Dataset:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/dataset"
+        self.response_treat = ResponseTreat()
+        self.OUTPUT_NAME = "datasetName"
+        self.URL = "datasetURI"
+        self.CLUSTER_IP = ip_from_cluster
+
+    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 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.
+        """
+        request_body = {self.OUTPUT_NAME: dataset_name,
+                        self.URL: url}
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
+
+        if pretty_response:
+            print("\n----------" + " CREATED FILE " + 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).
+        """
+        request_body = {self.OUTPUT_NAME: dataset_name,
+                        self.URL: url}
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
+                                                                     "---")
+        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 return indented string, else return dict.
+
+        return: All datasets metadata stored in Learning Orchestra or an empty
+        result.
+        """
+        request_url = self.cluster_url
+
+        response = requests.get(request_url)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for retrieving a specific
+        dataset
+
+        pretty_response: If true return indented string, else return dict.
+        dataset_name: Is the name of the dataset file.
+        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 dataset metadata stored in Learning Orchestra or an
+        error if there is no such dataset.
+        """
+        response = self.search_dataset_content(dataset_name, limit=1,
+                                               pretty_response=pretty_response)
+
+        return 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 return indented string, else return dict.
+        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.
+        """
+
+        request_url = self.cluster_url + "/" + dataset_name + \
+                      "?query=" + str(query) + \
+                      "&limit=" + str(limit) + \
+                      "&skip=" + str(skip)
+
+        response = requests.get(request_url)
+
+        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. The
+        delete operation is always synchronous because it is very fast, since
+        the deletion is performed in background. If a dataset was used by
+        another task (Ex. projection, histogram, pca, tuning and so forth), it
+        cannot be deleted.
+
+        pretty_response: If true return indented string, else return dict.
+        dataset_name: Represents the dataset name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        request_url = self.cluster_url + "/" + dataset_name
+
+        response = requests.delete(request_url)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+

Methods

+
+
+def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] +
+
+

description: This method is responsible for deleting the dataset. The +delete operation is always synchronous because it is very fast, since +the deletion is performed in background. If a dataset was used by +another task (Ex. projection, histogram, pca, tuning and so forth), it +cannot be deleted.

+

pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset name.

+

return: JSON object with an error message, a warning message or a +correct delete message

+
+ +Expand source code + +
def delete_dataset(self, dataset_name, pretty_response=False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for deleting the dataset. The
+    delete operation is always synchronous because it is very fast, since
+    the deletion is performed in background. If a dataset was used by
+    another task (Ex. projection, histogram, pca, tuning and so forth), it
+    cannot be deleted.
+
+    pretty_response: If true return indented string, else return dict.
+    dataset_name: Represents the dataset name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message
+    """
+
+    request_url = self.cluster_url + "/" + dataset_name
+
+    response = requests.delete(request_url)
+
+    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).

+
+ +Expand source code + +
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).
+    """
+    request_body = {self.OUTPUT_NAME: dataset_name,
+                    self.URL: url}
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
+                                                                 "---")
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+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 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.

+
+ +Expand source code + +
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 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.
+    """
+    request_body = {self.OUTPUT_NAME: dataset_name,
+                    self.URL: url}
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
+
+    if pretty_response:
+        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
+                                                                 "---")
+    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 return indented string, else return dict.

+

return: All datasets metadata stored in Learning Orchestra or an empty +result.

+
+ +Expand source code + +
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 return indented string, else return dict.
+
+    return: All datasets metadata stored in Learning Orchestra or an empty
+    result.
+    """
+    request_url = self.cluster_url
+
+    response = requests.get(request_url)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible for retrieving a specific +dataset

+

pretty_response: If true return indented string, else return dict. +dataset_name: Is the name of the dataset file. +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 dataset metadata stored in Learning Orchestra or an +error if there is no such dataset.

+
+ +Expand source code + +
def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for retrieving a specific
+    dataset
+
+    pretty_response: If true return indented string, else return dict.
+    dataset_name: Is the name of the dataset file.
+    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 dataset metadata stored in Learning Orchestra or an
+    error if there is no such dataset.
+    """
+    response = self.search_dataset_content(dataset_name, limit=1,
+                                           pretty_response=pretty_response)
+
+    return 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 return indented string, else return dict. +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.

+
+ +Expand source code + +
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 return indented string, else return dict.
+    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.
+    """
+
+    request_url = self.cluster_url + "/" + dataset_name + \
+                  "?query=" + str(query) + \
+                  "&limit=" + str(limit) + \
+                  "&skip=" + str(skip)
+
+    response = requests.get(request_url)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/dataset/index.html b/html/learning_orchestra_client/dataset/index.html new file mode 100644 index 0000000..b4c42b2 --- /dev/null +++ b/html/learning_orchestra_client/dataset/index.html @@ -0,0 +1,65 @@ + + + + + + +learning_orchestra_client.dataset API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/histogram.html b/html/learning_orchestra_client/explore/histogram.html new file mode 100644 index 0000000..e1abdfc --- /dev/null +++ b/html/learning_orchestra_client/explore/histogram.html @@ -0,0 +1,676 @@ + + + + + + +learning_orchestra_client.explore.histogram API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.explore.histogram

+
+
+
+ +Expand source code + +
from ..observer import Observer
+from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+import requests
+from typing import Union
+
+
+class Histogram:
+    def __init__(self, ip_from_cluster: str):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/histogram"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputDatasetName"
+        self.FIELDS = "names"
+        self.dataset = Dataset(ip_from_cluster)
+
+    def run_histogram_sync(self,
+                           dataset_name: str,
+                           histogram_name: str,
+                           fields: list,
+                           pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method run histogram algorithm to create a histogram
+        synchronously, 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 return indented string, else return dict.
+
+        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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
+            pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE HISTOGRAM FROM "
+                + dataset_name
+                + " TO "
+                + histogram_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 run histogram algorithm to create a histogram
+        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
+
+        dataset_name: Represents the name of dataset.
+        histogram_name: Represents the name of histogram.
+        fields: Represents a list of attributes.
+        pretty_response: If true return indented string, else return dict.
+
+        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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE HISTOGRAM FROM "
+                + dataset_name
+                + " TO "
+                + histogram_name
+                + " ----------"
+            )
+
+        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 names, it does not
+        retrieve the histogram content.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all histogram names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_histogram = self.cluster_url
+
+        response = requests.get(cluster_url_histogram)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_histogram_data(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 return indented string, else return dict.
+        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.
+        """
+
+        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
+                                "?query=" + str(query) + \
+                                "&limit=" + str(limit) + \
+                                "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_histogram)
+
+        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 synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        histogram_name: Represents the histogram name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        cluster_url_histogram = self.cluster_url + "/" + histogram_name
+
+        response = requests.delete(cluster_url_histogram)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Histogram +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Histogram:
+    def __init__(self, ip_from_cluster: str):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/histogram"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputDatasetName"
+        self.FIELDS = "names"
+        self.dataset = Dataset(ip_from_cluster)
+
+    def run_histogram_sync(self,
+                           dataset_name: str,
+                           histogram_name: str,
+                           fields: list,
+                           pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method run histogram algorithm to create a histogram
+        synchronously, 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 return indented string, else return dict.
+
+        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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
+            pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE HISTOGRAM FROM "
+                + dataset_name
+                + " TO "
+                + histogram_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 run histogram algorithm to create a histogram
+        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
+
+        dataset_name: Represents the name of dataset.
+        histogram_name: Represents the name of histogram.
+        fields: Represents a list of attributes.
+        pretty_response: If true return indented string, else return dict.
+
+        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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE HISTOGRAM FROM "
+                + dataset_name
+                + " TO "
+                + histogram_name
+                + " ----------"
+            )
+
+        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 names, it does not
+        retrieve the histogram content.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all histogram names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_histogram = self.cluster_url
+
+        response = requests.get(cluster_url_histogram)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_histogram_data(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 return indented string, else return dict.
+        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.
+        """
+
+        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
+                                "?query=" + str(query) + \
+                                "&limit=" + str(limit) + \
+                                "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_histogram)
+
+        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 synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        histogram_name: Represents the histogram name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        cluster_url_histogram = self.cluster_url + "/" + histogram_name
+
+        response = requests.delete(cluster_url_histogram)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+

Methods

+
+
+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 synchronous because it is very fast, +since the deletion is performed in background.

+

pretty_response: If true return indented string, else return dict. +histogram_name: Represents the histogram name.

+

return: JSON object with an error message, a warning message or a +correct delete message

+
+ +Expand source code + +
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 synchronous because it is very fast,
+    since the deletion is performed in background.
+
+    pretty_response: If true return indented string, else return dict.
+    histogram_name: Represents the histogram name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message
+    """
+
+    cluster_url_histogram = self.cluster_url + "/" + histogram_name
+
+    response = requests.delete(cluster_url_histogram)
+
+    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 run histogram algorithm to create a histogram +asynchronously, the caller does not wait until the histogram 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 histogram was inserted.

+

dataset_name: Represents the name of dataset. +histogram_name: Represents the name of histogram. +fields: Represents a list of attributes. +pretty_response: If true return indented string, else return dict.

+

return: A JSON object with error or warning messages. In case of +success, it returns a histogram.

+
+ +Expand source code + +
def run_histogram_async(self,
+                        dataset_name: str,
+                        histogram_name: str,
+                        fields: list,
+                        pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method run histogram algorithm to create a histogram
+    asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
+
+    dataset_name: Represents the name of dataset.
+    histogram_name: Represents the name of histogram.
+    fields: Represents a list of attributes.
+    pretty_response: If true return indented string, else return dict.
+
+    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.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE HISTOGRAM FROM "
+            + dataset_name
+            + " TO "
+            + histogram_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_histogram_sync(self, dataset_name: str, histogram_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run histogram algorithm to create a histogram +synchronously, 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 return indented string, else return dict.

+

return: A JSON object with error or warning messages. In case of +success, it returns a histogram.

+
+ +Expand source code + +
def run_histogram_sync(self,
+                       dataset_name: str,
+                       histogram_name: str,
+                       fields: list,
+                       pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method run histogram algorithm to create a histogram
+    synchronously, 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 return indented string, else return dict.
+
+    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.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    Observer(histogram_name, self.CLUSTER_IP).observe_processing(
+        pretty_response)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE HISTOGRAM FROM "
+            + dataset_name
+            + " TO "
+            + histogram_name
+            + " ----------"
+        )
+
+    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 names, it does not +retrieve the histogram content.

+

pretty_response: If true return indented string, else return dict.

+

return: A list with all histogram names stored in Learning Orchestra +or an empty result.

+
+ +Expand source code + +
def search_all_histograms(self, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves all histogram names, it does not
+    retrieve the histogram content.
+
+    pretty_response: If true return indented string, else return dict.
+
+    return: A list with all histogram names stored in Learning Orchestra
+    or an empty result.
+    """
+
+    cluster_url_histogram = self.cluster_url
+
+    response = requests.get(cluster_url_histogram)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_histogram_data(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 return indented string, else return dict. +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.

+
+ +Expand source code + +
def search_histogram_data(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 return indented string, else return dict.
+    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.
+    """
+
+    cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
+                            "?query=" + str(query) + \
+                            "&limit=" + str(limit) + \
+                            "&skip=" + str(skip)
+
+    response = requests.get(cluster_url_histogram)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/index.html b/html/learning_orchestra_client/explore/index.html new file mode 100644 index 0000000..d4f7495 --- /dev/null +++ b/html/learning_orchestra_client/explore/index.html @@ -0,0 +1,75 @@ + + + + + + +learning_orchestra_client.explore API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/pca.html b/html/learning_orchestra_client/explore/pca.html new file mode 100644 index 0000000..877a51d --- /dev/null +++ b/html/learning_orchestra_client/explore/pca.html @@ -0,0 +1,742 @@ + + + + + + +learning_orchestra_client.explore.pca API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.explore.pca

+
+
+
+ +Expand source code + +
from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+from PIL import Image
+import requests
+import time
+from typing import Union
+
+
+class Pca:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/pca"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputPlotName"
+        self.LABEL = "label"
+        self.dataset = Dataset(ip_from_cluster)
+        self.WAIT_TIME = 5
+        self.CLUSTER_IP = ip_from_cluster
+
+    def run_pca_sync(self,
+                     dataset_name: str,
+                     pca_name: str,
+                     label: str,
+                     pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run PCA algorithm to create an image plot
+        synchronously, the caller waits until the PCA image is inserted into
+        the Learning Orchestra storage mechanism.
+
+        dataset_name: Name of dataset.
+        pca_name: Name of PCA image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a PCA image plot.
+        """
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: pca_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        self.verify_pca_exist(pca_name, pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PCA IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + pca_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_pca_async(self,
+                      dataset_name: str,
+                      pca_name: str,
+                      label: str,
+                      pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run PCA algorithm to create an image plot
+        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
+
+        dataset_name: Name of dataset.
+        pca_name: Name of PCA image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a PCA image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: pca_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PCA IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + pca_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method retrieves all PCAs plot names, it does not
+        retrieve the image plot.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all PCAs plot names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_pca = self.cluster_url
+
+        response = requests.get(cluster_url_pca)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves a PCA image plot.
+
+        pca_name: Name of PCA image plot.
+        pretty_response: If true open an image plot, else return link to
+        open image plot.
+
+        return: A link to an image plot or open an image plot.
+        """
+
+        cluster_url_pca = self.cluster_url + "/" + pca_name
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " READ "
+                + pca_name
+                + " PCA IMAGE PLOT "
+                + " ----------"
+            )
+            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
+            img.show()
+        else:
+            return cluster_url_pca
+
+    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting the PCA image plot.
+        The delete operation is always synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        pca_name: Represents the PCA name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message.
+        """
+
+        cluster_url_pca = self.cluster_url + "/" + pca_name
+
+        response = requests.delete(cluster_url_pca)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible to verify if a PCA image
+        exist into the Learning Orchestra storage mechanism.
+
+        pca_name: Name of PCA image plot.
+
+        return: True if the PCA requested exist, false if does not.
+        """
+
+        if pretty_response:
+            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
+                                                           "----------")
+
+        exist = False
+        pca_name += ".png"
+
+        while not exist:
+            time.sleep(self.WAIT_TIME)
+            all_pca = self.search_all_pca()
+            exist = pca_name in all_pca.get('result')
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Pca +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Pca:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/pca"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputPlotName"
+        self.LABEL = "label"
+        self.dataset = Dataset(ip_from_cluster)
+        self.WAIT_TIME = 5
+        self.CLUSTER_IP = ip_from_cluster
+
+    def run_pca_sync(self,
+                     dataset_name: str,
+                     pca_name: str,
+                     label: str,
+                     pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run PCA algorithm to create an image plot
+        synchronously, the caller waits until the PCA image is inserted into
+        the Learning Orchestra storage mechanism.
+
+        dataset_name: Name of dataset.
+        pca_name: Name of PCA image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a PCA image plot.
+        """
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: pca_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        self.verify_pca_exist(pca_name, pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PCA IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + pca_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_pca_async(self,
+                      dataset_name: str,
+                      pca_name: str,
+                      label: str,
+                      pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run PCA algorithm to create an image plot
+        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
+
+        dataset_name: Name of dataset.
+        pca_name: Name of PCA image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a PCA image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: pca_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PCA IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + pca_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method retrieves all PCAs plot names, it does not
+        retrieve the image plot.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all PCAs plot names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_pca = self.cluster_url
+
+        response = requests.get(cluster_url_pca)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves a PCA image plot.
+
+        pca_name: Name of PCA image plot.
+        pretty_response: If true open an image plot, else return link to
+        open image plot.
+
+        return: A link to an image plot or open an image plot.
+        """
+
+        cluster_url_pca = self.cluster_url + "/" + pca_name
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " READ "
+                + pca_name
+                + " PCA IMAGE PLOT "
+                + " ----------"
+            )
+            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
+            img.show()
+        else:
+            return cluster_url_pca
+
+    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting the PCA image plot.
+        The delete operation is always synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        pca_name: Represents the PCA name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message.
+        """
+
+        cluster_url_pca = self.cluster_url + "/" + pca_name
+
+        response = requests.delete(cluster_url_pca)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible to verify if a PCA image
+        exist into the Learning Orchestra storage mechanism.
+
+        pca_name: Name of PCA image plot.
+
+        return: True if the PCA requested exist, false if does not.
+        """
+
+        if pretty_response:
+            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
+                                                           "----------")
+
+        exist = False
+        pca_name += ".png"
+
+        while not exist:
+            time.sleep(self.WAIT_TIME)
+            all_pca = self.search_all_pca()
+            exist = pca_name in all_pca.get('result')
+
+

Methods

+
+
+def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible for deleting the PCA image plot. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

+

pretty_response: If true return indented string, else return dict. +pca_name: Represents the PCA name.

+

return: JSON object with an error message, a warning message or a +correct delete message.

+
+ +Expand source code + +
def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for deleting the PCA image plot.
+    The delete operation is always synchronous because it is very fast,
+    since the deletion is performed in background.
+
+    pretty_response: If true return indented string, else return dict.
+    pca_name: Represents the PCA name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message.
+    """
+
+    cluster_url_pca = self.cluster_url + "/" + pca_name
+
+    response = requests.delete(cluster_url_pca)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_pca_async(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run PCA algorithm to create an image plot +asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.

+

dataset_name: Name of dataset. +pca_name: Name of PCA image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

+

return: A JSON object with error or warning messages. In case of +success, it returns a PCA image plot.

+
+ +Expand source code + +
def run_pca_async(self,
+                  dataset_name: str,
+                  pca_name: str,
+                  label: str,
+                  pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method run PCA algorithm to create an image plot
+    asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
+
+    dataset_name: Name of dataset.
+    pca_name: Name of PCA image plot.
+    label: The label is the label name of the column for machine learning
+    datasets which has labeled tuples.
+    pretty_response: If true open an image plot, else return link to open
+    image plot.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns a PCA image plot.
+    """
+
+    request_body = {
+        self.INPUT_NAME: dataset_name,
+        self.OUTPUT_NAME: pca_name,
+        self.LABEL: label,
+    }
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE PCA IMAGE PLOT FROM "
+            + dataset_name
+            + " TO "
+            + pca_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_pca_sync(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run PCA algorithm to create an image plot +synchronously, the caller waits until the PCA image is inserted into +the Learning Orchestra storage mechanism.

+

dataset_name: Name of dataset. +pca_name: Name of PCA image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

+

return: A JSON object with error or warning messages. In case of +success, it returns a PCA image plot.

+
+ +Expand source code + +
def run_pca_sync(self,
+                 dataset_name: str,
+                 pca_name: str,
+                 label: str,
+                 pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method run PCA algorithm to create an image plot
+    synchronously, the caller waits until the PCA image is inserted into
+    the Learning Orchestra storage mechanism.
+
+    dataset_name: Name of dataset.
+    pca_name: Name of PCA image plot.
+    label: The label is the label name of the column for machine learning
+    datasets which has labeled tuples.
+    pretty_response: If true open an image plot, else return link to open
+    image plot.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns a PCA image plot.
+    """
+    request_body = {
+        self.INPUT_NAME: dataset_name,
+        self.OUTPUT_NAME: pca_name,
+        self.LABEL: label,
+    }
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    self.verify_pca_exist(pca_name, pretty_response)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE PCA IMAGE PLOT FROM "
+            + dataset_name
+            + " TO "
+            + pca_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_all_pca(self, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method retrieves all PCAs plot names, it does not +retrieve the image plot.

+

pretty_response: If true return indented string, else return dict.

+

return: A list with all PCAs plot names stored in Learning Orchestra +or an empty result.

+
+ +Expand source code + +
def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method retrieves all PCAs plot names, it does not
+    retrieve the image plot.
+
+    pretty_response: If true return indented string, else return dict.
+
+    return: A list with all PCAs plot names stored in Learning Orchestra
+    or an empty result.
+    """
+
+    cluster_url_pca = self.cluster_url
+
+    response = requests.get(cluster_url_pca)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method retrieves a PCA image plot.

+

pca_name: Name of PCA image plot. +pretty_response: If true open an image plot, else return link to +open image plot.

+

return: A link to an image plot or open an image plot.

+
+ +Expand source code + +
def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves a PCA image plot.
+
+    pca_name: Name of PCA image plot.
+    pretty_response: If true open an image plot, else return link to
+    open image plot.
+
+    return: A link to an image plot or open an image plot.
+    """
+
+    cluster_url_pca = self.cluster_url + "/" + pca_name
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " READ "
+            + pca_name
+            + " PCA IMAGE PLOT "
+            + " ----------"
+        )
+        img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
+        img.show()
+    else:
+        return cluster_url_pca
+
+
+
+def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible to verify if a PCA image +exist into the Learning Orchestra storage mechanism.

+

pca_name: Name of PCA image plot.

+

return: True if the PCA requested exist, false if does not.

+
+ +Expand source code + +
def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible to verify if a PCA image
+    exist into the Learning Orchestra storage mechanism.
+
+    pca_name: Name of PCA image plot.
+
+    return: True if the PCA requested exist, false if does not.
+    """
+
+    if pretty_response:
+        print("\n---------- CHECKING IF " + pca_name + " FINISHED "
+                                                       "----------")
+
+    exist = False
+    pca_name += ".png"
+
+    while not exist:
+        time.sleep(self.WAIT_TIME)
+        all_pca = self.search_all_pca()
+        exist = pca_name in all_pca.get('result')
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/tsne.html b/html/learning_orchestra_client/explore/tsne.html new file mode 100644 index 0000000..b4e1b63 --- /dev/null +++ b/html/learning_orchestra_client/explore/tsne.html @@ -0,0 +1,742 @@ + + + + + + +learning_orchestra_client.explore.tsne API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.explore.tsne

+
+
+
+ +Expand source code + +
from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+from PIL import Image
+import requests
+import time
+from typing import Union
+
+
+class Tsne:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/tsne"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputPlotName"
+        self.LABEL = "label"
+        self.dataset = Dataset(ip_from_cluster)
+        self.WAIT_TIME = 5
+        self.CLUSTER_IP = ip_from_cluster
+
+    def run_tsne_sync(self,
+                      dataset_name: str,
+                      tsne_name: str,
+                      label: str,
+                      pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run t_SNE algorithm to create an image plot
+        synchronously, the caller waits until the t_SNE image is inserted into
+        the Learning Orchestra storage mechanism.
+
+        dataset_name: Name of dataset.
+        tsne_name: Name of t_SNE image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a t_SNE image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: tsne_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        self.verify_tsne_exist(tsne_name, pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE TSNE IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + tsne_name
+                + " ----------"
+            )
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_tsne_async(self,
+                       dataset_name: str,
+                       tsne_name: str,
+                       label: str,
+                       pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run t_SNE algorithm to create an image plot
+        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
+
+        dataset_name: Name of dataset.
+        tsne_name: Name of t_SNE image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a t_SNE image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: tsne_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE TSNE IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + tsne_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_tsne(self, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves all t_SNE plot names, it does not
+        retrieve the image plot.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all t_SNEs plot names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_tsne = self.cluster_url
+
+        response = requests.get(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves a t_SNE image plot.
+
+        tsne_name: Name of t_SNE image plot.
+        pretty_response: If true open an image plot, else return link to
+        open image plot.
+
+        return: A link to an image plot or open an image plot.
+        """
+
+        cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " READ"
+                + tsne_name
+                + " tsne IMAGE PLOT "
+                + " ----------"
+            )
+            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
+            img.show()
+        else:
+            return cluster_url_tsne
+
+    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting the t_SNE image
+        plot. The delete operation is always synchronous because it is very
+        fast, since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        tsne_name: Represents the tsne name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message.
+        """
+
+        cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+        response = requests.delete(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible to verify if a t_SNE image
+        exist into the Learning Orchestra storage mechanism.
+
+        tsne_name: Name of t_SNE image plot.
+
+        return: True if the t_SNE requested exist, false if does not.
+        """
+
+        if pretty_response:
+            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
+                                                            "----------")
+
+        exist = False
+        tsne_name += ".png"
+        while not exist:
+            time.sleep(self.WAIT_TIME)
+            all_tsne = self.search_all_tsne()
+            exist = tsne_name in all_tsne.get('result')
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Tsne +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Tsne:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/tsne"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputPlotName"
+        self.LABEL = "label"
+        self.dataset = Dataset(ip_from_cluster)
+        self.WAIT_TIME = 5
+        self.CLUSTER_IP = ip_from_cluster
+
+    def run_tsne_sync(self,
+                      dataset_name: str,
+                      tsne_name: str,
+                      label: str,
+                      pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run t_SNE algorithm to create an image plot
+        synchronously, the caller waits until the t_SNE image is inserted into
+        the Learning Orchestra storage mechanism.
+
+        dataset_name: Name of dataset.
+        tsne_name: Name of t_SNE image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a t_SNE image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: tsne_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        self.verify_tsne_exist(tsne_name, pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE TSNE IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + tsne_name
+                + " ----------"
+            )
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_tsne_async(self,
+                       dataset_name: str,
+                       tsne_name: str,
+                       label: str,
+                       pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run t_SNE algorithm to create an image plot
+        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
+
+        dataset_name: Name of dataset.
+        tsne_name: Name of t_SNE image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a t_SNE image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: tsne_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE TSNE IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + tsne_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_tsne(self, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves all t_SNE plot names, it does not
+        retrieve the image plot.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all t_SNEs plot names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_tsne = self.cluster_url
+
+        response = requests.get(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves a t_SNE image plot.
+
+        tsne_name: Name of t_SNE image plot.
+        pretty_response: If true open an image plot, else return link to
+        open image plot.
+
+        return: A link to an image plot or open an image plot.
+        """
+
+        cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " READ"
+                + tsne_name
+                + " tsne IMAGE PLOT "
+                + " ----------"
+            )
+            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
+            img.show()
+        else:
+            return cluster_url_tsne
+
+    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting the t_SNE image
+        plot. The delete operation is always synchronous because it is very
+        fast, since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        tsne_name: Represents the tsne name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message.
+        """
+
+        cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+        response = requests.delete(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible to verify if a t_SNE image
+        exist into the Learning Orchestra storage mechanism.
+
+        tsne_name: Name of t_SNE image plot.
+
+        return: True if the t_SNE requested exist, false if does not.
+        """
+
+        if pretty_response:
+            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
+                                                            "----------")
+
+        exist = False
+        tsne_name += ".png"
+        while not exist:
+            time.sleep(self.WAIT_TIME)
+            all_tsne = self.search_all_tsne()
+            exist = tsne_name in all_tsne.get('result')
+
+

Methods

+
+
+def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible for deleting the t_SNE image +plot. The delete operation is always synchronous because it is very +fast, since the deletion is performed in background.

+

pretty_response: If true return indented string, else return dict. +tsne_name: Represents the tsne name.

+

return: JSON object with an error message, a warning message or a +correct delete message.

+
+ +Expand source code + +
def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for deleting the t_SNE image
+    plot. The delete operation is always synchronous because it is very
+    fast, since the deletion is performed in background.
+
+    pretty_response: If true return indented string, else return dict.
+    tsne_name: Represents the tsne name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message.
+    """
+
+    cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+    response = requests.delete(cluster_url_tsne)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_tsne_async(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run t_SNE algorithm to create an image plot +asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.

+

dataset_name: Name of dataset. +tsne_name: Name of t_SNE image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

+

return: A JSON object with error or warning messages. In case of +success, it returns a t_SNE image plot.

+
+ +Expand source code + +
def run_tsne_async(self,
+                   dataset_name: str,
+                   tsne_name: str,
+                   label: str,
+                   pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method run t_SNE algorithm to create an image plot
+    asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
+
+    dataset_name: Name of dataset.
+    tsne_name: Name of t_SNE image plot.
+    label: The label is the label name of the column for machine learning
+    datasets which has labeled tuples.
+    pretty_response: If true open an image plot, else return link to open
+    image plot.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns a t_SNE image plot.
+    """
+
+    request_body = {
+        self.INPUT_NAME: dataset_name,
+        self.OUTPUT_NAME: tsne_name,
+        self.LABEL: label,
+    }
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE TSNE IMAGE PLOT FROM "
+            + dataset_name
+            + " TO "
+            + tsne_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_tsne_sync(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run t_SNE algorithm to create an image plot +synchronously, the caller waits until the t_SNE image is inserted into +the Learning Orchestra storage mechanism.

+

dataset_name: Name of dataset. +tsne_name: Name of t_SNE image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

+

return: A JSON object with error or warning messages. In case of +success, it returns a t_SNE image plot.

+
+ +Expand source code + +
def run_tsne_sync(self,
+                  dataset_name: str,
+                  tsne_name: str,
+                  label: str,
+                  pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method run t_SNE algorithm to create an image plot
+    synchronously, the caller waits until the t_SNE image is inserted into
+    the Learning Orchestra storage mechanism.
+
+    dataset_name: Name of dataset.
+    tsne_name: Name of t_SNE image plot.
+    label: The label is the label name of the column for machine learning
+    datasets which has labeled tuples.
+    pretty_response: If true open an image plot, else return link to open
+    image plot.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns a t_SNE image plot.
+    """
+
+    request_body = {
+        self.INPUT_NAME: dataset_name,
+        self.OUTPUT_NAME: tsne_name,
+        self.LABEL: label,
+    }
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    self.verify_tsne_exist(tsne_name, pretty_response)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE TSNE IMAGE PLOT FROM "
+            + dataset_name
+            + " TO "
+            + tsne_name
+            + " ----------"
+        )
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_all_tsne(self, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method retrieves all t_SNE plot names, it does not +retrieve the image plot.

+

pretty_response: If true return indented string, else return dict.

+

return: A list with all t_SNEs plot names stored in Learning Orchestra +or an empty result.

+
+ +Expand source code + +
def search_all_tsne(self, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves all t_SNE plot names, it does not
+    retrieve the image plot.
+
+    pretty_response: If true return indented string, else return dict.
+
+    return: A list with all t_SNEs plot names stored in Learning Orchestra
+    or an empty result.
+    """
+
+    cluster_url_tsne = self.cluster_url
+
+    response = requests.get(cluster_url_tsne)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method retrieves a t_SNE image plot.

+

tsne_name: Name of t_SNE image plot. +pretty_response: If true open an image plot, else return link to +open image plot.

+

return: A link to an image plot or open an image plot.

+
+ +Expand source code + +
def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves a t_SNE image plot.
+
+    tsne_name: Name of t_SNE image plot.
+    pretty_response: If true open an image plot, else return link to
+    open image plot.
+
+    return: A link to an image plot or open an image plot.
+    """
+
+    cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " READ"
+            + tsne_name
+            + " tsne IMAGE PLOT "
+            + " ----------"
+        )
+        img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
+        img.show()
+    else:
+        return cluster_url_tsne
+
+
+
+def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible to verify if a t_SNE image +exist into the Learning Orchestra storage mechanism.

+

tsne_name: Name of t_SNE image plot.

+

return: True if the t_SNE requested exist, false if does not.

+
+ +Expand source code + +
def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible to verify if a t_SNE image
+    exist into the Learning Orchestra storage mechanism.
+
+    tsne_name: Name of t_SNE image plot.
+
+    return: True if the t_SNE requested exist, false if does not.
+    """
+
+    if pretty_response:
+        print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
+                                                        "----------")
+
+    exist = False
+    tsne_name += ".png"
+    while not exist:
+        time.sleep(self.WAIT_TIME)
+        all_tsne = self.search_all_tsne()
+        exist = tsne_name in all_tsne.get('result')
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/index.html b/html/learning_orchestra_client/index.html new file mode 100644 index 0000000..64b720b --- /dev/null +++ b/html/learning_orchestra_client/index.html @@ -0,0 +1,85 @@ + + + + + + +learning_orchestra_client API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/observer.html b/html/learning_orchestra_client/observer.html new file mode 100644 index 0000000..a7d3aee --- /dev/null +++ b/html/learning_orchestra_client/observer.html @@ -0,0 +1,375 @@ + + + + + + +learning_orchestra_client.observer API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.observer

+
+
+
+ +Expand source code + +
from pymongo import MongoClient, change_stream
+
+
+class Observer:
+    def __init__(self, dataset_name: str, cluster_ip: str):
+        self.dataset_name = dataset_name
+
+        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
+        mongo_client = MongoClient(mongo_url)
+        self.database = mongo_client['database']
+
+    def set_dataset_name(self, dataset_name: str):
+        """
+        :description: Changes the dataset name used in object.
+        :param dataset_name: Name of dataset to observe.
+
+        :return: None.
+        """
+        self.dataset_name = dataset_name
+
+    def get_dataset_name(self) -> str:
+        """
+        :description: Retrieve the dataset name used in object.
+
+        :return: The dataset name.
+        """
+        return self.dataset_name
+
+    def observe_processing(self, pretty_response: bool = False) -> dict:
+        """
+        :description: Observe the finished processing status from some
+        processing, blocking the code execution until finish processing.
+
+        :return: A dict with metadata file of used dataset name.
+        """
+        if pretty_response:
+            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
+                                                                    "----------")
+        dataset_collection = self.database[self.dataset_name]
+        metadata_query = {"_id": 0}
+        dataset_metadata = dataset_collection.find_one(metadata_query)
+
+        if dataset_metadata is None:
+            print("Dataset name or dataset URL invalid")
+            exit()
+
+        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').next()['fullDocument']
+
+    def observe_storage(self) -> change_stream.CollectionChangeStream:
+        """
+        :description: Get all changes from a dataset
+
+        :return: A pymongo CollectionChangeStream object, use the builtin
+        next() method to iterate over changes.
+        """
+
+        observer_query = [
+            {'$match': {
+                '$or': [
+                    {'operationType': 'replace'},
+                    {'operationType': 'insert'},
+                    {'operationType': 'update'},
+                    {'operationType': 'delete'}
+
+                ]
+            }}
+        ]
+        return self.database[self.dataset_name].watch(
+            observer_query,
+            full_document='updateLookup')
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Observer +(dataset_name: str, cluster_ip: str) +
+
+
+
+ +Expand source code + +
class Observer:
+    def __init__(self, dataset_name: str, cluster_ip: str):
+        self.dataset_name = dataset_name
+
+        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
+        mongo_client = MongoClient(mongo_url)
+        self.database = mongo_client['database']
+
+    def set_dataset_name(self, dataset_name: str):
+        """
+        :description: Changes the dataset name used in object.
+        :param dataset_name: Name of dataset to observe.
+
+        :return: None.
+        """
+        self.dataset_name = dataset_name
+
+    def get_dataset_name(self) -> str:
+        """
+        :description: Retrieve the dataset name used in object.
+
+        :return: The dataset name.
+        """
+        return self.dataset_name
+
+    def observe_processing(self, pretty_response: bool = False) -> dict:
+        """
+        :description: Observe the finished processing status from some
+        processing, blocking the code execution until finish processing.
+
+        :return: A dict with metadata file of used dataset name.
+        """
+        if pretty_response:
+            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
+                                                                    "----------")
+        dataset_collection = self.database[self.dataset_name]
+        metadata_query = {"_id": 0}
+        dataset_metadata = dataset_collection.find_one(metadata_query)
+
+        if dataset_metadata is None:
+            print("Dataset name or dataset URL invalid")
+            exit()
+
+        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').next()['fullDocument']
+
+    def observe_storage(self) -> change_stream.CollectionChangeStream:
+        """
+        :description: Get all changes from a dataset
+
+        :return: A pymongo CollectionChangeStream object, use the builtin
+        next() method to iterate over changes.
+        """
+
+        observer_query = [
+            {'$match': {
+                '$or': [
+                    {'operationType': 'replace'},
+                    {'operationType': 'insert'},
+                    {'operationType': 'update'},
+                    {'operationType': 'delete'}
+
+                ]
+            }}
+        ]
+        return self.database[self.dataset_name].watch(
+            observer_query,
+            full_document='updateLookup')
+
+

Methods

+
+
+def get_dataset_name(self) ‑> str +
+
+

:description: Retrieve the dataset name used in object.

+

:return: The dataset name.

+
+ +Expand source code + +
def get_dataset_name(self) -> str:
+    """
+    :description: Retrieve the dataset name used in object.
+
+    :return: The dataset name.
+    """
+    return self.dataset_name
+
+
+
+def observe_processing(self, pretty_response: bool = False) ‑> dict +
+
+

:description: Observe the finished processing status from some +processing, blocking the code execution until finish processing.

+

:return: A dict with metadata file of used dataset name.

+
+ +Expand source code + +
def observe_processing(self, pretty_response: bool = False) -> dict:
+    """
+    :description: Observe the finished processing status from some
+    processing, blocking the code execution until finish processing.
+
+    :return: A dict with metadata file of used dataset name.
+    """
+    if pretty_response:
+        print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
+                                                                "----------")
+    dataset_collection = self.database[self.dataset_name]
+    metadata_query = {"_id": 0}
+    dataset_metadata = dataset_collection.find_one(metadata_query)
+
+    if dataset_metadata is None:
+        print("Dataset name or dataset URL invalid")
+        exit()
+
+    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').next()['fullDocument']
+
+
+
+def observe_storage(self) ‑> pymongo.change_stream.CollectionChangeStream +
+
+

:description: Get all changes from a dataset

+

:return: A pymongo CollectionChangeStream object, use the builtin +next() method to iterate over changes.

+
+ +Expand source code + +
def observe_storage(self) -> change_stream.CollectionChangeStream:
+    """
+    :description: Get all changes from a dataset
+
+    :return: A pymongo CollectionChangeStream object, use the builtin
+    next() method to iterate over changes.
+    """
+
+    observer_query = [
+        {'$match': {
+            '$or': [
+                {'operationType': 'replace'},
+                {'operationType': 'insert'},
+                {'operationType': 'update'},
+                {'operationType': 'delete'}
+
+            ]
+        }}
+    ]
+    return self.database[self.dataset_name].watch(
+        observer_query,
+        full_document='updateLookup')
+
+
+
+def set_dataset_name(self, dataset_name: str) +
+
+

:description: Changes the dataset name used in object. +:param dataset_name: Name of dataset to observe.

+

:return: None.

+
+ +Expand source code + +
def set_dataset_name(self, dataset_name: str):
+    """
+    :description: Changes the dataset name used in object.
+    :param dataset_name: Name of dataset to observe.
+
+    :return: None.
+    """
+    self.dataset_name = dataset_name
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/response_treat.html b/html/learning_orchestra_client/response_treat.html new file mode 100644 index 0000000..2c8bb2a --- /dev/null +++ b/html/learning_orchestra_client/response_treat.html @@ -0,0 +1,197 @@ + + + + + + +learning_orchestra_client.response_treat API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.response_treat

+
+
+
+ +Expand source code + +
__author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
+__credits__ = "all free source developers"
+__status__ = "Prototype"
+
+import json
+
+
+class ResponseTreat:
+    HTTP_CREATED = 201
+    HTTP_SUCCESS = 200
+    HTTP_ERROR = 500
+
+    def treatment(self, response, pretty_response: bool = True):
+        """
+        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:
+            return response.text
+        elif (
+                response.status_code != self.HTTP_SUCCESS
+                and response.status_code != self.HTTP_CREATED
+        ):
+            raise Exception(response.json()["result"])
+        else:
+            if pretty_response:
+                return json.dumps(response.json(), indent=4, sort_keys=True)
+            else:
+                return response.json()
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class ResponseTreat +
+
+
+
+ +Expand source code + +
class ResponseTreat:
+    HTTP_CREATED = 201
+    HTTP_SUCCESS = 200
+    HTTP_ERROR = 500
+
+    def treatment(self, response, pretty_response: bool = True):
+        """
+        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:
+            return response.text
+        elif (
+                response.status_code != self.HTTP_SUCCESS
+                and response.status_code != self.HTTP_CREATED
+        ):
+            raise Exception(response.json()["result"])
+        else:
+            if pretty_response:
+                return json.dumps(response.json(), indent=4, sort_keys=True)
+            else:
+                return response.json()
+
+

Class variables

+
+
var HTTP_CREATED
+
+
+
+
var HTTP_ERROR
+
+
+
+
var HTTP_SUCCESS
+
+
+
+
+

Methods

+
+
+def treatment(self, response, pretty_response: bool = True) +
+
+

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.

+
+ +Expand source code + +
def treatment(self, response, pretty_response: bool = True):
+    """
+    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:
+        return response.text
+    elif (
+            response.status_code != self.HTTP_SUCCESS
+            and response.status_code != self.HTTP_CREATED
+    ):
+        raise Exception(response.json()["result"])
+    else:
+        if pretty_response:
+            return json.dumps(response.json(), indent=4, sort_keys=True)
+        else:
+            return response.json()
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/data_type.html b/html/learning_orchestra_client/transform/data_type.html new file mode 100644 index 0000000..fcd25c1 --- /dev/null +++ b/html/learning_orchestra_client/transform/data_type.html @@ -0,0 +1,199 @@ + + + + + + +learning_orchestra_client.transform.data_type API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.transform.data_type

+
+
+
+ +Expand source code + +
from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+import requests
+from typing import Union
+
+
+class DataType:
+    def __init__(self, ip_from_cluster):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/transform/dataType"
+        self.ResponseTreat = ResponseTreat()
+        self.Dataset = Dataset(ip_from_cluster)
+        self.INPUT_NAME = "inputDatasetName"
+        self.TYPES = "types"
+
+    def update_dataset_types(self,
+                             dataset_name: str,
+                             fields_change: dict,
+                             pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: Change types of fields to number or string.
+
+        dataset_name: Represents the dataset name.
+        fields_change: Fields to change with types. This is a dict with each
+        key:value being field:type
+
+        return: A JSON object with error or warning messages.
+        """
+
+        url_request = self.cluster_url
+        body_request = {
+            self.INPUT_NAME: dataset_name,
+            self.TYPES: fields_change
+        }
+
+        response = requests.patch(url=url_request, json=body_request)
+
+        return self.ResponseTreat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class DataType +(ip_from_cluster) +
+
+
+
+ +Expand source code + +
class DataType:
+    def __init__(self, ip_from_cluster):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/transform/dataType"
+        self.ResponseTreat = ResponseTreat()
+        self.Dataset = Dataset(ip_from_cluster)
+        self.INPUT_NAME = "inputDatasetName"
+        self.TYPES = "types"
+
+    def update_dataset_types(self,
+                             dataset_name: str,
+                             fields_change: dict,
+                             pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: Change types of fields to number or string.
+
+        dataset_name: Represents the dataset name.
+        fields_change: Fields to change with types. This is a dict with each
+        key:value being field:type
+
+        return: A JSON object with error or warning messages.
+        """
+
+        url_request = self.cluster_url
+        body_request = {
+            self.INPUT_NAME: dataset_name,
+            self.TYPES: fields_change
+        }
+
+        response = requests.patch(url=url_request, json=body_request)
+
+        return self.ResponseTreat.treatment(response, pretty_response)
+
+

Methods

+
+
+def update_dataset_types(self, dataset_name: str, fields_change: dict, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: Change types of fields to number or string.

+

dataset_name: Represents the dataset name. +fields_change: Fields to change with types. This is a dict with each +key:value being field:type

+

return: A JSON object with error or warning messages.

+
+ +Expand source code + +
def update_dataset_types(self,
+                         dataset_name: str,
+                         fields_change: dict,
+                         pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: Change types of fields to number or string.
+
+    dataset_name: Represents the dataset name.
+    fields_change: Fields to change with types. This is a dict with each
+    key:value being field:type
+
+    return: A JSON object with error or warning messages.
+    """
+
+    url_request = self.cluster_url
+    body_request = {
+        self.INPUT_NAME: dataset_name,
+        self.TYPES: fields_change
+    }
+
+    response = requests.patch(url=url_request, json=body_request)
+
+    return self.ResponseTreat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/index.html b/html/learning_orchestra_client/transform/index.html new file mode 100644 index 0000000..271146f --- /dev/null +++ b/html/learning_orchestra_client/transform/index.html @@ -0,0 +1,70 @@ + + + + + + +learning_orchestra_client.transform API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/projection.html b/html/learning_orchestra_client/transform/projection.html new file mode 100644 index 0000000..7e84007 --- /dev/null +++ b/html/learning_orchestra_client/transform/projection.html @@ -0,0 +1,1035 @@ + + + + + + +learning_orchestra_client.transform.projection API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.transform.projection

+
+
+
+ +Expand source code + +
from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+from ..observer import Observer
+import requests
+from typing import Union
+
+
+class Projection:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/transform/projection"
+        self.METADATA_INDEX = 0
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputDatasetName"
+        self.FIELDS = "names"
+        self.dataset = Dataset(ip_from_cluster)
+        self.CLUSTER_IP = ip_from_cluster
+
+    def insert_dataset_attributes_sync(self,
+                                       dataset_name: str,
+                                       projection_name: str,
+                                       fields: list,
+                                       pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method inserts a set of attributes into a dataset
+        synchronously, the caller waits until the projection is inserted into
+        the Learning Orchestra storage mechanism.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields: Represents the set of attributes to be inserted. This is list
+        with all 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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(projection_name, self.CLUSTER_IP).observe_processing(
+            pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PROJECTION FROM "
+                + dataset_name
+                + " TO "
+                + projection_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def insert_dataset_attributes_async(self,
+                                        dataset_name: str,
+                                        projection_name: str,
+                                        fields: list,
+                                        pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method inserts a set of attributes into a dataset
+        asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields: Represents the set of attributes to be inserted. This is list
+        with all 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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PROJECTION FROM "
+                + dataset_name
+                + " TO "
+                + projection_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def delete_dataset_attributes_sync(self,
+                                       dataset_name: str,
+                                       projection_name: str,
+                                       fields_to_delete: list,
+                                       pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method delete a set of attributes on a dataset
+        synchronously, the caller waits until the projection is inserted into
+        the Learning Orchestra storage mechanism.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields_to_delete: Represents the set of attributes to be inserted.
+        This is list with all attributes.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns the projection metadata.
+        """
+        dataset_metadata = self.search_projections_content(dataset_name,
+                                                           limit=1)
+
+        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+            .get('fields')
+        for field in fields_to_delete:
+            fields_to_insert.remove(field)
+
+        response = self.insert_dataset_attributes_sync(dataset_name,
+                                                       projection_name,
+                                                       fields_to_insert,
+                                                       pretty_response)
+
+        return response
+
+    def delete_dataset_attributes_async(self,
+                                        dataset_name: str,
+                                        projection_name: str,
+                                        fields_to_delete: list,
+                                        pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method delete a set of attributes into a dataset
+        asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields_to_delete: Represents the set of attributes to be inserted.
+        This is list with all attributes.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns the projection metadata.
+        """
+        dataset_metadata = self.search_projections_content(dataset_name,
+                                                           limit=1)
+
+        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+            .get('fields')
+        for field in fields_to_delete:
+            fields_to_insert.remove(field)
+
+        response = self.insert_dataset_attributes_async(dataset_name,
+                                                        projection_name,
+                                                        fields_to_insert,
+                                                        pretty_response)
+
+        return response
+
+    def search_all_projections(self, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves all projection metadata, it does not
+        retrieve the projection content.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all projections metadata stored in Learning
+        Orchestra or an empty result.
+        """
+        cluster_url_projection = self.cluster_url
+
+        response = requests.get(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_projections(self, projection_name: str,
+                           pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description:  This method is responsible for retrieving a specific
+        projection.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
+        error if there is no such projections.
+        """
+        pretty = pretty_response
+
+        response = self.search_projections_content(projection_name, limit=1,
+                                                   pretty_response=pretty)
+
+        return response
+
+    def search_projections_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 dataset
+        content.
+
+        pretty_response: If true return indented string, else return dict.
+        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.
+        """
+
+        cluster_url_projection = self.cluster_url + "/" + projection_name + \
+                                 "?query=" + str(query) + \
+                                 "&limit=" + str(limit) + \
+                                 "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def delete_projections(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 synchronous because it is very fast,
+        since the deletion is performed in background. If a projection was
+        used by another task (Ex. histogram, pca, tuning and so forth),
+        it cannot be deleted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+        cluster_url_projection = self.cluster_url + "/" + projection_name
+
+        response = requests.delete(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Projection +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Projection:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/transform/projection"
+        self.METADATA_INDEX = 0
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputDatasetName"
+        self.FIELDS = "names"
+        self.dataset = Dataset(ip_from_cluster)
+        self.CLUSTER_IP = ip_from_cluster
+
+    def insert_dataset_attributes_sync(self,
+                                       dataset_name: str,
+                                       projection_name: str,
+                                       fields: list,
+                                       pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method inserts a set of attributes into a dataset
+        synchronously, the caller waits until the projection is inserted into
+        the Learning Orchestra storage mechanism.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields: Represents the set of attributes to be inserted. This is list
+        with all 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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(projection_name, self.CLUSTER_IP).observe_processing(
+            pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PROJECTION FROM "
+                + dataset_name
+                + " TO "
+                + projection_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def insert_dataset_attributes_async(self,
+                                        dataset_name: str,
+                                        projection_name: str,
+                                        fields: list,
+                                        pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method inserts a set of attributes into a dataset
+        asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields: Represents the set of attributes to be inserted. This is list
+        with all 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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PROJECTION FROM "
+                + dataset_name
+                + " TO "
+                + projection_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def delete_dataset_attributes_sync(self,
+                                       dataset_name: str,
+                                       projection_name: str,
+                                       fields_to_delete: list,
+                                       pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method delete a set of attributes on a dataset
+        synchronously, the caller waits until the projection is inserted into
+        the Learning Orchestra storage mechanism.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields_to_delete: Represents the set of attributes to be inserted.
+        This is list with all attributes.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns the projection metadata.
+        """
+        dataset_metadata = self.search_projections_content(dataset_name,
+                                                           limit=1)
+
+        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+            .get('fields')
+        for field in fields_to_delete:
+            fields_to_insert.remove(field)
+
+        response = self.insert_dataset_attributes_sync(dataset_name,
+                                                       projection_name,
+                                                       fields_to_insert,
+                                                       pretty_response)
+
+        return response
+
+    def delete_dataset_attributes_async(self,
+                                        dataset_name: str,
+                                        projection_name: str,
+                                        fields_to_delete: list,
+                                        pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method delete a set of attributes into a dataset
+        asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields_to_delete: Represents the set of attributes to be inserted.
+        This is list with all attributes.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns the projection metadata.
+        """
+        dataset_metadata = self.search_projections_content(dataset_name,
+                                                           limit=1)
+
+        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+            .get('fields')
+        for field in fields_to_delete:
+            fields_to_insert.remove(field)
+
+        response = self.insert_dataset_attributes_async(dataset_name,
+                                                        projection_name,
+                                                        fields_to_insert,
+                                                        pretty_response)
+
+        return response
+
+    def search_all_projections(self, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves all projection metadata, it does not
+        retrieve the projection content.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all projections metadata stored in Learning
+        Orchestra or an empty result.
+        """
+        cluster_url_projection = self.cluster_url
+
+        response = requests.get(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_projections(self, projection_name: str,
+                           pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description:  This method is responsible for retrieving a specific
+        projection.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
+        error if there is no such projections.
+        """
+        pretty = pretty_response
+
+        response = self.search_projections_content(projection_name, limit=1,
+                                                   pretty_response=pretty)
+
+        return response
+
+    def search_projections_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 dataset
+        content.
+
+        pretty_response: If true return indented string, else return dict.
+        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.
+        """
+
+        cluster_url_projection = self.cluster_url + "/" + projection_name + \
+                                 "?query=" + str(query) + \
+                                 "&limit=" + str(limit) + \
+                                 "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def delete_projections(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 synchronous because it is very fast,
+        since the deletion is performed in background. If a projection was
+        used by another task (Ex. histogram, pca, tuning and so forth),
+        it cannot be deleted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+        cluster_url_projection = self.cluster_url + "/" + projection_name
+
+        response = requests.delete(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+

Methods

+
+
+def delete_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method delete a set of attributes into a dataset +asynchronously, the caller does not wait until the projections 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 projection was inserted.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields_to_delete: Represents the set of attributes to be inserted. +This is list with all attributes.

+

return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

+
+ +Expand source code + +
def delete_dataset_attributes_async(self,
+                                    dataset_name: str,
+                                    projection_name: str,
+                                    fields_to_delete: list,
+                                    pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method delete a set of attributes into a dataset
+    asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+    dataset_name: Represents the dataset name.
+    fields_to_delete: Represents the set of attributes to be inserted.
+    This is list with all attributes.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns the projection metadata.
+    """
+    dataset_metadata = self.search_projections_content(dataset_name,
+                                                       limit=1)
+
+    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+        .get('fields')
+    for field in fields_to_delete:
+        fields_to_insert.remove(field)
+
+    response = self.insert_dataset_attributes_async(dataset_name,
+                                                    projection_name,
+                                                    fields_to_insert,
+                                                    pretty_response)
+
+    return response
+
+
+
+def delete_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method delete a set of attributes on a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields_to_delete: Represents the set of attributes to be inserted. +This is list with all attributes.

+

return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

+
+ +Expand source code + +
def delete_dataset_attributes_sync(self,
+                                   dataset_name: str,
+                                   projection_name: str,
+                                   fields_to_delete: list,
+                                   pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method delete a set of attributes on a dataset
+    synchronously, the caller waits until the projection is inserted into
+    the Learning Orchestra storage mechanism.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+    dataset_name: Represents the dataset name.
+    fields_to_delete: Represents the set of attributes to be inserted.
+    This is list with all attributes.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns the projection metadata.
+    """
+    dataset_metadata = self.search_projections_content(dataset_name,
+                                                       limit=1)
+
+    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+        .get('fields')
+    for field in fields_to_delete:
+        fields_to_insert.remove(field)
+
+    response = self.insert_dataset_attributes_sync(dataset_name,
+                                                   projection_name,
+                                                   fields_to_insert,
+                                                   pretty_response)
+
+    return response
+
+
+
+def delete_projections(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 synchronous because it is very fast, +since the deletion is performed in background. If a projection was +used by another task (Ex. histogram, pca, tuning and so forth), +it cannot be deleted.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name.

+

return: JSON object with an error message, a warning message or a +correct delete message

+
+ +Expand source code + +
def delete_projections(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 synchronous because it is very fast,
+    since the deletion is performed in background. If a projection was
+    used by another task (Ex. histogram, pca, tuning and so forth),
+    it cannot be deleted.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message
+    """
+    cluster_url_projection = self.cluster_url + "/" + projection_name
+
+    response = requests.delete(cluster_url_projection)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def insert_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method inserts a set of attributes into a dataset +asynchronously, the caller does not wait until the projections 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 projection was inserted.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all attributes.

+

return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

+
+ +Expand source code + +
def insert_dataset_attributes_async(self,
+                                    dataset_name: str,
+                                    projection_name: str,
+                                    fields: list,
+                                    pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method inserts a set of attributes into a dataset
+    asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+    dataset_name: Represents the dataset name.
+    fields: Represents the set of attributes to be inserted. This is list
+    with all 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.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE PROJECTION FROM "
+            + dataset_name
+            + " TO "
+            + projection_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def insert_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method inserts a set of attributes into a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all attributes.

+

return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

+
+ +Expand source code + +
def insert_dataset_attributes_sync(self,
+                                   dataset_name: str,
+                                   projection_name: str,
+                                   fields: list,
+                                   pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method inserts a set of attributes into a dataset
+    synchronously, the caller waits until the projection is inserted into
+    the Learning Orchestra storage mechanism.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+    dataset_name: Represents the dataset name.
+    fields: Represents the set of attributes to be inserted. This is list
+    with all 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.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    Observer(projection_name, self.CLUSTER_IP).observe_processing(
+        pretty_response)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE PROJECTION FROM "
+            + dataset_name
+            + " TO "
+            + projection_name
+            + " ----------"
+        )
+
+    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, it does not +retrieve the projection content.

+

pretty_response: If true return indented string, else return dict.

+

return: A list with all projections metadata stored in Learning +Orchestra or an empty result.

+
+ +Expand source code + +
def search_all_projections(self, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves all projection metadata, it does not
+    retrieve the projection content.
+
+    pretty_response: If true return indented string, else return dict.
+
+    return: A list with all projections metadata stored in Learning
+    Orchestra or an empty result.
+    """
+    cluster_url_projection = self.cluster_url
+
+    response = requests.get(cluster_url_projection)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_projections(self, projection_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: +This method is responsible for retrieving a specific +projection.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an +error if there is no such projections.

+
+ +Expand source code + +
def search_projections(self, projection_name: str,
+                       pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description:  This method is responsible for retrieving a specific
+    projection.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
+    error if there is no such projections.
+    """
+    pretty = pretty_response
+
+    response = self.search_projections_content(projection_name, limit=1,
+                                               pretty_response=pretty)
+
+    return response
+
+
+
+def search_projections_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 dataset +content.

+

pretty_response: If true return indented string, else return dict. +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.

+
+ +Expand source code + +
def search_projections_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 dataset
+    content.
+
+    pretty_response: If true return indented string, else return dict.
+    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.
+    """
+
+    cluster_url_projection = self.cluster_url + "/" + projection_name + \
+                             "?query=" + str(query) + \
+                             "&limit=" + str(limit) + \
+                             "&skip=" + str(skip)
+
+    response = requests.get(cluster_url_projection)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file From f2dd21cad6b56e04a17d514215872d6cc44d749d Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sun, 20 Dec 2020 13:10:10 -0300 Subject: [PATCH 02/28] docs --- docs/builder/builder.html | 790 ++++++++++++++++++++++++ docs/builder/index.html | 65 ++ docs/dataset/dataset.html | 678 +++++++++++++++++++++ docs/dataset/index.html | 65 ++ docs/explore/histogram.html | 676 +++++++++++++++++++++ docs/explore/index.html | 75 +++ docs/explore/pca.html | 742 +++++++++++++++++++++++ docs/explore/tsne.html | 742 +++++++++++++++++++++++ docs/index.html | 85 +++ docs/observer.html | 375 ++++++++++++ docs/response_treat.html | 197 ++++++ docs/transform/data_type.html | 199 ++++++ docs/transform/index.html | 70 +++ docs/transform/projection.html | 1035 ++++++++++++++++++++++++++++++++ 14 files changed, 5794 insertions(+) create mode 100644 docs/builder/builder.html create mode 100644 docs/builder/index.html create mode 100644 docs/dataset/dataset.html create mode 100644 docs/dataset/index.html create mode 100644 docs/explore/histogram.html create mode 100644 docs/explore/index.html create mode 100644 docs/explore/pca.html create mode 100644 docs/explore/tsne.html create mode 100644 docs/index.html create mode 100644 docs/observer.html create mode 100644 docs/response_treat.html create mode 100644 docs/transform/data_type.html create mode 100644 docs/transform/index.html create mode 100644 docs/transform/projection.html diff --git a/docs/builder/builder.html b/docs/builder/builder.html new file mode 100644 index 0000000..f450096 --- /dev/null +++ b/docs/builder/builder.html @@ -0,0 +1,790 @@ + + + + + + +learning_orchestra_client.builder.builder API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.builder.builder

+
+
+
+ +Expand source code + +
from ..observer import Observer
+from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+import requests
+from typing import Union
+
+
+class Builder:
+    def __init__(self, ip_from_cluster: str):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/builder"
+        self.response_treat = ResponseTreat()
+        self.TRAIN_NAME = "trainDatasetName"
+        self.TEST_NAME = "testDatasetName"
+        self.CODE = "modelingCode"
+        self.CLASSIFIERS_LIST = "classifiersList"
+        self.dataset = Dataset(ip_from_cluster)
+        self.METADATA_INDEX = 0
+
+    def run_builder_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 resource join several steps of machine
+        learning workflow (transform, tune, train and evaluate) coupling in
+        a unique resource, builder creates several model predictions using
+        your own modeling code using a defined set of classifiers. This is made
+        synchronously, the caller waits until the model predictions are inserted
+        into the Learning Orchestra storage mechanism.
+
+        train_dataset_name: Represent final train dataset.
+        test_dataset_name: Represent final test dataset.
+        modeling_code: Represent Python3 code for pyspark preprocessing model
+        model_classifiers: list of initial classifiers to be used in model
+        pretty_response: returns indented string for visualization if True
+
+        return: The resulted predictions URIs.
+        """
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE MODEL WITH "
+                + train_dataset_name
+                + " AND "
+                + test_dataset_name
+                + " ----------"
+            )
+
+        request_body_content = {
+            self.TRAIN_NAME: train_dataset_name,
+            self.TEST_NAME: test_dataset_name,
+            self.CODE: modeling_code,
+            self.CLASSIFIERS_LIST: model_classifiers,
+        }
+        response = requests.post(url=self.cluster_url,
+                                 json=request_body_content)
+
+        observer = Observer(test_dataset_name, self.CLUSTER_IP)
+
+        for model in model_classifiers:
+            observer.set_dataset_name(test_dataset_name + model)
+            observer.observe_processing(pretty_response)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_builder_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 resource join several steps of machine
+        learning workflow (transform, tune, train and evaluate) coupling in
+        a unique resource, builder creates several model predictions using
+        your own modeling code using a defined set of classifiers. This is made
+        asynchronously, the caller does not wait until the model predictions are
+        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 model predictions are inserted.
+
+        train_dataset_name: Represent final train dataset.
+        test_dataset_name: Represent final test dataset.
+        modeling_code: Represent Python3 code for pyspark preprocessing model
+        model_classifiers: list of initial classifiers to be used in model
+        pretty_response: returns indented string for visualization if True
+
+        return: The resulted predictions URIs.
+        """
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE MODEL WITH "
+                + train_dataset_name
+                + " AND "
+                + test_dataset_name
+                + " ----------"
+            )
+
+        request_body_content = {
+            self.TRAIN_NAME: train_dataset_name,
+            self.TEST_NAME: test_dataset_name,
+            self.CODE: modeling_code,
+            self.CLASSIFIERS_LIST: model_classifiers,
+        }
+        response = requests.post(url=self.cluster_url,
+                                 json=request_body_content)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_model(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 return indented string, else return dict.
+
+        return: A list with all model predictions metadata stored in Learning
+        Orchestra or an empty result.
+        """
+
+        cluster_url_tsne = self.cluster_url
+
+        response = requests.get(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_model_prediction(self,
+                                model_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 return indented string, else return dict.
+        model_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 there
+        is no such projection. The current page is also returned to be used in
+        future content requests.
+        """
+
+        cluster_url_dataset = self.cluster_url + "/" + model_name + \
+                              "?query=" + str(query) + \
+                              "&limit=" + str(limit) + \
+                              "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_dataset)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_model(self, model_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description:  This method is responsible for retrieving a specific
+        model prediction metadata.
+
+        pretty_response: If true return indented string, else return dict.
+        model_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_model_prediction(model_name, limit=1,
+                                                pretty_response=pretty_response)
+
+        return response
+
+    def delete_model(self, model_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting a model prediction.
+        The delete operation is always synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        model_name: Represents the projection name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        cluster_url_dataset = self.cluster_url + "/" + model_name
+
+        response = requests.delete(cluster_url_dataset)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Builder +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Builder:
+    def __init__(self, ip_from_cluster: str):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/builder"
+        self.response_treat = ResponseTreat()
+        self.TRAIN_NAME = "trainDatasetName"
+        self.TEST_NAME = "testDatasetName"
+        self.CODE = "modelingCode"
+        self.CLASSIFIERS_LIST = "classifiersList"
+        self.dataset = Dataset(ip_from_cluster)
+        self.METADATA_INDEX = 0
+
+    def run_builder_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 resource join several steps of machine
+        learning workflow (transform, tune, train and evaluate) coupling in
+        a unique resource, builder creates several model predictions using
+        your own modeling code using a defined set of classifiers. This is made
+        synchronously, the caller waits until the model predictions are inserted
+        into the Learning Orchestra storage mechanism.
+
+        train_dataset_name: Represent final train dataset.
+        test_dataset_name: Represent final test dataset.
+        modeling_code: Represent Python3 code for pyspark preprocessing model
+        model_classifiers: list of initial classifiers to be used in model
+        pretty_response: returns indented string for visualization if True
+
+        return: The resulted predictions URIs.
+        """
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE MODEL WITH "
+                + train_dataset_name
+                + " AND "
+                + test_dataset_name
+                + " ----------"
+            )
+
+        request_body_content = {
+            self.TRAIN_NAME: train_dataset_name,
+            self.TEST_NAME: test_dataset_name,
+            self.CODE: modeling_code,
+            self.CLASSIFIERS_LIST: model_classifiers,
+        }
+        response = requests.post(url=self.cluster_url,
+                                 json=request_body_content)
+
+        observer = Observer(test_dataset_name, self.CLUSTER_IP)
+
+        for model in model_classifiers:
+            observer.set_dataset_name(test_dataset_name + model)
+            observer.observe_processing(pretty_response)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_builder_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 resource join several steps of machine
+        learning workflow (transform, tune, train and evaluate) coupling in
+        a unique resource, builder creates several model predictions using
+        your own modeling code using a defined set of classifiers. This is made
+        asynchronously, the caller does not wait until the model predictions are
+        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 model predictions are inserted.
+
+        train_dataset_name: Represent final train dataset.
+        test_dataset_name: Represent final test dataset.
+        modeling_code: Represent Python3 code for pyspark preprocessing model
+        model_classifiers: list of initial classifiers to be used in model
+        pretty_response: returns indented string for visualization if True
+
+        return: The resulted predictions URIs.
+        """
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE MODEL WITH "
+                + train_dataset_name
+                + " AND "
+                + test_dataset_name
+                + " ----------"
+            )
+
+        request_body_content = {
+            self.TRAIN_NAME: train_dataset_name,
+            self.TEST_NAME: test_dataset_name,
+            self.CODE: modeling_code,
+            self.CLASSIFIERS_LIST: model_classifiers,
+        }
+        response = requests.post(url=self.cluster_url,
+                                 json=request_body_content)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_model(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 return indented string, else return dict.
+
+        return: A list with all model predictions metadata stored in Learning
+        Orchestra or an empty result.
+        """
+
+        cluster_url_tsne = self.cluster_url
+
+        response = requests.get(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_model_prediction(self,
+                                model_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 return indented string, else return dict.
+        model_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 there
+        is no such projection. The current page is also returned to be used in
+        future content requests.
+        """
+
+        cluster_url_dataset = self.cluster_url + "/" + model_name + \
+                              "?query=" + str(query) + \
+                              "&limit=" + str(limit) + \
+                              "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_dataset)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_model(self, model_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description:  This method is responsible for retrieving a specific
+        model prediction metadata.
+
+        pretty_response: If true return indented string, else return dict.
+        model_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_model_prediction(model_name, limit=1,
+                                                pretty_response=pretty_response)
+
+        return response
+
+    def delete_model(self, model_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting a model prediction.
+        The delete operation is always synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        model_name: Represents the projection name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        cluster_url_dataset = self.cluster_url + "/" + model_name
+
+        response = requests.delete(cluster_url_dataset)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+

Methods

+
+
+def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible for deleting a model prediction. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

+

pretty_response: If true return indented string, else return dict. +model_name: Represents the projection name.

+

return: JSON object with an error message, a warning message or a +correct delete message

+
+ +Expand source code + +
def delete_model(self, model_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for deleting a model prediction.
+    The delete operation is always synchronous because it is very fast,
+    since the deletion is performed in background.
+
+    pretty_response: If true return indented string, else return dict.
+    model_name: Represents the projection name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message
+    """
+
+    cluster_url_dataset = self.cluster_url + "/" + model_name
+
+    response = requests.delete(cluster_url_dataset)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +asynchronously, the caller does not wait until the model predictions are +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 model predictions are inserted.

+

train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

+

return: The resulted predictions URIs.

+
+ +Expand source code + +
def run_builder_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 resource join several steps of machine
+    learning workflow (transform, tune, train and evaluate) coupling in
+    a unique resource, builder creates several model predictions using
+    your own modeling code using a defined set of classifiers. This is made
+    asynchronously, the caller does not wait until the model predictions are
+    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 model predictions are inserted.
+
+    train_dataset_name: Represent final train dataset.
+    test_dataset_name: Represent final test dataset.
+    modeling_code: Represent Python3 code for pyspark preprocessing model
+    model_classifiers: list of initial classifiers to be used in model
+    pretty_response: returns indented string for visualization if True
+
+    return: The resulted predictions URIs.
+    """
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE MODEL WITH "
+            + train_dataset_name
+            + " AND "
+            + test_dataset_name
+            + " ----------"
+        )
+
+    request_body_content = {
+        self.TRAIN_NAME: train_dataset_name,
+        self.TEST_NAME: test_dataset_name,
+        self.CODE: modeling_code,
+        self.CLASSIFIERS_LIST: model_classifiers,
+    }
+    response = requests.post(url=self.cluster_url,
+                             json=request_body_content)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +synchronously, the caller waits until the model predictions are inserted +into the Learning Orchestra storage mechanism.

+

train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

+

return: The resulted predictions URIs.

+
+ +Expand source code + +
def run_builder_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 resource join several steps of machine
+    learning workflow (transform, tune, train and evaluate) coupling in
+    a unique resource, builder creates several model predictions using
+    your own modeling code using a defined set of classifiers. This is made
+    synchronously, the caller waits until the model predictions are inserted
+    into the Learning Orchestra storage mechanism.
+
+    train_dataset_name: Represent final train dataset.
+    test_dataset_name: Represent final test dataset.
+    modeling_code: Represent Python3 code for pyspark preprocessing model
+    model_classifiers: list of initial classifiers to be used in model
+    pretty_response: returns indented string for visualization if True
+
+    return: The resulted predictions URIs.
+    """
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE MODEL WITH "
+            + train_dataset_name
+            + " AND "
+            + test_dataset_name
+            + " ----------"
+        )
+
+    request_body_content = {
+        self.TRAIN_NAME: train_dataset_name,
+        self.TEST_NAME: test_dataset_name,
+        self.CODE: modeling_code,
+        self.CLASSIFIERS_LIST: model_classifiers,
+    }
+    response = requests.post(url=self.cluster_url,
+                             json=request_body_content)
+
+    observer = Observer(test_dataset_name, self.CLUSTER_IP)
+
+    for model in model_classifiers:
+        observer.set_dataset_name(test_dataset_name + model)
+        observer.observe_processing(pretty_response)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_all_model(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 return indented string, else return dict.

+

return: A list with all model predictions metadata stored in Learning +Orchestra or an empty result.

+
+ +Expand source code + +
def search_all_model(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 return indented string, else return dict.
+
+    return: A list with all model predictions metadata stored in Learning
+    Orchestra or an empty result.
+    """
+
+    cluster_url_tsne = self.cluster_url
+
+    response = requests.get(cluster_url_tsne)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: +This method is responsible for retrieving a specific +model prediction metadata.

+

pretty_response: If true return indented string, else return dict. +model_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.

+
+ +Expand source code + +
def search_model(self, model_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description:  This method is responsible for retrieving a specific
+    model prediction metadata.
+
+    pretty_response: If true return indented string, else return dict.
+    model_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_model_prediction(model_name, limit=1,
+                                            pretty_response=pretty_response)
+
+    return response
+
+
+
+def search_model_prediction(self, model_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 return indented string, else return dict. +model_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 there +is no such projection. The current page is also returned to be used in +future content requests.

+
+ +Expand source code + +
def search_model_prediction(self,
+                            model_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 return indented string, else return dict.
+    model_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 there
+    is no such projection. The current page is also returned to be used in
+    future content requests.
+    """
+
+    cluster_url_dataset = self.cluster_url + "/" + model_name + \
+                          "?query=" + str(query) + \
+                          "&limit=" + str(limit) + \
+                          "&skip=" + str(skip)
+
+    response = requests.get(cluster_url_dataset)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/builder/index.html b/docs/builder/index.html new file mode 100644 index 0000000..f6061e5 --- /dev/null +++ b/docs/builder/index.html @@ -0,0 +1,65 @@ + + + + + + +learning_orchestra_client.builder API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/docs/dataset/dataset.html b/docs/dataset/dataset.html new file mode 100644 index 0000000..64e61be --- /dev/null +++ b/docs/dataset/dataset.html @@ -0,0 +1,678 @@ + + + + + + +learning_orchestra_client.dataset.dataset API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.dataset.dataset

+
+
+
+ +Expand source code + +
__author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
+__credits__ = "all free source developers"
+__status__ = "Prototype"
+
+from ..observer import Observer
+from ..response_treat import ResponseTreat
+import requests
+from typing import Union
+
+
+class Dataset:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/dataset"
+        self.response_treat = ResponseTreat()
+        self.OUTPUT_NAME = "datasetName"
+        self.URL = "datasetURI"
+        self.CLUSTER_IP = ip_from_cluster
+
+    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 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.
+        """
+        request_body = {self.OUTPUT_NAME: dataset_name,
+                        self.URL: url}
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
+
+        if pretty_response:
+            print("\n----------" + " CREATED FILE " + 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).
+        """
+        request_body = {self.OUTPUT_NAME: dataset_name,
+                        self.URL: url}
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
+                                                                     "---")
+        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 return indented string, else return dict.
+
+        return: All datasets metadata stored in Learning Orchestra or an empty
+        result.
+        """
+        request_url = self.cluster_url
+
+        response = requests.get(request_url)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for retrieving a specific
+        dataset
+
+        pretty_response: If true return indented string, else return dict.
+        dataset_name: Is the name of the dataset file.
+        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 dataset metadata stored in Learning Orchestra or an
+        error if there is no such dataset.
+        """
+        response = self.search_dataset_content(dataset_name, limit=1,
+                                               pretty_response=pretty_response)
+
+        return 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 return indented string, else return dict.
+        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.
+        """
+
+        request_url = self.cluster_url + "/" + dataset_name + \
+                      "?query=" + str(query) + \
+                      "&limit=" + str(limit) + \
+                      "&skip=" + str(skip)
+
+        response = requests.get(request_url)
+
+        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. The
+        delete operation is always synchronous because it is very fast, since
+        the deletion is performed in background. If a dataset was used by
+        another task (Ex. projection, histogram, pca, tuning and so forth), it
+        cannot be deleted.
+
+        pretty_response: If true return indented string, else return dict.
+        dataset_name: Represents the dataset name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        request_url = self.cluster_url + "/" + dataset_name
+
+        response = requests.delete(request_url)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Dataset +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Dataset:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/dataset"
+        self.response_treat = ResponseTreat()
+        self.OUTPUT_NAME = "datasetName"
+        self.URL = "datasetURI"
+        self.CLUSTER_IP = ip_from_cluster
+
+    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 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.
+        """
+        request_body = {self.OUTPUT_NAME: dataset_name,
+                        self.URL: url}
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
+
+        if pretty_response:
+            print("\n----------" + " CREATED FILE " + 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).
+        """
+        request_body = {self.OUTPUT_NAME: dataset_name,
+                        self.URL: url}
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
+                                                                     "---")
+        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 return indented string, else return dict.
+
+        return: All datasets metadata stored in Learning Orchestra or an empty
+        result.
+        """
+        request_url = self.cluster_url
+
+        response = requests.get(request_url)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for retrieving a specific
+        dataset
+
+        pretty_response: If true return indented string, else return dict.
+        dataset_name: Is the name of the dataset file.
+        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 dataset metadata stored in Learning Orchestra or an
+        error if there is no such dataset.
+        """
+        response = self.search_dataset_content(dataset_name, limit=1,
+                                               pretty_response=pretty_response)
+
+        return 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 return indented string, else return dict.
+        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.
+        """
+
+        request_url = self.cluster_url + "/" + dataset_name + \
+                      "?query=" + str(query) + \
+                      "&limit=" + str(limit) + \
+                      "&skip=" + str(skip)
+
+        response = requests.get(request_url)
+
+        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. The
+        delete operation is always synchronous because it is very fast, since
+        the deletion is performed in background. If a dataset was used by
+        another task (Ex. projection, histogram, pca, tuning and so forth), it
+        cannot be deleted.
+
+        pretty_response: If true return indented string, else return dict.
+        dataset_name: Represents the dataset name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        request_url = self.cluster_url + "/" + dataset_name
+
+        response = requests.delete(request_url)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+

Methods

+
+
+def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] +
+
+

description: This method is responsible for deleting the dataset. The +delete operation is always synchronous because it is very fast, since +the deletion is performed in background. If a dataset was used by +another task (Ex. projection, histogram, pca, tuning and so forth), it +cannot be deleted.

+

pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset name.

+

return: JSON object with an error message, a warning message or a +correct delete message

+
+ +Expand source code + +
def delete_dataset(self, dataset_name, pretty_response=False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for deleting the dataset. The
+    delete operation is always synchronous because it is very fast, since
+    the deletion is performed in background. If a dataset was used by
+    another task (Ex. projection, histogram, pca, tuning and so forth), it
+    cannot be deleted.
+
+    pretty_response: If true return indented string, else return dict.
+    dataset_name: Represents the dataset name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message
+    """
+
+    request_url = self.cluster_url + "/" + dataset_name
+
+    response = requests.delete(request_url)
+
+    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).

+
+ +Expand source code + +
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).
+    """
+    request_body = {self.OUTPUT_NAME: dataset_name,
+                    self.URL: url}
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
+                                                                 "---")
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+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 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.

+
+ +Expand source code + +
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 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.
+    """
+    request_body = {self.OUTPUT_NAME: dataset_name,
+                    self.URL: url}
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
+
+    if pretty_response:
+        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
+                                                                 "---")
+    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 return indented string, else return dict.

+

return: All datasets metadata stored in Learning Orchestra or an empty +result.

+
+ +Expand source code + +
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 return indented string, else return dict.
+
+    return: All datasets metadata stored in Learning Orchestra or an empty
+    result.
+    """
+    request_url = self.cluster_url
+
+    response = requests.get(request_url)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible for retrieving a specific +dataset

+

pretty_response: If true return indented string, else return dict. +dataset_name: Is the name of the dataset file. +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 dataset metadata stored in Learning Orchestra or an +error if there is no such dataset.

+
+ +Expand source code + +
def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for retrieving a specific
+    dataset
+
+    pretty_response: If true return indented string, else return dict.
+    dataset_name: Is the name of the dataset file.
+    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 dataset metadata stored in Learning Orchestra or an
+    error if there is no such dataset.
+    """
+    response = self.search_dataset_content(dataset_name, limit=1,
+                                           pretty_response=pretty_response)
+
+    return 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 return indented string, else return dict. +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.

+
+ +Expand source code + +
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 return indented string, else return dict.
+    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.
+    """
+
+    request_url = self.cluster_url + "/" + dataset_name + \
+                  "?query=" + str(query) + \
+                  "&limit=" + str(limit) + \
+                  "&skip=" + str(skip)
+
+    response = requests.get(request_url)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/dataset/index.html b/docs/dataset/index.html new file mode 100644 index 0000000..b4c42b2 --- /dev/null +++ b/docs/dataset/index.html @@ -0,0 +1,65 @@ + + + + + + +learning_orchestra_client.dataset API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/docs/explore/histogram.html b/docs/explore/histogram.html new file mode 100644 index 0000000..e1abdfc --- /dev/null +++ b/docs/explore/histogram.html @@ -0,0 +1,676 @@ + + + + + + +learning_orchestra_client.explore.histogram API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.explore.histogram

+
+
+
+ +Expand source code + +
from ..observer import Observer
+from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+import requests
+from typing import Union
+
+
+class Histogram:
+    def __init__(self, ip_from_cluster: str):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/histogram"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputDatasetName"
+        self.FIELDS = "names"
+        self.dataset = Dataset(ip_from_cluster)
+
+    def run_histogram_sync(self,
+                           dataset_name: str,
+                           histogram_name: str,
+                           fields: list,
+                           pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method run histogram algorithm to create a histogram
+        synchronously, 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 return indented string, else return dict.
+
+        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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
+            pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE HISTOGRAM FROM "
+                + dataset_name
+                + " TO "
+                + histogram_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 run histogram algorithm to create a histogram
+        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
+
+        dataset_name: Represents the name of dataset.
+        histogram_name: Represents the name of histogram.
+        fields: Represents a list of attributes.
+        pretty_response: If true return indented string, else return dict.
+
+        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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE HISTOGRAM FROM "
+                + dataset_name
+                + " TO "
+                + histogram_name
+                + " ----------"
+            )
+
+        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 names, it does not
+        retrieve the histogram content.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all histogram names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_histogram = self.cluster_url
+
+        response = requests.get(cluster_url_histogram)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_histogram_data(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 return indented string, else return dict.
+        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.
+        """
+
+        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
+                                "?query=" + str(query) + \
+                                "&limit=" + str(limit) + \
+                                "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_histogram)
+
+        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 synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        histogram_name: Represents the histogram name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        cluster_url_histogram = self.cluster_url + "/" + histogram_name
+
+        response = requests.delete(cluster_url_histogram)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Histogram +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Histogram:
+    def __init__(self, ip_from_cluster: str):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/histogram"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputDatasetName"
+        self.FIELDS = "names"
+        self.dataset = Dataset(ip_from_cluster)
+
+    def run_histogram_sync(self,
+                           dataset_name: str,
+                           histogram_name: str,
+                           fields: list,
+                           pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method run histogram algorithm to create a histogram
+        synchronously, 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 return indented string, else return dict.
+
+        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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
+            pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE HISTOGRAM FROM "
+                + dataset_name
+                + " TO "
+                + histogram_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 run histogram algorithm to create a histogram
+        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
+
+        dataset_name: Represents the name of dataset.
+        histogram_name: Represents the name of histogram.
+        fields: Represents a list of attributes.
+        pretty_response: If true return indented string, else return dict.
+
+        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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE HISTOGRAM FROM "
+                + dataset_name
+                + " TO "
+                + histogram_name
+                + " ----------"
+            )
+
+        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 names, it does not
+        retrieve the histogram content.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all histogram names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_histogram = self.cluster_url
+
+        response = requests.get(cluster_url_histogram)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_histogram_data(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 return indented string, else return dict.
+        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.
+        """
+
+        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
+                                "?query=" + str(query) + \
+                                "&limit=" + str(limit) + \
+                                "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_histogram)
+
+        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 synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        histogram_name: Represents the histogram name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+
+        cluster_url_histogram = self.cluster_url + "/" + histogram_name
+
+        response = requests.delete(cluster_url_histogram)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+

Methods

+
+
+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 synchronous because it is very fast, +since the deletion is performed in background.

+

pretty_response: If true return indented string, else return dict. +histogram_name: Represents the histogram name.

+

return: JSON object with an error message, a warning message or a +correct delete message

+
+ +Expand source code + +
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 synchronous because it is very fast,
+    since the deletion is performed in background.
+
+    pretty_response: If true return indented string, else return dict.
+    histogram_name: Represents the histogram name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message
+    """
+
+    cluster_url_histogram = self.cluster_url + "/" + histogram_name
+
+    response = requests.delete(cluster_url_histogram)
+
+    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 run histogram algorithm to create a histogram +asynchronously, the caller does not wait until the histogram 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 histogram was inserted.

+

dataset_name: Represents the name of dataset. +histogram_name: Represents the name of histogram. +fields: Represents a list of attributes. +pretty_response: If true return indented string, else return dict.

+

return: A JSON object with error or warning messages. In case of +success, it returns a histogram.

+
+ +Expand source code + +
def run_histogram_async(self,
+                        dataset_name: str,
+                        histogram_name: str,
+                        fields: list,
+                        pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method run histogram algorithm to create a histogram
+    asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
+
+    dataset_name: Represents the name of dataset.
+    histogram_name: Represents the name of histogram.
+    fields: Represents a list of attributes.
+    pretty_response: If true return indented string, else return dict.
+
+    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.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE HISTOGRAM FROM "
+            + dataset_name
+            + " TO "
+            + histogram_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_histogram_sync(self, dataset_name: str, histogram_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run histogram algorithm to create a histogram +synchronously, 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 return indented string, else return dict.

+

return: A JSON object with error or warning messages. In case of +success, it returns a histogram.

+
+ +Expand source code + +
def run_histogram_sync(self,
+                       dataset_name: str,
+                       histogram_name: str,
+                       fields: list,
+                       pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method run histogram algorithm to create a histogram
+    synchronously, 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 return indented string, else return dict.
+
+    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.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    Observer(histogram_name, self.CLUSTER_IP).observe_processing(
+        pretty_response)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE HISTOGRAM FROM "
+            + dataset_name
+            + " TO "
+            + histogram_name
+            + " ----------"
+        )
+
+    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 names, it does not +retrieve the histogram content.

+

pretty_response: If true return indented string, else return dict.

+

return: A list with all histogram names stored in Learning Orchestra +or an empty result.

+
+ +Expand source code + +
def search_all_histograms(self, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves all histogram names, it does not
+    retrieve the histogram content.
+
+    pretty_response: If true return indented string, else return dict.
+
+    return: A list with all histogram names stored in Learning Orchestra
+    or an empty result.
+    """
+
+    cluster_url_histogram = self.cluster_url
+
+    response = requests.get(cluster_url_histogram)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_histogram_data(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 return indented string, else return dict. +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.

+
+ +Expand source code + +
def search_histogram_data(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 return indented string, else return dict.
+    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.
+    """
+
+    cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
+                            "?query=" + str(query) + \
+                            "&limit=" + str(limit) + \
+                            "&skip=" + str(skip)
+
+    response = requests.get(cluster_url_histogram)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/explore/index.html b/docs/explore/index.html new file mode 100644 index 0000000..d4f7495 --- /dev/null +++ b/docs/explore/index.html @@ -0,0 +1,75 @@ + + + + + + +learning_orchestra_client.explore API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/docs/explore/pca.html b/docs/explore/pca.html new file mode 100644 index 0000000..877a51d --- /dev/null +++ b/docs/explore/pca.html @@ -0,0 +1,742 @@ + + + + + + +learning_orchestra_client.explore.pca API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.explore.pca

+
+
+
+ +Expand source code + +
from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+from PIL import Image
+import requests
+import time
+from typing import Union
+
+
+class Pca:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/pca"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputPlotName"
+        self.LABEL = "label"
+        self.dataset = Dataset(ip_from_cluster)
+        self.WAIT_TIME = 5
+        self.CLUSTER_IP = ip_from_cluster
+
+    def run_pca_sync(self,
+                     dataset_name: str,
+                     pca_name: str,
+                     label: str,
+                     pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run PCA algorithm to create an image plot
+        synchronously, the caller waits until the PCA image is inserted into
+        the Learning Orchestra storage mechanism.
+
+        dataset_name: Name of dataset.
+        pca_name: Name of PCA image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a PCA image plot.
+        """
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: pca_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        self.verify_pca_exist(pca_name, pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PCA IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + pca_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_pca_async(self,
+                      dataset_name: str,
+                      pca_name: str,
+                      label: str,
+                      pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run PCA algorithm to create an image plot
+        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
+
+        dataset_name: Name of dataset.
+        pca_name: Name of PCA image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a PCA image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: pca_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PCA IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + pca_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method retrieves all PCAs plot names, it does not
+        retrieve the image plot.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all PCAs plot names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_pca = self.cluster_url
+
+        response = requests.get(cluster_url_pca)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves a PCA image plot.
+
+        pca_name: Name of PCA image plot.
+        pretty_response: If true open an image plot, else return link to
+        open image plot.
+
+        return: A link to an image plot or open an image plot.
+        """
+
+        cluster_url_pca = self.cluster_url + "/" + pca_name
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " READ "
+                + pca_name
+                + " PCA IMAGE PLOT "
+                + " ----------"
+            )
+            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
+            img.show()
+        else:
+            return cluster_url_pca
+
+    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting the PCA image plot.
+        The delete operation is always synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        pca_name: Represents the PCA name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message.
+        """
+
+        cluster_url_pca = self.cluster_url + "/" + pca_name
+
+        response = requests.delete(cluster_url_pca)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible to verify if a PCA image
+        exist into the Learning Orchestra storage mechanism.
+
+        pca_name: Name of PCA image plot.
+
+        return: True if the PCA requested exist, false if does not.
+        """
+
+        if pretty_response:
+            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
+                                                           "----------")
+
+        exist = False
+        pca_name += ".png"
+
+        while not exist:
+            time.sleep(self.WAIT_TIME)
+            all_pca = self.search_all_pca()
+            exist = pca_name in all_pca.get('result')
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Pca +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Pca:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/pca"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputPlotName"
+        self.LABEL = "label"
+        self.dataset = Dataset(ip_from_cluster)
+        self.WAIT_TIME = 5
+        self.CLUSTER_IP = ip_from_cluster
+
+    def run_pca_sync(self,
+                     dataset_name: str,
+                     pca_name: str,
+                     label: str,
+                     pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run PCA algorithm to create an image plot
+        synchronously, the caller waits until the PCA image is inserted into
+        the Learning Orchestra storage mechanism.
+
+        dataset_name: Name of dataset.
+        pca_name: Name of PCA image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a PCA image plot.
+        """
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: pca_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        self.verify_pca_exist(pca_name, pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PCA IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + pca_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_pca_async(self,
+                      dataset_name: str,
+                      pca_name: str,
+                      label: str,
+                      pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run PCA algorithm to create an image plot
+        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
+
+        dataset_name: Name of dataset.
+        pca_name: Name of PCA image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a PCA image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: pca_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PCA IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + pca_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method retrieves all PCAs plot names, it does not
+        retrieve the image plot.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all PCAs plot names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_pca = self.cluster_url
+
+        response = requests.get(cluster_url_pca)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves a PCA image plot.
+
+        pca_name: Name of PCA image plot.
+        pretty_response: If true open an image plot, else return link to
+        open image plot.
+
+        return: A link to an image plot or open an image plot.
+        """
+
+        cluster_url_pca = self.cluster_url + "/" + pca_name
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " READ "
+                + pca_name
+                + " PCA IMAGE PLOT "
+                + " ----------"
+            )
+            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
+            img.show()
+        else:
+            return cluster_url_pca
+
+    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting the PCA image plot.
+        The delete operation is always synchronous because it is very fast,
+        since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        pca_name: Represents the PCA name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message.
+        """
+
+        cluster_url_pca = self.cluster_url + "/" + pca_name
+
+        response = requests.delete(cluster_url_pca)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible to verify if a PCA image
+        exist into the Learning Orchestra storage mechanism.
+
+        pca_name: Name of PCA image plot.
+
+        return: True if the PCA requested exist, false if does not.
+        """
+
+        if pretty_response:
+            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
+                                                           "----------")
+
+        exist = False
+        pca_name += ".png"
+
+        while not exist:
+            time.sleep(self.WAIT_TIME)
+            all_pca = self.search_all_pca()
+            exist = pca_name in all_pca.get('result')
+
+

Methods

+
+
+def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible for deleting the PCA image plot. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

+

pretty_response: If true return indented string, else return dict. +pca_name: Represents the PCA name.

+

return: JSON object with an error message, a warning message or a +correct delete message.

+
+ +Expand source code + +
def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for deleting the PCA image plot.
+    The delete operation is always synchronous because it is very fast,
+    since the deletion is performed in background.
+
+    pretty_response: If true return indented string, else return dict.
+    pca_name: Represents the PCA name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message.
+    """
+
+    cluster_url_pca = self.cluster_url + "/" + pca_name
+
+    response = requests.delete(cluster_url_pca)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_pca_async(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run PCA algorithm to create an image plot +asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.

+

dataset_name: Name of dataset. +pca_name: Name of PCA image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

+

return: A JSON object with error or warning messages. In case of +success, it returns a PCA image plot.

+
+ +Expand source code + +
def run_pca_async(self,
+                  dataset_name: str,
+                  pca_name: str,
+                  label: str,
+                  pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method run PCA algorithm to create an image plot
+    asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
+
+    dataset_name: Name of dataset.
+    pca_name: Name of PCA image plot.
+    label: The label is the label name of the column for machine learning
+    datasets which has labeled tuples.
+    pretty_response: If true open an image plot, else return link to open
+    image plot.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns a PCA image plot.
+    """
+
+    request_body = {
+        self.INPUT_NAME: dataset_name,
+        self.OUTPUT_NAME: pca_name,
+        self.LABEL: label,
+    }
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE PCA IMAGE PLOT FROM "
+            + dataset_name
+            + " TO "
+            + pca_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_pca_sync(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run PCA algorithm to create an image plot +synchronously, the caller waits until the PCA image is inserted into +the Learning Orchestra storage mechanism.

+

dataset_name: Name of dataset. +pca_name: Name of PCA image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

+

return: A JSON object with error or warning messages. In case of +success, it returns a PCA image plot.

+
+ +Expand source code + +
def run_pca_sync(self,
+                 dataset_name: str,
+                 pca_name: str,
+                 label: str,
+                 pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method run PCA algorithm to create an image plot
+    synchronously, the caller waits until the PCA image is inserted into
+    the Learning Orchestra storage mechanism.
+
+    dataset_name: Name of dataset.
+    pca_name: Name of PCA image plot.
+    label: The label is the label name of the column for machine learning
+    datasets which has labeled tuples.
+    pretty_response: If true open an image plot, else return link to open
+    image plot.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns a PCA image plot.
+    """
+    request_body = {
+        self.INPUT_NAME: dataset_name,
+        self.OUTPUT_NAME: pca_name,
+        self.LABEL: label,
+    }
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    self.verify_pca_exist(pca_name, pretty_response)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE PCA IMAGE PLOT FROM "
+            + dataset_name
+            + " TO "
+            + pca_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_all_pca(self, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method retrieves all PCAs plot names, it does not +retrieve the image plot.

+

pretty_response: If true return indented string, else return dict.

+

return: A list with all PCAs plot names stored in Learning Orchestra +or an empty result.

+
+ +Expand source code + +
def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method retrieves all PCAs plot names, it does not
+    retrieve the image plot.
+
+    pretty_response: If true return indented string, else return dict.
+
+    return: A list with all PCAs plot names stored in Learning Orchestra
+    or an empty result.
+    """
+
+    cluster_url_pca = self.cluster_url
+
+    response = requests.get(cluster_url_pca)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method retrieves a PCA image plot.

+

pca_name: Name of PCA image plot. +pretty_response: If true open an image plot, else return link to +open image plot.

+

return: A link to an image plot or open an image plot.

+
+ +Expand source code + +
def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves a PCA image plot.
+
+    pca_name: Name of PCA image plot.
+    pretty_response: If true open an image plot, else return link to
+    open image plot.
+
+    return: A link to an image plot or open an image plot.
+    """
+
+    cluster_url_pca = self.cluster_url + "/" + pca_name
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " READ "
+            + pca_name
+            + " PCA IMAGE PLOT "
+            + " ----------"
+        )
+        img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
+        img.show()
+    else:
+        return cluster_url_pca
+
+
+
+def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible to verify if a PCA image +exist into the Learning Orchestra storage mechanism.

+

pca_name: Name of PCA image plot.

+

return: True if the PCA requested exist, false if does not.

+
+ +Expand source code + +
def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible to verify if a PCA image
+    exist into the Learning Orchestra storage mechanism.
+
+    pca_name: Name of PCA image plot.
+
+    return: True if the PCA requested exist, false if does not.
+    """
+
+    if pretty_response:
+        print("\n---------- CHECKING IF " + pca_name + " FINISHED "
+                                                       "----------")
+
+    exist = False
+    pca_name += ".png"
+
+    while not exist:
+        time.sleep(self.WAIT_TIME)
+        all_pca = self.search_all_pca()
+        exist = pca_name in all_pca.get('result')
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/explore/tsne.html b/docs/explore/tsne.html new file mode 100644 index 0000000..b4e1b63 --- /dev/null +++ b/docs/explore/tsne.html @@ -0,0 +1,742 @@ + + + + + + +learning_orchestra_client.explore.tsne API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.explore.tsne

+
+
+
+ +Expand source code + +
from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+from PIL import Image
+import requests
+import time
+from typing import Union
+
+
+class Tsne:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/tsne"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputPlotName"
+        self.LABEL = "label"
+        self.dataset = Dataset(ip_from_cluster)
+        self.WAIT_TIME = 5
+        self.CLUSTER_IP = ip_from_cluster
+
+    def run_tsne_sync(self,
+                      dataset_name: str,
+                      tsne_name: str,
+                      label: str,
+                      pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run t_SNE algorithm to create an image plot
+        synchronously, the caller waits until the t_SNE image is inserted into
+        the Learning Orchestra storage mechanism.
+
+        dataset_name: Name of dataset.
+        tsne_name: Name of t_SNE image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a t_SNE image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: tsne_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        self.verify_tsne_exist(tsne_name, pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE TSNE IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + tsne_name
+                + " ----------"
+            )
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_tsne_async(self,
+                       dataset_name: str,
+                       tsne_name: str,
+                       label: str,
+                       pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run t_SNE algorithm to create an image plot
+        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
+
+        dataset_name: Name of dataset.
+        tsne_name: Name of t_SNE image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a t_SNE image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: tsne_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE TSNE IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + tsne_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_tsne(self, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves all t_SNE plot names, it does not
+        retrieve the image plot.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all t_SNEs plot names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_tsne = self.cluster_url
+
+        response = requests.get(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves a t_SNE image plot.
+
+        tsne_name: Name of t_SNE image plot.
+        pretty_response: If true open an image plot, else return link to
+        open image plot.
+
+        return: A link to an image plot or open an image plot.
+        """
+
+        cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " READ"
+                + tsne_name
+                + " tsne IMAGE PLOT "
+                + " ----------"
+            )
+            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
+            img.show()
+        else:
+            return cluster_url_tsne
+
+    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting the t_SNE image
+        plot. The delete operation is always synchronous because it is very
+        fast, since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        tsne_name: Represents the tsne name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message.
+        """
+
+        cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+        response = requests.delete(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible to verify if a t_SNE image
+        exist into the Learning Orchestra storage mechanism.
+
+        tsne_name: Name of t_SNE image plot.
+
+        return: True if the t_SNE requested exist, false if does not.
+        """
+
+        if pretty_response:
+            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
+                                                            "----------")
+
+        exist = False
+        tsne_name += ".png"
+        while not exist:
+            time.sleep(self.WAIT_TIME)
+            all_tsne = self.search_all_tsne()
+            exist = tsne_name in all_tsne.get('result')
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Tsne +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Tsne:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/explore/tsne"
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputPlotName"
+        self.LABEL = "label"
+        self.dataset = Dataset(ip_from_cluster)
+        self.WAIT_TIME = 5
+        self.CLUSTER_IP = ip_from_cluster
+
+    def run_tsne_sync(self,
+                      dataset_name: str,
+                      tsne_name: str,
+                      label: str,
+                      pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run t_SNE algorithm to create an image plot
+        synchronously, the caller waits until the t_SNE image is inserted into
+        the Learning Orchestra storage mechanism.
+
+        dataset_name: Name of dataset.
+        tsne_name: Name of t_SNE image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a t_SNE image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: tsne_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        self.verify_tsne_exist(tsne_name, pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE TSNE IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + tsne_name
+                + " ----------"
+            )
+        return self.response_treat.treatment(response, pretty_response)
+
+    def run_tsne_async(self,
+                       dataset_name: str,
+                       tsne_name: str,
+                       label: str,
+                       pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description: This method run t_SNE algorithm to create an image plot
+        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
+
+        dataset_name: Name of dataset.
+        tsne_name: Name of t_SNE image plot.
+        label: The label is the label name of the column for machine learning
+        datasets which has labeled tuples.
+        pretty_response: If true open an image plot, else return link to open
+        image plot.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns a t_SNE image plot.
+        """
+
+        request_body = {
+            self.INPUT_NAME: dataset_name,
+            self.OUTPUT_NAME: tsne_name,
+            self.LABEL: label,
+        }
+        request_url = self.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE TSNE IMAGE PLOT FROM "
+                + dataset_name
+                + " TO "
+                + tsne_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_all_tsne(self, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves all t_SNE plot names, it does not
+        retrieve the image plot.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all t_SNEs plot names stored in Learning Orchestra
+        or an empty result.
+        """
+
+        cluster_url_tsne = self.cluster_url
+
+        response = requests.get(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves a t_SNE image plot.
+
+        tsne_name: Name of t_SNE image plot.
+        pretty_response: If true open an image plot, else return link to
+        open image plot.
+
+        return: A link to an image plot or open an image plot.
+        """
+
+        cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " READ"
+                + tsne_name
+                + " tsne IMAGE PLOT "
+                + " ----------"
+            )
+            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
+            img.show()
+        else:
+            return cluster_url_tsne
+
+    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible for deleting the t_SNE image
+        plot. The delete operation is always synchronous because it is very
+        fast, since the deletion is performed in background.
+
+        pretty_response: If true return indented string, else return dict.
+        tsne_name: Represents the tsne name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message.
+        """
+
+        cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+        response = requests.delete(cluster_url_tsne)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method is responsible to verify if a t_SNE image
+        exist into the Learning Orchestra storage mechanism.
+
+        tsne_name: Name of t_SNE image plot.
+
+        return: True if the t_SNE requested exist, false if does not.
+        """
+
+        if pretty_response:
+            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
+                                                            "----------")
+
+        exist = False
+        tsne_name += ".png"
+        while not exist:
+            time.sleep(self.WAIT_TIME)
+            all_tsne = self.search_all_tsne()
+            exist = tsne_name in all_tsne.get('result')
+
+

Methods

+
+
+def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible for deleting the t_SNE image +plot. The delete operation is always synchronous because it is very +fast, since the deletion is performed in background.

+

pretty_response: If true return indented string, else return dict. +tsne_name: Represents the tsne name.

+

return: JSON object with an error message, a warning message or a +correct delete message.

+
+ +Expand source code + +
def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible for deleting the t_SNE image
+    plot. The delete operation is always synchronous because it is very
+    fast, since the deletion is performed in background.
+
+    pretty_response: If true return indented string, else return dict.
+    tsne_name: Represents the tsne name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message.
+    """
+
+    cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+    response = requests.delete(cluster_url_tsne)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_tsne_async(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run t_SNE algorithm to create an image plot +asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.

+

dataset_name: Name of dataset. +tsne_name: Name of t_SNE image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

+

return: A JSON object with error or warning messages. In case of +success, it returns a t_SNE image plot.

+
+ +Expand source code + +
def run_tsne_async(self,
+                   dataset_name: str,
+                   tsne_name: str,
+                   label: str,
+                   pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method run t_SNE algorithm to create an image plot
+    asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
+
+    dataset_name: Name of dataset.
+    tsne_name: Name of t_SNE image plot.
+    label: The label is the label name of the column for machine learning
+    datasets which has labeled tuples.
+    pretty_response: If true open an image plot, else return link to open
+    image plot.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns a t_SNE image plot.
+    """
+
+    request_body = {
+        self.INPUT_NAME: dataset_name,
+        self.OUTPUT_NAME: tsne_name,
+        self.LABEL: label,
+    }
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE TSNE IMAGE PLOT FROM "
+            + dataset_name
+            + " TO "
+            + tsne_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def run_tsne_sync(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method run t_SNE algorithm to create an image plot +synchronously, the caller waits until the t_SNE image is inserted into +the Learning Orchestra storage mechanism.

+

dataset_name: Name of dataset. +tsne_name: Name of t_SNE image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

+

return: A JSON object with error or warning messages. In case of +success, it returns a t_SNE image plot.

+
+ +Expand source code + +
def run_tsne_sync(self,
+                  dataset_name: str,
+                  tsne_name: str,
+                  label: str,
+                  pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description: This method run t_SNE algorithm to create an image plot
+    synchronously, the caller waits until the t_SNE image is inserted into
+    the Learning Orchestra storage mechanism.
+
+    dataset_name: Name of dataset.
+    tsne_name: Name of t_SNE image plot.
+    label: The label is the label name of the column for machine learning
+    datasets which has labeled tuples.
+    pretty_response: If true open an image plot, else return link to open
+    image plot.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns a t_SNE image plot.
+    """
+
+    request_body = {
+        self.INPUT_NAME: dataset_name,
+        self.OUTPUT_NAME: tsne_name,
+        self.LABEL: label,
+    }
+    request_url = self.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    self.verify_tsne_exist(tsne_name, pretty_response)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE TSNE IMAGE PLOT FROM "
+            + dataset_name
+            + " TO "
+            + tsne_name
+            + " ----------"
+        )
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_all_tsne(self, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method retrieves all t_SNE plot names, it does not +retrieve the image plot.

+

pretty_response: If true return indented string, else return dict.

+

return: A list with all t_SNEs plot names stored in Learning Orchestra +or an empty result.

+
+ +Expand source code + +
def search_all_tsne(self, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves all t_SNE plot names, it does not
+    retrieve the image plot.
+
+    pretty_response: If true return indented string, else return dict.
+
+    return: A list with all t_SNEs plot names stored in Learning Orchestra
+    or an empty result.
+    """
+
+    cluster_url_tsne = self.cluster_url
+
+    response = requests.get(cluster_url_tsne)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method retrieves a t_SNE image plot.

+

tsne_name: Name of t_SNE image plot. +pretty_response: If true open an image plot, else return link to +open image plot.

+

return: A link to an image plot or open an image plot.

+
+ +Expand source code + +
def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves a t_SNE image plot.
+
+    tsne_name: Name of t_SNE image plot.
+    pretty_response: If true open an image plot, else return link to
+    open image plot.
+
+    return: A link to an image plot or open an image plot.
+    """
+
+    cluster_url_tsne = self.cluster_url + "/" + tsne_name
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " READ"
+            + tsne_name
+            + " tsne IMAGE PLOT "
+            + " ----------"
+        )
+        img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
+        img.show()
+    else:
+        return cluster_url_tsne
+
+
+
+def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method is responsible to verify if a t_SNE image +exist into the Learning Orchestra storage mechanism.

+

tsne_name: Name of t_SNE image plot.

+

return: True if the t_SNE requested exist, false if does not.

+
+ +Expand source code + +
def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method is responsible to verify if a t_SNE image
+    exist into the Learning Orchestra storage mechanism.
+
+    tsne_name: Name of t_SNE image plot.
+
+    return: True if the t_SNE requested exist, false if does not.
+    """
+
+    if pretty_response:
+        print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
+                                                        "----------")
+
+    exist = False
+    tsne_name += ".png"
+    while not exist:
+        time.sleep(self.WAIT_TIME)
+        all_tsne = self.search_all_tsne()
+        exist = tsne_name in all_tsne.get('result')
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..64b720b --- /dev/null +++ b/docs/index.html @@ -0,0 +1,85 @@ + + + + + + +learning_orchestra_client API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/docs/observer.html b/docs/observer.html new file mode 100644 index 0000000..a7d3aee --- /dev/null +++ b/docs/observer.html @@ -0,0 +1,375 @@ + + + + + + +learning_orchestra_client.observer API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.observer

+
+
+
+ +Expand source code + +
from pymongo import MongoClient, change_stream
+
+
+class Observer:
+    def __init__(self, dataset_name: str, cluster_ip: str):
+        self.dataset_name = dataset_name
+
+        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
+        mongo_client = MongoClient(mongo_url)
+        self.database = mongo_client['database']
+
+    def set_dataset_name(self, dataset_name: str):
+        """
+        :description: Changes the dataset name used in object.
+        :param dataset_name: Name of dataset to observe.
+
+        :return: None.
+        """
+        self.dataset_name = dataset_name
+
+    def get_dataset_name(self) -> str:
+        """
+        :description: Retrieve the dataset name used in object.
+
+        :return: The dataset name.
+        """
+        return self.dataset_name
+
+    def observe_processing(self, pretty_response: bool = False) -> dict:
+        """
+        :description: Observe the finished processing status from some
+        processing, blocking the code execution until finish processing.
+
+        :return: A dict with metadata file of used dataset name.
+        """
+        if pretty_response:
+            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
+                                                                    "----------")
+        dataset_collection = self.database[self.dataset_name]
+        metadata_query = {"_id": 0}
+        dataset_metadata = dataset_collection.find_one(metadata_query)
+
+        if dataset_metadata is None:
+            print("Dataset name or dataset URL invalid")
+            exit()
+
+        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').next()['fullDocument']
+
+    def observe_storage(self) -> change_stream.CollectionChangeStream:
+        """
+        :description: Get all changes from a dataset
+
+        :return: A pymongo CollectionChangeStream object, use the builtin
+        next() method to iterate over changes.
+        """
+
+        observer_query = [
+            {'$match': {
+                '$or': [
+                    {'operationType': 'replace'},
+                    {'operationType': 'insert'},
+                    {'operationType': 'update'},
+                    {'operationType': 'delete'}
+
+                ]
+            }}
+        ]
+        return self.database[self.dataset_name].watch(
+            observer_query,
+            full_document='updateLookup')
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Observer +(dataset_name: str, cluster_ip: str) +
+
+
+
+ +Expand source code + +
class Observer:
+    def __init__(self, dataset_name: str, cluster_ip: str):
+        self.dataset_name = dataset_name
+
+        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
+        mongo_client = MongoClient(mongo_url)
+        self.database = mongo_client['database']
+
+    def set_dataset_name(self, dataset_name: str):
+        """
+        :description: Changes the dataset name used in object.
+        :param dataset_name: Name of dataset to observe.
+
+        :return: None.
+        """
+        self.dataset_name = dataset_name
+
+    def get_dataset_name(self) -> str:
+        """
+        :description: Retrieve the dataset name used in object.
+
+        :return: The dataset name.
+        """
+        return self.dataset_name
+
+    def observe_processing(self, pretty_response: bool = False) -> dict:
+        """
+        :description: Observe the finished processing status from some
+        processing, blocking the code execution until finish processing.
+
+        :return: A dict with metadata file of used dataset name.
+        """
+        if pretty_response:
+            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
+                                                                    "----------")
+        dataset_collection = self.database[self.dataset_name]
+        metadata_query = {"_id": 0}
+        dataset_metadata = dataset_collection.find_one(metadata_query)
+
+        if dataset_metadata is None:
+            print("Dataset name or dataset URL invalid")
+            exit()
+
+        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').next()['fullDocument']
+
+    def observe_storage(self) -> change_stream.CollectionChangeStream:
+        """
+        :description: Get all changes from a dataset
+
+        :return: A pymongo CollectionChangeStream object, use the builtin
+        next() method to iterate over changes.
+        """
+
+        observer_query = [
+            {'$match': {
+                '$or': [
+                    {'operationType': 'replace'},
+                    {'operationType': 'insert'},
+                    {'operationType': 'update'},
+                    {'operationType': 'delete'}
+
+                ]
+            }}
+        ]
+        return self.database[self.dataset_name].watch(
+            observer_query,
+            full_document='updateLookup')
+
+

Methods

+
+
+def get_dataset_name(self) ‑> str +
+
+

:description: Retrieve the dataset name used in object.

+

:return: The dataset name.

+
+ +Expand source code + +
def get_dataset_name(self) -> str:
+    """
+    :description: Retrieve the dataset name used in object.
+
+    :return: The dataset name.
+    """
+    return self.dataset_name
+
+
+
+def observe_processing(self, pretty_response: bool = False) ‑> dict +
+
+

:description: Observe the finished processing status from some +processing, blocking the code execution until finish processing.

+

:return: A dict with metadata file of used dataset name.

+
+ +Expand source code + +
def observe_processing(self, pretty_response: bool = False) -> dict:
+    """
+    :description: Observe the finished processing status from some
+    processing, blocking the code execution until finish processing.
+
+    :return: A dict with metadata file of used dataset name.
+    """
+    if pretty_response:
+        print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
+                                                                "----------")
+    dataset_collection = self.database[self.dataset_name]
+    metadata_query = {"_id": 0}
+    dataset_metadata = dataset_collection.find_one(metadata_query)
+
+    if dataset_metadata is None:
+        print("Dataset name or dataset URL invalid")
+        exit()
+
+    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').next()['fullDocument']
+
+
+
+def observe_storage(self) ‑> pymongo.change_stream.CollectionChangeStream +
+
+

:description: Get all changes from a dataset

+

:return: A pymongo CollectionChangeStream object, use the builtin +next() method to iterate over changes.

+
+ +Expand source code + +
def observe_storage(self) -> change_stream.CollectionChangeStream:
+    """
+    :description: Get all changes from a dataset
+
+    :return: A pymongo CollectionChangeStream object, use the builtin
+    next() method to iterate over changes.
+    """
+
+    observer_query = [
+        {'$match': {
+            '$or': [
+                {'operationType': 'replace'},
+                {'operationType': 'insert'},
+                {'operationType': 'update'},
+                {'operationType': 'delete'}
+
+            ]
+        }}
+    ]
+    return self.database[self.dataset_name].watch(
+        observer_query,
+        full_document='updateLookup')
+
+
+
+def set_dataset_name(self, dataset_name: str) +
+
+

:description: Changes the dataset name used in object. +:param dataset_name: Name of dataset to observe.

+

:return: None.

+
+ +Expand source code + +
def set_dataset_name(self, dataset_name: str):
+    """
+    :description: Changes the dataset name used in object.
+    :param dataset_name: Name of dataset to observe.
+
+    :return: None.
+    """
+    self.dataset_name = dataset_name
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/response_treat.html b/docs/response_treat.html new file mode 100644 index 0000000..2c8bb2a --- /dev/null +++ b/docs/response_treat.html @@ -0,0 +1,197 @@ + + + + + + +learning_orchestra_client.response_treat API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.response_treat

+
+
+
+ +Expand source code + +
__author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
+__credits__ = "all free source developers"
+__status__ = "Prototype"
+
+import json
+
+
+class ResponseTreat:
+    HTTP_CREATED = 201
+    HTTP_SUCCESS = 200
+    HTTP_ERROR = 500
+
+    def treatment(self, response, pretty_response: bool = True):
+        """
+        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:
+            return response.text
+        elif (
+                response.status_code != self.HTTP_SUCCESS
+                and response.status_code != self.HTTP_CREATED
+        ):
+            raise Exception(response.json()["result"])
+        else:
+            if pretty_response:
+                return json.dumps(response.json(), indent=4, sort_keys=True)
+            else:
+                return response.json()
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class ResponseTreat +
+
+
+
+ +Expand source code + +
class ResponseTreat:
+    HTTP_CREATED = 201
+    HTTP_SUCCESS = 200
+    HTTP_ERROR = 500
+
+    def treatment(self, response, pretty_response: bool = True):
+        """
+        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:
+            return response.text
+        elif (
+                response.status_code != self.HTTP_SUCCESS
+                and response.status_code != self.HTTP_CREATED
+        ):
+            raise Exception(response.json()["result"])
+        else:
+            if pretty_response:
+                return json.dumps(response.json(), indent=4, sort_keys=True)
+            else:
+                return response.json()
+
+

Class variables

+
+
var HTTP_CREATED
+
+
+
+
var HTTP_ERROR
+
+
+
+
var HTTP_SUCCESS
+
+
+
+
+

Methods

+
+
+def treatment(self, response, pretty_response: bool = True) +
+
+

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.

+
+ +Expand source code + +
def treatment(self, response, pretty_response: bool = True):
+    """
+    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:
+        return response.text
+    elif (
+            response.status_code != self.HTTP_SUCCESS
+            and response.status_code != self.HTTP_CREATED
+    ):
+        raise Exception(response.json()["result"])
+    else:
+        if pretty_response:
+            return json.dumps(response.json(), indent=4, sort_keys=True)
+        else:
+            return response.json()
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/transform/data_type.html b/docs/transform/data_type.html new file mode 100644 index 0000000..fcd25c1 --- /dev/null +++ b/docs/transform/data_type.html @@ -0,0 +1,199 @@ + + + + + + +learning_orchestra_client.transform.data_type API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.transform.data_type

+
+
+
+ +Expand source code + +
from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+import requests
+from typing import Union
+
+
+class DataType:
+    def __init__(self, ip_from_cluster):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/transform/dataType"
+        self.ResponseTreat = ResponseTreat()
+        self.Dataset = Dataset(ip_from_cluster)
+        self.INPUT_NAME = "inputDatasetName"
+        self.TYPES = "types"
+
+    def update_dataset_types(self,
+                             dataset_name: str,
+                             fields_change: dict,
+                             pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: Change types of fields to number or string.
+
+        dataset_name: Represents the dataset name.
+        fields_change: Fields to change with types. This is a dict with each
+        key:value being field:type
+
+        return: A JSON object with error or warning messages.
+        """
+
+        url_request = self.cluster_url
+        body_request = {
+            self.INPUT_NAME: dataset_name,
+            self.TYPES: fields_change
+        }
+
+        response = requests.patch(url=url_request, json=body_request)
+
+        return self.ResponseTreat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class DataType +(ip_from_cluster) +
+
+
+
+ +Expand source code + +
class DataType:
+    def __init__(self, ip_from_cluster):
+        self.CLUSTER_IP = ip_from_cluster
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/transform/dataType"
+        self.ResponseTreat = ResponseTreat()
+        self.Dataset = Dataset(ip_from_cluster)
+        self.INPUT_NAME = "inputDatasetName"
+        self.TYPES = "types"
+
+    def update_dataset_types(self,
+                             dataset_name: str,
+                             fields_change: dict,
+                             pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: Change types of fields to number or string.
+
+        dataset_name: Represents the dataset name.
+        fields_change: Fields to change with types. This is a dict with each
+        key:value being field:type
+
+        return: A JSON object with error or warning messages.
+        """
+
+        url_request = self.cluster_url
+        body_request = {
+            self.INPUT_NAME: dataset_name,
+            self.TYPES: fields_change
+        }
+
+        response = requests.patch(url=url_request, json=body_request)
+
+        return self.ResponseTreat.treatment(response, pretty_response)
+
+

Methods

+
+
+def update_dataset_types(self, dataset_name: str, fields_change: dict, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: Change types of fields to number or string.

+

dataset_name: Represents the dataset name. +fields_change: Fields to change with types. This is a dict with each +key:value being field:type

+

return: A JSON object with error or warning messages.

+
+ +Expand source code + +
def update_dataset_types(self,
+                         dataset_name: str,
+                         fields_change: dict,
+                         pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: Change types of fields to number or string.
+
+    dataset_name: Represents the dataset name.
+    fields_change: Fields to change with types. This is a dict with each
+    key:value being field:type
+
+    return: A JSON object with error or warning messages.
+    """
+
+    url_request = self.cluster_url
+    body_request = {
+        self.INPUT_NAME: dataset_name,
+        self.TYPES: fields_change
+    }
+
+    response = requests.patch(url=url_request, json=body_request)
+
+    return self.ResponseTreat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/transform/index.html b/docs/transform/index.html new file mode 100644 index 0000000..271146f --- /dev/null +++ b/docs/transform/index.html @@ -0,0 +1,70 @@ + + + + + + +learning_orchestra_client.transform API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/docs/transform/projection.html b/docs/transform/projection.html new file mode 100644 index 0000000..7e84007 --- /dev/null +++ b/docs/transform/projection.html @@ -0,0 +1,1035 @@ + + + + + + +learning_orchestra_client.transform.projection API documentation + + + + + + + + + + + +
+
+
+

Module learning_orchestra_client.transform.projection

+
+
+
+ +Expand source code + +
from ..response_treat import ResponseTreat
+from ..dataset.dataset import Dataset
+from ..observer import Observer
+import requests
+from typing import Union
+
+
+class Projection:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/transform/projection"
+        self.METADATA_INDEX = 0
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputDatasetName"
+        self.FIELDS = "names"
+        self.dataset = Dataset(ip_from_cluster)
+        self.CLUSTER_IP = ip_from_cluster
+
+    def insert_dataset_attributes_sync(self,
+                                       dataset_name: str,
+                                       projection_name: str,
+                                       fields: list,
+                                       pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method inserts a set of attributes into a dataset
+        synchronously, the caller waits until the projection is inserted into
+        the Learning Orchestra storage mechanism.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields: Represents the set of attributes to be inserted. This is list
+        with all 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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(projection_name, self.CLUSTER_IP).observe_processing(
+            pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PROJECTION FROM "
+                + dataset_name
+                + " TO "
+                + projection_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def insert_dataset_attributes_async(self,
+                                        dataset_name: str,
+                                        projection_name: str,
+                                        fields: list,
+                                        pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method inserts a set of attributes into a dataset
+        asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields: Represents the set of attributes to be inserted. This is list
+        with all 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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PROJECTION FROM "
+                + dataset_name
+                + " TO "
+                + projection_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def delete_dataset_attributes_sync(self,
+                                       dataset_name: str,
+                                       projection_name: str,
+                                       fields_to_delete: list,
+                                       pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method delete a set of attributes on a dataset
+        synchronously, the caller waits until the projection is inserted into
+        the Learning Orchestra storage mechanism.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields_to_delete: Represents the set of attributes to be inserted.
+        This is list with all attributes.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns the projection metadata.
+        """
+        dataset_metadata = self.search_projections_content(dataset_name,
+                                                           limit=1)
+
+        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+            .get('fields')
+        for field in fields_to_delete:
+            fields_to_insert.remove(field)
+
+        response = self.insert_dataset_attributes_sync(dataset_name,
+                                                       projection_name,
+                                                       fields_to_insert,
+                                                       pretty_response)
+
+        return response
+
+    def delete_dataset_attributes_async(self,
+                                        dataset_name: str,
+                                        projection_name: str,
+                                        fields_to_delete: list,
+                                        pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method delete a set of attributes into a dataset
+        asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields_to_delete: Represents the set of attributes to be inserted.
+        This is list with all attributes.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns the projection metadata.
+        """
+        dataset_metadata = self.search_projections_content(dataset_name,
+                                                           limit=1)
+
+        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+            .get('fields')
+        for field in fields_to_delete:
+            fields_to_insert.remove(field)
+
+        response = self.insert_dataset_attributes_async(dataset_name,
+                                                        projection_name,
+                                                        fields_to_insert,
+                                                        pretty_response)
+
+        return response
+
+    def search_all_projections(self, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves all projection metadata, it does not
+        retrieve the projection content.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all projections metadata stored in Learning
+        Orchestra or an empty result.
+        """
+        cluster_url_projection = self.cluster_url
+
+        response = requests.get(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_projections(self, projection_name: str,
+                           pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description:  This method is responsible for retrieving a specific
+        projection.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
+        error if there is no such projections.
+        """
+        pretty = pretty_response
+
+        response = self.search_projections_content(projection_name, limit=1,
+                                                   pretty_response=pretty)
+
+        return response
+
+    def search_projections_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 dataset
+        content.
+
+        pretty_response: If true return indented string, else return dict.
+        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.
+        """
+
+        cluster_url_projection = self.cluster_url + "/" + projection_name + \
+                                 "?query=" + str(query) + \
+                                 "&limit=" + str(limit) + \
+                                 "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def delete_projections(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 synchronous because it is very fast,
+        since the deletion is performed in background. If a projection was
+        used by another task (Ex. histogram, pca, tuning and so forth),
+        it cannot be deleted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+        cluster_url_projection = self.cluster_url + "/" + projection_name
+
+        response = requests.delete(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Projection +(ip_from_cluster: str) +
+
+
+
+ +Expand source code + +
class Projection:
+    def __init__(self, ip_from_cluster: str):
+        self.cluster_url = "http://" + ip_from_cluster + \
+                           "/api/learningOrchestra/v1/transform/projection"
+        self.METADATA_INDEX = 0
+        self.response_treat = ResponseTreat()
+        self.INPUT_NAME = "inputDatasetName"
+        self.OUTPUT_NAME = "outputDatasetName"
+        self.FIELDS = "names"
+        self.dataset = Dataset(ip_from_cluster)
+        self.CLUSTER_IP = ip_from_cluster
+
+    def insert_dataset_attributes_sync(self,
+                                       dataset_name: str,
+                                       projection_name: str,
+                                       fields: list,
+                                       pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method inserts a set of attributes into a dataset
+        synchronously, the caller waits until the projection is inserted into
+        the Learning Orchestra storage mechanism.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields: Represents the set of attributes to be inserted. This is list
+        with all 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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        Observer(projection_name, self.CLUSTER_IP).observe_processing(
+            pretty_response)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PROJECTION FROM "
+                + dataset_name
+                + " TO "
+                + projection_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def insert_dataset_attributes_async(self,
+                                        dataset_name: str,
+                                        projection_name: str,
+                                        fields: list,
+                                        pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method inserts a set of attributes into a dataset
+        asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields: Represents the set of attributes to be inserted. This is list
+        with all 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.cluster_url
+
+        response = requests.post(url=request_url, json=request_body)
+
+        if pretty_response:
+            print(
+                "\n----------"
+                + " CREATE PROJECTION FROM "
+                + dataset_name
+                + " TO "
+                + projection_name
+                + " ----------"
+            )
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def delete_dataset_attributes_sync(self,
+                                       dataset_name: str,
+                                       projection_name: str,
+                                       fields_to_delete: list,
+                                       pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method delete a set of attributes on a dataset
+        synchronously, the caller waits until the projection is inserted into
+        the Learning Orchestra storage mechanism.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields_to_delete: Represents the set of attributes to be inserted.
+        This is list with all attributes.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns the projection metadata.
+        """
+        dataset_metadata = self.search_projections_content(dataset_name,
+                                                           limit=1)
+
+        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+            .get('fields')
+        for field in fields_to_delete:
+            fields_to_insert.remove(field)
+
+        response = self.insert_dataset_attributes_sync(dataset_name,
+                                                       projection_name,
+                                                       fields_to_insert,
+                                                       pretty_response)
+
+        return response
+
+    def delete_dataset_attributes_async(self,
+                                        dataset_name: str,
+                                        projection_name: str,
+                                        fields_to_delete: list,
+                                        pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method delete a set of attributes into a dataset
+        asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+        dataset_name: Represents the dataset name.
+        fields_to_delete: Represents the set of attributes to be inserted.
+        This is list with all attributes.
+
+        return: A JSON object with error or warning messages. In case of
+        success, it returns the projection metadata.
+        """
+        dataset_metadata = self.search_projections_content(dataset_name,
+                                                           limit=1)
+
+        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+            .get('fields')
+        for field in fields_to_delete:
+            fields_to_insert.remove(field)
+
+        response = self.insert_dataset_attributes_async(dataset_name,
+                                                        projection_name,
+                                                        fields_to_insert,
+                                                        pretty_response)
+
+        return response
+
+    def search_all_projections(self, pretty_response: bool = False) \
+            -> Union[dict, str]:
+        """
+        description: This method retrieves all projection metadata, it does not
+        retrieve the projection content.
+
+        pretty_response: If true return indented string, else return dict.
+
+        return: A list with all projections metadata stored in Learning
+        Orchestra or an empty result.
+        """
+        cluster_url_projection = self.cluster_url
+
+        response = requests.get(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def search_projections(self, projection_name: str,
+                           pretty_response: bool = False) -> Union[dict, str]:
+        """
+        description:  This method is responsible for retrieving a specific
+        projection.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
+        error if there is no such projections.
+        """
+        pretty = pretty_response
+
+        response = self.search_projections_content(projection_name, limit=1,
+                                                   pretty_response=pretty)
+
+        return response
+
+    def search_projections_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 dataset
+        content.
+
+        pretty_response: If true return indented string, else return dict.
+        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.
+        """
+
+        cluster_url_projection = self.cluster_url + "/" + projection_name + \
+                                 "?query=" + str(query) + \
+                                 "&limit=" + str(limit) + \
+                                 "&skip=" + str(skip)
+
+        response = requests.get(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+    def delete_projections(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 synchronous because it is very fast,
+        since the deletion is performed in background. If a projection was
+        used by another task (Ex. histogram, pca, tuning and so forth),
+        it cannot be deleted.
+
+        pretty_response: If true return indented string, else return dict.
+        projection_name: Represents the projection name.
+
+        return: JSON object with an error message, a warning message or a
+        correct delete message
+        """
+        cluster_url_projection = self.cluster_url + "/" + projection_name
+
+        response = requests.delete(cluster_url_projection)
+
+        return self.response_treat.treatment(response, pretty_response)
+
+

Methods

+
+
+def delete_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method delete a set of attributes into a dataset +asynchronously, the caller does not wait until the projections 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 projection was inserted.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields_to_delete: Represents the set of attributes to be inserted. +This is list with all attributes.

+

return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

+
+ +Expand source code + +
def delete_dataset_attributes_async(self,
+                                    dataset_name: str,
+                                    projection_name: str,
+                                    fields_to_delete: list,
+                                    pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method delete a set of attributes into a dataset
+    asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+    dataset_name: Represents the dataset name.
+    fields_to_delete: Represents the set of attributes to be inserted.
+    This is list with all attributes.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns the projection metadata.
+    """
+    dataset_metadata = self.search_projections_content(dataset_name,
+                                                       limit=1)
+
+    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+        .get('fields')
+    for field in fields_to_delete:
+        fields_to_insert.remove(field)
+
+    response = self.insert_dataset_attributes_async(dataset_name,
+                                                    projection_name,
+                                                    fields_to_insert,
+                                                    pretty_response)
+
+    return response
+
+
+
+def delete_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method delete a set of attributes on a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields_to_delete: Represents the set of attributes to be inserted. +This is list with all attributes.

+

return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

+
+ +Expand source code + +
def delete_dataset_attributes_sync(self,
+                                   dataset_name: str,
+                                   projection_name: str,
+                                   fields_to_delete: list,
+                                   pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method delete a set of attributes on a dataset
+    synchronously, the caller waits until the projection is inserted into
+    the Learning Orchestra storage mechanism.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+    dataset_name: Represents the dataset name.
+    fields_to_delete: Represents the set of attributes to be inserted.
+    This is list with all attributes.
+
+    return: A JSON object with error or warning messages. In case of
+    success, it returns the projection metadata.
+    """
+    dataset_metadata = self.search_projections_content(dataset_name,
+                                                       limit=1)
+
+    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
+        .get('fields')
+    for field in fields_to_delete:
+        fields_to_insert.remove(field)
+
+    response = self.insert_dataset_attributes_sync(dataset_name,
+                                                   projection_name,
+                                                   fields_to_insert,
+                                                   pretty_response)
+
+    return response
+
+
+
+def delete_projections(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 synchronous because it is very fast, +since the deletion is performed in background. If a projection was +used by another task (Ex. histogram, pca, tuning and so forth), +it cannot be deleted.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name.

+

return: JSON object with an error message, a warning message or a +correct delete message

+
+ +Expand source code + +
def delete_projections(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 synchronous because it is very fast,
+    since the deletion is performed in background. If a projection was
+    used by another task (Ex. histogram, pca, tuning and so forth),
+    it cannot be deleted.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+
+    return: JSON object with an error message, a warning message or a
+    correct delete message
+    """
+    cluster_url_projection = self.cluster_url + "/" + projection_name
+
+    response = requests.delete(cluster_url_projection)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def insert_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method inserts a set of attributes into a dataset +asynchronously, the caller does not wait until the projections 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 projection was inserted.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all attributes.

+

return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

+
+ +Expand source code + +
def insert_dataset_attributes_async(self,
+                                    dataset_name: str,
+                                    projection_name: str,
+                                    fields: list,
+                                    pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method inserts a set of attributes into a dataset
+    asynchronously, the caller does not wait until the projections 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 projection was inserted.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+    dataset_name: Represents the dataset name.
+    fields: Represents the set of attributes to be inserted. This is list
+    with all 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.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE PROJECTION FROM "
+            + dataset_name
+            + " TO "
+            + projection_name
+            + " ----------"
+        )
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def insert_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: This method inserts a set of attributes into a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all attributes.

+

return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

+
+ +Expand source code + +
def insert_dataset_attributes_sync(self,
+                                   dataset_name: str,
+                                   projection_name: str,
+                                   fields: list,
+                                   pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method inserts a set of attributes into a dataset
+    synchronously, the caller waits until the projection is inserted into
+    the Learning Orchestra storage mechanism.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection name.
+    dataset_name: Represents the dataset name.
+    fields: Represents the set of attributes to be inserted. This is list
+    with all 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.cluster_url
+
+    response = requests.post(url=request_url, json=request_body)
+
+    Observer(projection_name, self.CLUSTER_IP).observe_processing(
+        pretty_response)
+
+    if pretty_response:
+        print(
+            "\n----------"
+            + " CREATE PROJECTION FROM "
+            + dataset_name
+            + " TO "
+            + projection_name
+            + " ----------"
+        )
+
+    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, it does not +retrieve the projection content.

+

pretty_response: If true return indented string, else return dict.

+

return: A list with all projections metadata stored in Learning +Orchestra or an empty result.

+
+ +Expand source code + +
def search_all_projections(self, pretty_response: bool = False) \
+        -> Union[dict, str]:
+    """
+    description: This method retrieves all projection metadata, it does not
+    retrieve the projection content.
+
+    pretty_response: If true return indented string, else return dict.
+
+    return: A list with all projections metadata stored in Learning
+    Orchestra or an empty result.
+    """
+    cluster_url_projection = self.cluster_url
+
+    response = requests.get(cluster_url_projection)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+def search_projections(self, projection_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
+
+

description: +This method is responsible for retrieving a specific +projection.

+

pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an +error if there is no such projections.

+
+ +Expand source code + +
def search_projections(self, projection_name: str,
+                       pretty_response: bool = False) -> Union[dict, str]:
+    """
+    description:  This method is responsible for retrieving a specific
+    projection.
+
+    pretty_response: If true return indented string, else return dict.
+    projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
+    error if there is no such projections.
+    """
+    pretty = pretty_response
+
+    response = self.search_projections_content(projection_name, limit=1,
+                                               pretty_response=pretty)
+
+    return response
+
+
+
+def search_projections_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 dataset +content.

+

pretty_response: If true return indented string, else return dict. +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.

+
+ +Expand source code + +
def search_projections_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 dataset
+    content.
+
+    pretty_response: If true return indented string, else return dict.
+    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.
+    """
+
+    cluster_url_projection = self.cluster_url + "/" + projection_name + \
+                             "?query=" + str(query) + \
+                             "&limit=" + str(limit) + \
+                             "&skip=" + str(skip)
+
+    response = requests.get(cluster_url_projection)
+
+    return self.response_treat.treatment(response, pretty_response)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file From eec80d1a252d583dd116c6d3b8661274a4d5903e Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sun, 20 Dec 2020 13:12:38 -0300 Subject: [PATCH 03/28] update docs --- README.md | 207 ------------------------------------------------------ setup.py | 5 -- 2 files changed, 212 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 8452df8..0000000 --- a/README.md +++ /dev/null @@ -1,207 +0,0 @@ -

- - build-passing - tag - last-commit -

- -# pythonClient - -Python client for [learningOrchestra](https://github.com/learningOrchestra/learningOrchestra). - -# Installation - -Requires Python 3.x - -``` -pip install learning-orchestra-client -``` - -# Usage - -Import learning_orchestra_client: - -```python -from learning_orchestra_client import * -``` - - -Each functionality in learningOrchestra is contained in its own class. Check the python client docs for all the available. - -# Example - -Shown below is an example usage of learning-orchestra-client using the [Titanic Dataset](https://www.kaggle.com/c/titanic/overview): - -```python -from learning_orchestra_client import * - -cluster_ip = "34.95.187.26" - - -dataset = Dataset(cluster_ip) - -print(dataset.insert_dataset_sync( - "titanic_training", - "https://filebin.net/rpfdy8clm5984a4c/titanic_training.csv?t=gcnjz1yo")) -print(dataset.insert_dataset_sync( - "titanic_testing", - "https://filebin.net/mguee52ke97k0x9h/titanic_testing.csv?t=ub4nc1rc")) - -print(dataset.search_all_datasets()) - - -projection = Projection(cluster_ip) -required_columns = [ - "PassengerId", - "Pclass", - "Age", - "SibSp", - "Parch", - "Fare", - "Name", - "Sex", - "Embarked", - "Survived" - ] -print(projection.insert_dataset_attributes_sync( - "titanic_training", - "titanic_training_projection", - required_columns)) - -required_columns.remove("Survived") - -print(projection.insert_dataset_attributes_sync( - "titanic_testing", - "titanic_testing_projection", - required_columns)) - - -data_type_handler = DataType(cluster_ip) -type_fields = { - "Age": "number", - "Fare": "number", - "Parch": "number", - "PassengerId": "number", - "Pclass": "number", - "SibSp": "number" -} - -print(data_type_handler.update_dataset_types( - "titanic_testing_projection", - type_fields)) - -type_fields["Survived"] = "number" - -print(data_type_handler.update_dataset_types( - "titanic_training_projection", - type_fields)) - - -modeling_code = ''' -from pyspark.ml import Pipeline -from pyspark.sql.functions import ( - mean, col, split, - regexp_extract, when, lit) - -from pyspark.ml.feature import ( - VectorAssembler, - StringIndexer -) - -TRAINING_DF_INDEX = 0 -TESTING_DF_INDEX = 1 - -training_df = training_df.withColumnRenamed('Survived', 'label') -testing_df = testing_df.withColumn('label', lit(0)) -datasets_list = [training_df, testing_df] - -for index, dataset in enumerate(datasets_list): - dataset = dataset.withColumn( - "Initial", - regexp_extract(col("Name"), "([A-Za-z]+)\.", 1)) - datasets_list[index] = dataset - -misspelled_initials = [ - 'Mlle', 'Mme', 'Ms', 'Dr', - 'Major', 'Lady', 'Countess', - 'Jonkheer', 'Col', 'Rev', - 'Capt', 'Sir', 'Don' -] -correct_initials = [ - 'Miss', 'Miss', 'Miss', 'Mr', - 'Mr', 'Mrs', 'Mrs', - 'Other', 'Other', 'Other', - 'Mr', 'Mr', 'Mr' -] -for index, dataset in enumerate(datasets_list): - dataset = dataset.replace(misspelled_initials, correct_initials) - datasets_list[index] = dataset - - -initials_age = {"Miss": 22, - "Other": 46, - "Master": 5, - "Mr": 33, - "Mrs": 36} -for index, dataset in enumerate(datasets_list): - for initial, initial_age in initials_age.items(): - dataset = dataset.withColumn( - "Age", - when((dataset["Initial"] == initial) & - (dataset["Age"].isNull()), initial_age).otherwise( - dataset["Age"])) - datasets_list[index] = dataset - - -for index, dataset in enumerate(datasets_list): - dataset = dataset.na.fill({"Embarked": 'S'}) - datasets_list[index] = dataset - - -for index, dataset in enumerate(datasets_list): - dataset = dataset.withColumn("Family_Size", col('SibSp')+col('Parch')) - dataset = dataset.withColumn('Alone', lit(0)) - dataset = dataset.withColumn( - "Alone", - when(dataset["Family_Size"] == 0, 1).otherwise(dataset["Alone"])) - datasets_list[index] = dataset - - -text_fields = ["Sex", "Embarked", "Initial"] -for column in text_fields: - for index, dataset in enumerate(datasets_list): - dataset = StringIndexer( - inputCol=column, outputCol=column+"_index").\ - fit(dataset).\ - transform(dataset) - datasets_list[index] = dataset - - -non_required_columns = ["Name", "Embarked", "Sex", "Initial"] -for index, dataset in enumerate(datasets_list): - dataset = dataset.drop(*non_required_columns) - datasets_list[index] = dataset - - -training_df = datasets_list[TRAINING_DF_INDEX] -testing_df = datasets_list[TESTING_DF_INDEX] - -assembler = VectorAssembler( - inputCols=training_df.columns[:], - outputCol="features") -assembler.setHandleInvalid('skip') - -features_training = assembler.transform(training_df) -(features_training, features_evaluation) =\ - features_training.randomSplit([0.8, 0.2], seed=33) -features_testing = assembler.transform(testing_df) -''' - -builder = Builder(cluster_ip) - -print(builder.run_builder_sync( - "titanic_training_projection", - "titanic_testing_projection", - modeling_code, - ["lr", "dt", "gb", "rf", "nb"])) -``` diff --git a/setup.py b/setup.py index d4e837d..2a3319c 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,11 @@ import setuptools -with open("README.md", "r") as fh: - long_description = fh.read() - setuptools.setup( name="learning_orchestra_client", version="2.0.0", author="Gabriel Ribeiro", author_email="gabbriel.rribeiro@gmail.com", description="learningOrchestra python client", - long_description=long_description, - long_description_content_type="text/markdown", url="https://github.com/learningOrchestra/learningOrchestra-python-client", packages=setuptools.find_packages(), classifiers=[ From ad7adc089f4d3b8c5da7e908c214f2b9c28c6201 Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Mon, 21 Dec 2020 16:46:55 -0300 Subject: [PATCH 04/28] update docs --- docs/builder/builder.html | 790 ------------- docs/builder/index.html | 65 -- docs/dataset/dataset.html | 678 ----------- docs/dataset/index.html | 65 -- docs/explore/histogram.html | 2 +- docs/explore/pca.html | 2 +- docs/explore/tsne.html | 2 +- docs/index.html | 8 +- docs/transform/data_type.html | 2 +- docs/transform/projection.html | 2 +- .../builder/builder.html | 790 ------------- .../builder/index.html | 65 -- .../dataset/dataset.html | 678 ----------- .../dataset/index.html | 65 -- .../explore/histogram.html | 676 ----------- .../explore/index.html | 75 -- .../explore/pca.html | 742 ------------ .../explore/tsne.html | 742 ------------ html/learning_orchestra_client/index.html | 85 -- html/learning_orchestra_client/observer.html | 375 ------ .../response_treat.html | 197 ---- .../transform/data_type.html | 199 ---- .../transform/index.html | 70 -- .../transform/projection.html | 1035 ----------------- 24 files changed, 9 insertions(+), 7401 deletions(-) delete mode 100644 docs/builder/builder.html delete mode 100644 docs/builder/index.html delete mode 100644 docs/dataset/dataset.html delete mode 100644 docs/dataset/index.html delete mode 100644 html/learning_orchestra_client/builder/builder.html delete mode 100644 html/learning_orchestra_client/builder/index.html delete mode 100644 html/learning_orchestra_client/dataset/dataset.html delete mode 100644 html/learning_orchestra_client/dataset/index.html delete mode 100644 html/learning_orchestra_client/explore/histogram.html delete mode 100644 html/learning_orchestra_client/explore/index.html delete mode 100644 html/learning_orchestra_client/explore/pca.html delete mode 100644 html/learning_orchestra_client/explore/tsne.html delete mode 100644 html/learning_orchestra_client/index.html delete mode 100644 html/learning_orchestra_client/observer.html delete mode 100644 html/learning_orchestra_client/response_treat.html delete mode 100644 html/learning_orchestra_client/transform/data_type.html delete mode 100644 html/learning_orchestra_client/transform/index.html delete mode 100644 html/learning_orchestra_client/transform/projection.html diff --git a/docs/builder/builder.html b/docs/builder/builder.html deleted file mode 100644 index f450096..0000000 --- a/docs/builder/builder.html +++ /dev/null @@ -1,790 +0,0 @@ - - - - - - -learning_orchestra_client.builder.builder API documentation - - - - - - - - - - - -
-
-
-

Module learning_orchestra_client.builder.builder

-
-
-
- -Expand source code - -
from ..observer import Observer
-from ..response_treat import ResponseTreat
-from ..dataset.dataset import Dataset
-import requests
-from typing import Union
-
-
-class Builder:
-    def __init__(self, ip_from_cluster: str):
-        self.CLUSTER_IP = ip_from_cluster
-        self.cluster_url = "http://" + ip_from_cluster + \
-                           "/api/learningOrchestra/v1/builder"
-        self.response_treat = ResponseTreat()
-        self.TRAIN_NAME = "trainDatasetName"
-        self.TEST_NAME = "testDatasetName"
-        self.CODE = "modelingCode"
-        self.CLASSIFIERS_LIST = "classifiersList"
-        self.dataset = Dataset(ip_from_cluster)
-        self.METADATA_INDEX = 0
-
-    def run_builder_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 resource join several steps of machine
-        learning workflow (transform, tune, train and evaluate) coupling in
-        a unique resource, builder creates several model predictions using
-        your own modeling code using a defined set of classifiers. This is made
-        synchronously, the caller waits until the model predictions are inserted
-        into the Learning Orchestra storage mechanism.
-
-        train_dataset_name: Represent final train dataset.
-        test_dataset_name: Represent final test dataset.
-        modeling_code: Represent Python3 code for pyspark preprocessing model
-        model_classifiers: list of initial classifiers to be used in model
-        pretty_response: returns indented string for visualization if True
-
-        return: The resulted predictions URIs.
-        """
-
-        if pretty_response:
-            print(
-                "\n----------"
-                + " CREATE MODEL WITH "
-                + train_dataset_name
-                + " AND "
-                + test_dataset_name
-                + " ----------"
-            )
-
-        request_body_content = {
-            self.TRAIN_NAME: train_dataset_name,
-            self.TEST_NAME: test_dataset_name,
-            self.CODE: modeling_code,
-            self.CLASSIFIERS_LIST: model_classifiers,
-        }
-        response = requests.post(url=self.cluster_url,
-                                 json=request_body_content)
-
-        observer = Observer(test_dataset_name, self.CLUSTER_IP)
-
-        for model in model_classifiers:
-            observer.set_dataset_name(test_dataset_name + model)
-            observer.observe_processing(pretty_response)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def run_builder_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 resource join several steps of machine
-        learning workflow (transform, tune, train and evaluate) coupling in
-        a unique resource, builder creates several model predictions using
-        your own modeling code using a defined set of classifiers. This is made
-        asynchronously, the caller does not wait until the model predictions are
-        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 model predictions are inserted.
-
-        train_dataset_name: Represent final train dataset.
-        test_dataset_name: Represent final test dataset.
-        modeling_code: Represent Python3 code for pyspark preprocessing model
-        model_classifiers: list of initial classifiers to be used in model
-        pretty_response: returns indented string for visualization if True
-
-        return: The resulted predictions URIs.
-        """
-        if pretty_response:
-            print(
-                "\n----------"
-                + " CREATE MODEL WITH "
-                + train_dataset_name
-                + " AND "
-                + test_dataset_name
-                + " ----------"
-            )
-
-        request_body_content = {
-            self.TRAIN_NAME: train_dataset_name,
-            self.TEST_NAME: test_dataset_name,
-            self.CODE: modeling_code,
-            self.CLASSIFIERS_LIST: model_classifiers,
-        }
-        response = requests.post(url=self.cluster_url,
-                                 json=request_body_content)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def search_all_model(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 return indented string, else return dict.
-
-        return: A list with all model predictions metadata stored in Learning
-        Orchestra or an empty result.
-        """
-
-        cluster_url_tsne = self.cluster_url
-
-        response = requests.get(cluster_url_tsne)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def search_model_prediction(self,
-                                model_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 return indented string, else return dict.
-        model_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 there
-        is no such projection. The current page is also returned to be used in
-        future content requests.
-        """
-
-        cluster_url_dataset = self.cluster_url + "/" + model_name + \
-                              "?query=" + str(query) + \
-                              "&limit=" + str(limit) + \
-                              "&skip=" + str(skip)
-
-        response = requests.get(cluster_url_dataset)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def search_model(self, model_name: str, pretty_response: bool = False) \
-            -> Union[dict, str]:
-        """
-        description:  This method is responsible for retrieving a specific
-        model prediction metadata.
-
-        pretty_response: If true return indented string, else return dict.
-        model_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_model_prediction(model_name, limit=1,
-                                                pretty_response=pretty_response)
-
-        return response
-
-    def delete_model(self, model_name: str, pretty_response: bool = False) \
-            -> Union[dict, str]:
-        """
-        description: This method is responsible for deleting a model prediction.
-        The delete operation is always synchronous because it is very fast,
-        since the deletion is performed in background.
-
-        pretty_response: If true return indented string, else return dict.
-        model_name: Represents the projection name.
-
-        return: JSON object with an error message, a warning message or a
-        correct delete message
-        """
-
-        cluster_url_dataset = self.cluster_url + "/" + model_name
-
-        response = requests.delete(cluster_url_dataset)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-
-
-
-
-
-
-
-
-

Classes

-
-
-class Builder -(ip_from_cluster: str) -
-
-
-
- -Expand source code - -
class Builder:
-    def __init__(self, ip_from_cluster: str):
-        self.CLUSTER_IP = ip_from_cluster
-        self.cluster_url = "http://" + ip_from_cluster + \
-                           "/api/learningOrchestra/v1/builder"
-        self.response_treat = ResponseTreat()
-        self.TRAIN_NAME = "trainDatasetName"
-        self.TEST_NAME = "testDatasetName"
-        self.CODE = "modelingCode"
-        self.CLASSIFIERS_LIST = "classifiersList"
-        self.dataset = Dataset(ip_from_cluster)
-        self.METADATA_INDEX = 0
-
-    def run_builder_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 resource join several steps of machine
-        learning workflow (transform, tune, train and evaluate) coupling in
-        a unique resource, builder creates several model predictions using
-        your own modeling code using a defined set of classifiers. This is made
-        synchronously, the caller waits until the model predictions are inserted
-        into the Learning Orchestra storage mechanism.
-
-        train_dataset_name: Represent final train dataset.
-        test_dataset_name: Represent final test dataset.
-        modeling_code: Represent Python3 code for pyspark preprocessing model
-        model_classifiers: list of initial classifiers to be used in model
-        pretty_response: returns indented string for visualization if True
-
-        return: The resulted predictions URIs.
-        """
-
-        if pretty_response:
-            print(
-                "\n----------"
-                + " CREATE MODEL WITH "
-                + train_dataset_name
-                + " AND "
-                + test_dataset_name
-                + " ----------"
-            )
-
-        request_body_content = {
-            self.TRAIN_NAME: train_dataset_name,
-            self.TEST_NAME: test_dataset_name,
-            self.CODE: modeling_code,
-            self.CLASSIFIERS_LIST: model_classifiers,
-        }
-        response = requests.post(url=self.cluster_url,
-                                 json=request_body_content)
-
-        observer = Observer(test_dataset_name, self.CLUSTER_IP)
-
-        for model in model_classifiers:
-            observer.set_dataset_name(test_dataset_name + model)
-            observer.observe_processing(pretty_response)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def run_builder_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 resource join several steps of machine
-        learning workflow (transform, tune, train and evaluate) coupling in
-        a unique resource, builder creates several model predictions using
-        your own modeling code using a defined set of classifiers. This is made
-        asynchronously, the caller does not wait until the model predictions are
-        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 model predictions are inserted.
-
-        train_dataset_name: Represent final train dataset.
-        test_dataset_name: Represent final test dataset.
-        modeling_code: Represent Python3 code for pyspark preprocessing model
-        model_classifiers: list of initial classifiers to be used in model
-        pretty_response: returns indented string for visualization if True
-
-        return: The resulted predictions URIs.
-        """
-        if pretty_response:
-            print(
-                "\n----------"
-                + " CREATE MODEL WITH "
-                + train_dataset_name
-                + " AND "
-                + test_dataset_name
-                + " ----------"
-            )
-
-        request_body_content = {
-            self.TRAIN_NAME: train_dataset_name,
-            self.TEST_NAME: test_dataset_name,
-            self.CODE: modeling_code,
-            self.CLASSIFIERS_LIST: model_classifiers,
-        }
-        response = requests.post(url=self.cluster_url,
-                                 json=request_body_content)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def search_all_model(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 return indented string, else return dict.
-
-        return: A list with all model predictions metadata stored in Learning
-        Orchestra or an empty result.
-        """
-
-        cluster_url_tsne = self.cluster_url
-
-        response = requests.get(cluster_url_tsne)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def search_model_prediction(self,
-                                model_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 return indented string, else return dict.
-        model_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 there
-        is no such projection. The current page is also returned to be used in
-        future content requests.
-        """
-
-        cluster_url_dataset = self.cluster_url + "/" + model_name + \
-                              "?query=" + str(query) + \
-                              "&limit=" + str(limit) + \
-                              "&skip=" + str(skip)
-
-        response = requests.get(cluster_url_dataset)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def search_model(self, model_name: str, pretty_response: bool = False) \
-            -> Union[dict, str]:
-        """
-        description:  This method is responsible for retrieving a specific
-        model prediction metadata.
-
-        pretty_response: If true return indented string, else return dict.
-        model_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_model_prediction(model_name, limit=1,
-                                                pretty_response=pretty_response)
-
-        return response
-
-    def delete_model(self, model_name: str, pretty_response: bool = False) \
-            -> Union[dict, str]:
-        """
-        description: This method is responsible for deleting a model prediction.
-        The delete operation is always synchronous because it is very fast,
-        since the deletion is performed in background.
-
-        pretty_response: If true return indented string, else return dict.
-        model_name: Represents the projection name.
-
-        return: JSON object with an error message, a warning message or a
-        correct delete message
-        """
-
-        cluster_url_dataset = self.cluster_url + "/" + model_name
-
-        response = requests.delete(cluster_url_dataset)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-

Methods

-
-
-def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
-
-

description: This method is responsible for deleting a model prediction. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

-

pretty_response: If true return indented string, else return dict. -model_name: Represents the projection name.

-

return: JSON object with an error message, a warning message or a -correct delete message

-
- -Expand source code - -
def delete_model(self, model_name: str, pretty_response: bool = False) \
-        -> Union[dict, str]:
-    """
-    description: This method is responsible for deleting a model prediction.
-    The delete operation is always synchronous because it is very fast,
-    since the deletion is performed in background.
-
-    pretty_response: If true return indented string, else return dict.
-    model_name: Represents the projection name.
-
-    return: JSON object with an error message, a warning message or a
-    correct delete message
-    """
-
-    cluster_url_dataset = self.cluster_url + "/" + model_name
-
-    response = requests.delete(cluster_url_dataset)
-
-    return self.response_treat.treatment(response, pretty_response)
-
-
-
-def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -asynchronously, the caller does not wait until the model predictions are -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 model predictions are inserted.

-

train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

-

return: The resulted predictions URIs.

-
- -Expand source code - -
def run_builder_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 resource join several steps of machine
-    learning workflow (transform, tune, train and evaluate) coupling in
-    a unique resource, builder creates several model predictions using
-    your own modeling code using a defined set of classifiers. This is made
-    asynchronously, the caller does not wait until the model predictions are
-    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 model predictions are inserted.
-
-    train_dataset_name: Represent final train dataset.
-    test_dataset_name: Represent final test dataset.
-    modeling_code: Represent Python3 code for pyspark preprocessing model
-    model_classifiers: list of initial classifiers to be used in model
-    pretty_response: returns indented string for visualization if True
-
-    return: The resulted predictions URIs.
-    """
-    if pretty_response:
-        print(
-            "\n----------"
-            + " CREATE MODEL WITH "
-            + train_dataset_name
-            + " AND "
-            + test_dataset_name
-            + " ----------"
-        )
-
-    request_body_content = {
-        self.TRAIN_NAME: train_dataset_name,
-        self.TEST_NAME: test_dataset_name,
-        self.CODE: modeling_code,
-        self.CLASSIFIERS_LIST: model_classifiers,
-    }
-    response = requests.post(url=self.cluster_url,
-                             json=request_body_content)
-
-    return self.response_treat.treatment(response, pretty_response)
-
-
-
-def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -synchronously, the caller waits until the model predictions are inserted -into the Learning Orchestra storage mechanism.

-

train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

-

return: The resulted predictions URIs.

-
- -Expand source code - -
def run_builder_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 resource join several steps of machine
-    learning workflow (transform, tune, train and evaluate) coupling in
-    a unique resource, builder creates several model predictions using
-    your own modeling code using a defined set of classifiers. This is made
-    synchronously, the caller waits until the model predictions are inserted
-    into the Learning Orchestra storage mechanism.
-
-    train_dataset_name: Represent final train dataset.
-    test_dataset_name: Represent final test dataset.
-    modeling_code: Represent Python3 code for pyspark preprocessing model
-    model_classifiers: list of initial classifiers to be used in model
-    pretty_response: returns indented string for visualization if True
-
-    return: The resulted predictions URIs.
-    """
-
-    if pretty_response:
-        print(
-            "\n----------"
-            + " CREATE MODEL WITH "
-            + train_dataset_name
-            + " AND "
-            + test_dataset_name
-            + " ----------"
-        )
-
-    request_body_content = {
-        self.TRAIN_NAME: train_dataset_name,
-        self.TEST_NAME: test_dataset_name,
-        self.CODE: modeling_code,
-        self.CLASSIFIERS_LIST: model_classifiers,
-    }
-    response = requests.post(url=self.cluster_url,
-                             json=request_body_content)
-
-    observer = Observer(test_dataset_name, self.CLUSTER_IP)
-
-    for model in model_classifiers:
-        observer.set_dataset_name(test_dataset_name + model)
-        observer.observe_processing(pretty_response)
-
-    return self.response_treat.treatment(response, pretty_response)
-
-
-
-def search_all_model(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 return indented string, else return dict.

-

return: A list with all model predictions metadata stored in Learning -Orchestra or an empty result.

-
- -Expand source code - -
def search_all_model(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 return indented string, else return dict.
-
-    return: A list with all model predictions metadata stored in Learning
-    Orchestra or an empty result.
-    """
-
-    cluster_url_tsne = self.cluster_url
-
-    response = requests.get(cluster_url_tsne)
-
-    return self.response_treat.treatment(response, pretty_response)
-
-
-
-def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
-
-

description: -This method is responsible for retrieving a specific -model prediction metadata.

-

pretty_response: If true return indented string, else return dict. -model_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.

-
- -Expand source code - -
def search_model(self, model_name: str, pretty_response: bool = False) \
-        -> Union[dict, str]:
-    """
-    description:  This method is responsible for retrieving a specific
-    model prediction metadata.
-
-    pretty_response: If true return indented string, else return dict.
-    model_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_model_prediction(model_name, limit=1,
-                                            pretty_response=pretty_response)
-
-    return response
-
-
-
-def search_model_prediction(self, model_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 return indented string, else return dict. -model_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 there -is no such projection. The current page is also returned to be used in -future content requests.

-
- -Expand source code - -
def search_model_prediction(self,
-                            model_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 return indented string, else return dict.
-    model_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 there
-    is no such projection. The current page is also returned to be used in
-    future content requests.
-    """
-
-    cluster_url_dataset = self.cluster_url + "/" + model_name + \
-                          "?query=" + str(query) + \
-                          "&limit=" + str(limit) + \
-                          "&skip=" + str(skip)
-
-    response = requests.get(cluster_url_dataset)
-
-    return self.response_treat.treatment(response, pretty_response)
-
-
-
-
-
-
-
- -
- - - \ No newline at end of file diff --git a/docs/builder/index.html b/docs/builder/index.html deleted file mode 100644 index f6061e5..0000000 --- a/docs/builder/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -learning_orchestra_client.builder API documentation - - - - - - - - - - - -
- - -
- - - \ No newline at end of file diff --git a/docs/dataset/dataset.html b/docs/dataset/dataset.html deleted file mode 100644 index 64e61be..0000000 --- a/docs/dataset/dataset.html +++ /dev/null @@ -1,678 +0,0 @@ - - - - - - -learning_orchestra_client.dataset.dataset API documentation - - - - - - - - - - - -
-
-
-

Module learning_orchestra_client.dataset.dataset

-
-
-
- -Expand source code - -
__author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
-__credits__ = "all free source developers"
-__status__ = "Prototype"
-
-from ..observer import Observer
-from ..response_treat import ResponseTreat
-import requests
-from typing import Union
-
-
-class Dataset:
-    def __init__(self, ip_from_cluster: str):
-        self.cluster_url = "http://" + ip_from_cluster + \
-                           "/api/learningOrchestra/v1/dataset"
-        self.response_treat = ResponseTreat()
-        self.OUTPUT_NAME = "datasetName"
-        self.URL = "datasetURI"
-        self.CLUSTER_IP = ip_from_cluster
-
-    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 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.
-        """
-        request_body = {self.OUTPUT_NAME: dataset_name,
-                        self.URL: url}
-        request_url = self.cluster_url
-
-        response = requests.post(url=request_url, json=request_body)
-
-        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
-
-        if pretty_response:
-            print("\n----------" + " CREATED FILE " + 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).
-        """
-        request_body = {self.OUTPUT_NAME: dataset_name,
-                        self.URL: url}
-        request_url = self.cluster_url
-
-        response = requests.post(url=request_url, json=request_body)
-
-        if pretty_response:
-            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
-                                                                     "---")
-        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 return indented string, else return dict.
-
-        return: All datasets metadata stored in Learning Orchestra or an empty
-        result.
-        """
-        request_url = self.cluster_url
-
-        response = requests.get(request_url)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
-            -> Union[dict, str]:
-        """
-        description: This method is responsible for retrieving a specific
-        dataset
-
-        pretty_response: If true return indented string, else return dict.
-        dataset_name: Is the name of the dataset file.
-        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 dataset metadata stored in Learning Orchestra or an
-        error if there is no such dataset.
-        """
-        response = self.search_dataset_content(dataset_name, limit=1,
-                                               pretty_response=pretty_response)
-
-        return 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 return indented string, else return dict.
-        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.
-        """
-
-        request_url = self.cluster_url + "/" + dataset_name + \
-                      "?query=" + str(query) + \
-                      "&limit=" + str(limit) + \
-                      "&skip=" + str(skip)
-
-        response = requests.get(request_url)
-
-        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. The
-        delete operation is always synchronous because it is very fast, since
-        the deletion is performed in background. If a dataset was used by
-        another task (Ex. projection, histogram, pca, tuning and so forth), it
-        cannot be deleted.
-
-        pretty_response: If true return indented string, else return dict.
-        dataset_name: Represents the dataset name.
-
-        return: JSON object with an error message, a warning message or a
-        correct delete message
-        """
-
-        request_url = self.cluster_url + "/" + dataset_name
-
-        response = requests.delete(request_url)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-
-
-
-
-
-
-
-
-

Classes

-
-
-class Dataset -(ip_from_cluster: str) -
-
-
-
- -Expand source code - -
class Dataset:
-    def __init__(self, ip_from_cluster: str):
-        self.cluster_url = "http://" + ip_from_cluster + \
-                           "/api/learningOrchestra/v1/dataset"
-        self.response_treat = ResponseTreat()
-        self.OUTPUT_NAME = "datasetName"
-        self.URL = "datasetURI"
-        self.CLUSTER_IP = ip_from_cluster
-
-    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 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.
-        """
-        request_body = {self.OUTPUT_NAME: dataset_name,
-                        self.URL: url}
-        request_url = self.cluster_url
-
-        response = requests.post(url=request_url, json=request_body)
-
-        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
-
-        if pretty_response:
-            print("\n----------" + " CREATED FILE " + 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).
-        """
-        request_body = {self.OUTPUT_NAME: dataset_name,
-                        self.URL: url}
-        request_url = self.cluster_url
-
-        response = requests.post(url=request_url, json=request_body)
-
-        if pretty_response:
-            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
-                                                                     "---")
-        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 return indented string, else return dict.
-
-        return: All datasets metadata stored in Learning Orchestra or an empty
-        result.
-        """
-        request_url = self.cluster_url
-
-        response = requests.get(request_url)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
-            -> Union[dict, str]:
-        """
-        description: This method is responsible for retrieving a specific
-        dataset
-
-        pretty_response: If true return indented string, else return dict.
-        dataset_name: Is the name of the dataset file.
-        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 dataset metadata stored in Learning Orchestra or an
-        error if there is no such dataset.
-        """
-        response = self.search_dataset_content(dataset_name, limit=1,
-                                               pretty_response=pretty_response)
-
-        return 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 return indented string, else return dict.
-        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.
-        """
-
-        request_url = self.cluster_url + "/" + dataset_name + \
-                      "?query=" + str(query) + \
-                      "&limit=" + str(limit) + \
-                      "&skip=" + str(skip)
-
-        response = requests.get(request_url)
-
-        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. The
-        delete operation is always synchronous because it is very fast, since
-        the deletion is performed in background. If a dataset was used by
-        another task (Ex. projection, histogram, pca, tuning and so forth), it
-        cannot be deleted.
-
-        pretty_response: If true return indented string, else return dict.
-        dataset_name: Represents the dataset name.
-
-        return: JSON object with an error message, a warning message or a
-        correct delete message
-        """
-
-        request_url = self.cluster_url + "/" + dataset_name
-
-        response = requests.delete(request_url)
-
-        return self.response_treat.treatment(response, pretty_response)
-
-

Methods

-
-
-def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] -
-
-

description: This method is responsible for deleting the dataset. The -delete operation is always synchronous because it is very fast, since -the deletion is performed in background. If a dataset was used by -another task (Ex. projection, histogram, pca, tuning and so forth), it -cannot be deleted.

-

pretty_response: If true return indented string, else return dict. -dataset_name: Represents the dataset name.

-

return: JSON object with an error message, a warning message or a -correct delete message

-
- -Expand source code - -
def delete_dataset(self, dataset_name, pretty_response=False) \
-        -> Union[dict, str]:
-    """
-    description: This method is responsible for deleting the dataset. The
-    delete operation is always synchronous because it is very fast, since
-    the deletion is performed in background. If a dataset was used by
-    another task (Ex. projection, histogram, pca, tuning and so forth), it
-    cannot be deleted.
-
-    pretty_response: If true return indented string, else return dict.
-    dataset_name: Represents the dataset name.
-
-    return: JSON object with an error message, a warning message or a
-    correct delete message
-    """
-
-    request_url = self.cluster_url + "/" + dataset_name
-
-    response = requests.delete(request_url)
-
-    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).

-
- -Expand source code - -
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).
-    """
-    request_body = {self.OUTPUT_NAME: dataset_name,
-                    self.URL: url}
-    request_url = self.cluster_url
-
-    response = requests.post(url=request_url, json=request_body)
-
-    if pretty_response:
-        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
-                                                                 "---")
-    return self.response_treat.treatment(response, pretty_response)
-
-
-
-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 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.

-
- -Expand source code - -
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 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.
-    """
-    request_body = {self.OUTPUT_NAME: dataset_name,
-                    self.URL: url}
-    request_url = self.cluster_url
-
-    response = requests.post(url=request_url, json=request_body)
-
-    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
-
-    if pretty_response:
-        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
-                                                                 "---")
-    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 return indented string, else return dict.

-

return: All datasets metadata stored in Learning Orchestra or an empty -result.

-
- -Expand source code - -
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 return indented string, else return dict.
-
-    return: All datasets metadata stored in Learning Orchestra or an empty
-    result.
-    """
-    request_url = self.cluster_url
-
-    response = requests.get(request_url)
-
-    return self.response_treat.treatment(response, pretty_response)
-
-
-
-def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
-
-

description: This method is responsible for retrieving a specific -dataset

-

pretty_response: If true return indented string, else return dict. -dataset_name: Is the name of the dataset file. -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 dataset metadata stored in Learning Orchestra or an -error if there is no such dataset.

-
- -Expand source code - -
def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
-        -> Union[dict, str]:
-    """
-    description: This method is responsible for retrieving a specific
-    dataset
-
-    pretty_response: If true return indented string, else return dict.
-    dataset_name: Is the name of the dataset file.
-    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 dataset metadata stored in Learning Orchestra or an
-    error if there is no such dataset.
-    """
-    response = self.search_dataset_content(dataset_name, limit=1,
-                                           pretty_response=pretty_response)
-
-    return 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 return indented string, else return dict. -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.

-
- -Expand source code - -
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 return indented string, else return dict.
-    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.
-    """
-
-    request_url = self.cluster_url + "/" + dataset_name + \
-                  "?query=" + str(query) + \
-                  "&limit=" + str(limit) + \
-                  "&skip=" + str(skip)
-
-    response = requests.get(request_url)
-
-    return self.response_treat.treatment(response, pretty_response)
-
-
-
-
-
-
-
- -
- - - \ No newline at end of file diff --git a/docs/dataset/index.html b/docs/dataset/index.html deleted file mode 100644 index b4c42b2..0000000 --- a/docs/dataset/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -learning_orchestra_client.dataset API documentation - - - - - - - - - - - -
- - -
- - - \ No newline at end of file diff --git a/docs/explore/histogram.html b/docs/explore/histogram.html index e1abdfc..a90cf94 100644 --- a/docs/explore/histogram.html +++ b/docs/explore/histogram.html @@ -28,7 +28,7 @@

Module learning_orchestra_client.explore.histogram
from ..observer import Observer
 from ..response_treat import ResponseTreat
-from ..dataset.dataset import Dataset
+from ..dataset import Dataset
 import requests
 from typing import Union
 
diff --git a/docs/explore/pca.html b/docs/explore/pca.html
index 877a51d..7dbc910 100644
--- a/docs/explore/pca.html
+++ b/docs/explore/pca.html
@@ -27,7 +27,7 @@ 

Module learning_orchestra_client.explore.pca

Expand source code
from ..response_treat import ResponseTreat
-from ..dataset.dataset import Dataset
+from ..dataset import Dataset
 from PIL import Image
 import requests
 import time
diff --git a/docs/explore/tsne.html b/docs/explore/tsne.html
index b4e1b63..15569b0 100644
--- a/docs/explore/tsne.html
+++ b/docs/explore/tsne.html
@@ -27,7 +27,7 @@ 

Module learning_orchestra_client.explore.tsne

Expand source code
from ..response_treat import ResponseTreat
-from ..dataset.dataset import Dataset
+from ..dataset import Dataset
 from PIL import Image
 import requests
 import time
diff --git a/docs/index.html b/docs/index.html
index 64b720b..9189de8 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -26,11 +26,11 @@ 

Package learning_orchestra_client

Sub-modules

-
learning_orchestra_client.builder
+
learning_orchestra_client.builder
-
learning_orchestra_client.dataset
+
learning_orchestra_client.dataset
@@ -67,8 +67,8 @@

Index

  • Sub-modules

      -
    • learning_orchestra_client.builder
    • -
    • learning_orchestra_client.dataset
    • +
    • learning_orchestra_client.builder
    • +
    • learning_orchestra_client.dataset
    • learning_orchestra_client.explore
    • learning_orchestra_client.observer
    • learning_orchestra_client.response_treat
    • diff --git a/docs/transform/data_type.html b/docs/transform/data_type.html index fcd25c1..444301d 100644 --- a/docs/transform/data_type.html +++ b/docs/transform/data_type.html @@ -27,7 +27,7 @@

      Module learning_orchestra_client.transform.data_typeExpand source code
      from ..response_treat import ResponseTreat
      -from ..dataset.dataset import Dataset
      +from ..dataset import Dataset
       import requests
       from typing import Union
       
      diff --git a/docs/transform/projection.html b/docs/transform/projection.html
      index 7e84007..6158b25 100644
      --- a/docs/transform/projection.html
      +++ b/docs/transform/projection.html
      @@ -27,7 +27,7 @@ 

      Module learning_orchestra_client.transform.projectionExpand source code
      from ..response_treat import ResponseTreat
      -from ..dataset.dataset import Dataset
      +from ..dataset import Dataset
       from ..observer import Observer
       import requests
       from typing import Union
      diff --git a/html/learning_orchestra_client/builder/builder.html b/html/learning_orchestra_client/builder/builder.html
      deleted file mode 100644
      index f450096..0000000
      --- a/html/learning_orchestra_client/builder/builder.html
      +++ /dev/null
      @@ -1,790 +0,0 @@
      -
      -
      -
      -
      -
      -
      -learning_orchestra_client.builder.builder API documentation
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Module learning_orchestra_client.builder.builder

      -
      -
      -
      - -Expand source code - -
      from ..observer import Observer
      -from ..response_treat import ResponseTreat
      -from ..dataset.dataset import Dataset
      -import requests
      -from typing import Union
      -
      -
      -class Builder:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/builder"
      -        self.response_treat = ResponseTreat()
      -        self.TRAIN_NAME = "trainDatasetName"
      -        self.TEST_NAME = "testDatasetName"
      -        self.CODE = "modelingCode"
      -        self.CLASSIFIERS_LIST = "classifiersList"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.METADATA_INDEX = 0
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        synchronously, the caller waits until the model predictions are inserted
      -        into the Learning Orchestra storage mechanism.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
      -
      -        for model in model_classifiers:
      -            observer.set_dataset_name(test_dataset_name + model)
      -            observer.observe_processing(pretty_response)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        asynchronously, the caller does not wait until the model predictions are
      -        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 model predictions are inserted.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_model(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 return indented string, else return dict.
      -
      -        return: A list with all model predictions metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model_prediction(self,
      -                                model_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 return indented string, else return dict.
      -        model_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 there
      -        is no such projection. The current page is also returned to be used in
      -        future content requests.
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
      -                              "?query=" + str(query) + \
      -                              "&limit=" + str(limit) + \
      -                              "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        model prediction metadata.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_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_model_prediction(model_name, limit=1,
      -                                                pretty_response=pretty_response)
      -
      -        return response
      -
      -    def delete_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting a model prediction.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name
      -
      -        response = requests.delete(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Builder -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Builder:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/builder"
      -        self.response_treat = ResponseTreat()
      -        self.TRAIN_NAME = "trainDatasetName"
      -        self.TEST_NAME = "testDatasetName"
      -        self.CODE = "modelingCode"
      -        self.CLASSIFIERS_LIST = "classifiersList"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.METADATA_INDEX = 0
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        synchronously, the caller waits until the model predictions are inserted
      -        into the Learning Orchestra storage mechanism.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
      -
      -        for model in model_classifiers:
      -            observer.set_dataset_name(test_dataset_name + model)
      -            observer.observe_processing(pretty_response)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        asynchronously, the caller does not wait until the model predictions are
      -        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 model predictions are inserted.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_model(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 return indented string, else return dict.
      -
      -        return: A list with all model predictions metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model_prediction(self,
      -                                model_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 return indented string, else return dict.
      -        model_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 there
      -        is no such projection. The current page is also returned to be used in
      -        future content requests.
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
      -                              "?query=" + str(query) + \
      -                              "&limit=" + str(limit) + \
      -                              "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        model prediction metadata.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_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_model_prediction(model_name, limit=1,
      -                                                pretty_response=pretty_response)
      -
      -        return response
      -
      -    def delete_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting a model prediction.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name
      -
      -        response = requests.delete(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting a model prediction. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -model_name: Represents the projection name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      def delete_model(self, model_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting a model prediction.
      -    The delete operation is always synchronous because it is very fast,
      -    since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    model_name: Represents the projection name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -
      -    cluster_url_dataset = self.cluster_url + "/" + model_name
      -
      -    response = requests.delete(cluster_url_dataset)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -asynchronously, the caller does not wait until the model predictions are -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 model predictions are inserted.

      -

      train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

      -

      return: The resulted predictions URIs.

      -
      - -Expand source code - -
      def run_builder_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 resource join several steps of machine
      -    learning workflow (transform, tune, train and evaluate) coupling in
      -    a unique resource, builder creates several model predictions using
      -    your own modeling code using a defined set of classifiers. This is made
      -    asynchronously, the caller does not wait until the model predictions are
      -    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 model predictions are inserted.
      -
      -    train_dataset_name: Represent final train dataset.
      -    test_dataset_name: Represent final test dataset.
      -    modeling_code: Represent Python3 code for pyspark preprocessing model
      -    model_classifiers: list of initial classifiers to be used in model
      -    pretty_response: returns indented string for visualization if True
      -
      -    return: The resulted predictions URIs.
      -    """
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE MODEL WITH "
      -            + train_dataset_name
      -            + " AND "
      -            + test_dataset_name
      -            + " ----------"
      -        )
      -
      -    request_body_content = {
      -        self.TRAIN_NAME: train_dataset_name,
      -        self.TEST_NAME: test_dataset_name,
      -        self.CODE: modeling_code,
      -        self.CLASSIFIERS_LIST: model_classifiers,
      -    }
      -    response = requests.post(url=self.cluster_url,
      -                             json=request_body_content)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -synchronously, the caller waits until the model predictions are inserted -into the Learning Orchestra storage mechanism.

      -

      train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

      -

      return: The resulted predictions URIs.

      -
      - -Expand source code - -
      def run_builder_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 resource join several steps of machine
      -    learning workflow (transform, tune, train and evaluate) coupling in
      -    a unique resource, builder creates several model predictions using
      -    your own modeling code using a defined set of classifiers. This is made
      -    synchronously, the caller waits until the model predictions are inserted
      -    into the Learning Orchestra storage mechanism.
      -
      -    train_dataset_name: Represent final train dataset.
      -    test_dataset_name: Represent final test dataset.
      -    modeling_code: Represent Python3 code for pyspark preprocessing model
      -    model_classifiers: list of initial classifiers to be used in model
      -    pretty_response: returns indented string for visualization if True
      -
      -    return: The resulted predictions URIs.
      -    """
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE MODEL WITH "
      -            + train_dataset_name
      -            + " AND "
      -            + test_dataset_name
      -            + " ----------"
      -        )
      -
      -    request_body_content = {
      -        self.TRAIN_NAME: train_dataset_name,
      -        self.TEST_NAME: test_dataset_name,
      -        self.CODE: modeling_code,
      -        self.CLASSIFIERS_LIST: model_classifiers,
      -    }
      -    response = requests.post(url=self.cluster_url,
      -                             json=request_body_content)
      -
      -    observer = Observer(test_dataset_name, self.CLUSTER_IP)
      -
      -    for model in model_classifiers:
      -        observer.set_dataset_name(test_dataset_name + model)
      -        observer.observe_processing(pretty_response)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_all_model(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 return indented string, else return dict.

      -

      return: A list with all model predictions metadata stored in Learning -Orchestra or an empty result.

      -
      - -Expand source code - -
      def search_all_model(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 return indented string, else return dict.
      -
      -    return: A list with all model predictions metadata stored in Learning
      -    Orchestra or an empty result.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url
      -
      -    response = requests.get(cluster_url_tsne)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: -This method is responsible for retrieving a specific -model prediction metadata.

      -

      pretty_response: If true return indented string, else return dict. -model_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.

      -
      - -Expand source code - -
      def search_model(self, model_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description:  This method is responsible for retrieving a specific
      -    model prediction metadata.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    model_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_model_prediction(model_name, limit=1,
      -                                            pretty_response=pretty_response)
      -
      -    return response
      -
      -
      -
      -def search_model_prediction(self, model_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 return indented string, else return dict. -model_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 there -is no such projection. The current page is also returned to be used in -future content requests.

      -
      - -Expand source code - -
      def search_model_prediction(self,
      -                            model_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 return indented string, else return dict.
      -    model_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 there
      -    is no such projection. The current page is also returned to be used in
      -    future content requests.
      -    """
      -
      -    cluster_url_dataset = self.cluster_url + "/" + model_name + \
      -                          "?query=" + str(query) + \
      -                          "&limit=" + str(limit) + \
      -                          "&skip=" + str(skip)
      -
      -    response = requests.get(cluster_url_dataset)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/builder/index.html b/html/learning_orchestra_client/builder/index.html deleted file mode 100644 index f6061e5..0000000 --- a/html/learning_orchestra_client/builder/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -learning_orchestra_client.builder API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/dataset/dataset.html b/html/learning_orchestra_client/dataset/dataset.html deleted file mode 100644 index 64e61be..0000000 --- a/html/learning_orchestra_client/dataset/dataset.html +++ /dev/null @@ -1,678 +0,0 @@ - - - - - - -learning_orchestra_client.dataset.dataset API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.dataset.dataset

      -
      -
      -
      - -Expand source code - -
      __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
      -__credits__ = "all free source developers"
      -__status__ = "Prototype"
      -
      -from ..observer import Observer
      -from ..response_treat import ResponseTreat
      -import requests
      -from typing import Union
      -
      -
      -class Dataset:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/dataset"
      -        self.response_treat = ResponseTreat()
      -        self.OUTPUT_NAME = "datasetName"
      -        self.URL = "datasetURI"
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    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 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.
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + 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).
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                     "---")
      -        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 return indented string, else return dict.
      -
      -        return: All datasets metadata stored in Learning Orchestra or an empty
      -        result.
      -        """
      -        request_url = self.cluster_url
      -
      -        response = requests.get(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for retrieving a specific
      -        dataset
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Is the name of the dataset file.
      -        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 dataset metadata stored in Learning Orchestra or an
      -        error if there is no such dataset.
      -        """
      -        response = self.search_dataset_content(dataset_name, limit=1,
      -                                               pretty_response=pretty_response)
      -
      -        return 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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name + \
      -                      "?query=" + str(query) + \
      -                      "&limit=" + str(limit) + \
      -                      "&skip=" + str(skip)
      -
      -        response = requests.get(request_url)
      -
      -        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. The
      -        delete operation is always synchronous because it is very fast, since
      -        the deletion is performed in background. If a dataset was used by
      -        another task (Ex. projection, histogram, pca, tuning and so forth), it
      -        cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Represents the dataset name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name
      -
      -        response = requests.delete(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Dataset -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Dataset:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/dataset"
      -        self.response_treat = ResponseTreat()
      -        self.OUTPUT_NAME = "datasetName"
      -        self.URL = "datasetURI"
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    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 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.
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + 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).
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                     "---")
      -        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 return indented string, else return dict.
      -
      -        return: All datasets metadata stored in Learning Orchestra or an empty
      -        result.
      -        """
      -        request_url = self.cluster_url
      -
      -        response = requests.get(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for retrieving a specific
      -        dataset
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Is the name of the dataset file.
      -        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 dataset metadata stored in Learning Orchestra or an
      -        error if there is no such dataset.
      -        """
      -        response = self.search_dataset_content(dataset_name, limit=1,
      -                                               pretty_response=pretty_response)
      -
      -        return 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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name + \
      -                      "?query=" + str(query) + \
      -                      "&limit=" + str(limit) + \
      -                      "&skip=" + str(skip)
      -
      -        response = requests.get(request_url)
      -
      -        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. The
      -        delete operation is always synchronous because it is very fast, since
      -        the deletion is performed in background. If a dataset was used by
      -        another task (Ex. projection, histogram, pca, tuning and so forth), it
      -        cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Represents the dataset name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name
      -
      -        response = requests.delete(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting the dataset. The -delete operation is always synchronous because it is very fast, since -the deletion is performed in background. If a dataset was used by -another task (Ex. projection, histogram, pca, tuning and so forth), it -cannot be deleted.

      -

      pretty_response: If true return indented string, else return dict. -dataset_name: Represents the dataset name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      def delete_dataset(self, dataset_name, pretty_response=False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting the dataset. The
      -    delete operation is always synchronous because it is very fast, since
      -    the deletion is performed in background. If a dataset was used by
      -    another task (Ex. projection, histogram, pca, tuning and so forth), it
      -    cannot be deleted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    dataset_name: Represents the dataset name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -
      -    request_url = self.cluster_url + "/" + dataset_name
      -
      -    response = requests.delete(request_url)
      -
      -    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).

      -
      - -Expand source code - -
      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).
      -    """
      -    request_body = {self.OUTPUT_NAME: dataset_name,
      -                    self.URL: url}
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                 "---")
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -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 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.

      -
      - -Expand source code - -
      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 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.
      -    """
      -    request_body = {self.OUTPUT_NAME: dataset_name,
      -                    self.URL: url}
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      -
      -    if pretty_response:
      -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                 "---")
      -    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 return indented string, else return dict.

      -

      return: All datasets metadata stored in Learning Orchestra or an empty -result.

      -
      - -Expand source code - -
      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 return indented string, else return dict.
      -
      -    return: All datasets metadata stored in Learning Orchestra or an empty
      -    result.
      -    """
      -    request_url = self.cluster_url
      -
      -    response = requests.get(request_url)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for retrieving a specific -dataset

      -

      pretty_response: If true return indented string, else return dict. -dataset_name: Is the name of the dataset file. -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 dataset metadata stored in Learning Orchestra or an -error if there is no such dataset.

      -
      - -Expand source code - -
      def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for retrieving a specific
      -    dataset
      -
      -    pretty_response: If true return indented string, else return dict.
      -    dataset_name: Is the name of the dataset file.
      -    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 dataset metadata stored in Learning Orchestra or an
      -    error if there is no such dataset.
      -    """
      -    response = self.search_dataset_content(dataset_name, limit=1,
      -                                           pretty_response=pretty_response)
      -
      -    return 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 return indented string, else return dict. -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.

      -
      - -Expand source code - -
      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 return indented string, else return dict.
      -    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.
      -    """
      -
      -    request_url = self.cluster_url + "/" + dataset_name + \
      -                  "?query=" + str(query) + \
      -                  "&limit=" + str(limit) + \
      -                  "&skip=" + str(skip)
      -
      -    response = requests.get(request_url)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/dataset/index.html b/html/learning_orchestra_client/dataset/index.html deleted file mode 100644 index b4c42b2..0000000 --- a/html/learning_orchestra_client/dataset/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -learning_orchestra_client.dataset API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/histogram.html b/html/learning_orchestra_client/explore/histogram.html deleted file mode 100644 index e1abdfc..0000000 --- a/html/learning_orchestra_client/explore/histogram.html +++ /dev/null @@ -1,676 +0,0 @@ - - - - - - -learning_orchestra_client.explore.histogram API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.explore.histogram

      -
      -
      -
      - -Expand source code - -
      from ..observer import Observer
      -from ..response_treat import ResponseTreat
      -from ..dataset.dataset import Dataset
      -import requests
      -from typing import Union
      -
      -
      -class Histogram:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/histogram"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -
      -    def run_histogram_sync(self,
      -                           dataset_name: str,
      -                           histogram_name: str,
      -                           fields: list,
      -                           pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method run histogram algorithm to create a histogram
      -        synchronously, 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 return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_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 run histogram algorithm to create a histogram
      -        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      -
      -        dataset_name: Represents the name of dataset.
      -        histogram_name: Represents the name of histogram.
      -        fields: Represents a list of attributes.
      -        pretty_response: If true return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_name
      -                + " ----------"
      -            )
      -
      -        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 names, it does not
      -        retrieve the histogram content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all histogram names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_histogram_data(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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
      -                                "?query=" + str(query) + \
      -                                "&limit=" + str(limit) + \
      -                                "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        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 synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        histogram_name: Represents the histogram name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name
      -
      -        response = requests.delete(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Histogram -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Histogram:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/histogram"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -
      -    def run_histogram_sync(self,
      -                           dataset_name: str,
      -                           histogram_name: str,
      -                           fields: list,
      -                           pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method run histogram algorithm to create a histogram
      -        synchronously, 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 return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_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 run histogram algorithm to create a histogram
      -        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      -
      -        dataset_name: Represents the name of dataset.
      -        histogram_name: Represents the name of histogram.
      -        fields: Represents a list of attributes.
      -        pretty_response: If true return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_name
      -                + " ----------"
      -            )
      -
      -        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 names, it does not
      -        retrieve the histogram content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all histogram names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_histogram_data(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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
      -                                "?query=" + str(query) + \
      -                                "&limit=" + str(limit) + \
      -                                "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        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 synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        histogram_name: Represents the histogram name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name
      -
      -        response = requests.delete(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -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 synchronous because it is very fast, -since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -histogram_name: Represents the histogram name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      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 synchronous because it is very fast,
      -    since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    histogram_name: Represents the histogram name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -
      -    cluster_url_histogram = self.cluster_url + "/" + histogram_name
      -
      -    response = requests.delete(cluster_url_histogram)
      -
      -    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 run histogram algorithm to create a histogram -asynchronously, the caller does not wait until the histogram 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 histogram was inserted.

      -

      dataset_name: Represents the name of dataset. -histogram_name: Represents the name of histogram. -fields: Represents a list of attributes. -pretty_response: If true return indented string, else return dict.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a histogram.

      -
      - -Expand source code - -
      def run_histogram_async(self,
      -                        dataset_name: str,
      -                        histogram_name: str,
      -                        fields: list,
      -                        pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method run histogram algorithm to create a histogram
      -    asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      -
      -    dataset_name: Represents the name of dataset.
      -    histogram_name: Represents the name of histogram.
      -    fields: Represents a list of attributes.
      -    pretty_response: If true return indented string, else return dict.
      -
      -    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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE HISTOGRAM FROM "
      -            + dataset_name
      -            + " TO "
      -            + histogram_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_histogram_sync(self, dataset_name: str, histogram_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run histogram algorithm to create a histogram -synchronously, 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 return indented string, else return dict.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a histogram.

      -
      - -Expand source code - -
      def run_histogram_sync(self,
      -                       dataset_name: str,
      -                       histogram_name: str,
      -                       fields: list,
      -                       pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method run histogram algorithm to create a histogram
      -    synchronously, 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 return indented string, else return dict.
      -
      -    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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    Observer(histogram_name, self.CLUSTER_IP).observe_processing(
      -        pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE HISTOGRAM FROM "
      -            + dataset_name
      -            + " TO "
      -            + histogram_name
      -            + " ----------"
      -        )
      -
      -    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 names, it does not -retrieve the histogram content.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all histogram names stored in Learning Orchestra -or an empty result.

      -
      - -Expand source code - -
      def search_all_histograms(self, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves all histogram names, it does not
      -    retrieve the histogram content.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all histogram names stored in Learning Orchestra
      -    or an empty result.
      -    """
      -
      -    cluster_url_histogram = self.cluster_url
      -
      -    response = requests.get(cluster_url_histogram)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_histogram_data(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 return indented string, else return dict. -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.

      -
      - -Expand source code - -
      def search_histogram_data(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 return indented string, else return dict.
      -    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.
      -    """
      -
      -    cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
      -                            "?query=" + str(query) + \
      -                            "&limit=" + str(limit) + \
      -                            "&skip=" + str(skip)
      -
      -    response = requests.get(cluster_url_histogram)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/index.html b/html/learning_orchestra_client/explore/index.html deleted file mode 100644 index d4f7495..0000000 --- a/html/learning_orchestra_client/explore/index.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - -learning_orchestra_client.explore API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/pca.html b/html/learning_orchestra_client/explore/pca.html deleted file mode 100644 index 877a51d..0000000 --- a/html/learning_orchestra_client/explore/pca.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - - -learning_orchestra_client.explore.pca API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.explore.pca

      -
      -
      -
      - -Expand source code - -
      from ..response_treat import ResponseTreat
      -from ..dataset.dataset import Dataset
      -from PIL import Image
      -import requests
      -import time
      -from typing import Union
      -
      -
      -class Pca:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/pca"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_pca_sync(self,
      -                     dataset_name: str,
      -                     pca_name: str,
      -                     label: str,
      -                     pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        synchronously, the caller waits until the PCA image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_pca_exist(pca_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_pca_async(self,
      -                      dataset_name: str,
      -                      pca_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method retrieves all PCAs plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all PCAs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_pca = self.cluster_url
      -
      -        response = requests.get(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a PCA image plot.
      -
      -        pca_name: Name of PCA image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ "
      -                + pca_name
      -                + " PCA IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_pca
      -
      -    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the PCA image plot.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        pca_name: Represents the PCA name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        response = requests.delete(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a PCA image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        pca_name: Name of PCA image plot.
      -
      -        return: True if the PCA requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
      -                                                           "----------")
      -
      -        exist = False
      -        pca_name += ".png"
      -
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_pca = self.search_all_pca()
      -            exist = pca_name in all_pca.get('result')
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Pca -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Pca:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/pca"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_pca_sync(self,
      -                     dataset_name: str,
      -                     pca_name: str,
      -                     label: str,
      -                     pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        synchronously, the caller waits until the PCA image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_pca_exist(pca_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_pca_async(self,
      -                      dataset_name: str,
      -                      pca_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method retrieves all PCAs plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all PCAs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_pca = self.cluster_url
      -
      -        response = requests.get(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a PCA image plot.
      -
      -        pca_name: Name of PCA image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ "
      -                + pca_name
      -                + " PCA IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_pca
      -
      -    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the PCA image plot.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        pca_name: Represents the PCA name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        response = requests.delete(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a PCA image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        pca_name: Name of PCA image plot.
      -
      -        return: True if the PCA requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
      -                                                           "----------")
      -
      -        exist = False
      -        pca_name += ".png"
      -
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_pca = self.search_all_pca()
      -            exist = pca_name in all_pca.get('result')
      -
      -

      Methods

      -
      -
      -def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting the PCA image plot. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -pca_name: Represents the PCA name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message.

      -
      - -Expand source code - -
      def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting the PCA image plot.
      -    The delete operation is always synchronous because it is very fast,
      -    since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    pca_name: Represents the PCA name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message.
      -    """
      -
      -    cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -    response = requests.delete(cluster_url_pca)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_pca_async(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run PCA algorithm to create an image plot -asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.

      -

      dataset_name: Name of dataset. -pca_name: Name of PCA image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a PCA image plot.

      -
      - -Expand source code - -
      def run_pca_async(self,
      -                  dataset_name: str,
      -                  pca_name: str,
      -                  label: str,
      -                  pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run PCA algorithm to create an image plot
      -    asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
      -
      -    dataset_name: Name of dataset.
      -    pca_name: Name of PCA image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a PCA image plot.
      -    """
      -
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: pca_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PCA IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + pca_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_pca_sync(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run PCA algorithm to create an image plot -synchronously, the caller waits until the PCA image is inserted into -the Learning Orchestra storage mechanism.

      -

      dataset_name: Name of dataset. -pca_name: Name of PCA image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a PCA image plot.

      -
      - -Expand source code - -
      def run_pca_sync(self,
      -                 dataset_name: str,
      -                 pca_name: str,
      -                 label: str,
      -                 pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run PCA algorithm to create an image plot
      -    synchronously, the caller waits until the PCA image is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    dataset_name: Name of dataset.
      -    pca_name: Name of PCA image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a PCA image plot.
      -    """
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: pca_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    self.verify_pca_exist(pca_name, pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PCA IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + pca_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_all_pca(self, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves all PCAs plot names, it does not -retrieve the image plot.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all PCAs plot names stored in Learning Orchestra -or an empty result.

      -
      - -Expand source code - -
      def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method retrieves all PCAs plot names, it does not
      -    retrieve the image plot.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all PCAs plot names stored in Learning Orchestra
      -    or an empty result.
      -    """
      -
      -    cluster_url_pca = self.cluster_url
      -
      -    response = requests.get(cluster_url_pca)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves a PCA image plot.

      -

      pca_name: Name of PCA image plot. -pretty_response: If true open an image plot, else return link to -open image plot.

      -

      return: A link to an image plot or open an image plot.

      -
      - -Expand source code - -
      def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves a PCA image plot.
      -
      -    pca_name: Name of PCA image plot.
      -    pretty_response: If true open an image plot, else return link to
      -    open image plot.
      -
      -    return: A link to an image plot or open an image plot.
      -    """
      -
      -    cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " READ "
      -            + pca_name
      -            + " PCA IMAGE PLOT "
      -            + " ----------"
      -        )
      -        img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
      -        img.show()
      -    else:
      -        return cluster_url_pca
      -
      -
      -
      -def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible to verify if a PCA image -exist into the Learning Orchestra storage mechanism.

      -

      pca_name: Name of PCA image plot.

      -

      return: True if the PCA requested exist, false if does not.

      -
      - -Expand source code - -
      def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible to verify if a PCA image
      -    exist into the Learning Orchestra storage mechanism.
      -
      -    pca_name: Name of PCA image plot.
      -
      -    return: True if the PCA requested exist, false if does not.
      -    """
      -
      -    if pretty_response:
      -        print("\n---------- CHECKING IF " + pca_name + " FINISHED "
      -                                                       "----------")
      -
      -    exist = False
      -    pca_name += ".png"
      -
      -    while not exist:
      -        time.sleep(self.WAIT_TIME)
      -        all_pca = self.search_all_pca()
      -        exist = pca_name in all_pca.get('result')
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/tsne.html b/html/learning_orchestra_client/explore/tsne.html deleted file mode 100644 index b4e1b63..0000000 --- a/html/learning_orchestra_client/explore/tsne.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - - -learning_orchestra_client.explore.tsne API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.explore.tsne

      -
      -
      -
      - -Expand source code - -
      from ..response_treat import ResponseTreat
      -from ..dataset.dataset import Dataset
      -from PIL import Image
      -import requests
      -import time
      -from typing import Union
      -
      -
      -class Tsne:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/tsne"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_tsne_sync(self,
      -                      dataset_name: str,
      -                      tsne_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        synchronously, the caller waits until the t_SNE image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_tsne_exist(tsne_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_tsne_async(self,
      -                       dataset_name: str,
      -                       tsne_name: str,
      -                       label: str,
      -                       pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_tsne(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all t_SNE plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all t_SNEs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a t_SNE image plot.
      -
      -        tsne_name: Name of t_SNE image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ"
      -                + tsne_name
      -                + " tsne IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_tsne
      -
      -    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the t_SNE image
      -        plot. The delete operation is always synchronous because it is very
      -        fast, since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        tsne_name: Represents the tsne name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        response = requests.delete(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a t_SNE image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        tsne_name: Name of t_SNE image plot.
      -
      -        return: True if the t_SNE requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
      -                                                            "----------")
      -
      -        exist = False
      -        tsne_name += ".png"
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_tsne = self.search_all_tsne()
      -            exist = tsne_name in all_tsne.get('result')
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Tsne -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Tsne:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/tsne"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_tsne_sync(self,
      -                      dataset_name: str,
      -                      tsne_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        synchronously, the caller waits until the t_SNE image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_tsne_exist(tsne_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_tsne_async(self,
      -                       dataset_name: str,
      -                       tsne_name: str,
      -                       label: str,
      -                       pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_tsne(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all t_SNE plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all t_SNEs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a t_SNE image plot.
      -
      -        tsne_name: Name of t_SNE image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ"
      -                + tsne_name
      -                + " tsne IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_tsne
      -
      -    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the t_SNE image
      -        plot. The delete operation is always synchronous because it is very
      -        fast, since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        tsne_name: Represents the tsne name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        response = requests.delete(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a t_SNE image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        tsne_name: Name of t_SNE image plot.
      -
      -        return: True if the t_SNE requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
      -                                                            "----------")
      -
      -        exist = False
      -        tsne_name += ".png"
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_tsne = self.search_all_tsne()
      -            exist = tsne_name in all_tsne.get('result')
      -
      -

      Methods

      -
      -
      -def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting the t_SNE image -plot. The delete operation is always synchronous because it is very -fast, since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -tsne_name: Represents the tsne name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message.

      -
      - -Expand source code - -
      def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting the t_SNE image
      -    plot. The delete operation is always synchronous because it is very
      -    fast, since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    tsne_name: Represents the tsne name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -    response = requests.delete(cluster_url_tsne)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_tsne_async(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run t_SNE algorithm to create an image plot -asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.

      -

      dataset_name: Name of dataset. -tsne_name: Name of t_SNE image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a t_SNE image plot.

      -
      - -Expand source code - -
      def run_tsne_async(self,
      -                   dataset_name: str,
      -                   tsne_name: str,
      -                   label: str,
      -                   pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run t_SNE algorithm to create an image plot
      -    asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
      -
      -    dataset_name: Name of dataset.
      -    tsne_name: Name of t_SNE image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a t_SNE image plot.
      -    """
      -
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: tsne_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE TSNE IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + tsne_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_tsne_sync(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run t_SNE algorithm to create an image plot -synchronously, the caller waits until the t_SNE image is inserted into -the Learning Orchestra storage mechanism.

      -

      dataset_name: Name of dataset. -tsne_name: Name of t_SNE image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a t_SNE image plot.

      -
      - -Expand source code - -
      def run_tsne_sync(self,
      -                  dataset_name: str,
      -                  tsne_name: str,
      -                  label: str,
      -                  pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run t_SNE algorithm to create an image plot
      -    synchronously, the caller waits until the t_SNE image is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    dataset_name: Name of dataset.
      -    tsne_name: Name of t_SNE image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a t_SNE image plot.
      -    """
      -
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: tsne_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    self.verify_tsne_exist(tsne_name, pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE TSNE IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + tsne_name
      -            + " ----------"
      -        )
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_all_tsne(self, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves all t_SNE plot names, it does not -retrieve the image plot.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all t_SNEs plot names stored in Learning Orchestra -or an empty result.

      -
      - -Expand source code - -
      def search_all_tsne(self, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves all t_SNE plot names, it does not
      -    retrieve the image plot.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all t_SNEs plot names stored in Learning Orchestra
      -    or an empty result.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url
      -
      -    response = requests.get(cluster_url_tsne)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves a t_SNE image plot.

      -

      tsne_name: Name of t_SNE image plot. -pretty_response: If true open an image plot, else return link to -open image plot.

      -

      return: A link to an image plot or open an image plot.

      -
      - -Expand source code - -
      def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves a t_SNE image plot.
      -
      -    tsne_name: Name of t_SNE image plot.
      -    pretty_response: If true open an image plot, else return link to
      -    open image plot.
      -
      -    return: A link to an image plot or open an image plot.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " READ"
      -            + tsne_name
      -            + " tsne IMAGE PLOT "
      -            + " ----------"
      -        )
      -        img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
      -        img.show()
      -    else:
      -        return cluster_url_tsne
      -
      -
      -
      -def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible to verify if a t_SNE image -exist into the Learning Orchestra storage mechanism.

      -

      tsne_name: Name of t_SNE image plot.

      -

      return: True if the t_SNE requested exist, false if does not.

      -
      - -Expand source code - -
      def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible to verify if a t_SNE image
      -    exist into the Learning Orchestra storage mechanism.
      -
      -    tsne_name: Name of t_SNE image plot.
      -
      -    return: True if the t_SNE requested exist, false if does not.
      -    """
      -
      -    if pretty_response:
      -        print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
      -                                                        "----------")
      -
      -    exist = False
      -    tsne_name += ".png"
      -    while not exist:
      -        time.sleep(self.WAIT_TIME)
      -        all_tsne = self.search_all_tsne()
      -        exist = tsne_name in all_tsne.get('result')
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/index.html b/html/learning_orchestra_client/index.html deleted file mode 100644 index 64b720b..0000000 --- a/html/learning_orchestra_client/index.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - -learning_orchestra_client API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/observer.html b/html/learning_orchestra_client/observer.html deleted file mode 100644 index a7d3aee..0000000 --- a/html/learning_orchestra_client/observer.html +++ /dev/null @@ -1,375 +0,0 @@ - - - - - - -learning_orchestra_client.observer API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.observer

      -
      -
      -
      - -Expand source code - -
      from pymongo import MongoClient, change_stream
      -
      -
      -class Observer:
      -    def __init__(self, dataset_name: str, cluster_ip: str):
      -        self.dataset_name = dataset_name
      -
      -        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
      -        mongo_client = MongoClient(mongo_url)
      -        self.database = mongo_client['database']
      -
      -    def set_dataset_name(self, dataset_name: str):
      -        """
      -        :description: Changes the dataset name used in object.
      -        :param dataset_name: Name of dataset to observe.
      -
      -        :return: None.
      -        """
      -        self.dataset_name = dataset_name
      -
      -    def get_dataset_name(self) -> str:
      -        """
      -        :description: Retrieve the dataset name used in object.
      -
      -        :return: The dataset name.
      -        """
      -        return self.dataset_name
      -
      -    def observe_processing(self, pretty_response: bool = False) -> dict:
      -        """
      -        :description: Observe the finished processing status from some
      -        processing, blocking the code execution until finish processing.
      -
      -        :return: A dict with metadata file of used dataset name.
      -        """
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
      -                                                                    "----------")
      -        dataset_collection = self.database[self.dataset_name]
      -        metadata_query = {"_id": 0}
      -        dataset_metadata = dataset_collection.find_one(metadata_query)
      -
      -        if dataset_metadata is None:
      -            print("Dataset name or dataset URL invalid")
      -            exit()
      -
      -        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').next()['fullDocument']
      -
      -    def observe_storage(self) -> change_stream.CollectionChangeStream:
      -        """
      -        :description: Get all changes from a dataset
      -
      -        :return: A pymongo CollectionChangeStream object, use the builtin
      -        next() method to iterate over changes.
      -        """
      -
      -        observer_query = [
      -            {'$match': {
      -                '$or': [
      -                    {'operationType': 'replace'},
      -                    {'operationType': 'insert'},
      -                    {'operationType': 'update'},
      -                    {'operationType': 'delete'}
      -
      -                ]
      -            }}
      -        ]
      -        return self.database[self.dataset_name].watch(
      -            observer_query,
      -            full_document='updateLookup')
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Observer -(dataset_name: str, cluster_ip: str) -
      -
      -
      -
      - -Expand source code - -
      class Observer:
      -    def __init__(self, dataset_name: str, cluster_ip: str):
      -        self.dataset_name = dataset_name
      -
      -        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
      -        mongo_client = MongoClient(mongo_url)
      -        self.database = mongo_client['database']
      -
      -    def set_dataset_name(self, dataset_name: str):
      -        """
      -        :description: Changes the dataset name used in object.
      -        :param dataset_name: Name of dataset to observe.
      -
      -        :return: None.
      -        """
      -        self.dataset_name = dataset_name
      -
      -    def get_dataset_name(self) -> str:
      -        """
      -        :description: Retrieve the dataset name used in object.
      -
      -        :return: The dataset name.
      -        """
      -        return self.dataset_name
      -
      -    def observe_processing(self, pretty_response: bool = False) -> dict:
      -        """
      -        :description: Observe the finished processing status from some
      -        processing, blocking the code execution until finish processing.
      -
      -        :return: A dict with metadata file of used dataset name.
      -        """
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
      -                                                                    "----------")
      -        dataset_collection = self.database[self.dataset_name]
      -        metadata_query = {"_id": 0}
      -        dataset_metadata = dataset_collection.find_one(metadata_query)
      -
      -        if dataset_metadata is None:
      -            print("Dataset name or dataset URL invalid")
      -            exit()
      -
      -        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').next()['fullDocument']
      -
      -    def observe_storage(self) -> change_stream.CollectionChangeStream:
      -        """
      -        :description: Get all changes from a dataset
      -
      -        :return: A pymongo CollectionChangeStream object, use the builtin
      -        next() method to iterate over changes.
      -        """
      -
      -        observer_query = [
      -            {'$match': {
      -                '$or': [
      -                    {'operationType': 'replace'},
      -                    {'operationType': 'insert'},
      -                    {'operationType': 'update'},
      -                    {'operationType': 'delete'}
      -
      -                ]
      -            }}
      -        ]
      -        return self.database[self.dataset_name].watch(
      -            observer_query,
      -            full_document='updateLookup')
      -
      -

      Methods

      -
      -
      -def get_dataset_name(self) ‑> str -
      -
      -

      :description: Retrieve the dataset name used in object.

      -

      :return: The dataset name.

      -
      - -Expand source code - -
      def get_dataset_name(self) -> str:
      -    """
      -    :description: Retrieve the dataset name used in object.
      -
      -    :return: The dataset name.
      -    """
      -    return self.dataset_name
      -
      -
      -
      -def observe_processing(self, pretty_response: bool = False) ‑> dict -
      -
      -

      :description: Observe the finished processing status from some -processing, blocking the code execution until finish processing.

      -

      :return: A dict with metadata file of used dataset name.

      -
      - -Expand source code - -
      def observe_processing(self, pretty_response: bool = False) -> dict:
      -    """
      -    :description: Observe the finished processing status from some
      -    processing, blocking the code execution until finish processing.
      -
      -    :return: A dict with metadata file of used dataset name.
      -    """
      -    if pretty_response:
      -        print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
      -                                                                "----------")
      -    dataset_collection = self.database[self.dataset_name]
      -    metadata_query = {"_id": 0}
      -    dataset_metadata = dataset_collection.find_one(metadata_query)
      -
      -    if dataset_metadata is None:
      -        print("Dataset name or dataset URL invalid")
      -        exit()
      -
      -    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').next()['fullDocument']
      -
      -
      -
      -def observe_storage(self) ‑> pymongo.change_stream.CollectionChangeStream -
      -
      -

      :description: Get all changes from a dataset

      -

      :return: A pymongo CollectionChangeStream object, use the builtin -next() method to iterate over changes.

      -
      - -Expand source code - -
      def observe_storage(self) -> change_stream.CollectionChangeStream:
      -    """
      -    :description: Get all changes from a dataset
      -
      -    :return: A pymongo CollectionChangeStream object, use the builtin
      -    next() method to iterate over changes.
      -    """
      -
      -    observer_query = [
      -        {'$match': {
      -            '$or': [
      -                {'operationType': 'replace'},
      -                {'operationType': 'insert'},
      -                {'operationType': 'update'},
      -                {'operationType': 'delete'}
      -
      -            ]
      -        }}
      -    ]
      -    return self.database[self.dataset_name].watch(
      -        observer_query,
      -        full_document='updateLookup')
      -
      -
      -
      -def set_dataset_name(self, dataset_name: str) -
      -
      -

      :description: Changes the dataset name used in object. -:param dataset_name: Name of dataset to observe.

      -

      :return: None.

      -
      - -Expand source code - -
      def set_dataset_name(self, dataset_name: str):
      -    """
      -    :description: Changes the dataset name used in object.
      -    :param dataset_name: Name of dataset to observe.
      -
      -    :return: None.
      -    """
      -    self.dataset_name = dataset_name
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/response_treat.html b/html/learning_orchestra_client/response_treat.html deleted file mode 100644 index 2c8bb2a..0000000 --- a/html/learning_orchestra_client/response_treat.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - -learning_orchestra_client.response_treat API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.response_treat

      -
      -
      -
      - -Expand source code - -
      __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
      -__credits__ = "all free source developers"
      -__status__ = "Prototype"
      -
      -import json
      -
      -
      -class ResponseTreat:
      -    HTTP_CREATED = 201
      -    HTTP_SUCCESS = 200
      -    HTTP_ERROR = 500
      -
      -    def treatment(self, response, pretty_response: bool = True):
      -        """
      -        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:
      -            return response.text
      -        elif (
      -                response.status_code != self.HTTP_SUCCESS
      -                and response.status_code != self.HTTP_CREATED
      -        ):
      -            raise Exception(response.json()["result"])
      -        else:
      -            if pretty_response:
      -                return json.dumps(response.json(), indent=4, sort_keys=True)
      -            else:
      -                return response.json()
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class ResponseTreat -
      -
      -
      -
      - -Expand source code - -
      class ResponseTreat:
      -    HTTP_CREATED = 201
      -    HTTP_SUCCESS = 200
      -    HTTP_ERROR = 500
      -
      -    def treatment(self, response, pretty_response: bool = True):
      -        """
      -        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:
      -            return response.text
      -        elif (
      -                response.status_code != self.HTTP_SUCCESS
      -                and response.status_code != self.HTTP_CREATED
      -        ):
      -            raise Exception(response.json()["result"])
      -        else:
      -            if pretty_response:
      -                return json.dumps(response.json(), indent=4, sort_keys=True)
      -            else:
      -                return response.json()
      -
      -

      Class variables

      -
      -
      var HTTP_CREATED
      -
      -
      -
      -
      var HTTP_ERROR
      -
      -
      -
      -
      var HTTP_SUCCESS
      -
      -
      -
      -
      -

      Methods

      -
      -
      -def treatment(self, response, pretty_response: bool = True) -
      -
      -

      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.

      -
      - -Expand source code - -
      def treatment(self, response, pretty_response: bool = True):
      -    """
      -    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:
      -        return response.text
      -    elif (
      -            response.status_code != self.HTTP_SUCCESS
      -            and response.status_code != self.HTTP_CREATED
      -    ):
      -        raise Exception(response.json()["result"])
      -    else:
      -        if pretty_response:
      -            return json.dumps(response.json(), indent=4, sort_keys=True)
      -        else:
      -            return response.json()
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/data_type.html b/html/learning_orchestra_client/transform/data_type.html deleted file mode 100644 index fcd25c1..0000000 --- a/html/learning_orchestra_client/transform/data_type.html +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - -learning_orchestra_client.transform.data_type API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.transform.data_type

      -
      -
      -
      - -Expand source code - -
      from ..response_treat import ResponseTreat
      -from ..dataset.dataset import Dataset
      -import requests
      -from typing import Union
      -
      -
      -class DataType:
      -    def __init__(self, ip_from_cluster):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/dataType"
      -        self.ResponseTreat = ResponseTreat()
      -        self.Dataset = Dataset(ip_from_cluster)
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.TYPES = "types"
      -
      -    def update_dataset_types(self,
      -                             dataset_name: str,
      -                             fields_change: dict,
      -                             pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: Change types of fields to number or string.
      -
      -        dataset_name: Represents the dataset name.
      -        fields_change: Fields to change with types. This is a dict with each
      -        key:value being field:type
      -
      -        return: A JSON object with error or warning messages.
      -        """
      -
      -        url_request = self.cluster_url
      -        body_request = {
      -            self.INPUT_NAME: dataset_name,
      -            self.TYPES: fields_change
      -        }
      -
      -        response = requests.patch(url=url_request, json=body_request)
      -
      -        return self.ResponseTreat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class DataType -(ip_from_cluster) -
      -
      -
      -
      - -Expand source code - -
      class DataType:
      -    def __init__(self, ip_from_cluster):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/dataType"
      -        self.ResponseTreat = ResponseTreat()
      -        self.Dataset = Dataset(ip_from_cluster)
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.TYPES = "types"
      -
      -    def update_dataset_types(self,
      -                             dataset_name: str,
      -                             fields_change: dict,
      -                             pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: Change types of fields to number or string.
      -
      -        dataset_name: Represents the dataset name.
      -        fields_change: Fields to change with types. This is a dict with each
      -        key:value being field:type
      -
      -        return: A JSON object with error or warning messages.
      -        """
      -
      -        url_request = self.cluster_url
      -        body_request = {
      -            self.INPUT_NAME: dataset_name,
      -            self.TYPES: fields_change
      -        }
      -
      -        response = requests.patch(url=url_request, json=body_request)
      -
      -        return self.ResponseTreat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def update_dataset_types(self, dataset_name: str, fields_change: dict, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: Change types of fields to number or string.

      -

      dataset_name: Represents the dataset name. -fields_change: Fields to change with types. This is a dict with each -key:value being field:type

      -

      return: A JSON object with error or warning messages.

      -
      - -Expand source code - -
      def update_dataset_types(self,
      -                         dataset_name: str,
      -                         fields_change: dict,
      -                         pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: Change types of fields to number or string.
      -
      -    dataset_name: Represents the dataset name.
      -    fields_change: Fields to change with types. This is a dict with each
      -    key:value being field:type
      -
      -    return: A JSON object with error or warning messages.
      -    """
      -
      -    url_request = self.cluster_url
      -    body_request = {
      -        self.INPUT_NAME: dataset_name,
      -        self.TYPES: fields_change
      -    }
      -
      -    response = requests.patch(url=url_request, json=body_request)
      -
      -    return self.ResponseTreat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/index.html b/html/learning_orchestra_client/transform/index.html deleted file mode 100644 index 271146f..0000000 --- a/html/learning_orchestra_client/transform/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - -learning_orchestra_client.transform API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/projection.html b/html/learning_orchestra_client/transform/projection.html deleted file mode 100644 index 7e84007..0000000 --- a/html/learning_orchestra_client/transform/projection.html +++ /dev/null @@ -1,1035 +0,0 @@ - - - - - - -learning_orchestra_client.transform.projection API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.transform.projection

      -
      -
      -
      - -Expand source code - -
      from ..response_treat import ResponseTreat
      -from ..dataset.dataset import Dataset
      -from ..observer import Observer
      -import requests
      -from typing import Union
      -
      -
      -class Projection:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/projection"
      -        self.METADATA_INDEX = 0
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def insert_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(projection_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def insert_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields_to_delete: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes on a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_sync(dataset_name,
      -                                                       projection_name,
      -                                                       fields_to_insert,
      -                                                       pretty_response)
      -
      -        return response
      -
      -    def delete_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields_to_delete: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_async(dataset_name,
      -                                                        projection_name,
      -                                                        fields_to_insert,
      -                                                        pretty_response)
      -
      -        return response
      -
      -    def search_all_projections(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all projection metadata, it does not
      -        retrieve the projection content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all projections metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -        cluster_url_projection = self.cluster_url
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_projections(self, projection_name: str,
      -                           pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        projection.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
      -        error if there is no such projections.
      -        """
      -        pretty = pretty_response
      -
      -        response = self.search_projections_content(projection_name, limit=1,
      -                                                   pretty_response=pretty)
      -
      -        return response
      -
      -    def search_projections_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 dataset
      -        content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_projection = self.cluster_url + "/" + projection_name + \
      -                                 "?query=" + str(query) + \
      -                                 "&limit=" + str(limit) + \
      -                                 "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_projections(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 synchronous because it is very fast,
      -        since the deletion is performed in background. If a projection was
      -        used by another task (Ex. histogram, pca, tuning and so forth),
      -        it cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -        cluster_url_projection = self.cluster_url + "/" + projection_name
      -
      -        response = requests.delete(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Projection -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Projection:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/projection"
      -        self.METADATA_INDEX = 0
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def insert_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(projection_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def insert_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields_to_delete: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes on a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_sync(dataset_name,
      -                                                       projection_name,
      -                                                       fields_to_insert,
      -                                                       pretty_response)
      -
      -        return response
      -
      -    def delete_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields_to_delete: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_async(dataset_name,
      -                                                        projection_name,
      -                                                        fields_to_insert,
      -                                                        pretty_response)
      -
      -        return response
      -
      -    def search_all_projections(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all projection metadata, it does not
      -        retrieve the projection content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all projections metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -        cluster_url_projection = self.cluster_url
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_projections(self, projection_name: str,
      -                           pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        projection.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
      -        error if there is no such projections.
      -        """
      -        pretty = pretty_response
      -
      -        response = self.search_projections_content(projection_name, limit=1,
      -                                                   pretty_response=pretty)
      -
      -        return response
      -
      -    def search_projections_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 dataset
      -        content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_projection = self.cluster_url + "/" + projection_name + \
      -                                 "?query=" + str(query) + \
      -                                 "&limit=" + str(limit) + \
      -                                 "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_projections(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 synchronous because it is very fast,
      -        since the deletion is performed in background. If a projection was
      -        used by another task (Ex. histogram, pca, tuning and so forth),
      -        it cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -        cluster_url_projection = self.cluster_url + "/" + projection_name
      -
      -        response = requests.delete(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def delete_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method delete a set of attributes into a dataset -asynchronously, the caller does not wait until the projections 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 projection was inserted.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields_to_delete: Represents the set of attributes to be inserted. -This is list with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def delete_dataset_attributes_async(self,
      -                                    dataset_name: str,
      -                                    projection_name: str,
      -                                    fields_to_delete: list,
      -                                    pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method delete a set of attributes into a dataset
      -    asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields_to_delete: Represents the set of attributes to be inserted.
      -    This is list with all attributes.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns the projection metadata.
      -    """
      -    dataset_metadata = self.search_projections_content(dataset_name,
      -                                                       limit=1)
      -
      -    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -        .get('fields')
      -    for field in fields_to_delete:
      -        fields_to_insert.remove(field)
      -
      -    response = self.insert_dataset_attributes_async(dataset_name,
      -                                                    projection_name,
      -                                                    fields_to_insert,
      -                                                    pretty_response)
      -
      -    return response
      -
      -
      -
      -def delete_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method delete a set of attributes on a dataset -synchronously, the caller waits until the projection is inserted into -the Learning Orchestra storage mechanism.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields_to_delete: Represents the set of attributes to be inserted. -This is list with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def delete_dataset_attributes_sync(self,
      -                                   dataset_name: str,
      -                                   projection_name: str,
      -                                   fields_to_delete: list,
      -                                   pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method delete a set of attributes on a dataset
      -    synchronously, the caller waits until the projection is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields_to_delete: Represents the set of attributes to be inserted.
      -    This is list with all attributes.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns the projection metadata.
      -    """
      -    dataset_metadata = self.search_projections_content(dataset_name,
      -                                                       limit=1)
      -
      -    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -        .get('fields')
      -    for field in fields_to_delete:
      -        fields_to_insert.remove(field)
      -
      -    response = self.insert_dataset_attributes_sync(dataset_name,
      -                                                   projection_name,
      -                                                   fields_to_insert,
      -                                                   pretty_response)
      -
      -    return response
      -
      -
      -
      -def delete_projections(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 synchronous because it is very fast, -since the deletion is performed in background. If a projection was -used by another task (Ex. histogram, pca, tuning and so forth), -it cannot be deleted.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      def delete_projections(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 synchronous because it is very fast,
      -    since the deletion is performed in background. If a projection was
      -    used by another task (Ex. histogram, pca, tuning and so forth),
      -    it cannot be deleted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -    cluster_url_projection = self.cluster_url + "/" + projection_name
      -
      -    response = requests.delete(cluster_url_projection)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def insert_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method inserts a set of attributes into a dataset -asynchronously, the caller does not wait until the projections 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 projection was inserted.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields: Represents the set of attributes to be inserted. This is list -with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def insert_dataset_attributes_async(self,
      -                                    dataset_name: str,
      -                                    projection_name: str,
      -                                    fields: list,
      -                                    pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method inserts a set of attributes into a dataset
      -    asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields: Represents the set of attributes to be inserted. This is list
      -    with all 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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PROJECTION FROM "
      -            + dataset_name
      -            + " TO "
      -            + projection_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def insert_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method inserts a set of attributes into a dataset -synchronously, the caller waits until the projection is inserted into -the Learning Orchestra storage mechanism.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields: Represents the set of attributes to be inserted. This is list -with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def insert_dataset_attributes_sync(self,
      -                                   dataset_name: str,
      -                                   projection_name: str,
      -                                   fields: list,
      -                                   pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method inserts a set of attributes into a dataset
      -    synchronously, the caller waits until the projection is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields: Represents the set of attributes to be inserted. This is list
      -    with all 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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    Observer(projection_name, self.CLUSTER_IP).observe_processing(
      -        pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PROJECTION FROM "
      -            + dataset_name
      -            + " TO "
      -            + projection_name
      -            + " ----------"
      -        )
      -
      -    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, it does not -retrieve the projection content.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all projections metadata stored in Learning -Orchestra or an empty result.

      -
      - -Expand source code - -
      def search_all_projections(self, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves all projection metadata, it does not
      -    retrieve the projection content.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all projections metadata stored in Learning
      -    Orchestra or an empty result.
      -    """
      -    cluster_url_projection = self.cluster_url
      -
      -    response = requests.get(cluster_url_projection)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_projections(self, projection_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: -This method is responsible for retrieving a specific -projection.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an -error if there is no such projections.

      -
      - -Expand source code - -
      def search_projections(self, projection_name: str,
      -                       pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description:  This method is responsible for retrieving a specific
      -    projection.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
      -    error if there is no such projections.
      -    """
      -    pretty = pretty_response
      -
      -    response = self.search_projections_content(projection_name, limit=1,
      -                                               pretty_response=pretty)
      -
      -    return response
      -
      -
      -
      -def search_projections_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 dataset -content.

      -

      pretty_response: If true return indented string, else return dict. -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.

      -
      - -Expand source code - -
      def search_projections_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 dataset
      -    content.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    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.
      -    """
      -
      -    cluster_url_projection = self.cluster_url + "/" + projection_name + \
      -                             "?query=" + str(query) + \
      -                             "&limit=" + str(limit) + \
      -                             "&skip=" + str(skip)
      -
      -    response = requests.get(cluster_url_projection)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file From 073c8dc298c97c707d59ced06f6aaadc692d07fb Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Mon, 21 Dec 2020 16:47:17 -0300 Subject: [PATCH 05/28] update docs --- docs/builder.html | 790 ++++++++++++++++++++++++++++++++++++++++++++++ docs/dataset.html | 678 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 1468 insertions(+) create mode 100644 docs/builder.html create mode 100644 docs/dataset.html diff --git a/docs/builder.html b/docs/builder.html new file mode 100644 index 0000000..77f521b --- /dev/null +++ b/docs/builder.html @@ -0,0 +1,790 @@ + + + + + + +learning_orchestra_client.builder API documentation + + + + + + + + + + + +
      +
      +
      +

      Module learning_orchestra_client.builder

      +
      +
      +
      + +Expand source code + +
      from .observer import Observer
      +from .response_treat import ResponseTreat
      +from .dataset import Dataset
      +import requests
      +from typing import Union
      +
      +
      +class Builder:
      +    def __init__(self, ip_from_cluster: str):
      +        self.CLUSTER_IP = ip_from_cluster
      +        self.cluster_url = "http://" + ip_from_cluster + \
      +                           "/api/learningOrchestra/v1/builder"
      +        self.response_treat = ResponseTreat()
      +        self.TRAIN_NAME = "trainDatasetName"
      +        self.TEST_NAME = "testDatasetName"
      +        self.CODE = "modelingCode"
      +        self.CLASSIFIERS_LIST = "classifiersList"
      +        self.dataset = Dataset(ip_from_cluster)
      +        self.METADATA_INDEX = 0
      +
      +    def run_builder_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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        synchronously, the caller waits until the model predictions are inserted
      +        into the Learning Orchestra storage mechanism.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +
      +        if pretty_response:
      +            print(
      +                "\n----------"
      +                + " CREATE MODEL WITH "
      +                + train_dataset_name
      +                + " AND "
      +                + test_dataset_name
      +                + " ----------"
      +            )
      +
      +        request_body_content = {
      +            self.TRAIN_NAME: train_dataset_name,
      +            self.TEST_NAME: test_dataset_name,
      +            self.CODE: modeling_code,
      +            self.CLASSIFIERS_LIST: model_classifiers,
      +        }
      +        response = requests.post(url=self.cluster_url,
      +                                 json=request_body_content)
      +
      +        observer = Observer(test_dataset_name, self.CLUSTER_IP)
      +
      +        for model in model_classifiers:
      +            observer.set_dataset_name(test_dataset_name + model)
      +            observer.observe_processing(pretty_response)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def run_builder_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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        asynchronously, the caller does not wait until the model predictions are
      +        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 model predictions are inserted.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +        if pretty_response:
      +            print(
      +                "\n----------"
      +                + " CREATE MODEL WITH "
      +                + train_dataset_name
      +                + " AND "
      +                + test_dataset_name
      +                + " ----------"
      +            )
      +
      +        request_body_content = {
      +            self.TRAIN_NAME: train_dataset_name,
      +            self.TEST_NAME: test_dataset_name,
      +            self.CODE: modeling_code,
      +            self.CLASSIFIERS_LIST: model_classifiers,
      +        }
      +        response = requests.post(url=self.cluster_url,
      +                                 json=request_body_content)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def search_all_model(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 return indented string, else return dict.
      +
      +        return: A list with all model predictions metadata stored in Learning
      +        Orchestra or an empty result.
      +        """
      +
      +        cluster_url_tsne = self.cluster_url
      +
      +        response = requests.get(cluster_url_tsne)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def search_model_prediction(self,
      +                                model_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 return indented string, else return dict.
      +        model_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 there
      +        is no such projection. The current page is also returned to be used in
      +        future content requests.
      +        """
      +
      +        cluster_url_dataset = self.cluster_url + "/" + model_name + \
      +                              "?query=" + str(query) + \
      +                              "&limit=" + str(limit) + \
      +                              "&skip=" + str(skip)
      +
      +        response = requests.get(cluster_url_dataset)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def search_model(self, model_name: str, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description:  This method is responsible for retrieving a specific
      +        model prediction metadata.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        model_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_model_prediction(model_name, limit=1,
      +                                                pretty_response=pretty_response)
      +
      +        return response
      +
      +    def delete_model(self, model_name: str, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for deleting a model prediction.
      +        The delete operation is always synchronous because it is very fast,
      +        since the deletion is performed in background.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        model_name: Represents the projection name.
      +
      +        return: JSON object with an error message, a warning message or a
      +        correct delete message
      +        """
      +
      +        cluster_url_dataset = self.cluster_url + "/" + model_name
      +
      +        response = requests.delete(cluster_url_dataset)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +

      Classes

      +
      +
      +class Builder +(ip_from_cluster: str) +
      +
      +
      +
      + +Expand source code + +
      class Builder:
      +    def __init__(self, ip_from_cluster: str):
      +        self.CLUSTER_IP = ip_from_cluster
      +        self.cluster_url = "http://" + ip_from_cluster + \
      +                           "/api/learningOrchestra/v1/builder"
      +        self.response_treat = ResponseTreat()
      +        self.TRAIN_NAME = "trainDatasetName"
      +        self.TEST_NAME = "testDatasetName"
      +        self.CODE = "modelingCode"
      +        self.CLASSIFIERS_LIST = "classifiersList"
      +        self.dataset = Dataset(ip_from_cluster)
      +        self.METADATA_INDEX = 0
      +
      +    def run_builder_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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        synchronously, the caller waits until the model predictions are inserted
      +        into the Learning Orchestra storage mechanism.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +
      +        if pretty_response:
      +            print(
      +                "\n----------"
      +                + " CREATE MODEL WITH "
      +                + train_dataset_name
      +                + " AND "
      +                + test_dataset_name
      +                + " ----------"
      +            )
      +
      +        request_body_content = {
      +            self.TRAIN_NAME: train_dataset_name,
      +            self.TEST_NAME: test_dataset_name,
      +            self.CODE: modeling_code,
      +            self.CLASSIFIERS_LIST: model_classifiers,
      +        }
      +        response = requests.post(url=self.cluster_url,
      +                                 json=request_body_content)
      +
      +        observer = Observer(test_dataset_name, self.CLUSTER_IP)
      +
      +        for model in model_classifiers:
      +            observer.set_dataset_name(test_dataset_name + model)
      +            observer.observe_processing(pretty_response)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def run_builder_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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        asynchronously, the caller does not wait until the model predictions are
      +        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 model predictions are inserted.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +        if pretty_response:
      +            print(
      +                "\n----------"
      +                + " CREATE MODEL WITH "
      +                + train_dataset_name
      +                + " AND "
      +                + test_dataset_name
      +                + " ----------"
      +            )
      +
      +        request_body_content = {
      +            self.TRAIN_NAME: train_dataset_name,
      +            self.TEST_NAME: test_dataset_name,
      +            self.CODE: modeling_code,
      +            self.CLASSIFIERS_LIST: model_classifiers,
      +        }
      +        response = requests.post(url=self.cluster_url,
      +                                 json=request_body_content)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def search_all_model(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 return indented string, else return dict.
      +
      +        return: A list with all model predictions metadata stored in Learning
      +        Orchestra or an empty result.
      +        """
      +
      +        cluster_url_tsne = self.cluster_url
      +
      +        response = requests.get(cluster_url_tsne)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def search_model_prediction(self,
      +                                model_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 return indented string, else return dict.
      +        model_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 there
      +        is no such projection. The current page is also returned to be used in
      +        future content requests.
      +        """
      +
      +        cluster_url_dataset = self.cluster_url + "/" + model_name + \
      +                              "?query=" + str(query) + \
      +                              "&limit=" + str(limit) + \
      +                              "&skip=" + str(skip)
      +
      +        response = requests.get(cluster_url_dataset)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def search_model(self, model_name: str, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description:  This method is responsible for retrieving a specific
      +        model prediction metadata.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        model_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_model_prediction(model_name, limit=1,
      +                                                pretty_response=pretty_response)
      +
      +        return response
      +
      +    def delete_model(self, model_name: str, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for deleting a model prediction.
      +        The delete operation is always synchronous because it is very fast,
      +        since the deletion is performed in background.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        model_name: Represents the projection name.
      +
      +        return: JSON object with an error message, a warning message or a
      +        correct delete message
      +        """
      +
      +        cluster_url_dataset = self.cluster_url + "/" + model_name
      +
      +        response = requests.delete(cluster_url_dataset)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +

      Methods

      +
      +
      +def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
      +
      +

      description: This method is responsible for deleting a model prediction. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

      +

      pretty_response: If true return indented string, else return dict. +model_name: Represents the projection name.

      +

      return: JSON object with an error message, a warning message or a +correct delete message

      +
      + +Expand source code + +
      def delete_model(self, model_name: str, pretty_response: bool = False) \
      +        -> Union[dict, str]:
      +    """
      +    description: This method is responsible for deleting a model prediction.
      +    The delete operation is always synchronous because it is very fast,
      +    since the deletion is performed in background.
      +
      +    pretty_response: If true return indented string, else return dict.
      +    model_name: Represents the projection name.
      +
      +    return: JSON object with an error message, a warning message or a
      +    correct delete message
      +    """
      +
      +    cluster_url_dataset = self.cluster_url + "/" + model_name
      +
      +    response = requests.delete(cluster_url_dataset)
      +
      +    return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +asynchronously, the caller does not wait until the model predictions are +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 model predictions are inserted.

      +

      train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

      +

      return: The resulted predictions URIs.

      +
      + +Expand source code + +
      def run_builder_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 resource join several steps of machine
      +    learning workflow (transform, tune, train and evaluate) coupling in
      +    a unique resource, builder creates several model predictions using
      +    your own modeling code using a defined set of classifiers. This is made
      +    asynchronously, the caller does not wait until the model predictions are
      +    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 model predictions are inserted.
      +
      +    train_dataset_name: Represent final train dataset.
      +    test_dataset_name: Represent final test dataset.
      +    modeling_code: Represent Python3 code for pyspark preprocessing model
      +    model_classifiers: list of initial classifiers to be used in model
      +    pretty_response: returns indented string for visualization if True
      +
      +    return: The resulted predictions URIs.
      +    """
      +    if pretty_response:
      +        print(
      +            "\n----------"
      +            + " CREATE MODEL WITH "
      +            + train_dataset_name
      +            + " AND "
      +            + test_dataset_name
      +            + " ----------"
      +        )
      +
      +    request_body_content = {
      +        self.TRAIN_NAME: train_dataset_name,
      +        self.TEST_NAME: test_dataset_name,
      +        self.CODE: modeling_code,
      +        self.CLASSIFIERS_LIST: model_classifiers,
      +    }
      +    response = requests.post(url=self.cluster_url,
      +                             json=request_body_content)
      +
      +    return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +synchronously, the caller waits until the model predictions are inserted +into the Learning Orchestra storage mechanism.

      +

      train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

      +

      return: The resulted predictions URIs.

      +
      + +Expand source code + +
      def run_builder_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 resource join several steps of machine
      +    learning workflow (transform, tune, train and evaluate) coupling in
      +    a unique resource, builder creates several model predictions using
      +    your own modeling code using a defined set of classifiers. This is made
      +    synchronously, the caller waits until the model predictions are inserted
      +    into the Learning Orchestra storage mechanism.
      +
      +    train_dataset_name: Represent final train dataset.
      +    test_dataset_name: Represent final test dataset.
      +    modeling_code: Represent Python3 code for pyspark preprocessing model
      +    model_classifiers: list of initial classifiers to be used in model
      +    pretty_response: returns indented string for visualization if True
      +
      +    return: The resulted predictions URIs.
      +    """
      +
      +    if pretty_response:
      +        print(
      +            "\n----------"
      +            + " CREATE MODEL WITH "
      +            + train_dataset_name
      +            + " AND "
      +            + test_dataset_name
      +            + " ----------"
      +        )
      +
      +    request_body_content = {
      +        self.TRAIN_NAME: train_dataset_name,
      +        self.TEST_NAME: test_dataset_name,
      +        self.CODE: modeling_code,
      +        self.CLASSIFIERS_LIST: model_classifiers,
      +    }
      +    response = requests.post(url=self.cluster_url,
      +                             json=request_body_content)
      +
      +    observer = Observer(test_dataset_name, self.CLUSTER_IP)
      +
      +    for model in model_classifiers:
      +        observer.set_dataset_name(test_dataset_name + model)
      +        observer.observe_processing(pretty_response)
      +
      +    return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +def search_all_model(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 return indented string, else return dict.

      +

      return: A list with all model predictions metadata stored in Learning +Orchestra or an empty result.

      +
      + +Expand source code + +
      def search_all_model(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 return indented string, else return dict.
      +
      +    return: A list with all model predictions metadata stored in Learning
      +    Orchestra or an empty result.
      +    """
      +
      +    cluster_url_tsne = self.cluster_url
      +
      +    response = requests.get(cluster_url_tsne)
      +
      +    return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
      +
      +

      description: +This method is responsible for retrieving a specific +model prediction metadata.

      +

      pretty_response: If true return indented string, else return dict. +model_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.

      +
      + +Expand source code + +
      def search_model(self, model_name: str, pretty_response: bool = False) \
      +        -> Union[dict, str]:
      +    """
      +    description:  This method is responsible for retrieving a specific
      +    model prediction metadata.
      +
      +    pretty_response: If true return indented string, else return dict.
      +    model_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_model_prediction(model_name, limit=1,
      +                                            pretty_response=pretty_response)
      +
      +    return response
      +
      +
      +
      +def search_model_prediction(self, model_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 return indented string, else return dict. +model_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 there +is no such projection. The current page is also returned to be used in +future content requests.

      +
      + +Expand source code + +
      def search_model_prediction(self,
      +                            model_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 return indented string, else return dict.
      +    model_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 there
      +    is no such projection. The current page is also returned to be used in
      +    future content requests.
      +    """
      +
      +    cluster_url_dataset = self.cluster_url + "/" + model_name + \
      +                          "?query=" + str(query) + \
      +                          "&limit=" + str(limit) + \
      +                          "&skip=" + str(skip)
      +
      +    response = requests.get(cluster_url_dataset)
      +
      +    return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +
      +
      +
      +
      + +
      + + + \ No newline at end of file diff --git a/docs/dataset.html b/docs/dataset.html new file mode 100644 index 0000000..d8435fc --- /dev/null +++ b/docs/dataset.html @@ -0,0 +1,678 @@ + + + + + + +learning_orchestra_client.dataset API documentation + + + + + + + + + + + +
      +
      +
      +

      Module learning_orchestra_client.dataset

      +
      +
      +
      + +Expand source code + +
      __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
      +__credits__ = "all free source developers"
      +__status__ = "Prototype"
      +
      +from .observer import Observer
      +from .response_treat import ResponseTreat
      +import requests
      +from typing import Union
      +
      +
      +class Dataset:
      +    def __init__(self, ip_from_cluster: str):
      +        self.cluster_url = "http://" + ip_from_cluster + \
      +                           "/api/learningOrchestra/v1/dataset"
      +        self.response_treat = ResponseTreat()
      +        self.OUTPUT_NAME = "datasetName"
      +        self.URL = "datasetURI"
      +        self.CLUSTER_IP = ip_from_cluster
      +
      +    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 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.
      +        """
      +        request_body = {self.OUTPUT_NAME: dataset_name,
      +                        self.URL: url}
      +        request_url = self.cluster_url
      +
      +        response = requests.post(url=request_url, json=request_body)
      +
      +        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      +
      +        if pretty_response:
      +            print("\n----------" + " CREATED FILE " + 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).
      +        """
      +        request_body = {self.OUTPUT_NAME: dataset_name,
      +                        self.URL: url}
      +        request_url = self.cluster_url
      +
      +        response = requests.post(url=request_url, json=request_body)
      +
      +        if pretty_response:
      +            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      +                                                                     "---")
      +        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 return indented string, else return dict.
      +
      +        return: All datasets metadata stored in Learning Orchestra or an empty
      +        result.
      +        """
      +        request_url = self.cluster_url
      +
      +        response = requests.get(request_url)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for retrieving a specific
      +        dataset
      +
      +        pretty_response: If true return indented string, else return dict.
      +        dataset_name: Is the name of the dataset file.
      +        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 dataset metadata stored in Learning Orchestra or an
      +        error if there is no such dataset.
      +        """
      +        response = self.search_dataset_content(dataset_name, limit=1,
      +                                               pretty_response=pretty_response)
      +
      +        return 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 return indented string, else return dict.
      +        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.
      +        """
      +
      +        request_url = self.cluster_url + "/" + dataset_name + \
      +                      "?query=" + str(query) + \
      +                      "&limit=" + str(limit) + \
      +                      "&skip=" + str(skip)
      +
      +        response = requests.get(request_url)
      +
      +        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. The
      +        delete operation is always synchronous because it is very fast, since
      +        the deletion is performed in background. If a dataset was used by
      +        another task (Ex. projection, histogram, pca, tuning and so forth), it
      +        cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        dataset_name: Represents the dataset name.
      +
      +        return: JSON object with an error message, a warning message or a
      +        correct delete message
      +        """
      +
      +        request_url = self.cluster_url + "/" + dataset_name
      +
      +        response = requests.delete(request_url)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +

      Classes

      +
      +
      +class Dataset +(ip_from_cluster: str) +
      +
      +
      +
      + +Expand source code + +
      class Dataset:
      +    def __init__(self, ip_from_cluster: str):
      +        self.cluster_url = "http://" + ip_from_cluster + \
      +                           "/api/learningOrchestra/v1/dataset"
      +        self.response_treat = ResponseTreat()
      +        self.OUTPUT_NAME = "datasetName"
      +        self.URL = "datasetURI"
      +        self.CLUSTER_IP = ip_from_cluster
      +
      +    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 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.
      +        """
      +        request_body = {self.OUTPUT_NAME: dataset_name,
      +                        self.URL: url}
      +        request_url = self.cluster_url
      +
      +        response = requests.post(url=request_url, json=request_body)
      +
      +        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      +
      +        if pretty_response:
      +            print("\n----------" + " CREATED FILE " + 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).
      +        """
      +        request_body = {self.OUTPUT_NAME: dataset_name,
      +                        self.URL: url}
      +        request_url = self.cluster_url
      +
      +        response = requests.post(url=request_url, json=request_body)
      +
      +        if pretty_response:
      +            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      +                                                                     "---")
      +        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 return indented string, else return dict.
      +
      +        return: All datasets metadata stored in Learning Orchestra or an empty
      +        result.
      +        """
      +        request_url = self.cluster_url
      +
      +        response = requests.get(request_url)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for retrieving a specific
      +        dataset
      +
      +        pretty_response: If true return indented string, else return dict.
      +        dataset_name: Is the name of the dataset file.
      +        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 dataset metadata stored in Learning Orchestra or an
      +        error if there is no such dataset.
      +        """
      +        response = self.search_dataset_content(dataset_name, limit=1,
      +                                               pretty_response=pretty_response)
      +
      +        return 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 return indented string, else return dict.
      +        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.
      +        """
      +
      +        request_url = self.cluster_url + "/" + dataset_name + \
      +                      "?query=" + str(query) + \
      +                      "&limit=" + str(limit) + \
      +                      "&skip=" + str(skip)
      +
      +        response = requests.get(request_url)
      +
      +        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. The
      +        delete operation is always synchronous because it is very fast, since
      +        the deletion is performed in background. If a dataset was used by
      +        another task (Ex. projection, histogram, pca, tuning and so forth), it
      +        cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        dataset_name: Represents the dataset name.
      +
      +        return: JSON object with an error message, a warning message or a
      +        correct delete message
      +        """
      +
      +        request_url = self.cluster_url + "/" + dataset_name
      +
      +        response = requests.delete(request_url)
      +
      +        return self.response_treat.treatment(response, pretty_response)
      +
      +

      Methods

      +
      +
      +def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] +
      +
      +

      description: This method is responsible for deleting the dataset. The +delete operation is always synchronous because it is very fast, since +the deletion is performed in background. If a dataset was used by +another task (Ex. projection, histogram, pca, tuning and so forth), it +cannot be deleted.

      +

      pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset name.

      +

      return: JSON object with an error message, a warning message or a +correct delete message

      +
      + +Expand source code + +
      def delete_dataset(self, dataset_name, pretty_response=False) \
      +        -> Union[dict, str]:
      +    """
      +    description: This method is responsible for deleting the dataset. The
      +    delete operation is always synchronous because it is very fast, since
      +    the deletion is performed in background. If a dataset was used by
      +    another task (Ex. projection, histogram, pca, tuning and so forth), it
      +    cannot be deleted.
      +
      +    pretty_response: If true return indented string, else return dict.
      +    dataset_name: Represents the dataset name.
      +
      +    return: JSON object with an error message, a warning message or a
      +    correct delete message
      +    """
      +
      +    request_url = self.cluster_url + "/" + dataset_name
      +
      +    response = requests.delete(request_url)
      +
      +    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).

      +
      + +Expand source code + +
      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).
      +    """
      +    request_body = {self.OUTPUT_NAME: dataset_name,
      +                    self.URL: url}
      +    request_url = self.cluster_url
      +
      +    response = requests.post(url=request_url, json=request_body)
      +
      +    if pretty_response:
      +        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      +                                                                 "---")
      +    return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +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 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.

      +
      + +Expand source code + +
      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 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.
      +    """
      +    request_body = {self.OUTPUT_NAME: dataset_name,
      +                    self.URL: url}
      +    request_url = self.cluster_url
      +
      +    response = requests.post(url=request_url, json=request_body)
      +
      +    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      +
      +    if pretty_response:
      +        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      +                                                                 "---")
      +    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 return indented string, else return dict.

      +

      return: All datasets metadata stored in Learning Orchestra or an empty +result.

      +
      + +Expand source code + +
      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 return indented string, else return dict.
      +
      +    return: All datasets metadata stored in Learning Orchestra or an empty
      +    result.
      +    """
      +    request_url = self.cluster_url
      +
      +    response = requests.get(request_url)
      +
      +    return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
      +
      +

      description: This method is responsible for retrieving a specific +dataset

      +

      pretty_response: If true return indented string, else return dict. +dataset_name: Is the name of the dataset file. +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 dataset metadata stored in Learning Orchestra or an +error if there is no such dataset.

      +
      + +Expand source code + +
      def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      +        -> Union[dict, str]:
      +    """
      +    description: This method is responsible for retrieving a specific
      +    dataset
      +
      +    pretty_response: If true return indented string, else return dict.
      +    dataset_name: Is the name of the dataset file.
      +    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 dataset metadata stored in Learning Orchestra or an
      +    error if there is no such dataset.
      +    """
      +    response = self.search_dataset_content(dataset_name, limit=1,
      +                                           pretty_response=pretty_response)
      +
      +    return 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 return indented string, else return dict. +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.

      +
      + +Expand source code + +
      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 return indented string, else return dict.
      +    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.
      +    """
      +
      +    request_url = self.cluster_url + "/" + dataset_name + \
      +                  "?query=" + str(query) + \
      +                  "&limit=" + str(limit) + \
      +                  "&skip=" + str(skip)
      +
      +    response = requests.get(request_url)
      +
      +    return self.response_treat.treatment(response, pretty_response)
      +
      +
      +
      +
      +
      +
      +
      + +
      + + + \ No newline at end of file From cfaabc1a63d8e8231b029cdef6f7c2c1671eee01 Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Mon, 21 Dec 2020 19:51:51 -0300 Subject: [PATCH 06/28] update docs --- docs/builder.html | 2 +- docs/dataset.html | 2 +- docs/explore/histogram.html | 2 +- docs/explore/pca.html | 2 +- docs/explore/tsne.html | 2 +- docs/index.html | 5 - docs/response_treat.html | 197 --------------------------------- docs/transform/data_type.html | 2 +- docs/transform/projection.html | 2 +- 9 files changed, 7 insertions(+), 209 deletions(-) delete mode 100644 docs/response_treat.html diff --git a/docs/builder.html b/docs/builder.html index 77f521b..77ce1c4 100644 --- a/docs/builder.html +++ b/docs/builder.html @@ -27,7 +27,7 @@

      Module learning_orchestra_client.builder

      Expand source code
      from .observer import Observer
      -from .response_treat import ResponseTreat
      +from ._response_treat import ResponseTreat
       from .dataset import Dataset
       import requests
       from typing import Union
      diff --git a/docs/dataset.html b/docs/dataset.html
      index d8435fc..b8b02a0 100644
      --- a/docs/dataset.html
      +++ b/docs/dataset.html
      @@ -31,7 +31,7 @@ 

      Module learning_orchestra_client.dataset

      __status__ = "Prototype" from .observer import Observer -from .response_treat import ResponseTreat +from ._response_treat import ResponseTreat import requests from typing import Union diff --git a/docs/explore/histogram.html b/docs/explore/histogram.html index a90cf94..d4a510e 100644 --- a/docs/explore/histogram.html +++ b/docs/explore/histogram.html @@ -27,7 +27,7 @@

      Module learning_orchestra_client.explore.histogramExpand source code
      from ..observer import Observer
      -from ..response_treat import ResponseTreat
      +from .._response_treat import ResponseTreat
       from ..dataset import Dataset
       import requests
       from typing import Union
      diff --git a/docs/explore/pca.html b/docs/explore/pca.html
      index 7dbc910..96011a2 100644
      --- a/docs/explore/pca.html
      +++ b/docs/explore/pca.html
      @@ -26,7 +26,7 @@ 

      Module learning_orchestra_client.explore.pca

      Expand source code -
      from ..response_treat import ResponseTreat
      +
      from .._response_treat import ResponseTreat
       from ..dataset import Dataset
       from PIL import Image
       import requests
      diff --git a/docs/explore/tsne.html b/docs/explore/tsne.html
      index 15569b0..e027e0a 100644
      --- a/docs/explore/tsne.html
      +++ b/docs/explore/tsne.html
      @@ -26,7 +26,7 @@ 

      Module learning_orchestra_client.explore.tsne

      Expand source code -
      from ..response_treat import ResponseTreat
      +
      from .._response_treat import ResponseTreat
       from ..dataset import Dataset
       from PIL import Image
       import requests
      diff --git a/docs/index.html b/docs/index.html
      index 9189de8..46c4a70 100644
      --- a/docs/index.html
      +++ b/docs/index.html
      @@ -42,10 +42,6 @@ 

      Sub-modules

      -
      learning_orchestra_client.response_treat
      -
      -
      -
      learning_orchestra_client.transform
      @@ -71,7 +67,6 @@

      Index

    • learning_orchestra_client.dataset
    • learning_orchestra_client.explore
    • learning_orchestra_client.observer
    • -
    • learning_orchestra_client.response_treat
    • learning_orchestra_client.transform
  • diff --git a/docs/response_treat.html b/docs/response_treat.html deleted file mode 100644 index 2c8bb2a..0000000 --- a/docs/response_treat.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - -learning_orchestra_client.response_treat API documentation - - - - - - - - - - - -
    -
    -
    -

    Module learning_orchestra_client.response_treat

    -
    -
    -
    - -Expand source code - -
    __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
    -__credits__ = "all free source developers"
    -__status__ = "Prototype"
    -
    -import json
    -
    -
    -class ResponseTreat:
    -    HTTP_CREATED = 201
    -    HTTP_SUCCESS = 200
    -    HTTP_ERROR = 500
    -
    -    def treatment(self, response, pretty_response: bool = True):
    -        """
    -        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:
    -            return response.text
    -        elif (
    -                response.status_code != self.HTTP_SUCCESS
    -                and response.status_code != self.HTTP_CREATED
    -        ):
    -            raise Exception(response.json()["result"])
    -        else:
    -            if pretty_response:
    -                return json.dumps(response.json(), indent=4, sort_keys=True)
    -            else:
    -                return response.json()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -

    Classes

    -
    -
    -class ResponseTreat -
    -
    -
    -
    - -Expand source code - -
    class ResponseTreat:
    -    HTTP_CREATED = 201
    -    HTTP_SUCCESS = 200
    -    HTTP_ERROR = 500
    -
    -    def treatment(self, response, pretty_response: bool = True):
    -        """
    -        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:
    -            return response.text
    -        elif (
    -                response.status_code != self.HTTP_SUCCESS
    -                and response.status_code != self.HTTP_CREATED
    -        ):
    -            raise Exception(response.json()["result"])
    -        else:
    -            if pretty_response:
    -                return json.dumps(response.json(), indent=4, sort_keys=True)
    -            else:
    -                return response.json()
    -
    -

    Class variables

    -
    -
    var HTTP_CREATED
    -
    -
    -
    -
    var HTTP_ERROR
    -
    -
    -
    -
    var HTTP_SUCCESS
    -
    -
    -
    -
    -

    Methods

    -
    -
    -def treatment(self, response, pretty_response: bool = True) -
    -
    -

    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.

    -
    - -Expand source code - -
    def treatment(self, response, pretty_response: bool = True):
    -    """
    -    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:
    -        return response.text
    -    elif (
    -            response.status_code != self.HTTP_SUCCESS
    -            and response.status_code != self.HTTP_CREATED
    -    ):
    -        raise Exception(response.json()["result"])
    -    else:
    -        if pretty_response:
    -            return json.dumps(response.json(), indent=4, sort_keys=True)
    -        else:
    -            return response.json()
    -
    -
    -
    -
    -
    -
    -
    - -
    - - - \ No newline at end of file diff --git a/docs/transform/data_type.html b/docs/transform/data_type.html index 444301d..ab70288 100644 --- a/docs/transform/data_type.html +++ b/docs/transform/data_type.html @@ -26,7 +26,7 @@

    Module learning_orchestra_client.transform.data_type Expand source code -
    from ..response_treat import ResponseTreat
    +
    from .._response_treat import ResponseTreat
     from ..dataset import Dataset
     import requests
     from typing import Union
    diff --git a/docs/transform/projection.html b/docs/transform/projection.html
    index 6158b25..0ee1113 100644
    --- a/docs/transform/projection.html
    +++ b/docs/transform/projection.html
    @@ -26,7 +26,7 @@ 

    Module learning_orchestra_client.transform.projection Expand source code -
    from ..response_treat import ResponseTreat
    +
    from .._response_treat import ResponseTreat
     from ..dataset import Dataset
     from ..observer import Observer
     import requests
    
    From e8f3d78548e234a5fab353b45d9ac361c909bdd2 Mon Sep 17 00:00:00 2001
    From: Gabriel Ribeiro 
    Date: Sun, 20 Dec 2020 13:00:36 -0300
    Subject: [PATCH 07/28] docs
    
    ---
     .../builder/builder.html                      |  790 +++++++++++++
     .../builder/index.html                        |   65 ++
     .../dataset/dataset.html                      |  678 +++++++++++
     .../dataset/index.html                        |   65 ++
     .../explore/histogram.html                    |  676 +++++++++++
     .../explore/index.html                        |   75 ++
     .../explore/pca.html                          |  742 ++++++++++++
     .../explore/tsne.html                         |  742 ++++++++++++
     html/learning_orchestra_client/index.html     |   85 ++
     html/learning_orchestra_client/observer.html  |  375 ++++++
     .../response_treat.html                       |  197 ++++
     .../transform/data_type.html                  |  199 ++++
     .../transform/index.html                      |   70 ++
     .../transform/projection.html                 | 1035 +++++++++++++++++
     14 files changed, 5794 insertions(+)
     create mode 100644 html/learning_orchestra_client/builder/builder.html
     create mode 100644 html/learning_orchestra_client/builder/index.html
     create mode 100644 html/learning_orchestra_client/dataset/dataset.html
     create mode 100644 html/learning_orchestra_client/dataset/index.html
     create mode 100644 html/learning_orchestra_client/explore/histogram.html
     create mode 100644 html/learning_orchestra_client/explore/index.html
     create mode 100644 html/learning_orchestra_client/explore/pca.html
     create mode 100644 html/learning_orchestra_client/explore/tsne.html
     create mode 100644 html/learning_orchestra_client/index.html
     create mode 100644 html/learning_orchestra_client/observer.html
     create mode 100644 html/learning_orchestra_client/response_treat.html
     create mode 100644 html/learning_orchestra_client/transform/data_type.html
     create mode 100644 html/learning_orchestra_client/transform/index.html
     create mode 100644 html/learning_orchestra_client/transform/projection.html
    
    diff --git a/html/learning_orchestra_client/builder/builder.html b/html/learning_orchestra_client/builder/builder.html
    new file mode 100644
    index 0000000..f450096
    --- /dev/null
    +++ b/html/learning_orchestra_client/builder/builder.html
    @@ -0,0 +1,790 @@
    +
    +
    +
    +
    +
    +
    +learning_orchestra_client.builder.builder API documentation
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Module learning_orchestra_client.builder.builder

    +
    +
    +
    + +Expand source code + +
    from ..observer import Observer
    +from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +import requests
    +from typing import Union
    +
    +
    +class Builder:
    +    def __init__(self, ip_from_cluster: str):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/builder"
    +        self.response_treat = ResponseTreat()
    +        self.TRAIN_NAME = "trainDatasetName"
    +        self.TEST_NAME = "testDatasetName"
    +        self.CODE = "modelingCode"
    +        self.CLASSIFIERS_LIST = "classifiersList"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.METADATA_INDEX = 0
    +
    +    def run_builder_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 resource join several steps of machine
    +        learning workflow (transform, tune, train and evaluate) coupling in
    +        a unique resource, builder creates several model predictions using
    +        your own modeling code using a defined set of classifiers. This is made
    +        synchronously, the caller waits until the model predictions are inserted
    +        into the Learning Orchestra storage mechanism.
    +
    +        train_dataset_name: Represent final train dataset.
    +        test_dataset_name: Represent final test dataset.
    +        modeling_code: Represent Python3 code for pyspark preprocessing model
    +        model_classifiers: list of initial classifiers to be used in model
    +        pretty_response: returns indented string for visualization if True
    +
    +        return: The resulted predictions URIs.
    +        """
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE MODEL WITH "
    +                + train_dataset_name
    +                + " AND "
    +                + test_dataset_name
    +                + " ----------"
    +            )
    +
    +        request_body_content = {
    +            self.TRAIN_NAME: train_dataset_name,
    +            self.TEST_NAME: test_dataset_name,
    +            self.CODE: modeling_code,
    +            self.CLASSIFIERS_LIST: model_classifiers,
    +        }
    +        response = requests.post(url=self.cluster_url,
    +                                 json=request_body_content)
    +
    +        observer = Observer(test_dataset_name, self.CLUSTER_IP)
    +
    +        for model in model_classifiers:
    +            observer.set_dataset_name(test_dataset_name + model)
    +            observer.observe_processing(pretty_response)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_builder_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 resource join several steps of machine
    +        learning workflow (transform, tune, train and evaluate) coupling in
    +        a unique resource, builder creates several model predictions using
    +        your own modeling code using a defined set of classifiers. This is made
    +        asynchronously, the caller does not wait until the model predictions are
    +        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 model predictions are inserted.
    +
    +        train_dataset_name: Represent final train dataset.
    +        test_dataset_name: Represent final test dataset.
    +        modeling_code: Represent Python3 code for pyspark preprocessing model
    +        model_classifiers: list of initial classifiers to be used in model
    +        pretty_response: returns indented string for visualization if True
    +
    +        return: The resulted predictions URIs.
    +        """
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE MODEL WITH "
    +                + train_dataset_name
    +                + " AND "
    +                + test_dataset_name
    +                + " ----------"
    +            )
    +
    +        request_body_content = {
    +            self.TRAIN_NAME: train_dataset_name,
    +            self.TEST_NAME: test_dataset_name,
    +            self.CODE: modeling_code,
    +            self.CLASSIFIERS_LIST: model_classifiers,
    +        }
    +        response = requests.post(url=self.cluster_url,
    +                                 json=request_body_content)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_model(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 return indented string, else return dict.
    +
    +        return: A list with all model predictions metadata stored in Learning
    +        Orchestra or an empty result.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url
    +
    +        response = requests.get(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_model_prediction(self,
    +                                model_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 return indented string, else return dict.
    +        model_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 there
    +        is no such projection. The current page is also returned to be used in
    +        future content requests.
    +        """
    +
    +        cluster_url_dataset = self.cluster_url + "/" + model_name + \
    +                              "?query=" + str(query) + \
    +                              "&limit=" + str(limit) + \
    +                              "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_dataset)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_model(self, model_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description:  This method is responsible for retrieving a specific
    +        model prediction metadata.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        model_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_model_prediction(model_name, limit=1,
    +                                                pretty_response=pretty_response)
    +
    +        return response
    +
    +    def delete_model(self, model_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting a model prediction.
    +        The delete operation is always synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        model_name: Represents the projection name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        cluster_url_dataset = self.cluster_url + "/" + model_name
    +
    +        response = requests.delete(cluster_url_dataset)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Builder +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Builder:
    +    def __init__(self, ip_from_cluster: str):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/builder"
    +        self.response_treat = ResponseTreat()
    +        self.TRAIN_NAME = "trainDatasetName"
    +        self.TEST_NAME = "testDatasetName"
    +        self.CODE = "modelingCode"
    +        self.CLASSIFIERS_LIST = "classifiersList"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.METADATA_INDEX = 0
    +
    +    def run_builder_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 resource join several steps of machine
    +        learning workflow (transform, tune, train and evaluate) coupling in
    +        a unique resource, builder creates several model predictions using
    +        your own modeling code using a defined set of classifiers. This is made
    +        synchronously, the caller waits until the model predictions are inserted
    +        into the Learning Orchestra storage mechanism.
    +
    +        train_dataset_name: Represent final train dataset.
    +        test_dataset_name: Represent final test dataset.
    +        modeling_code: Represent Python3 code for pyspark preprocessing model
    +        model_classifiers: list of initial classifiers to be used in model
    +        pretty_response: returns indented string for visualization if True
    +
    +        return: The resulted predictions URIs.
    +        """
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE MODEL WITH "
    +                + train_dataset_name
    +                + " AND "
    +                + test_dataset_name
    +                + " ----------"
    +            )
    +
    +        request_body_content = {
    +            self.TRAIN_NAME: train_dataset_name,
    +            self.TEST_NAME: test_dataset_name,
    +            self.CODE: modeling_code,
    +            self.CLASSIFIERS_LIST: model_classifiers,
    +        }
    +        response = requests.post(url=self.cluster_url,
    +                                 json=request_body_content)
    +
    +        observer = Observer(test_dataset_name, self.CLUSTER_IP)
    +
    +        for model in model_classifiers:
    +            observer.set_dataset_name(test_dataset_name + model)
    +            observer.observe_processing(pretty_response)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_builder_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 resource join several steps of machine
    +        learning workflow (transform, tune, train and evaluate) coupling in
    +        a unique resource, builder creates several model predictions using
    +        your own modeling code using a defined set of classifiers. This is made
    +        asynchronously, the caller does not wait until the model predictions are
    +        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 model predictions are inserted.
    +
    +        train_dataset_name: Represent final train dataset.
    +        test_dataset_name: Represent final test dataset.
    +        modeling_code: Represent Python3 code for pyspark preprocessing model
    +        model_classifiers: list of initial classifiers to be used in model
    +        pretty_response: returns indented string for visualization if True
    +
    +        return: The resulted predictions URIs.
    +        """
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE MODEL WITH "
    +                + train_dataset_name
    +                + " AND "
    +                + test_dataset_name
    +                + " ----------"
    +            )
    +
    +        request_body_content = {
    +            self.TRAIN_NAME: train_dataset_name,
    +            self.TEST_NAME: test_dataset_name,
    +            self.CODE: modeling_code,
    +            self.CLASSIFIERS_LIST: model_classifiers,
    +        }
    +        response = requests.post(url=self.cluster_url,
    +                                 json=request_body_content)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_model(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 return indented string, else return dict.
    +
    +        return: A list with all model predictions metadata stored in Learning
    +        Orchestra or an empty result.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url
    +
    +        response = requests.get(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_model_prediction(self,
    +                                model_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 return indented string, else return dict.
    +        model_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 there
    +        is no such projection. The current page is also returned to be used in
    +        future content requests.
    +        """
    +
    +        cluster_url_dataset = self.cluster_url + "/" + model_name + \
    +                              "?query=" + str(query) + \
    +                              "&limit=" + str(limit) + \
    +                              "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_dataset)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_model(self, model_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description:  This method is responsible for retrieving a specific
    +        model prediction metadata.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        model_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_model_prediction(model_name, limit=1,
    +                                                pretty_response=pretty_response)
    +
    +        return response
    +
    +    def delete_model(self, model_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting a model prediction.
    +        The delete operation is always synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        model_name: Represents the projection name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        cluster_url_dataset = self.cluster_url + "/" + model_name
    +
    +        response = requests.delete(cluster_url_dataset)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for deleting a model prediction. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

    +

    pretty_response: If true return indented string, else return dict. +model_name: Represents the projection name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message

    +
    + +Expand source code + +
    def delete_model(self, model_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for deleting a model prediction.
    +    The delete operation is always synchronous because it is very fast,
    +    since the deletion is performed in background.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    model_name: Represents the projection name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message
    +    """
    +
    +    cluster_url_dataset = self.cluster_url + "/" + model_name
    +
    +    response = requests.delete(cluster_url_dataset)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +asynchronously, the caller does not wait until the model predictions are +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 model predictions are inserted.

    +

    train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

    +

    return: The resulted predictions URIs.

    +
    + +Expand source code + +
    def run_builder_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 resource join several steps of machine
    +    learning workflow (transform, tune, train and evaluate) coupling in
    +    a unique resource, builder creates several model predictions using
    +    your own modeling code using a defined set of classifiers. This is made
    +    asynchronously, the caller does not wait until the model predictions are
    +    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 model predictions are inserted.
    +
    +    train_dataset_name: Represent final train dataset.
    +    test_dataset_name: Represent final test dataset.
    +    modeling_code: Represent Python3 code for pyspark preprocessing model
    +    model_classifiers: list of initial classifiers to be used in model
    +    pretty_response: returns indented string for visualization if True
    +
    +    return: The resulted predictions URIs.
    +    """
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE MODEL WITH "
    +            + train_dataset_name
    +            + " AND "
    +            + test_dataset_name
    +            + " ----------"
    +        )
    +
    +    request_body_content = {
    +        self.TRAIN_NAME: train_dataset_name,
    +        self.TEST_NAME: test_dataset_name,
    +        self.CODE: modeling_code,
    +        self.CLASSIFIERS_LIST: model_classifiers,
    +    }
    +    response = requests.post(url=self.cluster_url,
    +                             json=request_body_content)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +synchronously, the caller waits until the model predictions are inserted +into the Learning Orchestra storage mechanism.

    +

    train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

    +

    return: The resulted predictions URIs.

    +
    + +Expand source code + +
    def run_builder_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 resource join several steps of machine
    +    learning workflow (transform, tune, train and evaluate) coupling in
    +    a unique resource, builder creates several model predictions using
    +    your own modeling code using a defined set of classifiers. This is made
    +    synchronously, the caller waits until the model predictions are inserted
    +    into the Learning Orchestra storage mechanism.
    +
    +    train_dataset_name: Represent final train dataset.
    +    test_dataset_name: Represent final test dataset.
    +    modeling_code: Represent Python3 code for pyspark preprocessing model
    +    model_classifiers: list of initial classifiers to be used in model
    +    pretty_response: returns indented string for visualization if True
    +
    +    return: The resulted predictions URIs.
    +    """
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE MODEL WITH "
    +            + train_dataset_name
    +            + " AND "
    +            + test_dataset_name
    +            + " ----------"
    +        )
    +
    +    request_body_content = {
    +        self.TRAIN_NAME: train_dataset_name,
    +        self.TEST_NAME: test_dataset_name,
    +        self.CODE: modeling_code,
    +        self.CLASSIFIERS_LIST: model_classifiers,
    +    }
    +    response = requests.post(url=self.cluster_url,
    +                             json=request_body_content)
    +
    +    observer = Observer(test_dataset_name, self.CLUSTER_IP)
    +
    +    for model in model_classifiers:
    +        observer.set_dataset_name(test_dataset_name + model)
    +        observer.observe_processing(pretty_response)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_all_model(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 return indented string, else return dict.

    +

    return: A list with all model predictions metadata stored in Learning +Orchestra or an empty result.

    +
    + +Expand source code + +
    def search_all_model(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 return indented string, else return dict.
    +
    +    return: A list with all model predictions metadata stored in Learning
    +    Orchestra or an empty result.
    +    """
    +
    +    cluster_url_tsne = self.cluster_url
    +
    +    response = requests.get(cluster_url_tsne)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: +This method is responsible for retrieving a specific +model prediction metadata.

    +

    pretty_response: If true return indented string, else return dict. +model_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.

    +
    + +Expand source code + +
    def search_model(self, model_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description:  This method is responsible for retrieving a specific
    +    model prediction metadata.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    model_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_model_prediction(model_name, limit=1,
    +                                            pretty_response=pretty_response)
    +
    +    return response
    +
    +
    +
    +def search_model_prediction(self, model_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 return indented string, else return dict. +model_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 there +is no such projection. The current page is also returned to be used in +future content requests.

    +
    + +Expand source code + +
    def search_model_prediction(self,
    +                            model_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 return indented string, else return dict.
    +    model_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 there
    +    is no such projection. The current page is also returned to be used in
    +    future content requests.
    +    """
    +
    +    cluster_url_dataset = self.cluster_url + "/" + model_name + \
    +                          "?query=" + str(query) + \
    +                          "&limit=" + str(limit) + \
    +                          "&skip=" + str(skip)
    +
    +    response = requests.get(cluster_url_dataset)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/builder/index.html b/html/learning_orchestra_client/builder/index.html new file mode 100644 index 0000000..f6061e5 --- /dev/null +++ b/html/learning_orchestra_client/builder/index.html @@ -0,0 +1,65 @@ + + + + + + +learning_orchestra_client.builder API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/dataset/dataset.html b/html/learning_orchestra_client/dataset/dataset.html new file mode 100644 index 0000000..64e61be --- /dev/null +++ b/html/learning_orchestra_client/dataset/dataset.html @@ -0,0 +1,678 @@ + + + + + + +learning_orchestra_client.dataset.dataset API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.dataset.dataset

    +
    +
    +
    + +Expand source code + +
    __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
    +__credits__ = "all free source developers"
    +__status__ = "Prototype"
    +
    +from ..observer import Observer
    +from ..response_treat import ResponseTreat
    +import requests
    +from typing import Union
    +
    +
    +class Dataset:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/dataset"
    +        self.response_treat = ResponseTreat()
    +        self.OUTPUT_NAME = "datasetName"
    +        self.URL = "datasetURI"
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    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 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.
    +        """
    +        request_body = {self.OUTPUT_NAME: dataset_name,
    +                        self.URL: url}
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
    +
    +        if pretty_response:
    +            print("\n----------" + " CREATED FILE " + 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).
    +        """
    +        request_body = {self.OUTPUT_NAME: dataset_name,
    +                        self.URL: url}
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    +                                                                     "---")
    +        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 return indented string, else return dict.
    +
    +        return: All datasets metadata stored in Learning Orchestra or an empty
    +        result.
    +        """
    +        request_url = self.cluster_url
    +
    +        response = requests.get(request_url)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for retrieving a specific
    +        dataset
    +
    +        pretty_response: If true return indented string, else return dict.
    +        dataset_name: Is the name of the dataset file.
    +        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 dataset metadata stored in Learning Orchestra or an
    +        error if there is no such dataset.
    +        """
    +        response = self.search_dataset_content(dataset_name, limit=1,
    +                                               pretty_response=pretty_response)
    +
    +        return 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 return indented string, else return dict.
    +        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.
    +        """
    +
    +        request_url = self.cluster_url + "/" + dataset_name + \
    +                      "?query=" + str(query) + \
    +                      "&limit=" + str(limit) + \
    +                      "&skip=" + str(skip)
    +
    +        response = requests.get(request_url)
    +
    +        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. The
    +        delete operation is always synchronous because it is very fast, since
    +        the deletion is performed in background. If a dataset was used by
    +        another task (Ex. projection, histogram, pca, tuning and so forth), it
    +        cannot be deleted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        dataset_name: Represents the dataset name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        request_url = self.cluster_url + "/" + dataset_name
    +
    +        response = requests.delete(request_url)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Dataset +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Dataset:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/dataset"
    +        self.response_treat = ResponseTreat()
    +        self.OUTPUT_NAME = "datasetName"
    +        self.URL = "datasetURI"
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    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 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.
    +        """
    +        request_body = {self.OUTPUT_NAME: dataset_name,
    +                        self.URL: url}
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
    +
    +        if pretty_response:
    +            print("\n----------" + " CREATED FILE " + 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).
    +        """
    +        request_body = {self.OUTPUT_NAME: dataset_name,
    +                        self.URL: url}
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    +                                                                     "---")
    +        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 return indented string, else return dict.
    +
    +        return: All datasets metadata stored in Learning Orchestra or an empty
    +        result.
    +        """
    +        request_url = self.cluster_url
    +
    +        response = requests.get(request_url)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for retrieving a specific
    +        dataset
    +
    +        pretty_response: If true return indented string, else return dict.
    +        dataset_name: Is the name of the dataset file.
    +        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 dataset metadata stored in Learning Orchestra or an
    +        error if there is no such dataset.
    +        """
    +        response = self.search_dataset_content(dataset_name, limit=1,
    +                                               pretty_response=pretty_response)
    +
    +        return 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 return indented string, else return dict.
    +        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.
    +        """
    +
    +        request_url = self.cluster_url + "/" + dataset_name + \
    +                      "?query=" + str(query) + \
    +                      "&limit=" + str(limit) + \
    +                      "&skip=" + str(skip)
    +
    +        response = requests.get(request_url)
    +
    +        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. The
    +        delete operation is always synchronous because it is very fast, since
    +        the deletion is performed in background. If a dataset was used by
    +        another task (Ex. projection, histogram, pca, tuning and so forth), it
    +        cannot be deleted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        dataset_name: Represents the dataset name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        request_url = self.cluster_url + "/" + dataset_name
    +
    +        response = requests.delete(request_url)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for deleting the dataset. The +delete operation is always synchronous because it is very fast, since +the deletion is performed in background. If a dataset was used by +another task (Ex. projection, histogram, pca, tuning and so forth), it +cannot be deleted.

    +

    pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message

    +
    + +Expand source code + +
    def delete_dataset(self, dataset_name, pretty_response=False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for deleting the dataset. The
    +    delete operation is always synchronous because it is very fast, since
    +    the deletion is performed in background. If a dataset was used by
    +    another task (Ex. projection, histogram, pca, tuning and so forth), it
    +    cannot be deleted.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    dataset_name: Represents the dataset name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message
    +    """
    +
    +    request_url = self.cluster_url + "/" + dataset_name
    +
    +    response = requests.delete(request_url)
    +
    +    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).

    +
    + +Expand source code + +
    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).
    +    """
    +    request_body = {self.OUTPUT_NAME: dataset_name,
    +                    self.URL: url}
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    +                                                                 "---")
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +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 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.

    +
    + +Expand source code + +
    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 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.
    +    """
    +    request_body = {self.OUTPUT_NAME: dataset_name,
    +                    self.URL: url}
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
    +
    +    if pretty_response:
    +        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    +                                                                 "---")
    +    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 return indented string, else return dict.

    +

    return: All datasets metadata stored in Learning Orchestra or an empty +result.

    +
    + +Expand source code + +
    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 return indented string, else return dict.
    +
    +    return: All datasets metadata stored in Learning Orchestra or an empty
    +    result.
    +    """
    +    request_url = self.cluster_url
    +
    +    response = requests.get(request_url)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for retrieving a specific +dataset

    +

    pretty_response: If true return indented string, else return dict. +dataset_name: Is the name of the dataset file. +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 dataset metadata stored in Learning Orchestra or an +error if there is no such dataset.

    +
    + +Expand source code + +
    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for retrieving a specific
    +    dataset
    +
    +    pretty_response: If true return indented string, else return dict.
    +    dataset_name: Is the name of the dataset file.
    +    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 dataset metadata stored in Learning Orchestra or an
    +    error if there is no such dataset.
    +    """
    +    response = self.search_dataset_content(dataset_name, limit=1,
    +                                           pretty_response=pretty_response)
    +
    +    return 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 return indented string, else return dict. +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.

    +
    + +Expand source code + +
    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 return indented string, else return dict.
    +    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.
    +    """
    +
    +    request_url = self.cluster_url + "/" + dataset_name + \
    +                  "?query=" + str(query) + \
    +                  "&limit=" + str(limit) + \
    +                  "&skip=" + str(skip)
    +
    +    response = requests.get(request_url)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/dataset/index.html b/html/learning_orchestra_client/dataset/index.html new file mode 100644 index 0000000..b4c42b2 --- /dev/null +++ b/html/learning_orchestra_client/dataset/index.html @@ -0,0 +1,65 @@ + + + + + + +learning_orchestra_client.dataset API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/histogram.html b/html/learning_orchestra_client/explore/histogram.html new file mode 100644 index 0000000..e1abdfc --- /dev/null +++ b/html/learning_orchestra_client/explore/histogram.html @@ -0,0 +1,676 @@ + + + + + + +learning_orchestra_client.explore.histogram API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.explore.histogram

    +
    +
    +
    + +Expand source code + +
    from ..observer import Observer
    +from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +import requests
    +from typing import Union
    +
    +
    +class Histogram:
    +    def __init__(self, ip_from_cluster: str):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/histogram"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputDatasetName"
    +        self.FIELDS = "names"
    +        self.dataset = Dataset(ip_from_cluster)
    +
    +    def run_histogram_sync(self,
    +                           dataset_name: str,
    +                           histogram_name: str,
    +                           fields: list,
    +                           pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method run histogram algorithm to create a histogram
    +        synchronously, 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 return indented string, else return dict.
    +
    +        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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
    +            pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE HISTOGRAM FROM "
    +                + dataset_name
    +                + " TO "
    +                + histogram_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 run histogram algorithm to create a histogram
    +        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
    +
    +        dataset_name: Represents the name of dataset.
    +        histogram_name: Represents the name of histogram.
    +        fields: Represents a list of attributes.
    +        pretty_response: If true return indented string, else return dict.
    +
    +        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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE HISTOGRAM FROM "
    +                + dataset_name
    +                + " TO "
    +                + histogram_name
    +                + " ----------"
    +            )
    +
    +        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 names, it does not
    +        retrieve the histogram content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all histogram names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_histogram = self.cluster_url
    +
    +        response = requests.get(cluster_url_histogram)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_histogram_data(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 return indented string, else return dict.
    +        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.
    +        """
    +
    +        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
    +                                "?query=" + str(query) + \
    +                                "&limit=" + str(limit) + \
    +                                "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_histogram)
    +
    +        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 synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        histogram_name: Represents the histogram name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        cluster_url_histogram = self.cluster_url + "/" + histogram_name
    +
    +        response = requests.delete(cluster_url_histogram)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Histogram +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Histogram:
    +    def __init__(self, ip_from_cluster: str):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/histogram"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputDatasetName"
    +        self.FIELDS = "names"
    +        self.dataset = Dataset(ip_from_cluster)
    +
    +    def run_histogram_sync(self,
    +                           dataset_name: str,
    +                           histogram_name: str,
    +                           fields: list,
    +                           pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method run histogram algorithm to create a histogram
    +        synchronously, 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 return indented string, else return dict.
    +
    +        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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
    +            pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE HISTOGRAM FROM "
    +                + dataset_name
    +                + " TO "
    +                + histogram_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 run histogram algorithm to create a histogram
    +        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
    +
    +        dataset_name: Represents the name of dataset.
    +        histogram_name: Represents the name of histogram.
    +        fields: Represents a list of attributes.
    +        pretty_response: If true return indented string, else return dict.
    +
    +        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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE HISTOGRAM FROM "
    +                + dataset_name
    +                + " TO "
    +                + histogram_name
    +                + " ----------"
    +            )
    +
    +        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 names, it does not
    +        retrieve the histogram content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all histogram names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_histogram = self.cluster_url
    +
    +        response = requests.get(cluster_url_histogram)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_histogram_data(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 return indented string, else return dict.
    +        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.
    +        """
    +
    +        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
    +                                "?query=" + str(query) + \
    +                                "&limit=" + str(limit) + \
    +                                "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_histogram)
    +
    +        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 synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        histogram_name: Represents the histogram name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        cluster_url_histogram = self.cluster_url + "/" + histogram_name
    +
    +        response = requests.delete(cluster_url_histogram)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +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 synchronous because it is very fast, +since the deletion is performed in background.

    +

    pretty_response: If true return indented string, else return dict. +histogram_name: Represents the histogram name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message

    +
    + +Expand source code + +
    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 synchronous because it is very fast,
    +    since the deletion is performed in background.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    histogram_name: Represents the histogram name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message
    +    """
    +
    +    cluster_url_histogram = self.cluster_url + "/" + histogram_name
    +
    +    response = requests.delete(cluster_url_histogram)
    +
    +    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 run histogram algorithm to create a histogram +asynchronously, the caller does not wait until the histogram 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 histogram was inserted.

    +

    dataset_name: Represents the name of dataset. +histogram_name: Represents the name of histogram. +fields: Represents a list of attributes. +pretty_response: If true return indented string, else return dict.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a histogram.

    +
    + +Expand source code + +
    def run_histogram_async(self,
    +                        dataset_name: str,
    +                        histogram_name: str,
    +                        fields: list,
    +                        pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method run histogram algorithm to create a histogram
    +    asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
    +
    +    dataset_name: Represents the name of dataset.
    +    histogram_name: Represents the name of histogram.
    +    fields: Represents a list of attributes.
    +    pretty_response: If true return indented string, else return dict.
    +
    +    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.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE HISTOGRAM FROM "
    +            + dataset_name
    +            + " TO "
    +            + histogram_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_histogram_sync(self, dataset_name: str, histogram_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run histogram algorithm to create a histogram +synchronously, 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 return indented string, else return dict.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a histogram.

    +
    + +Expand source code + +
    def run_histogram_sync(self,
    +                       dataset_name: str,
    +                       histogram_name: str,
    +                       fields: list,
    +                       pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method run histogram algorithm to create a histogram
    +    synchronously, 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 return indented string, else return dict.
    +
    +    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.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    Observer(histogram_name, self.CLUSTER_IP).observe_processing(
    +        pretty_response)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE HISTOGRAM FROM "
    +            + dataset_name
    +            + " TO "
    +            + histogram_name
    +            + " ----------"
    +        )
    +
    +    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 names, it does not +retrieve the histogram content.

    +

    pretty_response: If true return indented string, else return dict.

    +

    return: A list with all histogram names stored in Learning Orchestra +or an empty result.

    +
    + +Expand source code + +
    def search_all_histograms(self, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves all histogram names, it does not
    +    retrieve the histogram content.
    +
    +    pretty_response: If true return indented string, else return dict.
    +
    +    return: A list with all histogram names stored in Learning Orchestra
    +    or an empty result.
    +    """
    +
    +    cluster_url_histogram = self.cluster_url
    +
    +    response = requests.get(cluster_url_histogram)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_histogram_data(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 return indented string, else return dict. +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.

    +
    + +Expand source code + +
    def search_histogram_data(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 return indented string, else return dict.
    +    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.
    +    """
    +
    +    cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
    +                            "?query=" + str(query) + \
    +                            "&limit=" + str(limit) + \
    +                            "&skip=" + str(skip)
    +
    +    response = requests.get(cluster_url_histogram)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/index.html b/html/learning_orchestra_client/explore/index.html new file mode 100644 index 0000000..d4f7495 --- /dev/null +++ b/html/learning_orchestra_client/explore/index.html @@ -0,0 +1,75 @@ + + + + + + +learning_orchestra_client.explore API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/pca.html b/html/learning_orchestra_client/explore/pca.html new file mode 100644 index 0000000..877a51d --- /dev/null +++ b/html/learning_orchestra_client/explore/pca.html @@ -0,0 +1,742 @@ + + + + + + +learning_orchestra_client.explore.pca API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.explore.pca

    +
    +
    +
    + +Expand source code + +
    from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +from PIL import Image
    +import requests
    +import time
    +from typing import Union
    +
    +
    +class Pca:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/pca"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputPlotName"
    +        self.LABEL = "label"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.WAIT_TIME = 5
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def run_pca_sync(self,
    +                     dataset_name: str,
    +                     pca_name: str,
    +                     label: str,
    +                     pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run PCA algorithm to create an image plot
    +        synchronously, the caller waits until the PCA image is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        dataset_name: Name of dataset.
    +        pca_name: Name of PCA image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a PCA image plot.
    +        """
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: pca_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        self.verify_pca_exist(pca_name, pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PCA IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + pca_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_pca_async(self,
    +                      dataset_name: str,
    +                      pca_name: str,
    +                      label: str,
    +                      pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run PCA algorithm to create an image plot
    +        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
    +
    +        dataset_name: Name of dataset.
    +        pca_name: Name of PCA image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a PCA image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: pca_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PCA IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + pca_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method retrieves all PCAs plot names, it does not
    +        retrieve the image plot.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all PCAs plot names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_pca = self.cluster_url
    +
    +        response = requests.get(cluster_url_pca)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves a PCA image plot.
    +
    +        pca_name: Name of PCA image plot.
    +        pretty_response: If true open an image plot, else return link to
    +        open image plot.
    +
    +        return: A link to an image plot or open an image plot.
    +        """
    +
    +        cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " READ "
    +                + pca_name
    +                + " PCA IMAGE PLOT "
    +                + " ----------"
    +            )
    +            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
    +            img.show()
    +        else:
    +            return cluster_url_pca
    +
    +    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting the PCA image plot.
    +        The delete operation is always synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        pca_name: Represents the PCA name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message.
    +        """
    +
    +        cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +        response = requests.delete(cluster_url_pca)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible to verify if a PCA image
    +        exist into the Learning Orchestra storage mechanism.
    +
    +        pca_name: Name of PCA image plot.
    +
    +        return: True if the PCA requested exist, false if does not.
    +        """
    +
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
    +                                                           "----------")
    +
    +        exist = False
    +        pca_name += ".png"
    +
    +        while not exist:
    +            time.sleep(self.WAIT_TIME)
    +            all_pca = self.search_all_pca()
    +            exist = pca_name in all_pca.get('result')
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Pca +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Pca:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/pca"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputPlotName"
    +        self.LABEL = "label"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.WAIT_TIME = 5
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def run_pca_sync(self,
    +                     dataset_name: str,
    +                     pca_name: str,
    +                     label: str,
    +                     pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run PCA algorithm to create an image plot
    +        synchronously, the caller waits until the PCA image is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        dataset_name: Name of dataset.
    +        pca_name: Name of PCA image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a PCA image plot.
    +        """
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: pca_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        self.verify_pca_exist(pca_name, pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PCA IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + pca_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_pca_async(self,
    +                      dataset_name: str,
    +                      pca_name: str,
    +                      label: str,
    +                      pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run PCA algorithm to create an image plot
    +        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
    +
    +        dataset_name: Name of dataset.
    +        pca_name: Name of PCA image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a PCA image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: pca_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PCA IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + pca_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method retrieves all PCAs plot names, it does not
    +        retrieve the image plot.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all PCAs plot names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_pca = self.cluster_url
    +
    +        response = requests.get(cluster_url_pca)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves a PCA image plot.
    +
    +        pca_name: Name of PCA image plot.
    +        pretty_response: If true open an image plot, else return link to
    +        open image plot.
    +
    +        return: A link to an image plot or open an image plot.
    +        """
    +
    +        cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " READ "
    +                + pca_name
    +                + " PCA IMAGE PLOT "
    +                + " ----------"
    +            )
    +            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
    +            img.show()
    +        else:
    +            return cluster_url_pca
    +
    +    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting the PCA image plot.
    +        The delete operation is always synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        pca_name: Represents the PCA name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message.
    +        """
    +
    +        cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +        response = requests.delete(cluster_url_pca)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible to verify if a PCA image
    +        exist into the Learning Orchestra storage mechanism.
    +
    +        pca_name: Name of PCA image plot.
    +
    +        return: True if the PCA requested exist, false if does not.
    +        """
    +
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
    +                                                           "----------")
    +
    +        exist = False
    +        pca_name += ".png"
    +
    +        while not exist:
    +            time.sleep(self.WAIT_TIME)
    +            all_pca = self.search_all_pca()
    +            exist = pca_name in all_pca.get('result')
    +
    +

    Methods

    +
    +
    +def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for deleting the PCA image plot. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

    +

    pretty_response: If true return indented string, else return dict. +pca_name: Represents the PCA name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message.

    +
    + +Expand source code + +
    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for deleting the PCA image plot.
    +    The delete operation is always synchronous because it is very fast,
    +    since the deletion is performed in background.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    pca_name: Represents the PCA name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message.
    +    """
    +
    +    cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +    response = requests.delete(cluster_url_pca)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_pca_async(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run PCA algorithm to create an image plot +asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.

    +

    dataset_name: Name of dataset. +pca_name: Name of PCA image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a PCA image plot.

    +
    + +Expand source code + +
    def run_pca_async(self,
    +                  dataset_name: str,
    +                  pca_name: str,
    +                  label: str,
    +                  pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method run PCA algorithm to create an image plot
    +    asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
    +
    +    dataset_name: Name of dataset.
    +    pca_name: Name of PCA image plot.
    +    label: The label is the label name of the column for machine learning
    +    datasets which has labeled tuples.
    +    pretty_response: If true open an image plot, else return link to open
    +    image plot.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns a PCA image plot.
    +    """
    +
    +    request_body = {
    +        self.INPUT_NAME: dataset_name,
    +        self.OUTPUT_NAME: pca_name,
    +        self.LABEL: label,
    +    }
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE PCA IMAGE PLOT FROM "
    +            + dataset_name
    +            + " TO "
    +            + pca_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_pca_sync(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run PCA algorithm to create an image plot +synchronously, the caller waits until the PCA image is inserted into +the Learning Orchestra storage mechanism.

    +

    dataset_name: Name of dataset. +pca_name: Name of PCA image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a PCA image plot.

    +
    + +Expand source code + +
    def run_pca_sync(self,
    +                 dataset_name: str,
    +                 pca_name: str,
    +                 label: str,
    +                 pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method run PCA algorithm to create an image plot
    +    synchronously, the caller waits until the PCA image is inserted into
    +    the Learning Orchestra storage mechanism.
    +
    +    dataset_name: Name of dataset.
    +    pca_name: Name of PCA image plot.
    +    label: The label is the label name of the column for machine learning
    +    datasets which has labeled tuples.
    +    pretty_response: If true open an image plot, else return link to open
    +    image plot.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns a PCA image plot.
    +    """
    +    request_body = {
    +        self.INPUT_NAME: dataset_name,
    +        self.OUTPUT_NAME: pca_name,
    +        self.LABEL: label,
    +    }
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    self.verify_pca_exist(pca_name, pretty_response)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE PCA IMAGE PLOT FROM "
    +            + dataset_name
    +            + " TO "
    +            + pca_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_all_pca(self, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method retrieves all PCAs plot names, it does not +retrieve the image plot.

    +

    pretty_response: If true return indented string, else return dict.

    +

    return: A list with all PCAs plot names stored in Learning Orchestra +or an empty result.

    +
    + +Expand source code + +
    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method retrieves all PCAs plot names, it does not
    +    retrieve the image plot.
    +
    +    pretty_response: If true return indented string, else return dict.
    +
    +    return: A list with all PCAs plot names stored in Learning Orchestra
    +    or an empty result.
    +    """
    +
    +    cluster_url_pca = self.cluster_url
    +
    +    response = requests.get(cluster_url_pca)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method retrieves a PCA image plot.

    +

    pca_name: Name of PCA image plot. +pretty_response: If true open an image plot, else return link to +open image plot.

    +

    return: A link to an image plot or open an image plot.

    +
    + +Expand source code + +
    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves a PCA image plot.
    +
    +    pca_name: Name of PCA image plot.
    +    pretty_response: If true open an image plot, else return link to
    +    open image plot.
    +
    +    return: A link to an image plot or open an image plot.
    +    """
    +
    +    cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " READ "
    +            + pca_name
    +            + " PCA IMAGE PLOT "
    +            + " ----------"
    +        )
    +        img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
    +        img.show()
    +    else:
    +        return cluster_url_pca
    +
    +
    +
    +def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible to verify if a PCA image +exist into the Learning Orchestra storage mechanism.

    +

    pca_name: Name of PCA image plot.

    +

    return: True if the PCA requested exist, false if does not.

    +
    + +Expand source code + +
    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible to verify if a PCA image
    +    exist into the Learning Orchestra storage mechanism.
    +
    +    pca_name: Name of PCA image plot.
    +
    +    return: True if the PCA requested exist, false if does not.
    +    """
    +
    +    if pretty_response:
    +        print("\n---------- CHECKING IF " + pca_name + " FINISHED "
    +                                                       "----------")
    +
    +    exist = False
    +    pca_name += ".png"
    +
    +    while not exist:
    +        time.sleep(self.WAIT_TIME)
    +        all_pca = self.search_all_pca()
    +        exist = pca_name in all_pca.get('result')
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/tsne.html b/html/learning_orchestra_client/explore/tsne.html new file mode 100644 index 0000000..b4e1b63 --- /dev/null +++ b/html/learning_orchestra_client/explore/tsne.html @@ -0,0 +1,742 @@ + + + + + + +learning_orchestra_client.explore.tsne API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.explore.tsne

    +
    +
    +
    + +Expand source code + +
    from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +from PIL import Image
    +import requests
    +import time
    +from typing import Union
    +
    +
    +class Tsne:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/tsne"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputPlotName"
    +        self.LABEL = "label"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.WAIT_TIME = 5
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def run_tsne_sync(self,
    +                      dataset_name: str,
    +                      tsne_name: str,
    +                      label: str,
    +                      pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run t_SNE algorithm to create an image plot
    +        synchronously, the caller waits until the t_SNE image is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        dataset_name: Name of dataset.
    +        tsne_name: Name of t_SNE image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a t_SNE image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: tsne_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        self.verify_tsne_exist(tsne_name, pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE TSNE IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + tsne_name
    +                + " ----------"
    +            )
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_tsne_async(self,
    +                       dataset_name: str,
    +                       tsne_name: str,
    +                       label: str,
    +                       pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run t_SNE algorithm to create an image plot
    +        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
    +
    +        dataset_name: Name of dataset.
    +        tsne_name: Name of t_SNE image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a t_SNE image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: tsne_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE TSNE IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + tsne_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_tsne(self, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves all t_SNE plot names, it does not
    +        retrieve the image plot.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all t_SNEs plot names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url
    +
    +        response = requests.get(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves a t_SNE image plot.
    +
    +        tsne_name: Name of t_SNE image plot.
    +        pretty_response: If true open an image plot, else return link to
    +        open image plot.
    +
    +        return: A link to an image plot or open an image plot.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " READ"
    +                + tsne_name
    +                + " tsne IMAGE PLOT "
    +                + " ----------"
    +            )
    +            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
    +            img.show()
    +        else:
    +            return cluster_url_tsne
    +
    +    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting the t_SNE image
    +        plot. The delete operation is always synchronous because it is very
    +        fast, since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        tsne_name: Represents the tsne name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +        response = requests.delete(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible to verify if a t_SNE image
    +        exist into the Learning Orchestra storage mechanism.
    +
    +        tsne_name: Name of t_SNE image plot.
    +
    +        return: True if the t_SNE requested exist, false if does not.
    +        """
    +
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
    +                                                            "----------")
    +
    +        exist = False
    +        tsne_name += ".png"
    +        while not exist:
    +            time.sleep(self.WAIT_TIME)
    +            all_tsne = self.search_all_tsne()
    +            exist = tsne_name in all_tsne.get('result')
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Tsne +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Tsne:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/tsne"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputPlotName"
    +        self.LABEL = "label"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.WAIT_TIME = 5
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def run_tsne_sync(self,
    +                      dataset_name: str,
    +                      tsne_name: str,
    +                      label: str,
    +                      pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run t_SNE algorithm to create an image plot
    +        synchronously, the caller waits until the t_SNE image is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        dataset_name: Name of dataset.
    +        tsne_name: Name of t_SNE image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a t_SNE image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: tsne_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        self.verify_tsne_exist(tsne_name, pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE TSNE IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + tsne_name
    +                + " ----------"
    +            )
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_tsne_async(self,
    +                       dataset_name: str,
    +                       tsne_name: str,
    +                       label: str,
    +                       pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run t_SNE algorithm to create an image plot
    +        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
    +
    +        dataset_name: Name of dataset.
    +        tsne_name: Name of t_SNE image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a t_SNE image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: tsne_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE TSNE IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + tsne_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_tsne(self, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves all t_SNE plot names, it does not
    +        retrieve the image plot.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all t_SNEs plot names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url
    +
    +        response = requests.get(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves a t_SNE image plot.
    +
    +        tsne_name: Name of t_SNE image plot.
    +        pretty_response: If true open an image plot, else return link to
    +        open image plot.
    +
    +        return: A link to an image plot or open an image plot.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " READ"
    +                + tsne_name
    +                + " tsne IMAGE PLOT "
    +                + " ----------"
    +            )
    +            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
    +            img.show()
    +        else:
    +            return cluster_url_tsne
    +
    +    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting the t_SNE image
    +        plot. The delete operation is always synchronous because it is very
    +        fast, since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        tsne_name: Represents the tsne name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +        response = requests.delete(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible to verify if a t_SNE image
    +        exist into the Learning Orchestra storage mechanism.
    +
    +        tsne_name: Name of t_SNE image plot.
    +
    +        return: True if the t_SNE requested exist, false if does not.
    +        """
    +
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
    +                                                            "----------")
    +
    +        exist = False
    +        tsne_name += ".png"
    +        while not exist:
    +            time.sleep(self.WAIT_TIME)
    +            all_tsne = self.search_all_tsne()
    +            exist = tsne_name in all_tsne.get('result')
    +
    +

    Methods

    +
    +
    +def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for deleting the t_SNE image +plot. The delete operation is always synchronous because it is very +fast, since the deletion is performed in background.

    +

    pretty_response: If true return indented string, else return dict. +tsne_name: Represents the tsne name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message.

    +
    + +Expand source code + +
    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for deleting the t_SNE image
    +    plot. The delete operation is always synchronous because it is very
    +    fast, since the deletion is performed in background.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    tsne_name: Represents the tsne name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message.
    +    """
    +
    +    cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +    response = requests.delete(cluster_url_tsne)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_tsne_async(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run t_SNE algorithm to create an image plot +asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.

    +

    dataset_name: Name of dataset. +tsne_name: Name of t_SNE image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a t_SNE image plot.

    +
    + +Expand source code + +
    def run_tsne_async(self,
    +                   dataset_name: str,
    +                   tsne_name: str,
    +                   label: str,
    +                   pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method run t_SNE algorithm to create an image plot
    +    asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
    +
    +    dataset_name: Name of dataset.
    +    tsne_name: Name of t_SNE image plot.
    +    label: The label is the label name of the column for machine learning
    +    datasets which has labeled tuples.
    +    pretty_response: If true open an image plot, else return link to open
    +    image plot.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns a t_SNE image plot.
    +    """
    +
    +    request_body = {
    +        self.INPUT_NAME: dataset_name,
    +        self.OUTPUT_NAME: tsne_name,
    +        self.LABEL: label,
    +    }
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE TSNE IMAGE PLOT FROM "
    +            + dataset_name
    +            + " TO "
    +            + tsne_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_tsne_sync(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run t_SNE algorithm to create an image plot +synchronously, the caller waits until the t_SNE image is inserted into +the Learning Orchestra storage mechanism.

    +

    dataset_name: Name of dataset. +tsne_name: Name of t_SNE image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a t_SNE image plot.

    +
    + +Expand source code + +
    def run_tsne_sync(self,
    +                  dataset_name: str,
    +                  tsne_name: str,
    +                  label: str,
    +                  pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method run t_SNE algorithm to create an image plot
    +    synchronously, the caller waits until the t_SNE image is inserted into
    +    the Learning Orchestra storage mechanism.
    +
    +    dataset_name: Name of dataset.
    +    tsne_name: Name of t_SNE image plot.
    +    label: The label is the label name of the column for machine learning
    +    datasets which has labeled tuples.
    +    pretty_response: If true open an image plot, else return link to open
    +    image plot.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns a t_SNE image plot.
    +    """
    +
    +    request_body = {
    +        self.INPUT_NAME: dataset_name,
    +        self.OUTPUT_NAME: tsne_name,
    +        self.LABEL: label,
    +    }
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    self.verify_tsne_exist(tsne_name, pretty_response)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE TSNE IMAGE PLOT FROM "
    +            + dataset_name
    +            + " TO "
    +            + tsne_name
    +            + " ----------"
    +        )
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_all_tsne(self, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method retrieves all t_SNE plot names, it does not +retrieve the image plot.

    +

    pretty_response: If true return indented string, else return dict.

    +

    return: A list with all t_SNEs plot names stored in Learning Orchestra +or an empty result.

    +
    + +Expand source code + +
    def search_all_tsne(self, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves all t_SNE plot names, it does not
    +    retrieve the image plot.
    +
    +    pretty_response: If true return indented string, else return dict.
    +
    +    return: A list with all t_SNEs plot names stored in Learning Orchestra
    +    or an empty result.
    +    """
    +
    +    cluster_url_tsne = self.cluster_url
    +
    +    response = requests.get(cluster_url_tsne)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method retrieves a t_SNE image plot.

    +

    tsne_name: Name of t_SNE image plot. +pretty_response: If true open an image plot, else return link to +open image plot.

    +

    return: A link to an image plot or open an image plot.

    +
    + +Expand source code + +
    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves a t_SNE image plot.
    +
    +    tsne_name: Name of t_SNE image plot.
    +    pretty_response: If true open an image plot, else return link to
    +    open image plot.
    +
    +    return: A link to an image plot or open an image plot.
    +    """
    +
    +    cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " READ"
    +            + tsne_name
    +            + " tsne IMAGE PLOT "
    +            + " ----------"
    +        )
    +        img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
    +        img.show()
    +    else:
    +        return cluster_url_tsne
    +
    +
    +
    +def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible to verify if a t_SNE image +exist into the Learning Orchestra storage mechanism.

    +

    tsne_name: Name of t_SNE image plot.

    +

    return: True if the t_SNE requested exist, false if does not.

    +
    + +Expand source code + +
    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible to verify if a t_SNE image
    +    exist into the Learning Orchestra storage mechanism.
    +
    +    tsne_name: Name of t_SNE image plot.
    +
    +    return: True if the t_SNE requested exist, false if does not.
    +    """
    +
    +    if pretty_response:
    +        print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
    +                                                        "----------")
    +
    +    exist = False
    +    tsne_name += ".png"
    +    while not exist:
    +        time.sleep(self.WAIT_TIME)
    +        all_tsne = self.search_all_tsne()
    +        exist = tsne_name in all_tsne.get('result')
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/index.html b/html/learning_orchestra_client/index.html new file mode 100644 index 0000000..64b720b --- /dev/null +++ b/html/learning_orchestra_client/index.html @@ -0,0 +1,85 @@ + + + + + + +learning_orchestra_client API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/observer.html b/html/learning_orchestra_client/observer.html new file mode 100644 index 0000000..a7d3aee --- /dev/null +++ b/html/learning_orchestra_client/observer.html @@ -0,0 +1,375 @@ + + + + + + +learning_orchestra_client.observer API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.observer

    +
    +
    +
    + +Expand source code + +
    from pymongo import MongoClient, change_stream
    +
    +
    +class Observer:
    +    def __init__(self, dataset_name: str, cluster_ip: str):
    +        self.dataset_name = dataset_name
    +
    +        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
    +        mongo_client = MongoClient(mongo_url)
    +        self.database = mongo_client['database']
    +
    +    def set_dataset_name(self, dataset_name: str):
    +        """
    +        :description: Changes the dataset name used in object.
    +        :param dataset_name: Name of dataset to observe.
    +
    +        :return: None.
    +        """
    +        self.dataset_name = dataset_name
    +
    +    def get_dataset_name(self) -> str:
    +        """
    +        :description: Retrieve the dataset name used in object.
    +
    +        :return: The dataset name.
    +        """
    +        return self.dataset_name
    +
    +    def observe_processing(self, pretty_response: bool = False) -> dict:
    +        """
    +        :description: Observe the finished processing status from some
    +        processing, blocking the code execution until finish processing.
    +
    +        :return: A dict with metadata file of used dataset name.
    +        """
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
    +                                                                    "----------")
    +        dataset_collection = self.database[self.dataset_name]
    +        metadata_query = {"_id": 0}
    +        dataset_metadata = dataset_collection.find_one(metadata_query)
    +
    +        if dataset_metadata is None:
    +            print("Dataset name or dataset URL invalid")
    +            exit()
    +
    +        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').next()['fullDocument']
    +
    +    def observe_storage(self) -> change_stream.CollectionChangeStream:
    +        """
    +        :description: Get all changes from a dataset
    +
    +        :return: A pymongo CollectionChangeStream object, use the builtin
    +        next() method to iterate over changes.
    +        """
    +
    +        observer_query = [
    +            {'$match': {
    +                '$or': [
    +                    {'operationType': 'replace'},
    +                    {'operationType': 'insert'},
    +                    {'operationType': 'update'},
    +                    {'operationType': 'delete'}
    +
    +                ]
    +            }}
    +        ]
    +        return self.database[self.dataset_name].watch(
    +            observer_query,
    +            full_document='updateLookup')
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Observer +(dataset_name: str, cluster_ip: str) +
    +
    +
    +
    + +Expand source code + +
    class Observer:
    +    def __init__(self, dataset_name: str, cluster_ip: str):
    +        self.dataset_name = dataset_name
    +
    +        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
    +        mongo_client = MongoClient(mongo_url)
    +        self.database = mongo_client['database']
    +
    +    def set_dataset_name(self, dataset_name: str):
    +        """
    +        :description: Changes the dataset name used in object.
    +        :param dataset_name: Name of dataset to observe.
    +
    +        :return: None.
    +        """
    +        self.dataset_name = dataset_name
    +
    +    def get_dataset_name(self) -> str:
    +        """
    +        :description: Retrieve the dataset name used in object.
    +
    +        :return: The dataset name.
    +        """
    +        return self.dataset_name
    +
    +    def observe_processing(self, pretty_response: bool = False) -> dict:
    +        """
    +        :description: Observe the finished processing status from some
    +        processing, blocking the code execution until finish processing.
    +
    +        :return: A dict with metadata file of used dataset name.
    +        """
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
    +                                                                    "----------")
    +        dataset_collection = self.database[self.dataset_name]
    +        metadata_query = {"_id": 0}
    +        dataset_metadata = dataset_collection.find_one(metadata_query)
    +
    +        if dataset_metadata is None:
    +            print("Dataset name or dataset URL invalid")
    +            exit()
    +
    +        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').next()['fullDocument']
    +
    +    def observe_storage(self) -> change_stream.CollectionChangeStream:
    +        """
    +        :description: Get all changes from a dataset
    +
    +        :return: A pymongo CollectionChangeStream object, use the builtin
    +        next() method to iterate over changes.
    +        """
    +
    +        observer_query = [
    +            {'$match': {
    +                '$or': [
    +                    {'operationType': 'replace'},
    +                    {'operationType': 'insert'},
    +                    {'operationType': 'update'},
    +                    {'operationType': 'delete'}
    +
    +                ]
    +            }}
    +        ]
    +        return self.database[self.dataset_name].watch(
    +            observer_query,
    +            full_document='updateLookup')
    +
    +

    Methods

    +
    +
    +def get_dataset_name(self) ‑> str +
    +
    +

    :description: Retrieve the dataset name used in object.

    +

    :return: The dataset name.

    +
    + +Expand source code + +
    def get_dataset_name(self) -> str:
    +    """
    +    :description: Retrieve the dataset name used in object.
    +
    +    :return: The dataset name.
    +    """
    +    return self.dataset_name
    +
    +
    +
    +def observe_processing(self, pretty_response: bool = False) ‑> dict +
    +
    +

    :description: Observe the finished processing status from some +processing, blocking the code execution until finish processing.

    +

    :return: A dict with metadata file of used dataset name.

    +
    + +Expand source code + +
    def observe_processing(self, pretty_response: bool = False) -> dict:
    +    """
    +    :description: Observe the finished processing status from some
    +    processing, blocking the code execution until finish processing.
    +
    +    :return: A dict with metadata file of used dataset name.
    +    """
    +    if pretty_response:
    +        print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
    +                                                                "----------")
    +    dataset_collection = self.database[self.dataset_name]
    +    metadata_query = {"_id": 0}
    +    dataset_metadata = dataset_collection.find_one(metadata_query)
    +
    +    if dataset_metadata is None:
    +        print("Dataset name or dataset URL invalid")
    +        exit()
    +
    +    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').next()['fullDocument']
    +
    +
    +
    +def observe_storage(self) ‑> pymongo.change_stream.CollectionChangeStream +
    +
    +

    :description: Get all changes from a dataset

    +

    :return: A pymongo CollectionChangeStream object, use the builtin +next() method to iterate over changes.

    +
    + +Expand source code + +
    def observe_storage(self) -> change_stream.CollectionChangeStream:
    +    """
    +    :description: Get all changes from a dataset
    +
    +    :return: A pymongo CollectionChangeStream object, use the builtin
    +    next() method to iterate over changes.
    +    """
    +
    +    observer_query = [
    +        {'$match': {
    +            '$or': [
    +                {'operationType': 'replace'},
    +                {'operationType': 'insert'},
    +                {'operationType': 'update'},
    +                {'operationType': 'delete'}
    +
    +            ]
    +        }}
    +    ]
    +    return self.database[self.dataset_name].watch(
    +        observer_query,
    +        full_document='updateLookup')
    +
    +
    +
    +def set_dataset_name(self, dataset_name: str) +
    +
    +

    :description: Changes the dataset name used in object. +:param dataset_name: Name of dataset to observe.

    +

    :return: None.

    +
    + +Expand source code + +
    def set_dataset_name(self, dataset_name: str):
    +    """
    +    :description: Changes the dataset name used in object.
    +    :param dataset_name: Name of dataset to observe.
    +
    +    :return: None.
    +    """
    +    self.dataset_name = dataset_name
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/response_treat.html b/html/learning_orchestra_client/response_treat.html new file mode 100644 index 0000000..2c8bb2a --- /dev/null +++ b/html/learning_orchestra_client/response_treat.html @@ -0,0 +1,197 @@ + + + + + + +learning_orchestra_client.response_treat API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.response_treat

    +
    +
    +
    + +Expand source code + +
    __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
    +__credits__ = "all free source developers"
    +__status__ = "Prototype"
    +
    +import json
    +
    +
    +class ResponseTreat:
    +    HTTP_CREATED = 201
    +    HTTP_SUCCESS = 200
    +    HTTP_ERROR = 500
    +
    +    def treatment(self, response, pretty_response: bool = True):
    +        """
    +        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:
    +            return response.text
    +        elif (
    +                response.status_code != self.HTTP_SUCCESS
    +                and response.status_code != self.HTTP_CREATED
    +        ):
    +            raise Exception(response.json()["result"])
    +        else:
    +            if pretty_response:
    +                return json.dumps(response.json(), indent=4, sort_keys=True)
    +            else:
    +                return response.json()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class ResponseTreat +
    +
    +
    +
    + +Expand source code + +
    class ResponseTreat:
    +    HTTP_CREATED = 201
    +    HTTP_SUCCESS = 200
    +    HTTP_ERROR = 500
    +
    +    def treatment(self, response, pretty_response: bool = True):
    +        """
    +        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:
    +            return response.text
    +        elif (
    +                response.status_code != self.HTTP_SUCCESS
    +                and response.status_code != self.HTTP_CREATED
    +        ):
    +            raise Exception(response.json()["result"])
    +        else:
    +            if pretty_response:
    +                return json.dumps(response.json(), indent=4, sort_keys=True)
    +            else:
    +                return response.json()
    +
    +

    Class variables

    +
    +
    var HTTP_CREATED
    +
    +
    +
    +
    var HTTP_ERROR
    +
    +
    +
    +
    var HTTP_SUCCESS
    +
    +
    +
    +
    +

    Methods

    +
    +
    +def treatment(self, response, pretty_response: bool = True) +
    +
    +

    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.

    +
    + +Expand source code + +
    def treatment(self, response, pretty_response: bool = True):
    +    """
    +    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:
    +        return response.text
    +    elif (
    +            response.status_code != self.HTTP_SUCCESS
    +            and response.status_code != self.HTTP_CREATED
    +    ):
    +        raise Exception(response.json()["result"])
    +    else:
    +        if pretty_response:
    +            return json.dumps(response.json(), indent=4, sort_keys=True)
    +        else:
    +            return response.json()
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/data_type.html b/html/learning_orchestra_client/transform/data_type.html new file mode 100644 index 0000000..fcd25c1 --- /dev/null +++ b/html/learning_orchestra_client/transform/data_type.html @@ -0,0 +1,199 @@ + + + + + + +learning_orchestra_client.transform.data_type API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.transform.data_type

    +
    +
    +
    + +Expand source code + +
    from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +import requests
    +from typing import Union
    +
    +
    +class DataType:
    +    def __init__(self, ip_from_cluster):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/transform/dataType"
    +        self.ResponseTreat = ResponseTreat()
    +        self.Dataset = Dataset(ip_from_cluster)
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.TYPES = "types"
    +
    +    def update_dataset_types(self,
    +                             dataset_name: str,
    +                             fields_change: dict,
    +                             pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: Change types of fields to number or string.
    +
    +        dataset_name: Represents the dataset name.
    +        fields_change: Fields to change with types. This is a dict with each
    +        key:value being field:type
    +
    +        return: A JSON object with error or warning messages.
    +        """
    +
    +        url_request = self.cluster_url
    +        body_request = {
    +            self.INPUT_NAME: dataset_name,
    +            self.TYPES: fields_change
    +        }
    +
    +        response = requests.patch(url=url_request, json=body_request)
    +
    +        return self.ResponseTreat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class DataType +(ip_from_cluster) +
    +
    +
    +
    + +Expand source code + +
    class DataType:
    +    def __init__(self, ip_from_cluster):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/transform/dataType"
    +        self.ResponseTreat = ResponseTreat()
    +        self.Dataset = Dataset(ip_from_cluster)
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.TYPES = "types"
    +
    +    def update_dataset_types(self,
    +                             dataset_name: str,
    +                             fields_change: dict,
    +                             pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: Change types of fields to number or string.
    +
    +        dataset_name: Represents the dataset name.
    +        fields_change: Fields to change with types. This is a dict with each
    +        key:value being field:type
    +
    +        return: A JSON object with error or warning messages.
    +        """
    +
    +        url_request = self.cluster_url
    +        body_request = {
    +            self.INPUT_NAME: dataset_name,
    +            self.TYPES: fields_change
    +        }
    +
    +        response = requests.patch(url=url_request, json=body_request)
    +
    +        return self.ResponseTreat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +def update_dataset_types(self, dataset_name: str, fields_change: dict, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: Change types of fields to number or string.

    +

    dataset_name: Represents the dataset name. +fields_change: Fields to change with types. This is a dict with each +key:value being field:type

    +

    return: A JSON object with error or warning messages.

    +
    + +Expand source code + +
    def update_dataset_types(self,
    +                         dataset_name: str,
    +                         fields_change: dict,
    +                         pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: Change types of fields to number or string.
    +
    +    dataset_name: Represents the dataset name.
    +    fields_change: Fields to change with types. This is a dict with each
    +    key:value being field:type
    +
    +    return: A JSON object with error or warning messages.
    +    """
    +
    +    url_request = self.cluster_url
    +    body_request = {
    +        self.INPUT_NAME: dataset_name,
    +        self.TYPES: fields_change
    +    }
    +
    +    response = requests.patch(url=url_request, json=body_request)
    +
    +    return self.ResponseTreat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/index.html b/html/learning_orchestra_client/transform/index.html new file mode 100644 index 0000000..271146f --- /dev/null +++ b/html/learning_orchestra_client/transform/index.html @@ -0,0 +1,70 @@ + + + + + + +learning_orchestra_client.transform API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/projection.html b/html/learning_orchestra_client/transform/projection.html new file mode 100644 index 0000000..7e84007 --- /dev/null +++ b/html/learning_orchestra_client/transform/projection.html @@ -0,0 +1,1035 @@ + + + + + + +learning_orchestra_client.transform.projection API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.transform.projection

    +
    +
    +
    + +Expand source code + +
    from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +from ..observer import Observer
    +import requests
    +from typing import Union
    +
    +
    +class Projection:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/transform/projection"
    +        self.METADATA_INDEX = 0
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputDatasetName"
    +        self.FIELDS = "names"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def insert_dataset_attributes_sync(self,
    +                                       dataset_name: str,
    +                                       projection_name: str,
    +                                       fields: list,
    +                                       pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method inserts a set of attributes into a dataset
    +        synchronously, the caller waits until the projection is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields: Represents the set of attributes to be inserted. This is list
    +        with all 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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(projection_name, self.CLUSTER_IP).observe_processing(
    +            pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PROJECTION FROM "
    +                + dataset_name
    +                + " TO "
    +                + projection_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def insert_dataset_attributes_async(self,
    +                                        dataset_name: str,
    +                                        projection_name: str,
    +                                        fields: list,
    +                                        pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method inserts a set of attributes into a dataset
    +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields: Represents the set of attributes to be inserted. This is list
    +        with all 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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PROJECTION FROM "
    +                + dataset_name
    +                + " TO "
    +                + projection_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def delete_dataset_attributes_sync(self,
    +                                       dataset_name: str,
    +                                       projection_name: str,
    +                                       fields_to_delete: list,
    +                                       pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method delete a set of attributes on a dataset
    +        synchronously, the caller waits until the projection is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields_to_delete: Represents the set of attributes to be inserted.
    +        This is list with all attributes.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns the projection metadata.
    +        """
    +        dataset_metadata = self.search_projections_content(dataset_name,
    +                                                           limit=1)
    +
    +        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +            .get('fields')
    +        for field in fields_to_delete:
    +            fields_to_insert.remove(field)
    +
    +        response = self.insert_dataset_attributes_sync(dataset_name,
    +                                                       projection_name,
    +                                                       fields_to_insert,
    +                                                       pretty_response)
    +
    +        return response
    +
    +    def delete_dataset_attributes_async(self,
    +                                        dataset_name: str,
    +                                        projection_name: str,
    +                                        fields_to_delete: list,
    +                                        pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method delete a set of attributes into a dataset
    +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields_to_delete: Represents the set of attributes to be inserted.
    +        This is list with all attributes.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns the projection metadata.
    +        """
    +        dataset_metadata = self.search_projections_content(dataset_name,
    +                                                           limit=1)
    +
    +        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +            .get('fields')
    +        for field in fields_to_delete:
    +            fields_to_insert.remove(field)
    +
    +        response = self.insert_dataset_attributes_async(dataset_name,
    +                                                        projection_name,
    +                                                        fields_to_insert,
    +                                                        pretty_response)
    +
    +        return response
    +
    +    def search_all_projections(self, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves all projection metadata, it does not
    +        retrieve the projection content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all projections metadata stored in Learning
    +        Orchestra or an empty result.
    +        """
    +        cluster_url_projection = self.cluster_url
    +
    +        response = requests.get(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_projections(self, projection_name: str,
    +                           pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description:  This method is responsible for retrieving a specific
    +        projection.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
    +        error if there is no such projections.
    +        """
    +        pretty = pretty_response
    +
    +        response = self.search_projections_content(projection_name, limit=1,
    +                                                   pretty_response=pretty)
    +
    +        return response
    +
    +    def search_projections_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 dataset
    +        content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        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.
    +        """
    +
    +        cluster_url_projection = self.cluster_url + "/" + projection_name + \
    +                                 "?query=" + str(query) + \
    +                                 "&limit=" + str(limit) + \
    +                                 "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def delete_projections(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 synchronous because it is very fast,
    +        since the deletion is performed in background. If a projection was
    +        used by another task (Ex. histogram, pca, tuning and so forth),
    +        it cannot be deleted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +        cluster_url_projection = self.cluster_url + "/" + projection_name
    +
    +        response = requests.delete(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Projection +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Projection:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/transform/projection"
    +        self.METADATA_INDEX = 0
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputDatasetName"
    +        self.FIELDS = "names"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def insert_dataset_attributes_sync(self,
    +                                       dataset_name: str,
    +                                       projection_name: str,
    +                                       fields: list,
    +                                       pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method inserts a set of attributes into a dataset
    +        synchronously, the caller waits until the projection is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields: Represents the set of attributes to be inserted. This is list
    +        with all 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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(projection_name, self.CLUSTER_IP).observe_processing(
    +            pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PROJECTION FROM "
    +                + dataset_name
    +                + " TO "
    +                + projection_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def insert_dataset_attributes_async(self,
    +                                        dataset_name: str,
    +                                        projection_name: str,
    +                                        fields: list,
    +                                        pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method inserts a set of attributes into a dataset
    +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields: Represents the set of attributes to be inserted. This is list
    +        with all 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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PROJECTION FROM "
    +                + dataset_name
    +                + " TO "
    +                + projection_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def delete_dataset_attributes_sync(self,
    +                                       dataset_name: str,
    +                                       projection_name: str,
    +                                       fields_to_delete: list,
    +                                       pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method delete a set of attributes on a dataset
    +        synchronously, the caller waits until the projection is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields_to_delete: Represents the set of attributes to be inserted.
    +        This is list with all attributes.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns the projection metadata.
    +        """
    +        dataset_metadata = self.search_projections_content(dataset_name,
    +                                                           limit=1)
    +
    +        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +            .get('fields')
    +        for field in fields_to_delete:
    +            fields_to_insert.remove(field)
    +
    +        response = self.insert_dataset_attributes_sync(dataset_name,
    +                                                       projection_name,
    +                                                       fields_to_insert,
    +                                                       pretty_response)
    +
    +        return response
    +
    +    def delete_dataset_attributes_async(self,
    +                                        dataset_name: str,
    +                                        projection_name: str,
    +                                        fields_to_delete: list,
    +                                        pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method delete a set of attributes into a dataset
    +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields_to_delete: Represents the set of attributes to be inserted.
    +        This is list with all attributes.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns the projection metadata.
    +        """
    +        dataset_metadata = self.search_projections_content(dataset_name,
    +                                                           limit=1)
    +
    +        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +            .get('fields')
    +        for field in fields_to_delete:
    +            fields_to_insert.remove(field)
    +
    +        response = self.insert_dataset_attributes_async(dataset_name,
    +                                                        projection_name,
    +                                                        fields_to_insert,
    +                                                        pretty_response)
    +
    +        return response
    +
    +    def search_all_projections(self, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves all projection metadata, it does not
    +        retrieve the projection content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all projections metadata stored in Learning
    +        Orchestra or an empty result.
    +        """
    +        cluster_url_projection = self.cluster_url
    +
    +        response = requests.get(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_projections(self, projection_name: str,
    +                           pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description:  This method is responsible for retrieving a specific
    +        projection.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
    +        error if there is no such projections.
    +        """
    +        pretty = pretty_response
    +
    +        response = self.search_projections_content(projection_name, limit=1,
    +                                                   pretty_response=pretty)
    +
    +        return response
    +
    +    def search_projections_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 dataset
    +        content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        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.
    +        """
    +
    +        cluster_url_projection = self.cluster_url + "/" + projection_name + \
    +                                 "?query=" + str(query) + \
    +                                 "&limit=" + str(limit) + \
    +                                 "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def delete_projections(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 synchronous because it is very fast,
    +        since the deletion is performed in background. If a projection was
    +        used by another task (Ex. histogram, pca, tuning and so forth),
    +        it cannot be deleted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +        cluster_url_projection = self.cluster_url + "/" + projection_name
    +
    +        response = requests.delete(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +def delete_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method delete a set of attributes into a dataset +asynchronously, the caller does not wait until the projections 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 projection was inserted.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields_to_delete: Represents the set of attributes to be inserted. +This is list with all attributes.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

    +
    + +Expand source code + +
    def delete_dataset_attributes_async(self,
    +                                    dataset_name: str,
    +                                    projection_name: str,
    +                                    fields_to_delete: list,
    +                                    pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method delete a set of attributes into a dataset
    +    asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +    dataset_name: Represents the dataset name.
    +    fields_to_delete: Represents the set of attributes to be inserted.
    +    This is list with all attributes.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns the projection metadata.
    +    """
    +    dataset_metadata = self.search_projections_content(dataset_name,
    +                                                       limit=1)
    +
    +    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +        .get('fields')
    +    for field in fields_to_delete:
    +        fields_to_insert.remove(field)
    +
    +    response = self.insert_dataset_attributes_async(dataset_name,
    +                                                    projection_name,
    +                                                    fields_to_insert,
    +                                                    pretty_response)
    +
    +    return response
    +
    +
    +
    +def delete_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method delete a set of attributes on a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields_to_delete: Represents the set of attributes to be inserted. +This is list with all attributes.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

    +
    + +Expand source code + +
    def delete_dataset_attributes_sync(self,
    +                                   dataset_name: str,
    +                                   projection_name: str,
    +                                   fields_to_delete: list,
    +                                   pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method delete a set of attributes on a dataset
    +    synchronously, the caller waits until the projection is inserted into
    +    the Learning Orchestra storage mechanism.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +    dataset_name: Represents the dataset name.
    +    fields_to_delete: Represents the set of attributes to be inserted.
    +    This is list with all attributes.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns the projection metadata.
    +    """
    +    dataset_metadata = self.search_projections_content(dataset_name,
    +                                                       limit=1)
    +
    +    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +        .get('fields')
    +    for field in fields_to_delete:
    +        fields_to_insert.remove(field)
    +
    +    response = self.insert_dataset_attributes_sync(dataset_name,
    +                                                   projection_name,
    +                                                   fields_to_insert,
    +                                                   pretty_response)
    +
    +    return response
    +
    +
    +
    +def delete_projections(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 synchronous because it is very fast, +since the deletion is performed in background. If a projection was +used by another task (Ex. histogram, pca, tuning and so forth), +it cannot be deleted.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message

    +
    + +Expand source code + +
    def delete_projections(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 synchronous because it is very fast,
    +    since the deletion is performed in background. If a projection was
    +    used by another task (Ex. histogram, pca, tuning and so forth),
    +    it cannot be deleted.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message
    +    """
    +    cluster_url_projection = self.cluster_url + "/" + projection_name
    +
    +    response = requests.delete(cluster_url_projection)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def insert_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method inserts a set of attributes into a dataset +asynchronously, the caller does not wait until the projections 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 projection was inserted.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all attributes.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

    +
    + +Expand source code + +
    def insert_dataset_attributes_async(self,
    +                                    dataset_name: str,
    +                                    projection_name: str,
    +                                    fields: list,
    +                                    pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method inserts a set of attributes into a dataset
    +    asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +    dataset_name: Represents the dataset name.
    +    fields: Represents the set of attributes to be inserted. This is list
    +    with all 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.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE PROJECTION FROM "
    +            + dataset_name
    +            + " TO "
    +            + projection_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def insert_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method inserts a set of attributes into a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all attributes.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

    +
    + +Expand source code + +
    def insert_dataset_attributes_sync(self,
    +                                   dataset_name: str,
    +                                   projection_name: str,
    +                                   fields: list,
    +                                   pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method inserts a set of attributes into a dataset
    +    synchronously, the caller waits until the projection is inserted into
    +    the Learning Orchestra storage mechanism.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +    dataset_name: Represents the dataset name.
    +    fields: Represents the set of attributes to be inserted. This is list
    +    with all 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.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    Observer(projection_name, self.CLUSTER_IP).observe_processing(
    +        pretty_response)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE PROJECTION FROM "
    +            + dataset_name
    +            + " TO "
    +            + projection_name
    +            + " ----------"
    +        )
    +
    +    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, it does not +retrieve the projection content.

    +

    pretty_response: If true return indented string, else return dict.

    +

    return: A list with all projections metadata stored in Learning +Orchestra or an empty result.

    +
    + +Expand source code + +
    def search_all_projections(self, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves all projection metadata, it does not
    +    retrieve the projection content.
    +
    +    pretty_response: If true return indented string, else return dict.
    +
    +    return: A list with all projections metadata stored in Learning
    +    Orchestra or an empty result.
    +    """
    +    cluster_url_projection = self.cluster_url
    +
    +    response = requests.get(cluster_url_projection)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_projections(self, projection_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: +This method is responsible for retrieving a specific +projection.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an +error if there is no such projections.

    +
    + +Expand source code + +
    def search_projections(self, projection_name: str,
    +                       pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description:  This method is responsible for retrieving a specific
    +    projection.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
    +    error if there is no such projections.
    +    """
    +    pretty = pretty_response
    +
    +    response = self.search_projections_content(projection_name, limit=1,
    +                                               pretty_response=pretty)
    +
    +    return response
    +
    +
    +
    +def search_projections_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 dataset +content.

    +

    pretty_response: If true return indented string, else return dict. +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.

    +
    + +Expand source code + +
    def search_projections_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 dataset
    +    content.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    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.
    +    """
    +
    +    cluster_url_projection = self.cluster_url + "/" + projection_name + \
    +                             "?query=" + str(query) + \
    +                             "&limit=" + str(limit) + \
    +                             "&skip=" + str(skip)
    +
    +    response = requests.get(cluster_url_projection)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file From b018b16b53d82223a1fc03b27889db27db1e5435 Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sun, 20 Dec 2020 13:10:10 -0300 Subject: [PATCH 08/28] docs --- docs/builder/builder.html | 790 ++++++++++++++++++++++++ docs/builder/index.html | 65 ++ docs/dataset/dataset.html | 678 +++++++++++++++++++++ docs/dataset/index.html | 65 ++ docs/explore/histogram.html | 676 +++++++++++++++++++++ docs/explore/index.html | 75 +++ docs/explore/pca.html | 742 +++++++++++++++++++++++ docs/explore/tsne.html | 742 +++++++++++++++++++++++ docs/index.html | 85 +++ docs/observer.html | 375 ++++++++++++ docs/response_treat.html | 197 ++++++ docs/transform/data_type.html | 199 ++++++ docs/transform/index.html | 70 +++ docs/transform/projection.html | 1035 ++++++++++++++++++++++++++++++++ 14 files changed, 5794 insertions(+) create mode 100644 docs/builder/builder.html create mode 100644 docs/builder/index.html create mode 100644 docs/dataset/dataset.html create mode 100644 docs/dataset/index.html create mode 100644 docs/explore/histogram.html create mode 100644 docs/explore/index.html create mode 100644 docs/explore/pca.html create mode 100644 docs/explore/tsne.html create mode 100644 docs/index.html create mode 100644 docs/observer.html create mode 100644 docs/response_treat.html create mode 100644 docs/transform/data_type.html create mode 100644 docs/transform/index.html create mode 100644 docs/transform/projection.html diff --git a/docs/builder/builder.html b/docs/builder/builder.html new file mode 100644 index 0000000..f450096 --- /dev/null +++ b/docs/builder/builder.html @@ -0,0 +1,790 @@ + + + + + + +learning_orchestra_client.builder.builder API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.builder.builder

    +
    +
    +
    + +Expand source code + +
    from ..observer import Observer
    +from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +import requests
    +from typing import Union
    +
    +
    +class Builder:
    +    def __init__(self, ip_from_cluster: str):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/builder"
    +        self.response_treat = ResponseTreat()
    +        self.TRAIN_NAME = "trainDatasetName"
    +        self.TEST_NAME = "testDatasetName"
    +        self.CODE = "modelingCode"
    +        self.CLASSIFIERS_LIST = "classifiersList"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.METADATA_INDEX = 0
    +
    +    def run_builder_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 resource join several steps of machine
    +        learning workflow (transform, tune, train and evaluate) coupling in
    +        a unique resource, builder creates several model predictions using
    +        your own modeling code using a defined set of classifiers. This is made
    +        synchronously, the caller waits until the model predictions are inserted
    +        into the Learning Orchestra storage mechanism.
    +
    +        train_dataset_name: Represent final train dataset.
    +        test_dataset_name: Represent final test dataset.
    +        modeling_code: Represent Python3 code for pyspark preprocessing model
    +        model_classifiers: list of initial classifiers to be used in model
    +        pretty_response: returns indented string for visualization if True
    +
    +        return: The resulted predictions URIs.
    +        """
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE MODEL WITH "
    +                + train_dataset_name
    +                + " AND "
    +                + test_dataset_name
    +                + " ----------"
    +            )
    +
    +        request_body_content = {
    +            self.TRAIN_NAME: train_dataset_name,
    +            self.TEST_NAME: test_dataset_name,
    +            self.CODE: modeling_code,
    +            self.CLASSIFIERS_LIST: model_classifiers,
    +        }
    +        response = requests.post(url=self.cluster_url,
    +                                 json=request_body_content)
    +
    +        observer = Observer(test_dataset_name, self.CLUSTER_IP)
    +
    +        for model in model_classifiers:
    +            observer.set_dataset_name(test_dataset_name + model)
    +            observer.observe_processing(pretty_response)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_builder_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 resource join several steps of machine
    +        learning workflow (transform, tune, train and evaluate) coupling in
    +        a unique resource, builder creates several model predictions using
    +        your own modeling code using a defined set of classifiers. This is made
    +        asynchronously, the caller does not wait until the model predictions are
    +        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 model predictions are inserted.
    +
    +        train_dataset_name: Represent final train dataset.
    +        test_dataset_name: Represent final test dataset.
    +        modeling_code: Represent Python3 code for pyspark preprocessing model
    +        model_classifiers: list of initial classifiers to be used in model
    +        pretty_response: returns indented string for visualization if True
    +
    +        return: The resulted predictions URIs.
    +        """
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE MODEL WITH "
    +                + train_dataset_name
    +                + " AND "
    +                + test_dataset_name
    +                + " ----------"
    +            )
    +
    +        request_body_content = {
    +            self.TRAIN_NAME: train_dataset_name,
    +            self.TEST_NAME: test_dataset_name,
    +            self.CODE: modeling_code,
    +            self.CLASSIFIERS_LIST: model_classifiers,
    +        }
    +        response = requests.post(url=self.cluster_url,
    +                                 json=request_body_content)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_model(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 return indented string, else return dict.
    +
    +        return: A list with all model predictions metadata stored in Learning
    +        Orchestra or an empty result.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url
    +
    +        response = requests.get(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_model_prediction(self,
    +                                model_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 return indented string, else return dict.
    +        model_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 there
    +        is no such projection. The current page is also returned to be used in
    +        future content requests.
    +        """
    +
    +        cluster_url_dataset = self.cluster_url + "/" + model_name + \
    +                              "?query=" + str(query) + \
    +                              "&limit=" + str(limit) + \
    +                              "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_dataset)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_model(self, model_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description:  This method is responsible for retrieving a specific
    +        model prediction metadata.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        model_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_model_prediction(model_name, limit=1,
    +                                                pretty_response=pretty_response)
    +
    +        return response
    +
    +    def delete_model(self, model_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting a model prediction.
    +        The delete operation is always synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        model_name: Represents the projection name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        cluster_url_dataset = self.cluster_url + "/" + model_name
    +
    +        response = requests.delete(cluster_url_dataset)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Builder +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Builder:
    +    def __init__(self, ip_from_cluster: str):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/builder"
    +        self.response_treat = ResponseTreat()
    +        self.TRAIN_NAME = "trainDatasetName"
    +        self.TEST_NAME = "testDatasetName"
    +        self.CODE = "modelingCode"
    +        self.CLASSIFIERS_LIST = "classifiersList"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.METADATA_INDEX = 0
    +
    +    def run_builder_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 resource join several steps of machine
    +        learning workflow (transform, tune, train and evaluate) coupling in
    +        a unique resource, builder creates several model predictions using
    +        your own modeling code using a defined set of classifiers. This is made
    +        synchronously, the caller waits until the model predictions are inserted
    +        into the Learning Orchestra storage mechanism.
    +
    +        train_dataset_name: Represent final train dataset.
    +        test_dataset_name: Represent final test dataset.
    +        modeling_code: Represent Python3 code for pyspark preprocessing model
    +        model_classifiers: list of initial classifiers to be used in model
    +        pretty_response: returns indented string for visualization if True
    +
    +        return: The resulted predictions URIs.
    +        """
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE MODEL WITH "
    +                + train_dataset_name
    +                + " AND "
    +                + test_dataset_name
    +                + " ----------"
    +            )
    +
    +        request_body_content = {
    +            self.TRAIN_NAME: train_dataset_name,
    +            self.TEST_NAME: test_dataset_name,
    +            self.CODE: modeling_code,
    +            self.CLASSIFIERS_LIST: model_classifiers,
    +        }
    +        response = requests.post(url=self.cluster_url,
    +                                 json=request_body_content)
    +
    +        observer = Observer(test_dataset_name, self.CLUSTER_IP)
    +
    +        for model in model_classifiers:
    +            observer.set_dataset_name(test_dataset_name + model)
    +            observer.observe_processing(pretty_response)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_builder_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 resource join several steps of machine
    +        learning workflow (transform, tune, train and evaluate) coupling in
    +        a unique resource, builder creates several model predictions using
    +        your own modeling code using a defined set of classifiers. This is made
    +        asynchronously, the caller does not wait until the model predictions are
    +        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 model predictions are inserted.
    +
    +        train_dataset_name: Represent final train dataset.
    +        test_dataset_name: Represent final test dataset.
    +        modeling_code: Represent Python3 code for pyspark preprocessing model
    +        model_classifiers: list of initial classifiers to be used in model
    +        pretty_response: returns indented string for visualization if True
    +
    +        return: The resulted predictions URIs.
    +        """
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE MODEL WITH "
    +                + train_dataset_name
    +                + " AND "
    +                + test_dataset_name
    +                + " ----------"
    +            )
    +
    +        request_body_content = {
    +            self.TRAIN_NAME: train_dataset_name,
    +            self.TEST_NAME: test_dataset_name,
    +            self.CODE: modeling_code,
    +            self.CLASSIFIERS_LIST: model_classifiers,
    +        }
    +        response = requests.post(url=self.cluster_url,
    +                                 json=request_body_content)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_model(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 return indented string, else return dict.
    +
    +        return: A list with all model predictions metadata stored in Learning
    +        Orchestra or an empty result.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url
    +
    +        response = requests.get(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_model_prediction(self,
    +                                model_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 return indented string, else return dict.
    +        model_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 there
    +        is no such projection. The current page is also returned to be used in
    +        future content requests.
    +        """
    +
    +        cluster_url_dataset = self.cluster_url + "/" + model_name + \
    +                              "?query=" + str(query) + \
    +                              "&limit=" + str(limit) + \
    +                              "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_dataset)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_model(self, model_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description:  This method is responsible for retrieving a specific
    +        model prediction metadata.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        model_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_model_prediction(model_name, limit=1,
    +                                                pretty_response=pretty_response)
    +
    +        return response
    +
    +    def delete_model(self, model_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting a model prediction.
    +        The delete operation is always synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        model_name: Represents the projection name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        cluster_url_dataset = self.cluster_url + "/" + model_name
    +
    +        response = requests.delete(cluster_url_dataset)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for deleting a model prediction. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

    +

    pretty_response: If true return indented string, else return dict. +model_name: Represents the projection name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message

    +
    + +Expand source code + +
    def delete_model(self, model_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for deleting a model prediction.
    +    The delete operation is always synchronous because it is very fast,
    +    since the deletion is performed in background.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    model_name: Represents the projection name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message
    +    """
    +
    +    cluster_url_dataset = self.cluster_url + "/" + model_name
    +
    +    response = requests.delete(cluster_url_dataset)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +asynchronously, the caller does not wait until the model predictions are +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 model predictions are inserted.

    +

    train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

    +

    return: The resulted predictions URIs.

    +
    + +Expand source code + +
    def run_builder_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 resource join several steps of machine
    +    learning workflow (transform, tune, train and evaluate) coupling in
    +    a unique resource, builder creates several model predictions using
    +    your own modeling code using a defined set of classifiers. This is made
    +    asynchronously, the caller does not wait until the model predictions are
    +    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 model predictions are inserted.
    +
    +    train_dataset_name: Represent final train dataset.
    +    test_dataset_name: Represent final test dataset.
    +    modeling_code: Represent Python3 code for pyspark preprocessing model
    +    model_classifiers: list of initial classifiers to be used in model
    +    pretty_response: returns indented string for visualization if True
    +
    +    return: The resulted predictions URIs.
    +    """
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE MODEL WITH "
    +            + train_dataset_name
    +            + " AND "
    +            + test_dataset_name
    +            + " ----------"
    +        )
    +
    +    request_body_content = {
    +        self.TRAIN_NAME: train_dataset_name,
    +        self.TEST_NAME: test_dataset_name,
    +        self.CODE: modeling_code,
    +        self.CLASSIFIERS_LIST: model_classifiers,
    +    }
    +    response = requests.post(url=self.cluster_url,
    +                             json=request_body_content)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +synchronously, the caller waits until the model predictions are inserted +into the Learning Orchestra storage mechanism.

    +

    train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

    +

    return: The resulted predictions URIs.

    +
    + +Expand source code + +
    def run_builder_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 resource join several steps of machine
    +    learning workflow (transform, tune, train and evaluate) coupling in
    +    a unique resource, builder creates several model predictions using
    +    your own modeling code using a defined set of classifiers. This is made
    +    synchronously, the caller waits until the model predictions are inserted
    +    into the Learning Orchestra storage mechanism.
    +
    +    train_dataset_name: Represent final train dataset.
    +    test_dataset_name: Represent final test dataset.
    +    modeling_code: Represent Python3 code for pyspark preprocessing model
    +    model_classifiers: list of initial classifiers to be used in model
    +    pretty_response: returns indented string for visualization if True
    +
    +    return: The resulted predictions URIs.
    +    """
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE MODEL WITH "
    +            + train_dataset_name
    +            + " AND "
    +            + test_dataset_name
    +            + " ----------"
    +        )
    +
    +    request_body_content = {
    +        self.TRAIN_NAME: train_dataset_name,
    +        self.TEST_NAME: test_dataset_name,
    +        self.CODE: modeling_code,
    +        self.CLASSIFIERS_LIST: model_classifiers,
    +    }
    +    response = requests.post(url=self.cluster_url,
    +                             json=request_body_content)
    +
    +    observer = Observer(test_dataset_name, self.CLUSTER_IP)
    +
    +    for model in model_classifiers:
    +        observer.set_dataset_name(test_dataset_name + model)
    +        observer.observe_processing(pretty_response)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_all_model(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 return indented string, else return dict.

    +

    return: A list with all model predictions metadata stored in Learning +Orchestra or an empty result.

    +
    + +Expand source code + +
    def search_all_model(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 return indented string, else return dict.
    +
    +    return: A list with all model predictions metadata stored in Learning
    +    Orchestra or an empty result.
    +    """
    +
    +    cluster_url_tsne = self.cluster_url
    +
    +    response = requests.get(cluster_url_tsne)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: +This method is responsible for retrieving a specific +model prediction metadata.

    +

    pretty_response: If true return indented string, else return dict. +model_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.

    +
    + +Expand source code + +
    def search_model(self, model_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description:  This method is responsible for retrieving a specific
    +    model prediction metadata.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    model_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_model_prediction(model_name, limit=1,
    +                                            pretty_response=pretty_response)
    +
    +    return response
    +
    +
    +
    +def search_model_prediction(self, model_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 return indented string, else return dict. +model_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 there +is no such projection. The current page is also returned to be used in +future content requests.

    +
    + +Expand source code + +
    def search_model_prediction(self,
    +                            model_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 return indented string, else return dict.
    +    model_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 there
    +    is no such projection. The current page is also returned to be used in
    +    future content requests.
    +    """
    +
    +    cluster_url_dataset = self.cluster_url + "/" + model_name + \
    +                          "?query=" + str(query) + \
    +                          "&limit=" + str(limit) + \
    +                          "&skip=" + str(skip)
    +
    +    response = requests.get(cluster_url_dataset)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/docs/builder/index.html b/docs/builder/index.html new file mode 100644 index 0000000..f6061e5 --- /dev/null +++ b/docs/builder/index.html @@ -0,0 +1,65 @@ + + + + + + +learning_orchestra_client.builder API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/docs/dataset/dataset.html b/docs/dataset/dataset.html new file mode 100644 index 0000000..64e61be --- /dev/null +++ b/docs/dataset/dataset.html @@ -0,0 +1,678 @@ + + + + + + +learning_orchestra_client.dataset.dataset API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.dataset.dataset

    +
    +
    +
    + +Expand source code + +
    __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
    +__credits__ = "all free source developers"
    +__status__ = "Prototype"
    +
    +from ..observer import Observer
    +from ..response_treat import ResponseTreat
    +import requests
    +from typing import Union
    +
    +
    +class Dataset:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/dataset"
    +        self.response_treat = ResponseTreat()
    +        self.OUTPUT_NAME = "datasetName"
    +        self.URL = "datasetURI"
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    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 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.
    +        """
    +        request_body = {self.OUTPUT_NAME: dataset_name,
    +                        self.URL: url}
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
    +
    +        if pretty_response:
    +            print("\n----------" + " CREATED FILE " + 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).
    +        """
    +        request_body = {self.OUTPUT_NAME: dataset_name,
    +                        self.URL: url}
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    +                                                                     "---")
    +        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 return indented string, else return dict.
    +
    +        return: All datasets metadata stored in Learning Orchestra or an empty
    +        result.
    +        """
    +        request_url = self.cluster_url
    +
    +        response = requests.get(request_url)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for retrieving a specific
    +        dataset
    +
    +        pretty_response: If true return indented string, else return dict.
    +        dataset_name: Is the name of the dataset file.
    +        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 dataset metadata stored in Learning Orchestra or an
    +        error if there is no such dataset.
    +        """
    +        response = self.search_dataset_content(dataset_name, limit=1,
    +                                               pretty_response=pretty_response)
    +
    +        return 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 return indented string, else return dict.
    +        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.
    +        """
    +
    +        request_url = self.cluster_url + "/" + dataset_name + \
    +                      "?query=" + str(query) + \
    +                      "&limit=" + str(limit) + \
    +                      "&skip=" + str(skip)
    +
    +        response = requests.get(request_url)
    +
    +        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. The
    +        delete operation is always synchronous because it is very fast, since
    +        the deletion is performed in background. If a dataset was used by
    +        another task (Ex. projection, histogram, pca, tuning and so forth), it
    +        cannot be deleted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        dataset_name: Represents the dataset name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        request_url = self.cluster_url + "/" + dataset_name
    +
    +        response = requests.delete(request_url)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Dataset +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Dataset:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/dataset"
    +        self.response_treat = ResponseTreat()
    +        self.OUTPUT_NAME = "datasetName"
    +        self.URL = "datasetURI"
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    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 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.
    +        """
    +        request_body = {self.OUTPUT_NAME: dataset_name,
    +                        self.URL: url}
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
    +
    +        if pretty_response:
    +            print("\n----------" + " CREATED FILE " + 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).
    +        """
    +        request_body = {self.OUTPUT_NAME: dataset_name,
    +                        self.URL: url}
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    +                                                                     "---")
    +        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 return indented string, else return dict.
    +
    +        return: All datasets metadata stored in Learning Orchestra or an empty
    +        result.
    +        """
    +        request_url = self.cluster_url
    +
    +        response = requests.get(request_url)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for retrieving a specific
    +        dataset
    +
    +        pretty_response: If true return indented string, else return dict.
    +        dataset_name: Is the name of the dataset file.
    +        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 dataset metadata stored in Learning Orchestra or an
    +        error if there is no such dataset.
    +        """
    +        response = self.search_dataset_content(dataset_name, limit=1,
    +                                               pretty_response=pretty_response)
    +
    +        return 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 return indented string, else return dict.
    +        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.
    +        """
    +
    +        request_url = self.cluster_url + "/" + dataset_name + \
    +                      "?query=" + str(query) + \
    +                      "&limit=" + str(limit) + \
    +                      "&skip=" + str(skip)
    +
    +        response = requests.get(request_url)
    +
    +        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. The
    +        delete operation is always synchronous because it is very fast, since
    +        the deletion is performed in background. If a dataset was used by
    +        another task (Ex. projection, histogram, pca, tuning and so forth), it
    +        cannot be deleted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        dataset_name: Represents the dataset name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        request_url = self.cluster_url + "/" + dataset_name
    +
    +        response = requests.delete(request_url)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for deleting the dataset. The +delete operation is always synchronous because it is very fast, since +the deletion is performed in background. If a dataset was used by +another task (Ex. projection, histogram, pca, tuning and so forth), it +cannot be deleted.

    +

    pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message

    +
    + +Expand source code + +
    def delete_dataset(self, dataset_name, pretty_response=False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for deleting the dataset. The
    +    delete operation is always synchronous because it is very fast, since
    +    the deletion is performed in background. If a dataset was used by
    +    another task (Ex. projection, histogram, pca, tuning and so forth), it
    +    cannot be deleted.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    dataset_name: Represents the dataset name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message
    +    """
    +
    +    request_url = self.cluster_url + "/" + dataset_name
    +
    +    response = requests.delete(request_url)
    +
    +    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).

    +
    + +Expand source code + +
    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).
    +    """
    +    request_body = {self.OUTPUT_NAME: dataset_name,
    +                    self.URL: url}
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    +                                                                 "---")
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +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 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.

    +
    + +Expand source code + +
    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 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.
    +    """
    +    request_body = {self.OUTPUT_NAME: dataset_name,
    +                    self.URL: url}
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
    +
    +    if pretty_response:
    +        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    +                                                                 "---")
    +    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 return indented string, else return dict.

    +

    return: All datasets metadata stored in Learning Orchestra or an empty +result.

    +
    + +Expand source code + +
    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 return indented string, else return dict.
    +
    +    return: All datasets metadata stored in Learning Orchestra or an empty
    +    result.
    +    """
    +    request_url = self.cluster_url
    +
    +    response = requests.get(request_url)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for retrieving a specific +dataset

    +

    pretty_response: If true return indented string, else return dict. +dataset_name: Is the name of the dataset file. +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 dataset metadata stored in Learning Orchestra or an +error if there is no such dataset.

    +
    + +Expand source code + +
    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for retrieving a specific
    +    dataset
    +
    +    pretty_response: If true return indented string, else return dict.
    +    dataset_name: Is the name of the dataset file.
    +    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 dataset metadata stored in Learning Orchestra or an
    +    error if there is no such dataset.
    +    """
    +    response = self.search_dataset_content(dataset_name, limit=1,
    +                                           pretty_response=pretty_response)
    +
    +    return 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 return indented string, else return dict. +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.

    +
    + +Expand source code + +
    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 return indented string, else return dict.
    +    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.
    +    """
    +
    +    request_url = self.cluster_url + "/" + dataset_name + \
    +                  "?query=" + str(query) + \
    +                  "&limit=" + str(limit) + \
    +                  "&skip=" + str(skip)
    +
    +    response = requests.get(request_url)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/docs/dataset/index.html b/docs/dataset/index.html new file mode 100644 index 0000000..b4c42b2 --- /dev/null +++ b/docs/dataset/index.html @@ -0,0 +1,65 @@ + + + + + + +learning_orchestra_client.dataset API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/docs/explore/histogram.html b/docs/explore/histogram.html new file mode 100644 index 0000000..e1abdfc --- /dev/null +++ b/docs/explore/histogram.html @@ -0,0 +1,676 @@ + + + + + + +learning_orchestra_client.explore.histogram API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.explore.histogram

    +
    +
    +
    + +Expand source code + +
    from ..observer import Observer
    +from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +import requests
    +from typing import Union
    +
    +
    +class Histogram:
    +    def __init__(self, ip_from_cluster: str):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/histogram"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputDatasetName"
    +        self.FIELDS = "names"
    +        self.dataset = Dataset(ip_from_cluster)
    +
    +    def run_histogram_sync(self,
    +                           dataset_name: str,
    +                           histogram_name: str,
    +                           fields: list,
    +                           pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method run histogram algorithm to create a histogram
    +        synchronously, 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 return indented string, else return dict.
    +
    +        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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
    +            pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE HISTOGRAM FROM "
    +                + dataset_name
    +                + " TO "
    +                + histogram_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 run histogram algorithm to create a histogram
    +        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
    +
    +        dataset_name: Represents the name of dataset.
    +        histogram_name: Represents the name of histogram.
    +        fields: Represents a list of attributes.
    +        pretty_response: If true return indented string, else return dict.
    +
    +        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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE HISTOGRAM FROM "
    +                + dataset_name
    +                + " TO "
    +                + histogram_name
    +                + " ----------"
    +            )
    +
    +        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 names, it does not
    +        retrieve the histogram content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all histogram names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_histogram = self.cluster_url
    +
    +        response = requests.get(cluster_url_histogram)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_histogram_data(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 return indented string, else return dict.
    +        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.
    +        """
    +
    +        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
    +                                "?query=" + str(query) + \
    +                                "&limit=" + str(limit) + \
    +                                "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_histogram)
    +
    +        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 synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        histogram_name: Represents the histogram name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        cluster_url_histogram = self.cluster_url + "/" + histogram_name
    +
    +        response = requests.delete(cluster_url_histogram)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Histogram +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Histogram:
    +    def __init__(self, ip_from_cluster: str):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/histogram"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputDatasetName"
    +        self.FIELDS = "names"
    +        self.dataset = Dataset(ip_from_cluster)
    +
    +    def run_histogram_sync(self,
    +                           dataset_name: str,
    +                           histogram_name: str,
    +                           fields: list,
    +                           pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method run histogram algorithm to create a histogram
    +        synchronously, 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 return indented string, else return dict.
    +
    +        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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
    +            pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE HISTOGRAM FROM "
    +                + dataset_name
    +                + " TO "
    +                + histogram_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 run histogram algorithm to create a histogram
    +        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
    +
    +        dataset_name: Represents the name of dataset.
    +        histogram_name: Represents the name of histogram.
    +        fields: Represents a list of attributes.
    +        pretty_response: If true return indented string, else return dict.
    +
    +        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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE HISTOGRAM FROM "
    +                + dataset_name
    +                + " TO "
    +                + histogram_name
    +                + " ----------"
    +            )
    +
    +        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 names, it does not
    +        retrieve the histogram content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all histogram names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_histogram = self.cluster_url
    +
    +        response = requests.get(cluster_url_histogram)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_histogram_data(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 return indented string, else return dict.
    +        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.
    +        """
    +
    +        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
    +                                "?query=" + str(query) + \
    +                                "&limit=" + str(limit) + \
    +                                "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_histogram)
    +
    +        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 synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        histogram_name: Represents the histogram name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +
    +        cluster_url_histogram = self.cluster_url + "/" + histogram_name
    +
    +        response = requests.delete(cluster_url_histogram)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +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 synchronous because it is very fast, +since the deletion is performed in background.

    +

    pretty_response: If true return indented string, else return dict. +histogram_name: Represents the histogram name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message

    +
    + +Expand source code + +
    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 synchronous because it is very fast,
    +    since the deletion is performed in background.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    histogram_name: Represents the histogram name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message
    +    """
    +
    +    cluster_url_histogram = self.cluster_url + "/" + histogram_name
    +
    +    response = requests.delete(cluster_url_histogram)
    +
    +    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 run histogram algorithm to create a histogram +asynchronously, the caller does not wait until the histogram 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 histogram was inserted.

    +

    dataset_name: Represents the name of dataset. +histogram_name: Represents the name of histogram. +fields: Represents a list of attributes. +pretty_response: If true return indented string, else return dict.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a histogram.

    +
    + +Expand source code + +
    def run_histogram_async(self,
    +                        dataset_name: str,
    +                        histogram_name: str,
    +                        fields: list,
    +                        pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method run histogram algorithm to create a histogram
    +    asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
    +
    +    dataset_name: Represents the name of dataset.
    +    histogram_name: Represents the name of histogram.
    +    fields: Represents a list of attributes.
    +    pretty_response: If true return indented string, else return dict.
    +
    +    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.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE HISTOGRAM FROM "
    +            + dataset_name
    +            + " TO "
    +            + histogram_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_histogram_sync(self, dataset_name: str, histogram_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run histogram algorithm to create a histogram +synchronously, 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 return indented string, else return dict.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a histogram.

    +
    + +Expand source code + +
    def run_histogram_sync(self,
    +                       dataset_name: str,
    +                       histogram_name: str,
    +                       fields: list,
    +                       pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method run histogram algorithm to create a histogram
    +    synchronously, 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 return indented string, else return dict.
    +
    +    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.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    Observer(histogram_name, self.CLUSTER_IP).observe_processing(
    +        pretty_response)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE HISTOGRAM FROM "
    +            + dataset_name
    +            + " TO "
    +            + histogram_name
    +            + " ----------"
    +        )
    +
    +    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 names, it does not +retrieve the histogram content.

    +

    pretty_response: If true return indented string, else return dict.

    +

    return: A list with all histogram names stored in Learning Orchestra +or an empty result.

    +
    + +Expand source code + +
    def search_all_histograms(self, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves all histogram names, it does not
    +    retrieve the histogram content.
    +
    +    pretty_response: If true return indented string, else return dict.
    +
    +    return: A list with all histogram names stored in Learning Orchestra
    +    or an empty result.
    +    """
    +
    +    cluster_url_histogram = self.cluster_url
    +
    +    response = requests.get(cluster_url_histogram)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_histogram_data(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 return indented string, else return dict. +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.

    +
    + +Expand source code + +
    def search_histogram_data(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 return indented string, else return dict.
    +    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.
    +    """
    +
    +    cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
    +                            "?query=" + str(query) + \
    +                            "&limit=" + str(limit) + \
    +                            "&skip=" + str(skip)
    +
    +    response = requests.get(cluster_url_histogram)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/docs/explore/index.html b/docs/explore/index.html new file mode 100644 index 0000000..d4f7495 --- /dev/null +++ b/docs/explore/index.html @@ -0,0 +1,75 @@ + + + + + + +learning_orchestra_client.explore API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/docs/explore/pca.html b/docs/explore/pca.html new file mode 100644 index 0000000..877a51d --- /dev/null +++ b/docs/explore/pca.html @@ -0,0 +1,742 @@ + + + + + + +learning_orchestra_client.explore.pca API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.explore.pca

    +
    +
    +
    + +Expand source code + +
    from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +from PIL import Image
    +import requests
    +import time
    +from typing import Union
    +
    +
    +class Pca:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/pca"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputPlotName"
    +        self.LABEL = "label"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.WAIT_TIME = 5
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def run_pca_sync(self,
    +                     dataset_name: str,
    +                     pca_name: str,
    +                     label: str,
    +                     pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run PCA algorithm to create an image plot
    +        synchronously, the caller waits until the PCA image is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        dataset_name: Name of dataset.
    +        pca_name: Name of PCA image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a PCA image plot.
    +        """
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: pca_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        self.verify_pca_exist(pca_name, pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PCA IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + pca_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_pca_async(self,
    +                      dataset_name: str,
    +                      pca_name: str,
    +                      label: str,
    +                      pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run PCA algorithm to create an image plot
    +        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
    +
    +        dataset_name: Name of dataset.
    +        pca_name: Name of PCA image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a PCA image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: pca_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PCA IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + pca_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method retrieves all PCAs plot names, it does not
    +        retrieve the image plot.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all PCAs plot names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_pca = self.cluster_url
    +
    +        response = requests.get(cluster_url_pca)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves a PCA image plot.
    +
    +        pca_name: Name of PCA image plot.
    +        pretty_response: If true open an image plot, else return link to
    +        open image plot.
    +
    +        return: A link to an image plot or open an image plot.
    +        """
    +
    +        cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " READ "
    +                + pca_name
    +                + " PCA IMAGE PLOT "
    +                + " ----------"
    +            )
    +            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
    +            img.show()
    +        else:
    +            return cluster_url_pca
    +
    +    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting the PCA image plot.
    +        The delete operation is always synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        pca_name: Represents the PCA name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message.
    +        """
    +
    +        cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +        response = requests.delete(cluster_url_pca)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible to verify if a PCA image
    +        exist into the Learning Orchestra storage mechanism.
    +
    +        pca_name: Name of PCA image plot.
    +
    +        return: True if the PCA requested exist, false if does not.
    +        """
    +
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
    +                                                           "----------")
    +
    +        exist = False
    +        pca_name += ".png"
    +
    +        while not exist:
    +            time.sleep(self.WAIT_TIME)
    +            all_pca = self.search_all_pca()
    +            exist = pca_name in all_pca.get('result')
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Pca +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Pca:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/pca"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputPlotName"
    +        self.LABEL = "label"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.WAIT_TIME = 5
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def run_pca_sync(self,
    +                     dataset_name: str,
    +                     pca_name: str,
    +                     label: str,
    +                     pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run PCA algorithm to create an image plot
    +        synchronously, the caller waits until the PCA image is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        dataset_name: Name of dataset.
    +        pca_name: Name of PCA image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a PCA image plot.
    +        """
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: pca_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        self.verify_pca_exist(pca_name, pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PCA IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + pca_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_pca_async(self,
    +                      dataset_name: str,
    +                      pca_name: str,
    +                      label: str,
    +                      pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run PCA algorithm to create an image plot
    +        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
    +
    +        dataset_name: Name of dataset.
    +        pca_name: Name of PCA image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a PCA image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: pca_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PCA IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + pca_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method retrieves all PCAs plot names, it does not
    +        retrieve the image plot.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all PCAs plot names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_pca = self.cluster_url
    +
    +        response = requests.get(cluster_url_pca)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves a PCA image plot.
    +
    +        pca_name: Name of PCA image plot.
    +        pretty_response: If true open an image plot, else return link to
    +        open image plot.
    +
    +        return: A link to an image plot or open an image plot.
    +        """
    +
    +        cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " READ "
    +                + pca_name
    +                + " PCA IMAGE PLOT "
    +                + " ----------"
    +            )
    +            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
    +            img.show()
    +        else:
    +            return cluster_url_pca
    +
    +    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting the PCA image plot.
    +        The delete operation is always synchronous because it is very fast,
    +        since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        pca_name: Represents the PCA name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message.
    +        """
    +
    +        cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +        response = requests.delete(cluster_url_pca)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible to verify if a PCA image
    +        exist into the Learning Orchestra storage mechanism.
    +
    +        pca_name: Name of PCA image plot.
    +
    +        return: True if the PCA requested exist, false if does not.
    +        """
    +
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
    +                                                           "----------")
    +
    +        exist = False
    +        pca_name += ".png"
    +
    +        while not exist:
    +            time.sleep(self.WAIT_TIME)
    +            all_pca = self.search_all_pca()
    +            exist = pca_name in all_pca.get('result')
    +
    +

    Methods

    +
    +
    +def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for deleting the PCA image plot. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

    +

    pretty_response: If true return indented string, else return dict. +pca_name: Represents the PCA name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message.

    +
    + +Expand source code + +
    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for deleting the PCA image plot.
    +    The delete operation is always synchronous because it is very fast,
    +    since the deletion is performed in background.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    pca_name: Represents the PCA name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message.
    +    """
    +
    +    cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +    response = requests.delete(cluster_url_pca)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_pca_async(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run PCA algorithm to create an image plot +asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.

    +

    dataset_name: Name of dataset. +pca_name: Name of PCA image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a PCA image plot.

    +
    + +Expand source code + +
    def run_pca_async(self,
    +                  dataset_name: str,
    +                  pca_name: str,
    +                  label: str,
    +                  pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method run PCA algorithm to create an image plot
    +    asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
    +
    +    dataset_name: Name of dataset.
    +    pca_name: Name of PCA image plot.
    +    label: The label is the label name of the column for machine learning
    +    datasets which has labeled tuples.
    +    pretty_response: If true open an image plot, else return link to open
    +    image plot.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns a PCA image plot.
    +    """
    +
    +    request_body = {
    +        self.INPUT_NAME: dataset_name,
    +        self.OUTPUT_NAME: pca_name,
    +        self.LABEL: label,
    +    }
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE PCA IMAGE PLOT FROM "
    +            + dataset_name
    +            + " TO "
    +            + pca_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_pca_sync(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run PCA algorithm to create an image plot +synchronously, the caller waits until the PCA image is inserted into +the Learning Orchestra storage mechanism.

    +

    dataset_name: Name of dataset. +pca_name: Name of PCA image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a PCA image plot.

    +
    + +Expand source code + +
    def run_pca_sync(self,
    +                 dataset_name: str,
    +                 pca_name: str,
    +                 label: str,
    +                 pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method run PCA algorithm to create an image plot
    +    synchronously, the caller waits until the PCA image is inserted into
    +    the Learning Orchestra storage mechanism.
    +
    +    dataset_name: Name of dataset.
    +    pca_name: Name of PCA image plot.
    +    label: The label is the label name of the column for machine learning
    +    datasets which has labeled tuples.
    +    pretty_response: If true open an image plot, else return link to open
    +    image plot.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns a PCA image plot.
    +    """
    +    request_body = {
    +        self.INPUT_NAME: dataset_name,
    +        self.OUTPUT_NAME: pca_name,
    +        self.LABEL: label,
    +    }
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    self.verify_pca_exist(pca_name, pretty_response)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE PCA IMAGE PLOT FROM "
    +            + dataset_name
    +            + " TO "
    +            + pca_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_all_pca(self, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method retrieves all PCAs plot names, it does not +retrieve the image plot.

    +

    pretty_response: If true return indented string, else return dict.

    +

    return: A list with all PCAs plot names stored in Learning Orchestra +or an empty result.

    +
    + +Expand source code + +
    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method retrieves all PCAs plot names, it does not
    +    retrieve the image plot.
    +
    +    pretty_response: If true return indented string, else return dict.
    +
    +    return: A list with all PCAs plot names stored in Learning Orchestra
    +    or an empty result.
    +    """
    +
    +    cluster_url_pca = self.cluster_url
    +
    +    response = requests.get(cluster_url_pca)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method retrieves a PCA image plot.

    +

    pca_name: Name of PCA image plot. +pretty_response: If true open an image plot, else return link to +open image plot.

    +

    return: A link to an image plot or open an image plot.

    +
    + +Expand source code + +
    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves a PCA image plot.
    +
    +    pca_name: Name of PCA image plot.
    +    pretty_response: If true open an image plot, else return link to
    +    open image plot.
    +
    +    return: A link to an image plot or open an image plot.
    +    """
    +
    +    cluster_url_pca = self.cluster_url + "/" + pca_name
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " READ "
    +            + pca_name
    +            + " PCA IMAGE PLOT "
    +            + " ----------"
    +        )
    +        img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
    +        img.show()
    +    else:
    +        return cluster_url_pca
    +
    +
    +
    +def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible to verify if a PCA image +exist into the Learning Orchestra storage mechanism.

    +

    pca_name: Name of PCA image plot.

    +

    return: True if the PCA requested exist, false if does not.

    +
    + +Expand source code + +
    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible to verify if a PCA image
    +    exist into the Learning Orchestra storage mechanism.
    +
    +    pca_name: Name of PCA image plot.
    +
    +    return: True if the PCA requested exist, false if does not.
    +    """
    +
    +    if pretty_response:
    +        print("\n---------- CHECKING IF " + pca_name + " FINISHED "
    +                                                       "----------")
    +
    +    exist = False
    +    pca_name += ".png"
    +
    +    while not exist:
    +        time.sleep(self.WAIT_TIME)
    +        all_pca = self.search_all_pca()
    +        exist = pca_name in all_pca.get('result')
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/docs/explore/tsne.html b/docs/explore/tsne.html new file mode 100644 index 0000000..b4e1b63 --- /dev/null +++ b/docs/explore/tsne.html @@ -0,0 +1,742 @@ + + + + + + +learning_orchestra_client.explore.tsne API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.explore.tsne

    +
    +
    +
    + +Expand source code + +
    from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +from PIL import Image
    +import requests
    +import time
    +from typing import Union
    +
    +
    +class Tsne:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/tsne"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputPlotName"
    +        self.LABEL = "label"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.WAIT_TIME = 5
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def run_tsne_sync(self,
    +                      dataset_name: str,
    +                      tsne_name: str,
    +                      label: str,
    +                      pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run t_SNE algorithm to create an image plot
    +        synchronously, the caller waits until the t_SNE image is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        dataset_name: Name of dataset.
    +        tsne_name: Name of t_SNE image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a t_SNE image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: tsne_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        self.verify_tsne_exist(tsne_name, pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE TSNE IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + tsne_name
    +                + " ----------"
    +            )
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_tsne_async(self,
    +                       dataset_name: str,
    +                       tsne_name: str,
    +                       label: str,
    +                       pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run t_SNE algorithm to create an image plot
    +        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
    +
    +        dataset_name: Name of dataset.
    +        tsne_name: Name of t_SNE image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a t_SNE image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: tsne_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE TSNE IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + tsne_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_tsne(self, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves all t_SNE plot names, it does not
    +        retrieve the image plot.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all t_SNEs plot names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url
    +
    +        response = requests.get(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves a t_SNE image plot.
    +
    +        tsne_name: Name of t_SNE image plot.
    +        pretty_response: If true open an image plot, else return link to
    +        open image plot.
    +
    +        return: A link to an image plot or open an image plot.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " READ"
    +                + tsne_name
    +                + " tsne IMAGE PLOT "
    +                + " ----------"
    +            )
    +            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
    +            img.show()
    +        else:
    +            return cluster_url_tsne
    +
    +    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting the t_SNE image
    +        plot. The delete operation is always synchronous because it is very
    +        fast, since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        tsne_name: Represents the tsne name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +        response = requests.delete(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible to verify if a t_SNE image
    +        exist into the Learning Orchestra storage mechanism.
    +
    +        tsne_name: Name of t_SNE image plot.
    +
    +        return: True if the t_SNE requested exist, false if does not.
    +        """
    +
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
    +                                                            "----------")
    +
    +        exist = False
    +        tsne_name += ".png"
    +        while not exist:
    +            time.sleep(self.WAIT_TIME)
    +            all_tsne = self.search_all_tsne()
    +            exist = tsne_name in all_tsne.get('result')
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Tsne +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Tsne:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/explore/tsne"
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputPlotName"
    +        self.LABEL = "label"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.WAIT_TIME = 5
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def run_tsne_sync(self,
    +                      dataset_name: str,
    +                      tsne_name: str,
    +                      label: str,
    +                      pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run t_SNE algorithm to create an image plot
    +        synchronously, the caller waits until the t_SNE image is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        dataset_name: Name of dataset.
    +        tsne_name: Name of t_SNE image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a t_SNE image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: tsne_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        self.verify_tsne_exist(tsne_name, pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE TSNE IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + tsne_name
    +                + " ----------"
    +            )
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def run_tsne_async(self,
    +                       dataset_name: str,
    +                       tsne_name: str,
    +                       label: str,
    +                       pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description: This method run t_SNE algorithm to create an image plot
    +        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
    +
    +        dataset_name: Name of dataset.
    +        tsne_name: Name of t_SNE image plot.
    +        label: The label is the label name of the column for machine learning
    +        datasets which has labeled tuples.
    +        pretty_response: If true open an image plot, else return link to open
    +        image plot.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns a t_SNE image plot.
    +        """
    +
    +        request_body = {
    +            self.INPUT_NAME: dataset_name,
    +            self.OUTPUT_NAME: tsne_name,
    +            self.LABEL: label,
    +        }
    +        request_url = self.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE TSNE IMAGE PLOT FROM "
    +                + dataset_name
    +                + " TO "
    +                + tsne_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_all_tsne(self, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves all t_SNE plot names, it does not
    +        retrieve the image plot.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all t_SNEs plot names stored in Learning Orchestra
    +        or an empty result.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url
    +
    +        response = requests.get(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves a t_SNE image plot.
    +
    +        tsne_name: Name of t_SNE image plot.
    +        pretty_response: If true open an image plot, else return link to
    +        open image plot.
    +
    +        return: A link to an image plot or open an image plot.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " READ"
    +                + tsne_name
    +                + " tsne IMAGE PLOT "
    +                + " ----------"
    +            )
    +            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
    +            img.show()
    +        else:
    +            return cluster_url_tsne
    +
    +    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible for deleting the t_SNE image
    +        plot. The delete operation is always synchronous because it is very
    +        fast, since the deletion is performed in background.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        tsne_name: Represents the tsne name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message.
    +        """
    +
    +        cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +        response = requests.delete(cluster_url_tsne)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method is responsible to verify if a t_SNE image
    +        exist into the Learning Orchestra storage mechanism.
    +
    +        tsne_name: Name of t_SNE image plot.
    +
    +        return: True if the t_SNE requested exist, false if does not.
    +        """
    +
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
    +                                                            "----------")
    +
    +        exist = False
    +        tsne_name += ".png"
    +        while not exist:
    +            time.sleep(self.WAIT_TIME)
    +            all_tsne = self.search_all_tsne()
    +            exist = tsne_name in all_tsne.get('result')
    +
    +

    Methods

    +
    +
    +def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible for deleting the t_SNE image +plot. The delete operation is always synchronous because it is very +fast, since the deletion is performed in background.

    +

    pretty_response: If true return indented string, else return dict. +tsne_name: Represents the tsne name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message.

    +
    + +Expand source code + +
    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible for deleting the t_SNE image
    +    plot. The delete operation is always synchronous because it is very
    +    fast, since the deletion is performed in background.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    tsne_name: Represents the tsne name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message.
    +    """
    +
    +    cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +    response = requests.delete(cluster_url_tsne)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_tsne_async(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run t_SNE algorithm to create an image plot +asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.

    +

    dataset_name: Name of dataset. +tsne_name: Name of t_SNE image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a t_SNE image plot.

    +
    + +Expand source code + +
    def run_tsne_async(self,
    +                   dataset_name: str,
    +                   tsne_name: str,
    +                   label: str,
    +                   pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method run t_SNE algorithm to create an image plot
    +    asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
    +
    +    dataset_name: Name of dataset.
    +    tsne_name: Name of t_SNE image plot.
    +    label: The label is the label name of the column for machine learning
    +    datasets which has labeled tuples.
    +    pretty_response: If true open an image plot, else return link to open
    +    image plot.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns a t_SNE image plot.
    +    """
    +
    +    request_body = {
    +        self.INPUT_NAME: dataset_name,
    +        self.OUTPUT_NAME: tsne_name,
    +        self.LABEL: label,
    +    }
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE TSNE IMAGE PLOT FROM "
    +            + dataset_name
    +            + " TO "
    +            + tsne_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def run_tsne_sync(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method run t_SNE algorithm to create an image plot +synchronously, the caller waits until the t_SNE image is inserted into +the Learning Orchestra storage mechanism.

    +

    dataset_name: Name of dataset. +tsne_name: Name of t_SNE image plot. +label: The label is the label name of the column for machine learning +datasets which has labeled tuples. +pretty_response: If true open an image plot, else return link to open +image plot.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns a t_SNE image plot.

    +
    + +Expand source code + +
    def run_tsne_sync(self,
    +                  dataset_name: str,
    +                  tsne_name: str,
    +                  label: str,
    +                  pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description: This method run t_SNE algorithm to create an image plot
    +    synchronously, the caller waits until the t_SNE image is inserted into
    +    the Learning Orchestra storage mechanism.
    +
    +    dataset_name: Name of dataset.
    +    tsne_name: Name of t_SNE image plot.
    +    label: The label is the label name of the column for machine learning
    +    datasets which has labeled tuples.
    +    pretty_response: If true open an image plot, else return link to open
    +    image plot.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns a t_SNE image plot.
    +    """
    +
    +    request_body = {
    +        self.INPUT_NAME: dataset_name,
    +        self.OUTPUT_NAME: tsne_name,
    +        self.LABEL: label,
    +    }
    +    request_url = self.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    self.verify_tsne_exist(tsne_name, pretty_response)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE TSNE IMAGE PLOT FROM "
    +            + dataset_name
    +            + " TO "
    +            + tsne_name
    +            + " ----------"
    +        )
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_all_tsne(self, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method retrieves all t_SNE plot names, it does not +retrieve the image plot.

    +

    pretty_response: If true return indented string, else return dict.

    +

    return: A list with all t_SNEs plot names stored in Learning Orchestra +or an empty result.

    +
    + +Expand source code + +
    def search_all_tsne(self, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves all t_SNE plot names, it does not
    +    retrieve the image plot.
    +
    +    pretty_response: If true return indented string, else return dict.
    +
    +    return: A list with all t_SNEs plot names stored in Learning Orchestra
    +    or an empty result.
    +    """
    +
    +    cluster_url_tsne = self.cluster_url
    +
    +    response = requests.get(cluster_url_tsne)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method retrieves a t_SNE image plot.

    +

    tsne_name: Name of t_SNE image plot. +pretty_response: If true open an image plot, else return link to +open image plot.

    +

    return: A link to an image plot or open an image plot.

    +
    + +Expand source code + +
    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves a t_SNE image plot.
    +
    +    tsne_name: Name of t_SNE image plot.
    +    pretty_response: If true open an image plot, else return link to
    +    open image plot.
    +
    +    return: A link to an image plot or open an image plot.
    +    """
    +
    +    cluster_url_tsne = self.cluster_url + "/" + tsne_name
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " READ"
    +            + tsne_name
    +            + " tsne IMAGE PLOT "
    +            + " ----------"
    +        )
    +        img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
    +        img.show()
    +    else:
    +        return cluster_url_tsne
    +
    +
    +
    +def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method is responsible to verify if a t_SNE image +exist into the Learning Orchestra storage mechanism.

    +

    tsne_name: Name of t_SNE image plot.

    +

    return: True if the t_SNE requested exist, false if does not.

    +
    + +Expand source code + +
    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method is responsible to verify if a t_SNE image
    +    exist into the Learning Orchestra storage mechanism.
    +
    +    tsne_name: Name of t_SNE image plot.
    +
    +    return: True if the t_SNE requested exist, false if does not.
    +    """
    +
    +    if pretty_response:
    +        print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
    +                                                        "----------")
    +
    +    exist = False
    +    tsne_name += ".png"
    +    while not exist:
    +        time.sleep(self.WAIT_TIME)
    +        all_tsne = self.search_all_tsne()
    +        exist = tsne_name in all_tsne.get('result')
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..64b720b --- /dev/null +++ b/docs/index.html @@ -0,0 +1,85 @@ + + + + + + +learning_orchestra_client API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/docs/observer.html b/docs/observer.html new file mode 100644 index 0000000..a7d3aee --- /dev/null +++ b/docs/observer.html @@ -0,0 +1,375 @@ + + + + + + +learning_orchestra_client.observer API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.observer

    +
    +
    +
    + +Expand source code + +
    from pymongo import MongoClient, change_stream
    +
    +
    +class Observer:
    +    def __init__(self, dataset_name: str, cluster_ip: str):
    +        self.dataset_name = dataset_name
    +
    +        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
    +        mongo_client = MongoClient(mongo_url)
    +        self.database = mongo_client['database']
    +
    +    def set_dataset_name(self, dataset_name: str):
    +        """
    +        :description: Changes the dataset name used in object.
    +        :param dataset_name: Name of dataset to observe.
    +
    +        :return: None.
    +        """
    +        self.dataset_name = dataset_name
    +
    +    def get_dataset_name(self) -> str:
    +        """
    +        :description: Retrieve the dataset name used in object.
    +
    +        :return: The dataset name.
    +        """
    +        return self.dataset_name
    +
    +    def observe_processing(self, pretty_response: bool = False) -> dict:
    +        """
    +        :description: Observe the finished processing status from some
    +        processing, blocking the code execution until finish processing.
    +
    +        :return: A dict with metadata file of used dataset name.
    +        """
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
    +                                                                    "----------")
    +        dataset_collection = self.database[self.dataset_name]
    +        metadata_query = {"_id": 0}
    +        dataset_metadata = dataset_collection.find_one(metadata_query)
    +
    +        if dataset_metadata is None:
    +            print("Dataset name or dataset URL invalid")
    +            exit()
    +
    +        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').next()['fullDocument']
    +
    +    def observe_storage(self) -> change_stream.CollectionChangeStream:
    +        """
    +        :description: Get all changes from a dataset
    +
    +        :return: A pymongo CollectionChangeStream object, use the builtin
    +        next() method to iterate over changes.
    +        """
    +
    +        observer_query = [
    +            {'$match': {
    +                '$or': [
    +                    {'operationType': 'replace'},
    +                    {'operationType': 'insert'},
    +                    {'operationType': 'update'},
    +                    {'operationType': 'delete'}
    +
    +                ]
    +            }}
    +        ]
    +        return self.database[self.dataset_name].watch(
    +            observer_query,
    +            full_document='updateLookup')
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Observer +(dataset_name: str, cluster_ip: str) +
    +
    +
    +
    + +Expand source code + +
    class Observer:
    +    def __init__(self, dataset_name: str, cluster_ip: str):
    +        self.dataset_name = dataset_name
    +
    +        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
    +        mongo_client = MongoClient(mongo_url)
    +        self.database = mongo_client['database']
    +
    +    def set_dataset_name(self, dataset_name: str):
    +        """
    +        :description: Changes the dataset name used in object.
    +        :param dataset_name: Name of dataset to observe.
    +
    +        :return: None.
    +        """
    +        self.dataset_name = dataset_name
    +
    +    def get_dataset_name(self) -> str:
    +        """
    +        :description: Retrieve the dataset name used in object.
    +
    +        :return: The dataset name.
    +        """
    +        return self.dataset_name
    +
    +    def observe_processing(self, pretty_response: bool = False) -> dict:
    +        """
    +        :description: Observe the finished processing status from some
    +        processing, blocking the code execution until finish processing.
    +
    +        :return: A dict with metadata file of used dataset name.
    +        """
    +        if pretty_response:
    +            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
    +                                                                    "----------")
    +        dataset_collection = self.database[self.dataset_name]
    +        metadata_query = {"_id": 0}
    +        dataset_metadata = dataset_collection.find_one(metadata_query)
    +
    +        if dataset_metadata is None:
    +            print("Dataset name or dataset URL invalid")
    +            exit()
    +
    +        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').next()['fullDocument']
    +
    +    def observe_storage(self) -> change_stream.CollectionChangeStream:
    +        """
    +        :description: Get all changes from a dataset
    +
    +        :return: A pymongo CollectionChangeStream object, use the builtin
    +        next() method to iterate over changes.
    +        """
    +
    +        observer_query = [
    +            {'$match': {
    +                '$or': [
    +                    {'operationType': 'replace'},
    +                    {'operationType': 'insert'},
    +                    {'operationType': 'update'},
    +                    {'operationType': 'delete'}
    +
    +                ]
    +            }}
    +        ]
    +        return self.database[self.dataset_name].watch(
    +            observer_query,
    +            full_document='updateLookup')
    +
    +

    Methods

    +
    +
    +def get_dataset_name(self) ‑> str +
    +
    +

    :description: Retrieve the dataset name used in object.

    +

    :return: The dataset name.

    +
    + +Expand source code + +
    def get_dataset_name(self) -> str:
    +    """
    +    :description: Retrieve the dataset name used in object.
    +
    +    :return: The dataset name.
    +    """
    +    return self.dataset_name
    +
    +
    +
    +def observe_processing(self, pretty_response: bool = False) ‑> dict +
    +
    +

    :description: Observe the finished processing status from some +processing, blocking the code execution until finish processing.

    +

    :return: A dict with metadata file of used dataset name.

    +
    + +Expand source code + +
    def observe_processing(self, pretty_response: bool = False) -> dict:
    +    """
    +    :description: Observe the finished processing status from some
    +    processing, blocking the code execution until finish processing.
    +
    +    :return: A dict with metadata file of used dataset name.
    +    """
    +    if pretty_response:
    +        print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
    +                                                                "----------")
    +    dataset_collection = self.database[self.dataset_name]
    +    metadata_query = {"_id": 0}
    +    dataset_metadata = dataset_collection.find_one(metadata_query)
    +
    +    if dataset_metadata is None:
    +        print("Dataset name or dataset URL invalid")
    +        exit()
    +
    +    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').next()['fullDocument']
    +
    +
    +
    +def observe_storage(self) ‑> pymongo.change_stream.CollectionChangeStream +
    +
    +

    :description: Get all changes from a dataset

    +

    :return: A pymongo CollectionChangeStream object, use the builtin +next() method to iterate over changes.

    +
    + +Expand source code + +
    def observe_storage(self) -> change_stream.CollectionChangeStream:
    +    """
    +    :description: Get all changes from a dataset
    +
    +    :return: A pymongo CollectionChangeStream object, use the builtin
    +    next() method to iterate over changes.
    +    """
    +
    +    observer_query = [
    +        {'$match': {
    +            '$or': [
    +                {'operationType': 'replace'},
    +                {'operationType': 'insert'},
    +                {'operationType': 'update'},
    +                {'operationType': 'delete'}
    +
    +            ]
    +        }}
    +    ]
    +    return self.database[self.dataset_name].watch(
    +        observer_query,
    +        full_document='updateLookup')
    +
    +
    +
    +def set_dataset_name(self, dataset_name: str) +
    +
    +

    :description: Changes the dataset name used in object. +:param dataset_name: Name of dataset to observe.

    +

    :return: None.

    +
    + +Expand source code + +
    def set_dataset_name(self, dataset_name: str):
    +    """
    +    :description: Changes the dataset name used in object.
    +    :param dataset_name: Name of dataset to observe.
    +
    +    :return: None.
    +    """
    +    self.dataset_name = dataset_name
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/docs/response_treat.html b/docs/response_treat.html new file mode 100644 index 0000000..2c8bb2a --- /dev/null +++ b/docs/response_treat.html @@ -0,0 +1,197 @@ + + + + + + +learning_orchestra_client.response_treat API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.response_treat

    +
    +
    +
    + +Expand source code + +
    __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
    +__credits__ = "all free source developers"
    +__status__ = "Prototype"
    +
    +import json
    +
    +
    +class ResponseTreat:
    +    HTTP_CREATED = 201
    +    HTTP_SUCCESS = 200
    +    HTTP_ERROR = 500
    +
    +    def treatment(self, response, pretty_response: bool = True):
    +        """
    +        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:
    +            return response.text
    +        elif (
    +                response.status_code != self.HTTP_SUCCESS
    +                and response.status_code != self.HTTP_CREATED
    +        ):
    +            raise Exception(response.json()["result"])
    +        else:
    +            if pretty_response:
    +                return json.dumps(response.json(), indent=4, sort_keys=True)
    +            else:
    +                return response.json()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class ResponseTreat +
    +
    +
    +
    + +Expand source code + +
    class ResponseTreat:
    +    HTTP_CREATED = 201
    +    HTTP_SUCCESS = 200
    +    HTTP_ERROR = 500
    +
    +    def treatment(self, response, pretty_response: bool = True):
    +        """
    +        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:
    +            return response.text
    +        elif (
    +                response.status_code != self.HTTP_SUCCESS
    +                and response.status_code != self.HTTP_CREATED
    +        ):
    +            raise Exception(response.json()["result"])
    +        else:
    +            if pretty_response:
    +                return json.dumps(response.json(), indent=4, sort_keys=True)
    +            else:
    +                return response.json()
    +
    +

    Class variables

    +
    +
    var HTTP_CREATED
    +
    +
    +
    +
    var HTTP_ERROR
    +
    +
    +
    +
    var HTTP_SUCCESS
    +
    +
    +
    +
    +

    Methods

    +
    +
    +def treatment(self, response, pretty_response: bool = True) +
    +
    +

    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.

    +
    + +Expand source code + +
    def treatment(self, response, pretty_response: bool = True):
    +    """
    +    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:
    +        return response.text
    +    elif (
    +            response.status_code != self.HTTP_SUCCESS
    +            and response.status_code != self.HTTP_CREATED
    +    ):
    +        raise Exception(response.json()["result"])
    +    else:
    +        if pretty_response:
    +            return json.dumps(response.json(), indent=4, sort_keys=True)
    +        else:
    +            return response.json()
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/docs/transform/data_type.html b/docs/transform/data_type.html new file mode 100644 index 0000000..fcd25c1 --- /dev/null +++ b/docs/transform/data_type.html @@ -0,0 +1,199 @@ + + + + + + +learning_orchestra_client.transform.data_type API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.transform.data_type

    +
    +
    +
    + +Expand source code + +
    from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +import requests
    +from typing import Union
    +
    +
    +class DataType:
    +    def __init__(self, ip_from_cluster):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/transform/dataType"
    +        self.ResponseTreat = ResponseTreat()
    +        self.Dataset = Dataset(ip_from_cluster)
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.TYPES = "types"
    +
    +    def update_dataset_types(self,
    +                             dataset_name: str,
    +                             fields_change: dict,
    +                             pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: Change types of fields to number or string.
    +
    +        dataset_name: Represents the dataset name.
    +        fields_change: Fields to change with types. This is a dict with each
    +        key:value being field:type
    +
    +        return: A JSON object with error or warning messages.
    +        """
    +
    +        url_request = self.cluster_url
    +        body_request = {
    +            self.INPUT_NAME: dataset_name,
    +            self.TYPES: fields_change
    +        }
    +
    +        response = requests.patch(url=url_request, json=body_request)
    +
    +        return self.ResponseTreat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class DataType +(ip_from_cluster) +
    +
    +
    +
    + +Expand source code + +
    class DataType:
    +    def __init__(self, ip_from_cluster):
    +        self.CLUSTER_IP = ip_from_cluster
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/transform/dataType"
    +        self.ResponseTreat = ResponseTreat()
    +        self.Dataset = Dataset(ip_from_cluster)
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.TYPES = "types"
    +
    +    def update_dataset_types(self,
    +                             dataset_name: str,
    +                             fields_change: dict,
    +                             pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: Change types of fields to number or string.
    +
    +        dataset_name: Represents the dataset name.
    +        fields_change: Fields to change with types. This is a dict with each
    +        key:value being field:type
    +
    +        return: A JSON object with error or warning messages.
    +        """
    +
    +        url_request = self.cluster_url
    +        body_request = {
    +            self.INPUT_NAME: dataset_name,
    +            self.TYPES: fields_change
    +        }
    +
    +        response = requests.patch(url=url_request, json=body_request)
    +
    +        return self.ResponseTreat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +def update_dataset_types(self, dataset_name: str, fields_change: dict, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: Change types of fields to number or string.

    +

    dataset_name: Represents the dataset name. +fields_change: Fields to change with types. This is a dict with each +key:value being field:type

    +

    return: A JSON object with error or warning messages.

    +
    + +Expand source code + +
    def update_dataset_types(self,
    +                         dataset_name: str,
    +                         fields_change: dict,
    +                         pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: Change types of fields to number or string.
    +
    +    dataset_name: Represents the dataset name.
    +    fields_change: Fields to change with types. This is a dict with each
    +    key:value being field:type
    +
    +    return: A JSON object with error or warning messages.
    +    """
    +
    +    url_request = self.cluster_url
    +    body_request = {
    +        self.INPUT_NAME: dataset_name,
    +        self.TYPES: fields_change
    +    }
    +
    +    response = requests.patch(url=url_request, json=body_request)
    +
    +    return self.ResponseTreat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/docs/transform/index.html b/docs/transform/index.html new file mode 100644 index 0000000..271146f --- /dev/null +++ b/docs/transform/index.html @@ -0,0 +1,70 @@ + + + + + + +learning_orchestra_client.transform API documentation + + + + + + + + + + + +
    + + +
    + + + \ No newline at end of file diff --git a/docs/transform/projection.html b/docs/transform/projection.html new file mode 100644 index 0000000..7e84007 --- /dev/null +++ b/docs/transform/projection.html @@ -0,0 +1,1035 @@ + + + + + + +learning_orchestra_client.transform.projection API documentation + + + + + + + + + + + +
    +
    +
    +

    Module learning_orchestra_client.transform.projection

    +
    +
    +
    + +Expand source code + +
    from ..response_treat import ResponseTreat
    +from ..dataset.dataset import Dataset
    +from ..observer import Observer
    +import requests
    +from typing import Union
    +
    +
    +class Projection:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/transform/projection"
    +        self.METADATA_INDEX = 0
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputDatasetName"
    +        self.FIELDS = "names"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def insert_dataset_attributes_sync(self,
    +                                       dataset_name: str,
    +                                       projection_name: str,
    +                                       fields: list,
    +                                       pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method inserts a set of attributes into a dataset
    +        synchronously, the caller waits until the projection is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields: Represents the set of attributes to be inserted. This is list
    +        with all 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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(projection_name, self.CLUSTER_IP).observe_processing(
    +            pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PROJECTION FROM "
    +                + dataset_name
    +                + " TO "
    +                + projection_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def insert_dataset_attributes_async(self,
    +                                        dataset_name: str,
    +                                        projection_name: str,
    +                                        fields: list,
    +                                        pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method inserts a set of attributes into a dataset
    +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields: Represents the set of attributes to be inserted. This is list
    +        with all 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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PROJECTION FROM "
    +                + dataset_name
    +                + " TO "
    +                + projection_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def delete_dataset_attributes_sync(self,
    +                                       dataset_name: str,
    +                                       projection_name: str,
    +                                       fields_to_delete: list,
    +                                       pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method delete a set of attributes on a dataset
    +        synchronously, the caller waits until the projection is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields_to_delete: Represents the set of attributes to be inserted.
    +        This is list with all attributes.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns the projection metadata.
    +        """
    +        dataset_metadata = self.search_projections_content(dataset_name,
    +                                                           limit=1)
    +
    +        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +            .get('fields')
    +        for field in fields_to_delete:
    +            fields_to_insert.remove(field)
    +
    +        response = self.insert_dataset_attributes_sync(dataset_name,
    +                                                       projection_name,
    +                                                       fields_to_insert,
    +                                                       pretty_response)
    +
    +        return response
    +
    +    def delete_dataset_attributes_async(self,
    +                                        dataset_name: str,
    +                                        projection_name: str,
    +                                        fields_to_delete: list,
    +                                        pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method delete a set of attributes into a dataset
    +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields_to_delete: Represents the set of attributes to be inserted.
    +        This is list with all attributes.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns the projection metadata.
    +        """
    +        dataset_metadata = self.search_projections_content(dataset_name,
    +                                                           limit=1)
    +
    +        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +            .get('fields')
    +        for field in fields_to_delete:
    +            fields_to_insert.remove(field)
    +
    +        response = self.insert_dataset_attributes_async(dataset_name,
    +                                                        projection_name,
    +                                                        fields_to_insert,
    +                                                        pretty_response)
    +
    +        return response
    +
    +    def search_all_projections(self, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves all projection metadata, it does not
    +        retrieve the projection content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all projections metadata stored in Learning
    +        Orchestra or an empty result.
    +        """
    +        cluster_url_projection = self.cluster_url
    +
    +        response = requests.get(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_projections(self, projection_name: str,
    +                           pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description:  This method is responsible for retrieving a specific
    +        projection.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
    +        error if there is no such projections.
    +        """
    +        pretty = pretty_response
    +
    +        response = self.search_projections_content(projection_name, limit=1,
    +                                                   pretty_response=pretty)
    +
    +        return response
    +
    +    def search_projections_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 dataset
    +        content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        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.
    +        """
    +
    +        cluster_url_projection = self.cluster_url + "/" + projection_name + \
    +                                 "?query=" + str(query) + \
    +                                 "&limit=" + str(limit) + \
    +                                 "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def delete_projections(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 synchronous because it is very fast,
    +        since the deletion is performed in background. If a projection was
    +        used by another task (Ex. histogram, pca, tuning and so forth),
    +        it cannot be deleted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +        cluster_url_projection = self.cluster_url + "/" + projection_name
    +
    +        response = requests.delete(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Classes

    +
    +
    +class Projection +(ip_from_cluster: str) +
    +
    +
    +
    + +Expand source code + +
    class Projection:
    +    def __init__(self, ip_from_cluster: str):
    +        self.cluster_url = "http://" + ip_from_cluster + \
    +                           "/api/learningOrchestra/v1/transform/projection"
    +        self.METADATA_INDEX = 0
    +        self.response_treat = ResponseTreat()
    +        self.INPUT_NAME = "inputDatasetName"
    +        self.OUTPUT_NAME = "outputDatasetName"
    +        self.FIELDS = "names"
    +        self.dataset = Dataset(ip_from_cluster)
    +        self.CLUSTER_IP = ip_from_cluster
    +
    +    def insert_dataset_attributes_sync(self,
    +                                       dataset_name: str,
    +                                       projection_name: str,
    +                                       fields: list,
    +                                       pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method inserts a set of attributes into a dataset
    +        synchronously, the caller waits until the projection is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields: Represents the set of attributes to be inserted. This is list
    +        with all 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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        Observer(projection_name, self.CLUSTER_IP).observe_processing(
    +            pretty_response)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PROJECTION FROM "
    +                + dataset_name
    +                + " TO "
    +                + projection_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def insert_dataset_attributes_async(self,
    +                                        dataset_name: str,
    +                                        projection_name: str,
    +                                        fields: list,
    +                                        pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method inserts a set of attributes into a dataset
    +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields: Represents the set of attributes to be inserted. This is list
    +        with all 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.cluster_url
    +
    +        response = requests.post(url=request_url, json=request_body)
    +
    +        if pretty_response:
    +            print(
    +                "\n----------"
    +                + " CREATE PROJECTION FROM "
    +                + dataset_name
    +                + " TO "
    +                + projection_name
    +                + " ----------"
    +            )
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def delete_dataset_attributes_sync(self,
    +                                       dataset_name: str,
    +                                       projection_name: str,
    +                                       fields_to_delete: list,
    +                                       pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method delete a set of attributes on a dataset
    +        synchronously, the caller waits until the projection is inserted into
    +        the Learning Orchestra storage mechanism.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields_to_delete: Represents the set of attributes to be inserted.
    +        This is list with all attributes.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns the projection metadata.
    +        """
    +        dataset_metadata = self.search_projections_content(dataset_name,
    +                                                           limit=1)
    +
    +        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +            .get('fields')
    +        for field in fields_to_delete:
    +            fields_to_insert.remove(field)
    +
    +        response = self.insert_dataset_attributes_sync(dataset_name,
    +                                                       projection_name,
    +                                                       fields_to_insert,
    +                                                       pretty_response)
    +
    +        return response
    +
    +    def delete_dataset_attributes_async(self,
    +                                        dataset_name: str,
    +                                        projection_name: str,
    +                                        fields_to_delete: list,
    +                                        pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method delete a set of attributes into a dataset
    +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +        dataset_name: Represents the dataset name.
    +        fields_to_delete: Represents the set of attributes to be inserted.
    +        This is list with all attributes.
    +
    +        return: A JSON object with error or warning messages. In case of
    +        success, it returns the projection metadata.
    +        """
    +        dataset_metadata = self.search_projections_content(dataset_name,
    +                                                           limit=1)
    +
    +        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +            .get('fields')
    +        for field in fields_to_delete:
    +            fields_to_insert.remove(field)
    +
    +        response = self.insert_dataset_attributes_async(dataset_name,
    +                                                        projection_name,
    +                                                        fields_to_insert,
    +                                                        pretty_response)
    +
    +        return response
    +
    +    def search_all_projections(self, pretty_response: bool = False) \
    +            -> Union[dict, str]:
    +        """
    +        description: This method retrieves all projection metadata, it does not
    +        retrieve the projection content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +
    +        return: A list with all projections metadata stored in Learning
    +        Orchestra or an empty result.
    +        """
    +        cluster_url_projection = self.cluster_url
    +
    +        response = requests.get(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def search_projections(self, projection_name: str,
    +                           pretty_response: bool = False) -> Union[dict, str]:
    +        """
    +        description:  This method is responsible for retrieving a specific
    +        projection.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
    +        error if there is no such projections.
    +        """
    +        pretty = pretty_response
    +
    +        response = self.search_projections_content(projection_name, limit=1,
    +                                                   pretty_response=pretty)
    +
    +        return response
    +
    +    def search_projections_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 dataset
    +        content.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        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.
    +        """
    +
    +        cluster_url_projection = self.cluster_url + "/" + projection_name + \
    +                                 "?query=" + str(query) + \
    +                                 "&limit=" + str(limit) + \
    +                                 "&skip=" + str(skip)
    +
    +        response = requests.get(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +    def delete_projections(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 synchronous because it is very fast,
    +        since the deletion is performed in background. If a projection was
    +        used by another task (Ex. histogram, pca, tuning and so forth),
    +        it cannot be deleted.
    +
    +        pretty_response: If true return indented string, else return dict.
    +        projection_name: Represents the projection name.
    +
    +        return: JSON object with an error message, a warning message or a
    +        correct delete message
    +        """
    +        cluster_url_projection = self.cluster_url + "/" + projection_name
    +
    +        response = requests.delete(cluster_url_projection)
    +
    +        return self.response_treat.treatment(response, pretty_response)
    +
    +

    Methods

    +
    +
    +def delete_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method delete a set of attributes into a dataset +asynchronously, the caller does not wait until the projections 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 projection was inserted.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields_to_delete: Represents the set of attributes to be inserted. +This is list with all attributes.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

    +
    + +Expand source code + +
    def delete_dataset_attributes_async(self,
    +                                    dataset_name: str,
    +                                    projection_name: str,
    +                                    fields_to_delete: list,
    +                                    pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method delete a set of attributes into a dataset
    +    asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +    dataset_name: Represents the dataset name.
    +    fields_to_delete: Represents the set of attributes to be inserted.
    +    This is list with all attributes.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns the projection metadata.
    +    """
    +    dataset_metadata = self.search_projections_content(dataset_name,
    +                                                       limit=1)
    +
    +    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +        .get('fields')
    +    for field in fields_to_delete:
    +        fields_to_insert.remove(field)
    +
    +    response = self.insert_dataset_attributes_async(dataset_name,
    +                                                    projection_name,
    +                                                    fields_to_insert,
    +                                                    pretty_response)
    +
    +    return response
    +
    +
    +
    +def delete_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method delete a set of attributes on a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields_to_delete: Represents the set of attributes to be inserted. +This is list with all attributes.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

    +
    + +Expand source code + +
    def delete_dataset_attributes_sync(self,
    +                                   dataset_name: str,
    +                                   projection_name: str,
    +                                   fields_to_delete: list,
    +                                   pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method delete a set of attributes on a dataset
    +    synchronously, the caller waits until the projection is inserted into
    +    the Learning Orchestra storage mechanism.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +    dataset_name: Represents the dataset name.
    +    fields_to_delete: Represents the set of attributes to be inserted.
    +    This is list with all attributes.
    +
    +    return: A JSON object with error or warning messages. In case of
    +    success, it returns the projection metadata.
    +    """
    +    dataset_metadata = self.search_projections_content(dataset_name,
    +                                                       limit=1)
    +
    +    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
    +        .get('fields')
    +    for field in fields_to_delete:
    +        fields_to_insert.remove(field)
    +
    +    response = self.insert_dataset_attributes_sync(dataset_name,
    +                                                   projection_name,
    +                                                   fields_to_insert,
    +                                                   pretty_response)
    +
    +    return response
    +
    +
    +
    +def delete_projections(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 synchronous because it is very fast, +since the deletion is performed in background. If a projection was +used by another task (Ex. histogram, pca, tuning and so forth), +it cannot be deleted.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name.

    +

    return: JSON object with an error message, a warning message or a +correct delete message

    +
    + +Expand source code + +
    def delete_projections(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 synchronous because it is very fast,
    +    since the deletion is performed in background. If a projection was
    +    used by another task (Ex. histogram, pca, tuning and so forth),
    +    it cannot be deleted.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +
    +    return: JSON object with an error message, a warning message or a
    +    correct delete message
    +    """
    +    cluster_url_projection = self.cluster_url + "/" + projection_name
    +
    +    response = requests.delete(cluster_url_projection)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def insert_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method inserts a set of attributes into a dataset +asynchronously, the caller does not wait until the projections 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 projection was inserted.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all attributes.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

    +
    + +Expand source code + +
    def insert_dataset_attributes_async(self,
    +                                    dataset_name: str,
    +                                    projection_name: str,
    +                                    fields: list,
    +                                    pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method inserts a set of attributes into a dataset
    +    asynchronously, the caller does not wait until the projections 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 projection was inserted.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +    dataset_name: Represents the dataset name.
    +    fields: Represents the set of attributes to be inserted. This is list
    +    with all 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.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE PROJECTION FROM "
    +            + dataset_name
    +            + " TO "
    +            + projection_name
    +            + " ----------"
    +        )
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def insert_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: This method inserts a set of attributes into a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all attributes.

    +

    return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

    +
    + +Expand source code + +
    def insert_dataset_attributes_sync(self,
    +                                   dataset_name: str,
    +                                   projection_name: str,
    +                                   fields: list,
    +                                   pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method inserts a set of attributes into a dataset
    +    synchronously, the caller waits until the projection is inserted into
    +    the Learning Orchestra storage mechanism.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection name.
    +    dataset_name: Represents the dataset name.
    +    fields: Represents the set of attributes to be inserted. This is list
    +    with all 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.cluster_url
    +
    +    response = requests.post(url=request_url, json=request_body)
    +
    +    Observer(projection_name, self.CLUSTER_IP).observe_processing(
    +        pretty_response)
    +
    +    if pretty_response:
    +        print(
    +            "\n----------"
    +            + " CREATE PROJECTION FROM "
    +            + dataset_name
    +            + " TO "
    +            + projection_name
    +            + " ----------"
    +        )
    +
    +    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, it does not +retrieve the projection content.

    +

    pretty_response: If true return indented string, else return dict.

    +

    return: A list with all projections metadata stored in Learning +Orchestra or an empty result.

    +
    + +Expand source code + +
    def search_all_projections(self, pretty_response: bool = False) \
    +        -> Union[dict, str]:
    +    """
    +    description: This method retrieves all projection metadata, it does not
    +    retrieve the projection content.
    +
    +    pretty_response: If true return indented string, else return dict.
    +
    +    return: A list with all projections metadata stored in Learning
    +    Orchestra or an empty result.
    +    """
    +    cluster_url_projection = self.cluster_url
    +
    +    response = requests.get(cluster_url_projection)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +def search_projections(self, projection_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
    +
    +

    description: +This method is responsible for retrieving a specific +projection.

    +

    pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an +error if there is no such projections.

    +
    + +Expand source code + +
    def search_projections(self, projection_name: str,
    +                       pretty_response: bool = False) -> Union[dict, str]:
    +    """
    +    description:  This method is responsible for retrieving a specific
    +    projection.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
    +    error if there is no such projections.
    +    """
    +    pretty = pretty_response
    +
    +    response = self.search_projections_content(projection_name, limit=1,
    +                                               pretty_response=pretty)
    +
    +    return response
    +
    +
    +
    +def search_projections_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 dataset +content.

    +

    pretty_response: If true return indented string, else return dict. +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.

    +
    + +Expand source code + +
    def search_projections_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 dataset
    +    content.
    +
    +    pretty_response: If true return indented string, else return dict.
    +    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.
    +    """
    +
    +    cluster_url_projection = self.cluster_url + "/" + projection_name + \
    +                             "?query=" + str(query) + \
    +                             "&limit=" + str(limit) + \
    +                             "&skip=" + str(skip)
    +
    +    response = requests.get(cluster_url_projection)
    +
    +    return self.response_treat.treatment(response, pretty_response)
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file From 89c3c1a0c54cf086206b3b1daf8b60e5d268ccef Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Mon, 21 Dec 2020 16:46:55 -0300 Subject: [PATCH 09/28] update docs --- docs/builder/builder.html | 790 ------------- docs/builder/index.html | 65 -- docs/dataset/dataset.html | 678 ----------- docs/dataset/index.html | 65 -- docs/explore/histogram.html | 2 +- docs/explore/pca.html | 2 +- docs/explore/tsne.html | 2 +- docs/index.html | 8 +- docs/transform/data_type.html | 2 +- docs/transform/projection.html | 2 +- .../builder/builder.html | 790 ------------- .../builder/index.html | 65 -- .../dataset/dataset.html | 678 ----------- .../dataset/index.html | 65 -- .../explore/histogram.html | 676 ----------- .../explore/index.html | 75 -- .../explore/pca.html | 742 ------------ .../explore/tsne.html | 742 ------------ html/learning_orchestra_client/index.html | 85 -- html/learning_orchestra_client/observer.html | 375 ------ .../response_treat.html | 197 ---- .../transform/data_type.html | 199 ---- .../transform/index.html | 70 -- .../transform/projection.html | 1035 ----------------- 24 files changed, 9 insertions(+), 7401 deletions(-) delete mode 100644 docs/builder/builder.html delete mode 100644 docs/builder/index.html delete mode 100644 docs/dataset/dataset.html delete mode 100644 docs/dataset/index.html delete mode 100644 html/learning_orchestra_client/builder/builder.html delete mode 100644 html/learning_orchestra_client/builder/index.html delete mode 100644 html/learning_orchestra_client/dataset/dataset.html delete mode 100644 html/learning_orchestra_client/dataset/index.html delete mode 100644 html/learning_orchestra_client/explore/histogram.html delete mode 100644 html/learning_orchestra_client/explore/index.html delete mode 100644 html/learning_orchestra_client/explore/pca.html delete mode 100644 html/learning_orchestra_client/explore/tsne.html delete mode 100644 html/learning_orchestra_client/index.html delete mode 100644 html/learning_orchestra_client/observer.html delete mode 100644 html/learning_orchestra_client/response_treat.html delete mode 100644 html/learning_orchestra_client/transform/data_type.html delete mode 100644 html/learning_orchestra_client/transform/index.html delete mode 100644 html/learning_orchestra_client/transform/projection.html diff --git a/docs/builder/builder.html b/docs/builder/builder.html deleted file mode 100644 index f450096..0000000 --- a/docs/builder/builder.html +++ /dev/null @@ -1,790 +0,0 @@ - - - - - - -learning_orchestra_client.builder.builder API documentation - - - - - - - - - - - -
    -
    -
    -

    Module learning_orchestra_client.builder.builder

    -
    -
    -
    - -Expand source code - -
    from ..observer import Observer
    -from ..response_treat import ResponseTreat
    -from ..dataset.dataset import Dataset
    -import requests
    -from typing import Union
    -
    -
    -class Builder:
    -    def __init__(self, ip_from_cluster: str):
    -        self.CLUSTER_IP = ip_from_cluster
    -        self.cluster_url = "http://" + ip_from_cluster + \
    -                           "/api/learningOrchestra/v1/builder"
    -        self.response_treat = ResponseTreat()
    -        self.TRAIN_NAME = "trainDatasetName"
    -        self.TEST_NAME = "testDatasetName"
    -        self.CODE = "modelingCode"
    -        self.CLASSIFIERS_LIST = "classifiersList"
    -        self.dataset = Dataset(ip_from_cluster)
    -        self.METADATA_INDEX = 0
    -
    -    def run_builder_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 resource join several steps of machine
    -        learning workflow (transform, tune, train and evaluate) coupling in
    -        a unique resource, builder creates several model predictions using
    -        your own modeling code using a defined set of classifiers. This is made
    -        synchronously, the caller waits until the model predictions are inserted
    -        into the Learning Orchestra storage mechanism.
    -
    -        train_dataset_name: Represent final train dataset.
    -        test_dataset_name: Represent final test dataset.
    -        modeling_code: Represent Python3 code for pyspark preprocessing model
    -        model_classifiers: list of initial classifiers to be used in model
    -        pretty_response: returns indented string for visualization if True
    -
    -        return: The resulted predictions URIs.
    -        """
    -
    -        if pretty_response:
    -            print(
    -                "\n----------"
    -                + " CREATE MODEL WITH "
    -                + train_dataset_name
    -                + " AND "
    -                + test_dataset_name
    -                + " ----------"
    -            )
    -
    -        request_body_content = {
    -            self.TRAIN_NAME: train_dataset_name,
    -            self.TEST_NAME: test_dataset_name,
    -            self.CODE: modeling_code,
    -            self.CLASSIFIERS_LIST: model_classifiers,
    -        }
    -        response = requests.post(url=self.cluster_url,
    -                                 json=request_body_content)
    -
    -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
    -
    -        for model in model_classifiers:
    -            observer.set_dataset_name(test_dataset_name + model)
    -            observer.observe_processing(pretty_response)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def run_builder_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 resource join several steps of machine
    -        learning workflow (transform, tune, train and evaluate) coupling in
    -        a unique resource, builder creates several model predictions using
    -        your own modeling code using a defined set of classifiers. This is made
    -        asynchronously, the caller does not wait until the model predictions are
    -        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 model predictions are inserted.
    -
    -        train_dataset_name: Represent final train dataset.
    -        test_dataset_name: Represent final test dataset.
    -        modeling_code: Represent Python3 code for pyspark preprocessing model
    -        model_classifiers: list of initial classifiers to be used in model
    -        pretty_response: returns indented string for visualization if True
    -
    -        return: The resulted predictions URIs.
    -        """
    -        if pretty_response:
    -            print(
    -                "\n----------"
    -                + " CREATE MODEL WITH "
    -                + train_dataset_name
    -                + " AND "
    -                + test_dataset_name
    -                + " ----------"
    -            )
    -
    -        request_body_content = {
    -            self.TRAIN_NAME: train_dataset_name,
    -            self.TEST_NAME: test_dataset_name,
    -            self.CODE: modeling_code,
    -            self.CLASSIFIERS_LIST: model_classifiers,
    -        }
    -        response = requests.post(url=self.cluster_url,
    -                                 json=request_body_content)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def search_all_model(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 return indented string, else return dict.
    -
    -        return: A list with all model predictions metadata stored in Learning
    -        Orchestra or an empty result.
    -        """
    -
    -        cluster_url_tsne = self.cluster_url
    -
    -        response = requests.get(cluster_url_tsne)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def search_model_prediction(self,
    -                                model_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 return indented string, else return dict.
    -        model_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 there
    -        is no such projection. The current page is also returned to be used in
    -        future content requests.
    -        """
    -
    -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
    -                              "?query=" + str(query) + \
    -                              "&limit=" + str(limit) + \
    -                              "&skip=" + str(skip)
    -
    -        response = requests.get(cluster_url_dataset)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def search_model(self, model_name: str, pretty_response: bool = False) \
    -            -> Union[dict, str]:
    -        """
    -        description:  This method is responsible for retrieving a specific
    -        model prediction metadata.
    -
    -        pretty_response: If true return indented string, else return dict.
    -        model_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_model_prediction(model_name, limit=1,
    -                                                pretty_response=pretty_response)
    -
    -        return response
    -
    -    def delete_model(self, model_name: str, pretty_response: bool = False) \
    -            -> Union[dict, str]:
    -        """
    -        description: This method is responsible for deleting a model prediction.
    -        The delete operation is always synchronous because it is very fast,
    -        since the deletion is performed in background.
    -
    -        pretty_response: If true return indented string, else return dict.
    -        model_name: Represents the projection name.
    -
    -        return: JSON object with an error message, a warning message or a
    -        correct delete message
    -        """
    -
    -        cluster_url_dataset = self.cluster_url + "/" + model_name
    -
    -        response = requests.delete(cluster_url_dataset)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -

    Classes

    -
    -
    -class Builder -(ip_from_cluster: str) -
    -
    -
    -
    - -Expand source code - -
    class Builder:
    -    def __init__(self, ip_from_cluster: str):
    -        self.CLUSTER_IP = ip_from_cluster
    -        self.cluster_url = "http://" + ip_from_cluster + \
    -                           "/api/learningOrchestra/v1/builder"
    -        self.response_treat = ResponseTreat()
    -        self.TRAIN_NAME = "trainDatasetName"
    -        self.TEST_NAME = "testDatasetName"
    -        self.CODE = "modelingCode"
    -        self.CLASSIFIERS_LIST = "classifiersList"
    -        self.dataset = Dataset(ip_from_cluster)
    -        self.METADATA_INDEX = 0
    -
    -    def run_builder_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 resource join several steps of machine
    -        learning workflow (transform, tune, train and evaluate) coupling in
    -        a unique resource, builder creates several model predictions using
    -        your own modeling code using a defined set of classifiers. This is made
    -        synchronously, the caller waits until the model predictions are inserted
    -        into the Learning Orchestra storage mechanism.
    -
    -        train_dataset_name: Represent final train dataset.
    -        test_dataset_name: Represent final test dataset.
    -        modeling_code: Represent Python3 code for pyspark preprocessing model
    -        model_classifiers: list of initial classifiers to be used in model
    -        pretty_response: returns indented string for visualization if True
    -
    -        return: The resulted predictions URIs.
    -        """
    -
    -        if pretty_response:
    -            print(
    -                "\n----------"
    -                + " CREATE MODEL WITH "
    -                + train_dataset_name
    -                + " AND "
    -                + test_dataset_name
    -                + " ----------"
    -            )
    -
    -        request_body_content = {
    -            self.TRAIN_NAME: train_dataset_name,
    -            self.TEST_NAME: test_dataset_name,
    -            self.CODE: modeling_code,
    -            self.CLASSIFIERS_LIST: model_classifiers,
    -        }
    -        response = requests.post(url=self.cluster_url,
    -                                 json=request_body_content)
    -
    -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
    -
    -        for model in model_classifiers:
    -            observer.set_dataset_name(test_dataset_name + model)
    -            observer.observe_processing(pretty_response)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def run_builder_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 resource join several steps of machine
    -        learning workflow (transform, tune, train and evaluate) coupling in
    -        a unique resource, builder creates several model predictions using
    -        your own modeling code using a defined set of classifiers. This is made
    -        asynchronously, the caller does not wait until the model predictions are
    -        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 model predictions are inserted.
    -
    -        train_dataset_name: Represent final train dataset.
    -        test_dataset_name: Represent final test dataset.
    -        modeling_code: Represent Python3 code for pyspark preprocessing model
    -        model_classifiers: list of initial classifiers to be used in model
    -        pretty_response: returns indented string for visualization if True
    -
    -        return: The resulted predictions URIs.
    -        """
    -        if pretty_response:
    -            print(
    -                "\n----------"
    -                + " CREATE MODEL WITH "
    -                + train_dataset_name
    -                + " AND "
    -                + test_dataset_name
    -                + " ----------"
    -            )
    -
    -        request_body_content = {
    -            self.TRAIN_NAME: train_dataset_name,
    -            self.TEST_NAME: test_dataset_name,
    -            self.CODE: modeling_code,
    -            self.CLASSIFIERS_LIST: model_classifiers,
    -        }
    -        response = requests.post(url=self.cluster_url,
    -                                 json=request_body_content)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def search_all_model(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 return indented string, else return dict.
    -
    -        return: A list with all model predictions metadata stored in Learning
    -        Orchestra or an empty result.
    -        """
    -
    -        cluster_url_tsne = self.cluster_url
    -
    -        response = requests.get(cluster_url_tsne)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def search_model_prediction(self,
    -                                model_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 return indented string, else return dict.
    -        model_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 there
    -        is no such projection. The current page is also returned to be used in
    -        future content requests.
    -        """
    -
    -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
    -                              "?query=" + str(query) + \
    -                              "&limit=" + str(limit) + \
    -                              "&skip=" + str(skip)
    -
    -        response = requests.get(cluster_url_dataset)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def search_model(self, model_name: str, pretty_response: bool = False) \
    -            -> Union[dict, str]:
    -        """
    -        description:  This method is responsible for retrieving a specific
    -        model prediction metadata.
    -
    -        pretty_response: If true return indented string, else return dict.
    -        model_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_model_prediction(model_name, limit=1,
    -                                                pretty_response=pretty_response)
    -
    -        return response
    -
    -    def delete_model(self, model_name: str, pretty_response: bool = False) \
    -            -> Union[dict, str]:
    -        """
    -        description: This method is responsible for deleting a model prediction.
    -        The delete operation is always synchronous because it is very fast,
    -        since the deletion is performed in background.
    -
    -        pretty_response: If true return indented string, else return dict.
    -        model_name: Represents the projection name.
    -
    -        return: JSON object with an error message, a warning message or a
    -        correct delete message
    -        """
    -
    -        cluster_url_dataset = self.cluster_url + "/" + model_name
    -
    -        response = requests.delete(cluster_url_dataset)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -

    Methods

    -
    -
    -def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
    -
    -

    description: This method is responsible for deleting a model prediction. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

    -

    pretty_response: If true return indented string, else return dict. -model_name: Represents the projection name.

    -

    return: JSON object with an error message, a warning message or a -correct delete message

    -
    - -Expand source code - -
    def delete_model(self, model_name: str, pretty_response: bool = False) \
    -        -> Union[dict, str]:
    -    """
    -    description: This method is responsible for deleting a model prediction.
    -    The delete operation is always synchronous because it is very fast,
    -    since the deletion is performed in background.
    -
    -    pretty_response: If true return indented string, else return dict.
    -    model_name: Represents the projection name.
    -
    -    return: JSON object with an error message, a warning message or a
    -    correct delete message
    -    """
    -
    -    cluster_url_dataset = self.cluster_url + "/" + model_name
    -
    -    response = requests.delete(cluster_url_dataset)
    -
    -    return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -asynchronously, the caller does not wait until the model predictions are -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 model predictions are inserted.

    -

    train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

    -

    return: The resulted predictions URIs.

    -
    - -Expand source code - -
    def run_builder_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 resource join several steps of machine
    -    learning workflow (transform, tune, train and evaluate) coupling in
    -    a unique resource, builder creates several model predictions using
    -    your own modeling code using a defined set of classifiers. This is made
    -    asynchronously, the caller does not wait until the model predictions are
    -    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 model predictions are inserted.
    -
    -    train_dataset_name: Represent final train dataset.
    -    test_dataset_name: Represent final test dataset.
    -    modeling_code: Represent Python3 code for pyspark preprocessing model
    -    model_classifiers: list of initial classifiers to be used in model
    -    pretty_response: returns indented string for visualization if True
    -
    -    return: The resulted predictions URIs.
    -    """
    -    if pretty_response:
    -        print(
    -            "\n----------"
    -            + " CREATE MODEL WITH "
    -            + train_dataset_name
    -            + " AND "
    -            + test_dataset_name
    -            + " ----------"
    -        )
    -
    -    request_body_content = {
    -        self.TRAIN_NAME: train_dataset_name,
    -        self.TEST_NAME: test_dataset_name,
    -        self.CODE: modeling_code,
    -        self.CLASSIFIERS_LIST: model_classifiers,
    -    }
    -    response = requests.post(url=self.cluster_url,
    -                             json=request_body_content)
    -
    -    return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -synchronously, the caller waits until the model predictions are inserted -into the Learning Orchestra storage mechanism.

    -

    train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

    -

    return: The resulted predictions URIs.

    -
    - -Expand source code - -
    def run_builder_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 resource join several steps of machine
    -    learning workflow (transform, tune, train and evaluate) coupling in
    -    a unique resource, builder creates several model predictions using
    -    your own modeling code using a defined set of classifiers. This is made
    -    synchronously, the caller waits until the model predictions are inserted
    -    into the Learning Orchestra storage mechanism.
    -
    -    train_dataset_name: Represent final train dataset.
    -    test_dataset_name: Represent final test dataset.
    -    modeling_code: Represent Python3 code for pyspark preprocessing model
    -    model_classifiers: list of initial classifiers to be used in model
    -    pretty_response: returns indented string for visualization if True
    -
    -    return: The resulted predictions URIs.
    -    """
    -
    -    if pretty_response:
    -        print(
    -            "\n----------"
    -            + " CREATE MODEL WITH "
    -            + train_dataset_name
    -            + " AND "
    -            + test_dataset_name
    -            + " ----------"
    -        )
    -
    -    request_body_content = {
    -        self.TRAIN_NAME: train_dataset_name,
    -        self.TEST_NAME: test_dataset_name,
    -        self.CODE: modeling_code,
    -        self.CLASSIFIERS_LIST: model_classifiers,
    -    }
    -    response = requests.post(url=self.cluster_url,
    -                             json=request_body_content)
    -
    -    observer = Observer(test_dataset_name, self.CLUSTER_IP)
    -
    -    for model in model_classifiers:
    -        observer.set_dataset_name(test_dataset_name + model)
    -        observer.observe_processing(pretty_response)
    -
    -    return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -def search_all_model(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 return indented string, else return dict.

    -

    return: A list with all model predictions metadata stored in Learning -Orchestra or an empty result.

    -
    - -Expand source code - -
    def search_all_model(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 return indented string, else return dict.
    -
    -    return: A list with all model predictions metadata stored in Learning
    -    Orchestra or an empty result.
    -    """
    -
    -    cluster_url_tsne = self.cluster_url
    -
    -    response = requests.get(cluster_url_tsne)
    -
    -    return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
    -
    -

    description: -This method is responsible for retrieving a specific -model prediction metadata.

    -

    pretty_response: If true return indented string, else return dict. -model_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.

    -
    - -Expand source code - -
    def search_model(self, model_name: str, pretty_response: bool = False) \
    -        -> Union[dict, str]:
    -    """
    -    description:  This method is responsible for retrieving a specific
    -    model prediction metadata.
    -
    -    pretty_response: If true return indented string, else return dict.
    -    model_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_model_prediction(model_name, limit=1,
    -                                            pretty_response=pretty_response)
    -
    -    return response
    -
    -
    -
    -def search_model_prediction(self, model_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 return indented string, else return dict. -model_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 there -is no such projection. The current page is also returned to be used in -future content requests.

    -
    - -Expand source code - -
    def search_model_prediction(self,
    -                            model_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 return indented string, else return dict.
    -    model_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 there
    -    is no such projection. The current page is also returned to be used in
    -    future content requests.
    -    """
    -
    -    cluster_url_dataset = self.cluster_url + "/" + model_name + \
    -                          "?query=" + str(query) + \
    -                          "&limit=" + str(limit) + \
    -                          "&skip=" + str(skip)
    -
    -    response = requests.get(cluster_url_dataset)
    -
    -    return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -
    -
    -
    -
    - -
    - - - \ No newline at end of file diff --git a/docs/builder/index.html b/docs/builder/index.html deleted file mode 100644 index f6061e5..0000000 --- a/docs/builder/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -learning_orchestra_client.builder API documentation - - - - - - - - - - - -
    - - -
    - - - \ No newline at end of file diff --git a/docs/dataset/dataset.html b/docs/dataset/dataset.html deleted file mode 100644 index 64e61be..0000000 --- a/docs/dataset/dataset.html +++ /dev/null @@ -1,678 +0,0 @@ - - - - - - -learning_orchestra_client.dataset.dataset API documentation - - - - - - - - - - - -
    -
    -
    -

    Module learning_orchestra_client.dataset.dataset

    -
    -
    -
    - -Expand source code - -
    __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
    -__credits__ = "all free source developers"
    -__status__ = "Prototype"
    -
    -from ..observer import Observer
    -from ..response_treat import ResponseTreat
    -import requests
    -from typing import Union
    -
    -
    -class Dataset:
    -    def __init__(self, ip_from_cluster: str):
    -        self.cluster_url = "http://" + ip_from_cluster + \
    -                           "/api/learningOrchestra/v1/dataset"
    -        self.response_treat = ResponseTreat()
    -        self.OUTPUT_NAME = "datasetName"
    -        self.URL = "datasetURI"
    -        self.CLUSTER_IP = ip_from_cluster
    -
    -    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 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.
    -        """
    -        request_body = {self.OUTPUT_NAME: dataset_name,
    -                        self.URL: url}
    -        request_url = self.cluster_url
    -
    -        response = requests.post(url=request_url, json=request_body)
    -
    -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
    -
    -        if pretty_response:
    -            print("\n----------" + " CREATED FILE " + 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).
    -        """
    -        request_body = {self.OUTPUT_NAME: dataset_name,
    -                        self.URL: url}
    -        request_url = self.cluster_url
    -
    -        response = requests.post(url=request_url, json=request_body)
    -
    -        if pretty_response:
    -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    -                                                                     "---")
    -        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 return indented string, else return dict.
    -
    -        return: All datasets metadata stored in Learning Orchestra or an empty
    -        result.
    -        """
    -        request_url = self.cluster_url
    -
    -        response = requests.get(request_url)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
    -            -> Union[dict, str]:
    -        """
    -        description: This method is responsible for retrieving a specific
    -        dataset
    -
    -        pretty_response: If true return indented string, else return dict.
    -        dataset_name: Is the name of the dataset file.
    -        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 dataset metadata stored in Learning Orchestra or an
    -        error if there is no such dataset.
    -        """
    -        response = self.search_dataset_content(dataset_name, limit=1,
    -                                               pretty_response=pretty_response)
    -
    -        return 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 return indented string, else return dict.
    -        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.
    -        """
    -
    -        request_url = self.cluster_url + "/" + dataset_name + \
    -                      "?query=" + str(query) + \
    -                      "&limit=" + str(limit) + \
    -                      "&skip=" + str(skip)
    -
    -        response = requests.get(request_url)
    -
    -        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. The
    -        delete operation is always synchronous because it is very fast, since
    -        the deletion is performed in background. If a dataset was used by
    -        another task (Ex. projection, histogram, pca, tuning and so forth), it
    -        cannot be deleted.
    -
    -        pretty_response: If true return indented string, else return dict.
    -        dataset_name: Represents the dataset name.
    -
    -        return: JSON object with an error message, a warning message or a
    -        correct delete message
    -        """
    -
    -        request_url = self.cluster_url + "/" + dataset_name
    -
    -        response = requests.delete(request_url)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -

    Classes

    -
    -
    -class Dataset -(ip_from_cluster: str) -
    -
    -
    -
    - -Expand source code - -
    class Dataset:
    -    def __init__(self, ip_from_cluster: str):
    -        self.cluster_url = "http://" + ip_from_cluster + \
    -                           "/api/learningOrchestra/v1/dataset"
    -        self.response_treat = ResponseTreat()
    -        self.OUTPUT_NAME = "datasetName"
    -        self.URL = "datasetURI"
    -        self.CLUSTER_IP = ip_from_cluster
    -
    -    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 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.
    -        """
    -        request_body = {self.OUTPUT_NAME: dataset_name,
    -                        self.URL: url}
    -        request_url = self.cluster_url
    -
    -        response = requests.post(url=request_url, json=request_body)
    -
    -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
    -
    -        if pretty_response:
    -            print("\n----------" + " CREATED FILE " + 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).
    -        """
    -        request_body = {self.OUTPUT_NAME: dataset_name,
    -                        self.URL: url}
    -        request_url = self.cluster_url
    -
    -        response = requests.post(url=request_url, json=request_body)
    -
    -        if pretty_response:
    -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    -                                                                     "---")
    -        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 return indented string, else return dict.
    -
    -        return: All datasets metadata stored in Learning Orchestra or an empty
    -        result.
    -        """
    -        request_url = self.cluster_url
    -
    -        response = requests.get(request_url)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
    -            -> Union[dict, str]:
    -        """
    -        description: This method is responsible for retrieving a specific
    -        dataset
    -
    -        pretty_response: If true return indented string, else return dict.
    -        dataset_name: Is the name of the dataset file.
    -        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 dataset metadata stored in Learning Orchestra or an
    -        error if there is no such dataset.
    -        """
    -        response = self.search_dataset_content(dataset_name, limit=1,
    -                                               pretty_response=pretty_response)
    -
    -        return 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 return indented string, else return dict.
    -        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.
    -        """
    -
    -        request_url = self.cluster_url + "/" + dataset_name + \
    -                      "?query=" + str(query) + \
    -                      "&limit=" + str(limit) + \
    -                      "&skip=" + str(skip)
    -
    -        response = requests.get(request_url)
    -
    -        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. The
    -        delete operation is always synchronous because it is very fast, since
    -        the deletion is performed in background. If a dataset was used by
    -        another task (Ex. projection, histogram, pca, tuning and so forth), it
    -        cannot be deleted.
    -
    -        pretty_response: If true return indented string, else return dict.
    -        dataset_name: Represents the dataset name.
    -
    -        return: JSON object with an error message, a warning message or a
    -        correct delete message
    -        """
    -
    -        request_url = self.cluster_url + "/" + dataset_name
    -
    -        response = requests.delete(request_url)
    -
    -        return self.response_treat.treatment(response, pretty_response)
    -
    -

    Methods

    -
    -
    -def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] -
    -
    -

    description: This method is responsible for deleting the dataset. The -delete operation is always synchronous because it is very fast, since -the deletion is performed in background. If a dataset was used by -another task (Ex. projection, histogram, pca, tuning and so forth), it -cannot be deleted.

    -

    pretty_response: If true return indented string, else return dict. -dataset_name: Represents the dataset name.

    -

    return: JSON object with an error message, a warning message or a -correct delete message

    -
    - -Expand source code - -
    def delete_dataset(self, dataset_name, pretty_response=False) \
    -        -> Union[dict, str]:
    -    """
    -    description: This method is responsible for deleting the dataset. The
    -    delete operation is always synchronous because it is very fast, since
    -    the deletion is performed in background. If a dataset was used by
    -    another task (Ex. projection, histogram, pca, tuning and so forth), it
    -    cannot be deleted.
    -
    -    pretty_response: If true return indented string, else return dict.
    -    dataset_name: Represents the dataset name.
    -
    -    return: JSON object with an error message, a warning message or a
    -    correct delete message
    -    """
    -
    -    request_url = self.cluster_url + "/" + dataset_name
    -
    -    response = requests.delete(request_url)
    -
    -    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).

    -
    - -Expand source code - -
    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).
    -    """
    -    request_body = {self.OUTPUT_NAME: dataset_name,
    -                    self.URL: url}
    -    request_url = self.cluster_url
    -
    -    response = requests.post(url=request_url, json=request_body)
    -
    -    if pretty_response:
    -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    -                                                                 "---")
    -    return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -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 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.

    -
    - -Expand source code - -
    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 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.
    -    """
    -    request_body = {self.OUTPUT_NAME: dataset_name,
    -                    self.URL: url}
    -    request_url = self.cluster_url
    -
    -    response = requests.post(url=request_url, json=request_body)
    -
    -    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
    -
    -    if pretty_response:
    -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
    -                                                                 "---")
    -    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 return indented string, else return dict.

    -

    return: All datasets metadata stored in Learning Orchestra or an empty -result.

    -
    - -Expand source code - -
    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 return indented string, else return dict.
    -
    -    return: All datasets metadata stored in Learning Orchestra or an empty
    -    result.
    -    """
    -    request_url = self.cluster_url
    -
    -    response = requests.get(request_url)
    -
    -    return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
    -
    -

    description: This method is responsible for retrieving a specific -dataset

    -

    pretty_response: If true return indented string, else return dict. -dataset_name: Is the name of the dataset file. -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 dataset metadata stored in Learning Orchestra or an -error if there is no such dataset.

    -
    - -Expand source code - -
    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
    -        -> Union[dict, str]:
    -    """
    -    description: This method is responsible for retrieving a specific
    -    dataset
    -
    -    pretty_response: If true return indented string, else return dict.
    -    dataset_name: Is the name of the dataset file.
    -    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 dataset metadata stored in Learning Orchestra or an
    -    error if there is no such dataset.
    -    """
    -    response = self.search_dataset_content(dataset_name, limit=1,
    -                                           pretty_response=pretty_response)
    -
    -    return 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 return indented string, else return dict. -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.

    -
    - -Expand source code - -
    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 return indented string, else return dict.
    -    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.
    -    """
    -
    -    request_url = self.cluster_url + "/" + dataset_name + \
    -                  "?query=" + str(query) + \
    -                  "&limit=" + str(limit) + \
    -                  "&skip=" + str(skip)
    -
    -    response = requests.get(request_url)
    -
    -    return self.response_treat.treatment(response, pretty_response)
    -
    -
    -
    -
    -
    -
    -
    - -
    - - - \ No newline at end of file diff --git a/docs/dataset/index.html b/docs/dataset/index.html deleted file mode 100644 index b4c42b2..0000000 --- a/docs/dataset/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -learning_orchestra_client.dataset API documentation - - - - - - - - - - - -
    - - -
    - - - \ No newline at end of file diff --git a/docs/explore/histogram.html b/docs/explore/histogram.html index e1abdfc..a90cf94 100644 --- a/docs/explore/histogram.html +++ b/docs/explore/histogram.html @@ -28,7 +28,7 @@

    Module learning_orchestra_client.explore.histogram
    from ..observer import Observer
     from ..response_treat import ResponseTreat
    -from ..dataset.dataset import Dataset
    +from ..dataset import Dataset
     import requests
     from typing import Union
     
    diff --git a/docs/explore/pca.html b/docs/explore/pca.html
    index 877a51d..7dbc910 100644
    --- a/docs/explore/pca.html
    +++ b/docs/explore/pca.html
    @@ -27,7 +27,7 @@ 

    Module learning_orchestra_client.explore.pca

    Expand source code
    from ..response_treat import ResponseTreat
    -from ..dataset.dataset import Dataset
    +from ..dataset import Dataset
     from PIL import Image
     import requests
     import time
    diff --git a/docs/explore/tsne.html b/docs/explore/tsne.html
    index b4e1b63..15569b0 100644
    --- a/docs/explore/tsne.html
    +++ b/docs/explore/tsne.html
    @@ -27,7 +27,7 @@ 

    Module learning_orchestra_client.explore.tsne

    Expand source code
    from ..response_treat import ResponseTreat
    -from ..dataset.dataset import Dataset
    +from ..dataset import Dataset
     from PIL import Image
     import requests
     import time
    diff --git a/docs/index.html b/docs/index.html
    index 64b720b..9189de8 100644
    --- a/docs/index.html
    +++ b/docs/index.html
    @@ -26,11 +26,11 @@ 

    Package learning_orchestra_client

    Sub-modules

    -
    learning_orchestra_client.builder
    +
    learning_orchestra_client.builder
    -
    learning_orchestra_client.dataset
    +
    learning_orchestra_client.dataset
    @@ -67,8 +67,8 @@

    Index

    • Sub-modules

        -
      • learning_orchestra_client.builder
      • -
      • learning_orchestra_client.dataset
      • +
      • learning_orchestra_client.builder
      • +
      • learning_orchestra_client.dataset
      • learning_orchestra_client.explore
      • learning_orchestra_client.observer
      • learning_orchestra_client.response_treat
      • diff --git a/docs/transform/data_type.html b/docs/transform/data_type.html index fcd25c1..444301d 100644 --- a/docs/transform/data_type.html +++ b/docs/transform/data_type.html @@ -27,7 +27,7 @@

        Module learning_orchestra_client.transform.data_typeExpand source code
        from ..response_treat import ResponseTreat
        -from ..dataset.dataset import Dataset
        +from ..dataset import Dataset
         import requests
         from typing import Union
         
        diff --git a/docs/transform/projection.html b/docs/transform/projection.html
        index 7e84007..6158b25 100644
        --- a/docs/transform/projection.html
        +++ b/docs/transform/projection.html
        @@ -27,7 +27,7 @@ 

        Module learning_orchestra_client.transform.projectionExpand source code
        from ..response_treat import ResponseTreat
        -from ..dataset.dataset import Dataset
        +from ..dataset import Dataset
         from ..observer import Observer
         import requests
         from typing import Union
        diff --git a/html/learning_orchestra_client/builder/builder.html b/html/learning_orchestra_client/builder/builder.html
        deleted file mode 100644
        index f450096..0000000
        --- a/html/learning_orchestra_client/builder/builder.html
        +++ /dev/null
        @@ -1,790 +0,0 @@
        -
        -
        -
        -
        -
        -
        -learning_orchestra_client.builder.builder API documentation
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Module learning_orchestra_client.builder.builder

        -
        -
        -
        - -Expand source code - -
        from ..observer import Observer
        -from ..response_treat import ResponseTreat
        -from ..dataset.dataset import Dataset
        -import requests
        -from typing import Union
        -
        -
        -class Builder:
        -    def __init__(self, ip_from_cluster: str):
        -        self.CLUSTER_IP = ip_from_cluster
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/builder"
        -        self.response_treat = ResponseTreat()
        -        self.TRAIN_NAME = "trainDatasetName"
        -        self.TEST_NAME = "testDatasetName"
        -        self.CODE = "modelingCode"
        -        self.CLASSIFIERS_LIST = "classifiersList"
        -        self.dataset = Dataset(ip_from_cluster)
        -        self.METADATA_INDEX = 0
        -
        -    def run_builder_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 resource join several steps of machine
        -        learning workflow (transform, tune, train and evaluate) coupling in
        -        a unique resource, builder creates several model predictions using
        -        your own modeling code using a defined set of classifiers. This is made
        -        synchronously, the caller waits until the model predictions are inserted
        -        into the Learning Orchestra storage mechanism.
        -
        -        train_dataset_name: Represent final train dataset.
        -        test_dataset_name: Represent final test dataset.
        -        modeling_code: Represent Python3 code for pyspark preprocessing model
        -        model_classifiers: list of initial classifiers to be used in model
        -        pretty_response: returns indented string for visualization if True
        -
        -        return: The resulted predictions URIs.
        -        """
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE MODEL WITH "
        -                + train_dataset_name
        -                + " AND "
        -                + test_dataset_name
        -                + " ----------"
        -            )
        -
        -        request_body_content = {
        -            self.TRAIN_NAME: train_dataset_name,
        -            self.TEST_NAME: test_dataset_name,
        -            self.CODE: modeling_code,
        -            self.CLASSIFIERS_LIST: model_classifiers,
        -        }
        -        response = requests.post(url=self.cluster_url,
        -                                 json=request_body_content)
        -
        -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
        -
        -        for model in model_classifiers:
        -            observer.set_dataset_name(test_dataset_name + model)
        -            observer.observe_processing(pretty_response)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def run_builder_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 resource join several steps of machine
        -        learning workflow (transform, tune, train and evaluate) coupling in
        -        a unique resource, builder creates several model predictions using
        -        your own modeling code using a defined set of classifiers. This is made
        -        asynchronously, the caller does not wait until the model predictions are
        -        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 model predictions are inserted.
        -
        -        train_dataset_name: Represent final train dataset.
        -        test_dataset_name: Represent final test dataset.
        -        modeling_code: Represent Python3 code for pyspark preprocessing model
        -        model_classifiers: list of initial classifiers to be used in model
        -        pretty_response: returns indented string for visualization if True
        -
        -        return: The resulted predictions URIs.
        -        """
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE MODEL WITH "
        -                + train_dataset_name
        -                + " AND "
        -                + test_dataset_name
        -                + " ----------"
        -            )
        -
        -        request_body_content = {
        -            self.TRAIN_NAME: train_dataset_name,
        -            self.TEST_NAME: test_dataset_name,
        -            self.CODE: modeling_code,
        -            self.CLASSIFIERS_LIST: model_classifiers,
        -        }
        -        response = requests.post(url=self.cluster_url,
        -                                 json=request_body_content)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_all_model(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 return indented string, else return dict.
        -
        -        return: A list with all model predictions metadata stored in Learning
        -        Orchestra or an empty result.
        -        """
        -
        -        cluster_url_tsne = self.cluster_url
        -
        -        response = requests.get(cluster_url_tsne)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_model_prediction(self,
        -                                model_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 return indented string, else return dict.
        -        model_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 there
        -        is no such projection. The current page is also returned to be used in
        -        future content requests.
        -        """
        -
        -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
        -                              "?query=" + str(query) + \
        -                              "&limit=" + str(limit) + \
        -                              "&skip=" + str(skip)
        -
        -        response = requests.get(cluster_url_dataset)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_model(self, model_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description:  This method is responsible for retrieving a specific
        -        model prediction metadata.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        model_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_model_prediction(model_name, limit=1,
        -                                                pretty_response=pretty_response)
        -
        -        return response
        -
        -    def delete_model(self, model_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible for deleting a model prediction.
        -        The delete operation is always synchronous because it is very fast,
        -        since the deletion is performed in background.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        model_name: Represents the projection name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message
        -        """
        -
        -        cluster_url_dataset = self.cluster_url + "/" + model_name
        -
        -        response = requests.delete(cluster_url_dataset)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Classes

        -
        -
        -class Builder -(ip_from_cluster: str) -
        -
        -
        -
        - -Expand source code - -
        class Builder:
        -    def __init__(self, ip_from_cluster: str):
        -        self.CLUSTER_IP = ip_from_cluster
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/builder"
        -        self.response_treat = ResponseTreat()
        -        self.TRAIN_NAME = "trainDatasetName"
        -        self.TEST_NAME = "testDatasetName"
        -        self.CODE = "modelingCode"
        -        self.CLASSIFIERS_LIST = "classifiersList"
        -        self.dataset = Dataset(ip_from_cluster)
        -        self.METADATA_INDEX = 0
        -
        -    def run_builder_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 resource join several steps of machine
        -        learning workflow (transform, tune, train and evaluate) coupling in
        -        a unique resource, builder creates several model predictions using
        -        your own modeling code using a defined set of classifiers. This is made
        -        synchronously, the caller waits until the model predictions are inserted
        -        into the Learning Orchestra storage mechanism.
        -
        -        train_dataset_name: Represent final train dataset.
        -        test_dataset_name: Represent final test dataset.
        -        modeling_code: Represent Python3 code for pyspark preprocessing model
        -        model_classifiers: list of initial classifiers to be used in model
        -        pretty_response: returns indented string for visualization if True
        -
        -        return: The resulted predictions URIs.
        -        """
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE MODEL WITH "
        -                + train_dataset_name
        -                + " AND "
        -                + test_dataset_name
        -                + " ----------"
        -            )
        -
        -        request_body_content = {
        -            self.TRAIN_NAME: train_dataset_name,
        -            self.TEST_NAME: test_dataset_name,
        -            self.CODE: modeling_code,
        -            self.CLASSIFIERS_LIST: model_classifiers,
        -        }
        -        response = requests.post(url=self.cluster_url,
        -                                 json=request_body_content)
        -
        -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
        -
        -        for model in model_classifiers:
        -            observer.set_dataset_name(test_dataset_name + model)
        -            observer.observe_processing(pretty_response)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def run_builder_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 resource join several steps of machine
        -        learning workflow (transform, tune, train and evaluate) coupling in
        -        a unique resource, builder creates several model predictions using
        -        your own modeling code using a defined set of classifiers. This is made
        -        asynchronously, the caller does not wait until the model predictions are
        -        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 model predictions are inserted.
        -
        -        train_dataset_name: Represent final train dataset.
        -        test_dataset_name: Represent final test dataset.
        -        modeling_code: Represent Python3 code for pyspark preprocessing model
        -        model_classifiers: list of initial classifiers to be used in model
        -        pretty_response: returns indented string for visualization if True
        -
        -        return: The resulted predictions URIs.
        -        """
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE MODEL WITH "
        -                + train_dataset_name
        -                + " AND "
        -                + test_dataset_name
        -                + " ----------"
        -            )
        -
        -        request_body_content = {
        -            self.TRAIN_NAME: train_dataset_name,
        -            self.TEST_NAME: test_dataset_name,
        -            self.CODE: modeling_code,
        -            self.CLASSIFIERS_LIST: model_classifiers,
        -        }
        -        response = requests.post(url=self.cluster_url,
        -                                 json=request_body_content)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_all_model(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 return indented string, else return dict.
        -
        -        return: A list with all model predictions metadata stored in Learning
        -        Orchestra or an empty result.
        -        """
        -
        -        cluster_url_tsne = self.cluster_url
        -
        -        response = requests.get(cluster_url_tsne)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_model_prediction(self,
        -                                model_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 return indented string, else return dict.
        -        model_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 there
        -        is no such projection. The current page is also returned to be used in
        -        future content requests.
        -        """
        -
        -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
        -                              "?query=" + str(query) + \
        -                              "&limit=" + str(limit) + \
        -                              "&skip=" + str(skip)
        -
        -        response = requests.get(cluster_url_dataset)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_model(self, model_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description:  This method is responsible for retrieving a specific
        -        model prediction metadata.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        model_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_model_prediction(model_name, limit=1,
        -                                                pretty_response=pretty_response)
        -
        -        return response
        -
        -    def delete_model(self, model_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible for deleting a model prediction.
        -        The delete operation is always synchronous because it is very fast,
        -        since the deletion is performed in background.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        model_name: Represents the projection name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message
        -        """
        -
        -        cluster_url_dataset = self.cluster_url + "/" + model_name
        -
        -        response = requests.delete(cluster_url_dataset)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -

        Methods

        -
        -
        -def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method is responsible for deleting a model prediction. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

        -

        pretty_response: If true return indented string, else return dict. -model_name: Represents the projection name.

        -

        return: JSON object with an error message, a warning message or a -correct delete message

        -
        - -Expand source code - -
        def delete_model(self, model_name: str, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method is responsible for deleting a model prediction.
        -    The delete operation is always synchronous because it is very fast,
        -    since the deletion is performed in background.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    model_name: Represents the projection name.
        -
        -    return: JSON object with an error message, a warning message or a
        -    correct delete message
        -    """
        -
        -    cluster_url_dataset = self.cluster_url + "/" + model_name
        -
        -    response = requests.delete(cluster_url_dataset)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -asynchronously, the caller does not wait until the model predictions are -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 model predictions are inserted.

        -

        train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

        -

        return: The resulted predictions URIs.

        -
        - -Expand source code - -
        def run_builder_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 resource join several steps of machine
        -    learning workflow (transform, tune, train and evaluate) coupling in
        -    a unique resource, builder creates several model predictions using
        -    your own modeling code using a defined set of classifiers. This is made
        -    asynchronously, the caller does not wait until the model predictions are
        -    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 model predictions are inserted.
        -
        -    train_dataset_name: Represent final train dataset.
        -    test_dataset_name: Represent final test dataset.
        -    modeling_code: Represent Python3 code for pyspark preprocessing model
        -    model_classifiers: list of initial classifiers to be used in model
        -    pretty_response: returns indented string for visualization if True
        -
        -    return: The resulted predictions URIs.
        -    """
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE MODEL WITH "
        -            + train_dataset_name
        -            + " AND "
        -            + test_dataset_name
        -            + " ----------"
        -        )
        -
        -    request_body_content = {
        -        self.TRAIN_NAME: train_dataset_name,
        -        self.TEST_NAME: test_dataset_name,
        -        self.CODE: modeling_code,
        -        self.CLASSIFIERS_LIST: model_classifiers,
        -    }
        -    response = requests.post(url=self.cluster_url,
        -                             json=request_body_content)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -synchronously, the caller waits until the model predictions are inserted -into the Learning Orchestra storage mechanism.

        -

        train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

        -

        return: The resulted predictions URIs.

        -
        - -Expand source code - -
        def run_builder_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 resource join several steps of machine
        -    learning workflow (transform, tune, train and evaluate) coupling in
        -    a unique resource, builder creates several model predictions using
        -    your own modeling code using a defined set of classifiers. This is made
        -    synchronously, the caller waits until the model predictions are inserted
        -    into the Learning Orchestra storage mechanism.
        -
        -    train_dataset_name: Represent final train dataset.
        -    test_dataset_name: Represent final test dataset.
        -    modeling_code: Represent Python3 code for pyspark preprocessing model
        -    model_classifiers: list of initial classifiers to be used in model
        -    pretty_response: returns indented string for visualization if True
        -
        -    return: The resulted predictions URIs.
        -    """
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE MODEL WITH "
        -            + train_dataset_name
        -            + " AND "
        -            + test_dataset_name
        -            + " ----------"
        -        )
        -
        -    request_body_content = {
        -        self.TRAIN_NAME: train_dataset_name,
        -        self.TEST_NAME: test_dataset_name,
        -        self.CODE: modeling_code,
        -        self.CLASSIFIERS_LIST: model_classifiers,
        -    }
        -    response = requests.post(url=self.cluster_url,
        -                             json=request_body_content)
        -
        -    observer = Observer(test_dataset_name, self.CLUSTER_IP)
        -
        -    for model in model_classifiers:
        -        observer.set_dataset_name(test_dataset_name + model)
        -        observer.observe_processing(pretty_response)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def search_all_model(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 return indented string, else return dict.

        -

        return: A list with all model predictions metadata stored in Learning -Orchestra or an empty result.

        -
        - -Expand source code - -
        def search_all_model(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 return indented string, else return dict.
        -
        -    return: A list with all model predictions metadata stored in Learning
        -    Orchestra or an empty result.
        -    """
        -
        -    cluster_url_tsne = self.cluster_url
        -
        -    response = requests.get(cluster_url_tsne)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: -This method is responsible for retrieving a specific -model prediction metadata.

        -

        pretty_response: If true return indented string, else return dict. -model_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.

        -
        - -Expand source code - -
        def search_model(self, model_name: str, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description:  This method is responsible for retrieving a specific
        -    model prediction metadata.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    model_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_model_prediction(model_name, limit=1,
        -                                            pretty_response=pretty_response)
        -
        -    return response
        -
        -
        -
        -def search_model_prediction(self, model_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 return indented string, else return dict. -model_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 there -is no such projection. The current page is also returned to be used in -future content requests.

        -
        - -Expand source code - -
        def search_model_prediction(self,
        -                            model_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 return indented string, else return dict.
        -    model_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 there
        -    is no such projection. The current page is also returned to be used in
        -    future content requests.
        -    """
        -
        -    cluster_url_dataset = self.cluster_url + "/" + model_name + \
        -                          "?query=" + str(query) + \
        -                          "&limit=" + str(limit) + \
        -                          "&skip=" + str(skip)
        -
        -    response = requests.get(cluster_url_dataset)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/builder/index.html b/html/learning_orchestra_client/builder/index.html deleted file mode 100644 index f6061e5..0000000 --- a/html/learning_orchestra_client/builder/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -learning_orchestra_client.builder API documentation - - - - - - - - - - - -
        - - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/dataset/dataset.html b/html/learning_orchestra_client/dataset/dataset.html deleted file mode 100644 index 64e61be..0000000 --- a/html/learning_orchestra_client/dataset/dataset.html +++ /dev/null @@ -1,678 +0,0 @@ - - - - - - -learning_orchestra_client.dataset.dataset API documentation - - - - - - - - - - - -
        -
        -
        -

        Module learning_orchestra_client.dataset.dataset

        -
        -
        -
        - -Expand source code - -
        __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
        -__credits__ = "all free source developers"
        -__status__ = "Prototype"
        -
        -from ..observer import Observer
        -from ..response_treat import ResponseTreat
        -import requests
        -from typing import Union
        -
        -
        -class Dataset:
        -    def __init__(self, ip_from_cluster: str):
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/dataset"
        -        self.response_treat = ResponseTreat()
        -        self.OUTPUT_NAME = "datasetName"
        -        self.URL = "datasetURI"
        -        self.CLUSTER_IP = ip_from_cluster
        -
        -    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 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.
        -        """
        -        request_body = {self.OUTPUT_NAME: dataset_name,
        -                        self.URL: url}
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
        -
        -        if pretty_response:
        -            print("\n----------" + " CREATED FILE " + 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).
        -        """
        -        request_body = {self.OUTPUT_NAME: dataset_name,
        -                        self.URL: url}
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
        -                                                                     "---")
        -        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 return indented string, else return dict.
        -
        -        return: All datasets metadata stored in Learning Orchestra or an empty
        -        result.
        -        """
        -        request_url = self.cluster_url
        -
        -        response = requests.get(request_url)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible for retrieving a specific
        -        dataset
        -
        -        pretty_response: If true return indented string, else return dict.
        -        dataset_name: Is the name of the dataset file.
        -        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 dataset metadata stored in Learning Orchestra or an
        -        error if there is no such dataset.
        -        """
        -        response = self.search_dataset_content(dataset_name, limit=1,
        -                                               pretty_response=pretty_response)
        -
        -        return 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 return indented string, else return dict.
        -        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.
        -        """
        -
        -        request_url = self.cluster_url + "/" + dataset_name + \
        -                      "?query=" + str(query) + \
        -                      "&limit=" + str(limit) + \
        -                      "&skip=" + str(skip)
        -
        -        response = requests.get(request_url)
        -
        -        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. The
        -        delete operation is always synchronous because it is very fast, since
        -        the deletion is performed in background. If a dataset was used by
        -        another task (Ex. projection, histogram, pca, tuning and so forth), it
        -        cannot be deleted.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        dataset_name: Represents the dataset name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message
        -        """
        -
        -        request_url = self.cluster_url + "/" + dataset_name
        -
        -        response = requests.delete(request_url)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Classes

        -
        -
        -class Dataset -(ip_from_cluster: str) -
        -
        -
        -
        - -Expand source code - -
        class Dataset:
        -    def __init__(self, ip_from_cluster: str):
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/dataset"
        -        self.response_treat = ResponseTreat()
        -        self.OUTPUT_NAME = "datasetName"
        -        self.URL = "datasetURI"
        -        self.CLUSTER_IP = ip_from_cluster
        -
        -    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 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.
        -        """
        -        request_body = {self.OUTPUT_NAME: dataset_name,
        -                        self.URL: url}
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
        -
        -        if pretty_response:
        -            print("\n----------" + " CREATED FILE " + 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).
        -        """
        -        request_body = {self.OUTPUT_NAME: dataset_name,
        -                        self.URL: url}
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
        -                                                                     "---")
        -        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 return indented string, else return dict.
        -
        -        return: All datasets metadata stored in Learning Orchestra or an empty
        -        result.
        -        """
        -        request_url = self.cluster_url
        -
        -        response = requests.get(request_url)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible for retrieving a specific
        -        dataset
        -
        -        pretty_response: If true return indented string, else return dict.
        -        dataset_name: Is the name of the dataset file.
        -        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 dataset metadata stored in Learning Orchestra or an
        -        error if there is no such dataset.
        -        """
        -        response = self.search_dataset_content(dataset_name, limit=1,
        -                                               pretty_response=pretty_response)
        -
        -        return 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 return indented string, else return dict.
        -        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.
        -        """
        -
        -        request_url = self.cluster_url + "/" + dataset_name + \
        -                      "?query=" + str(query) + \
        -                      "&limit=" + str(limit) + \
        -                      "&skip=" + str(skip)
        -
        -        response = requests.get(request_url)
        -
        -        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. The
        -        delete operation is always synchronous because it is very fast, since
        -        the deletion is performed in background. If a dataset was used by
        -        another task (Ex. projection, histogram, pca, tuning and so forth), it
        -        cannot be deleted.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        dataset_name: Represents the dataset name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message
        -        """
        -
        -        request_url = self.cluster_url + "/" + dataset_name
        -
        -        response = requests.delete(request_url)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -

        Methods

        -
        -
        -def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] -
        -
        -

        description: This method is responsible for deleting the dataset. The -delete operation is always synchronous because it is very fast, since -the deletion is performed in background. If a dataset was used by -another task (Ex. projection, histogram, pca, tuning and so forth), it -cannot be deleted.

        -

        pretty_response: If true return indented string, else return dict. -dataset_name: Represents the dataset name.

        -

        return: JSON object with an error message, a warning message or a -correct delete message

        -
        - -Expand source code - -
        def delete_dataset(self, dataset_name, pretty_response=False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method is responsible for deleting the dataset. The
        -    delete operation is always synchronous because it is very fast, since
        -    the deletion is performed in background. If a dataset was used by
        -    another task (Ex. projection, histogram, pca, tuning and so forth), it
        -    cannot be deleted.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    dataset_name: Represents the dataset name.
        -
        -    return: JSON object with an error message, a warning message or a
        -    correct delete message
        -    """
        -
        -    request_url = self.cluster_url + "/" + dataset_name
        -
        -    response = requests.delete(request_url)
        -
        -    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).

        -
        - -Expand source code - -
        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).
        -    """
        -    request_body = {self.OUTPUT_NAME: dataset_name,
        -                    self.URL: url}
        -    request_url = self.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    if pretty_response:
        -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
        -                                                                 "---")
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -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 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.

        -
        - -Expand source code - -
        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 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.
        -    """
        -    request_body = {self.OUTPUT_NAME: dataset_name,
        -                    self.URL: url}
        -    request_url = self.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
        -
        -    if pretty_response:
        -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
        -                                                                 "---")
        -    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 return indented string, else return dict.

        -

        return: All datasets metadata stored in Learning Orchestra or an empty -result.

        -
        - -Expand source code - -
        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 return indented string, else return dict.
        -
        -    return: All datasets metadata stored in Learning Orchestra or an empty
        -    result.
        -    """
        -    request_url = self.cluster_url
        -
        -    response = requests.get(request_url)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method is responsible for retrieving a specific -dataset

        -

        pretty_response: If true return indented string, else return dict. -dataset_name: Is the name of the dataset file. -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 dataset metadata stored in Learning Orchestra or an -error if there is no such dataset.

        -
        - -Expand source code - -
        def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method is responsible for retrieving a specific
        -    dataset
        -
        -    pretty_response: If true return indented string, else return dict.
        -    dataset_name: Is the name of the dataset file.
        -    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 dataset metadata stored in Learning Orchestra or an
        -    error if there is no such dataset.
        -    """
        -    response = self.search_dataset_content(dataset_name, limit=1,
        -                                           pretty_response=pretty_response)
        -
        -    return 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 return indented string, else return dict. -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.

        -
        - -Expand source code - -
        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 return indented string, else return dict.
        -    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.
        -    """
        -
        -    request_url = self.cluster_url + "/" + dataset_name + \
        -                  "?query=" + str(query) + \
        -                  "&limit=" + str(limit) + \
        -                  "&skip=" + str(skip)
        -
        -    response = requests.get(request_url)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/dataset/index.html b/html/learning_orchestra_client/dataset/index.html deleted file mode 100644 index b4c42b2..0000000 --- a/html/learning_orchestra_client/dataset/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -learning_orchestra_client.dataset API documentation - - - - - - - - - - - -
        - - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/histogram.html b/html/learning_orchestra_client/explore/histogram.html deleted file mode 100644 index e1abdfc..0000000 --- a/html/learning_orchestra_client/explore/histogram.html +++ /dev/null @@ -1,676 +0,0 @@ - - - - - - -learning_orchestra_client.explore.histogram API documentation - - - - - - - - - - - -
        -
        -
        -

        Module learning_orchestra_client.explore.histogram

        -
        -
        -
        - -Expand source code - -
        from ..observer import Observer
        -from ..response_treat import ResponseTreat
        -from ..dataset.dataset import Dataset
        -import requests
        -from typing import Union
        -
        -
        -class Histogram:
        -    def __init__(self, ip_from_cluster: str):
        -        self.CLUSTER_IP = ip_from_cluster
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/explore/histogram"
        -        self.response_treat = ResponseTreat()
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.OUTPUT_NAME = "outputDatasetName"
        -        self.FIELDS = "names"
        -        self.dataset = Dataset(ip_from_cluster)
        -
        -    def run_histogram_sync(self,
        -                           dataset_name: str,
        -                           histogram_name: str,
        -                           fields: list,
        -                           pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method run histogram algorithm to create a histogram
        -        synchronously, 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 return indented string, else return dict.
        -
        -        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.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
        -            pretty_response)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE HISTOGRAM FROM "
        -                + dataset_name
        -                + " TO "
        -                + histogram_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 run histogram algorithm to create a histogram
        -        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
        -
        -        dataset_name: Represents the name of dataset.
        -        histogram_name: Represents the name of histogram.
        -        fields: Represents a list of attributes.
        -        pretty_response: If true return indented string, else return dict.
        -
        -        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.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE HISTOGRAM FROM "
        -                + dataset_name
        -                + " TO "
        -                + histogram_name
        -                + " ----------"
        -            )
        -
        -        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 names, it does not
        -        retrieve the histogram content.
        -
        -        pretty_response: If true return indented string, else return dict.
        -
        -        return: A list with all histogram names stored in Learning Orchestra
        -        or an empty result.
        -        """
        -
        -        cluster_url_histogram = self.cluster_url
        -
        -        response = requests.get(cluster_url_histogram)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_histogram_data(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 return indented string, else return dict.
        -        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.
        -        """
        -
        -        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
        -                                "?query=" + str(query) + \
        -                                "&limit=" + str(limit) + \
        -                                "&skip=" + str(skip)
        -
        -        response = requests.get(cluster_url_histogram)
        -
        -        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 synchronous because it is very fast,
        -        since the deletion is performed in background.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        histogram_name: Represents the histogram name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message
        -        """
        -
        -        cluster_url_histogram = self.cluster_url + "/" + histogram_name
        -
        -        response = requests.delete(cluster_url_histogram)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Classes

        -
        -
        -class Histogram -(ip_from_cluster: str) -
        -
        -
        -
        - -Expand source code - -
        class Histogram:
        -    def __init__(self, ip_from_cluster: str):
        -        self.CLUSTER_IP = ip_from_cluster
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/explore/histogram"
        -        self.response_treat = ResponseTreat()
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.OUTPUT_NAME = "outputDatasetName"
        -        self.FIELDS = "names"
        -        self.dataset = Dataset(ip_from_cluster)
        -
        -    def run_histogram_sync(self,
        -                           dataset_name: str,
        -                           histogram_name: str,
        -                           fields: list,
        -                           pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method run histogram algorithm to create a histogram
        -        synchronously, 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 return indented string, else return dict.
        -
        -        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.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
        -            pretty_response)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE HISTOGRAM FROM "
        -                + dataset_name
        -                + " TO "
        -                + histogram_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 run histogram algorithm to create a histogram
        -        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
        -
        -        dataset_name: Represents the name of dataset.
        -        histogram_name: Represents the name of histogram.
        -        fields: Represents a list of attributes.
        -        pretty_response: If true return indented string, else return dict.
        -
        -        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.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE HISTOGRAM FROM "
        -                + dataset_name
        -                + " TO "
        -                + histogram_name
        -                + " ----------"
        -            )
        -
        -        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 names, it does not
        -        retrieve the histogram content.
        -
        -        pretty_response: If true return indented string, else return dict.
        -
        -        return: A list with all histogram names stored in Learning Orchestra
        -        or an empty result.
        -        """
        -
        -        cluster_url_histogram = self.cluster_url
        -
        -        response = requests.get(cluster_url_histogram)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_histogram_data(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 return indented string, else return dict.
        -        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.
        -        """
        -
        -        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
        -                                "?query=" + str(query) + \
        -                                "&limit=" + str(limit) + \
        -                                "&skip=" + str(skip)
        -
        -        response = requests.get(cluster_url_histogram)
        -
        -        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 synchronous because it is very fast,
        -        since the deletion is performed in background.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        histogram_name: Represents the histogram name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message
        -        """
        -
        -        cluster_url_histogram = self.cluster_url + "/" + histogram_name
        -
        -        response = requests.delete(cluster_url_histogram)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -

        Methods

        -
        -
        -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 synchronous because it is very fast, -since the deletion is performed in background.

        -

        pretty_response: If true return indented string, else return dict. -histogram_name: Represents the histogram name.

        -

        return: JSON object with an error message, a warning message or a -correct delete message

        -
        - -Expand source code - -
        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 synchronous because it is very fast,
        -    since the deletion is performed in background.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    histogram_name: Represents the histogram name.
        -
        -    return: JSON object with an error message, a warning message or a
        -    correct delete message
        -    """
        -
        -    cluster_url_histogram = self.cluster_url + "/" + histogram_name
        -
        -    response = requests.delete(cluster_url_histogram)
        -
        -    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 run histogram algorithm to create a histogram -asynchronously, the caller does not wait until the histogram 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 histogram was inserted.

        -

        dataset_name: Represents the name of dataset. -histogram_name: Represents the name of histogram. -fields: Represents a list of attributes. -pretty_response: If true return indented string, else return dict.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns a histogram.

        -
        - -Expand source code - -
        def run_histogram_async(self,
        -                        dataset_name: str,
        -                        histogram_name: str,
        -                        fields: list,
        -                        pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method run histogram algorithm to create a histogram
        -    asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
        -
        -    dataset_name: Represents the name of dataset.
        -    histogram_name: Represents the name of histogram.
        -    fields: Represents a list of attributes.
        -    pretty_response: If true return indented string, else return dict.
        -
        -    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.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE HISTOGRAM FROM "
        -            + dataset_name
        -            + " TO "
        -            + histogram_name
        -            + " ----------"
        -        )
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def run_histogram_sync(self, dataset_name: str, histogram_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method run histogram algorithm to create a histogram -synchronously, 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 return indented string, else return dict.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns a histogram.

        -
        - -Expand source code - -
        def run_histogram_sync(self,
        -                       dataset_name: str,
        -                       histogram_name: str,
        -                       fields: list,
        -                       pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method run histogram algorithm to create a histogram
        -    synchronously, 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 return indented string, else return dict.
        -
        -    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.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    Observer(histogram_name, self.CLUSTER_IP).observe_processing(
        -        pretty_response)
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE HISTOGRAM FROM "
        -            + dataset_name
        -            + " TO "
        -            + histogram_name
        -            + " ----------"
        -        )
        -
        -    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 names, it does not -retrieve the histogram content.

        -

        pretty_response: If true return indented string, else return dict.

        -

        return: A list with all histogram names stored in Learning Orchestra -or an empty result.

        -
        - -Expand source code - -
        def search_all_histograms(self, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method retrieves all histogram names, it does not
        -    retrieve the histogram content.
        -
        -    pretty_response: If true return indented string, else return dict.
        -
        -    return: A list with all histogram names stored in Learning Orchestra
        -    or an empty result.
        -    """
        -
        -    cluster_url_histogram = self.cluster_url
        -
        -    response = requests.get(cluster_url_histogram)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def search_histogram_data(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 return indented string, else return dict. -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.

        -
        - -Expand source code - -
        def search_histogram_data(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 return indented string, else return dict.
        -    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.
        -    """
        -
        -    cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
        -                            "?query=" + str(query) + \
        -                            "&limit=" + str(limit) + \
        -                            "&skip=" + str(skip)
        -
        -    response = requests.get(cluster_url_histogram)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/index.html b/html/learning_orchestra_client/explore/index.html deleted file mode 100644 index d4f7495..0000000 --- a/html/learning_orchestra_client/explore/index.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - -learning_orchestra_client.explore API documentation - - - - - - - - - - - -
        - - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/pca.html b/html/learning_orchestra_client/explore/pca.html deleted file mode 100644 index 877a51d..0000000 --- a/html/learning_orchestra_client/explore/pca.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - - -learning_orchestra_client.explore.pca API documentation - - - - - - - - - - - -
        -
        -
        -

        Module learning_orchestra_client.explore.pca

        -
        -
        -
        - -Expand source code - -
        from ..response_treat import ResponseTreat
        -from ..dataset.dataset import Dataset
        -from PIL import Image
        -import requests
        -import time
        -from typing import Union
        -
        -
        -class Pca:
        -    def __init__(self, ip_from_cluster: str):
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/explore/pca"
        -        self.response_treat = ResponseTreat()
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.OUTPUT_NAME = "outputPlotName"
        -        self.LABEL = "label"
        -        self.dataset = Dataset(ip_from_cluster)
        -        self.WAIT_TIME = 5
        -        self.CLUSTER_IP = ip_from_cluster
        -
        -    def run_pca_sync(self,
        -                     dataset_name: str,
        -                     pca_name: str,
        -                     label: str,
        -                     pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method run PCA algorithm to create an image plot
        -        synchronously, the caller waits until the PCA image is inserted into
        -        the Learning Orchestra storage mechanism.
        -
        -        dataset_name: Name of dataset.
        -        pca_name: Name of PCA image plot.
        -        label: The label is the label name of the column for machine learning
        -        datasets which has labeled tuples.
        -        pretty_response: If true open an image plot, else return link to open
        -        image plot.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns a PCA image plot.
        -        """
        -        request_body = {
        -            self.INPUT_NAME: dataset_name,
        -            self.OUTPUT_NAME: pca_name,
        -            self.LABEL: label,
        -        }
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        self.verify_pca_exist(pca_name, pretty_response)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE PCA IMAGE PLOT FROM "
        -                + dataset_name
        -                + " TO "
        -                + pca_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def run_pca_async(self,
        -                      dataset_name: str,
        -                      pca_name: str,
        -                      label: str,
        -                      pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method run PCA algorithm to create an image plot
        -        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
        -
        -        dataset_name: Name of dataset.
        -        pca_name: Name of PCA image plot.
        -        label: The label is the label name of the column for machine learning
        -        datasets which has labeled tuples.
        -        pretty_response: If true open an image plot, else return link to open
        -        image plot.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns a PCA image plot.
        -        """
        -
        -        request_body = {
        -            self.INPUT_NAME: dataset_name,
        -            self.OUTPUT_NAME: pca_name,
        -            self.LABEL: label,
        -        }
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE PCA IMAGE PLOT FROM "
        -                + dataset_name
        -                + " TO "
        -                + pca_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method retrieves all PCAs plot names, it does not
        -        retrieve the image plot.
        -
        -        pretty_response: If true return indented string, else return dict.
        -
        -        return: A list with all PCAs plot names stored in Learning Orchestra
        -        or an empty result.
        -        """
        -
        -        cluster_url_pca = self.cluster_url
        -
        -        response = requests.get(cluster_url_pca)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method retrieves a PCA image plot.
        -
        -        pca_name: Name of PCA image plot.
        -        pretty_response: If true open an image plot, else return link to
        -        open image plot.
        -
        -        return: A link to an image plot or open an image plot.
        -        """
        -
        -        cluster_url_pca = self.cluster_url + "/" + pca_name
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " READ "
        -                + pca_name
        -                + " PCA IMAGE PLOT "
        -                + " ----------"
        -            )
        -            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
        -            img.show()
        -        else:
        -            return cluster_url_pca
        -
        -    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible for deleting the PCA image plot.
        -        The delete operation is always synchronous because it is very fast,
        -        since the deletion is performed in background.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        pca_name: Represents the PCA name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message.
        -        """
        -
        -        cluster_url_pca = self.cluster_url + "/" + pca_name
        -
        -        response = requests.delete(cluster_url_pca)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible to verify if a PCA image
        -        exist into the Learning Orchestra storage mechanism.
        -
        -        pca_name: Name of PCA image plot.
        -
        -        return: True if the PCA requested exist, false if does not.
        -        """
        -
        -        if pretty_response:
        -            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
        -                                                           "----------")
        -
        -        exist = False
        -        pca_name += ".png"
        -
        -        while not exist:
        -            time.sleep(self.WAIT_TIME)
        -            all_pca = self.search_all_pca()
        -            exist = pca_name in all_pca.get('result')
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Classes

        -
        -
        -class Pca -(ip_from_cluster: str) -
        -
        -
        -
        - -Expand source code - -
        class Pca:
        -    def __init__(self, ip_from_cluster: str):
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/explore/pca"
        -        self.response_treat = ResponseTreat()
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.OUTPUT_NAME = "outputPlotName"
        -        self.LABEL = "label"
        -        self.dataset = Dataset(ip_from_cluster)
        -        self.WAIT_TIME = 5
        -        self.CLUSTER_IP = ip_from_cluster
        -
        -    def run_pca_sync(self,
        -                     dataset_name: str,
        -                     pca_name: str,
        -                     label: str,
        -                     pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method run PCA algorithm to create an image plot
        -        synchronously, the caller waits until the PCA image is inserted into
        -        the Learning Orchestra storage mechanism.
        -
        -        dataset_name: Name of dataset.
        -        pca_name: Name of PCA image plot.
        -        label: The label is the label name of the column for machine learning
        -        datasets which has labeled tuples.
        -        pretty_response: If true open an image plot, else return link to open
        -        image plot.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns a PCA image plot.
        -        """
        -        request_body = {
        -            self.INPUT_NAME: dataset_name,
        -            self.OUTPUT_NAME: pca_name,
        -            self.LABEL: label,
        -        }
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        self.verify_pca_exist(pca_name, pretty_response)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE PCA IMAGE PLOT FROM "
        -                + dataset_name
        -                + " TO "
        -                + pca_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def run_pca_async(self,
        -                      dataset_name: str,
        -                      pca_name: str,
        -                      label: str,
        -                      pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method run PCA algorithm to create an image plot
        -        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
        -
        -        dataset_name: Name of dataset.
        -        pca_name: Name of PCA image plot.
        -        label: The label is the label name of the column for machine learning
        -        datasets which has labeled tuples.
        -        pretty_response: If true open an image plot, else return link to open
        -        image plot.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns a PCA image plot.
        -        """
        -
        -        request_body = {
        -            self.INPUT_NAME: dataset_name,
        -            self.OUTPUT_NAME: pca_name,
        -            self.LABEL: label,
        -        }
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE PCA IMAGE PLOT FROM "
        -                + dataset_name
        -                + " TO "
        -                + pca_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method retrieves all PCAs plot names, it does not
        -        retrieve the image plot.
        -
        -        pretty_response: If true return indented string, else return dict.
        -
        -        return: A list with all PCAs plot names stored in Learning Orchestra
        -        or an empty result.
        -        """
        -
        -        cluster_url_pca = self.cluster_url
        -
        -        response = requests.get(cluster_url_pca)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method retrieves a PCA image plot.
        -
        -        pca_name: Name of PCA image plot.
        -        pretty_response: If true open an image plot, else return link to
        -        open image plot.
        -
        -        return: A link to an image plot or open an image plot.
        -        """
        -
        -        cluster_url_pca = self.cluster_url + "/" + pca_name
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " READ "
        -                + pca_name
        -                + " PCA IMAGE PLOT "
        -                + " ----------"
        -            )
        -            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
        -            img.show()
        -        else:
        -            return cluster_url_pca
        -
        -    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible for deleting the PCA image plot.
        -        The delete operation is always synchronous because it is very fast,
        -        since the deletion is performed in background.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        pca_name: Represents the PCA name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message.
        -        """
        -
        -        cluster_url_pca = self.cluster_url + "/" + pca_name
        -
        -        response = requests.delete(cluster_url_pca)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible to verify if a PCA image
        -        exist into the Learning Orchestra storage mechanism.
        -
        -        pca_name: Name of PCA image plot.
        -
        -        return: True if the PCA requested exist, false if does not.
        -        """
        -
        -        if pretty_response:
        -            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
        -                                                           "----------")
        -
        -        exist = False
        -        pca_name += ".png"
        -
        -        while not exist:
        -            time.sleep(self.WAIT_TIME)
        -            all_pca = self.search_all_pca()
        -            exist = pca_name in all_pca.get('result')
        -
        -

        Methods

        -
        -
        -def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method is responsible for deleting the PCA image plot. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

        -

        pretty_response: If true return indented string, else return dict. -pca_name: Represents the PCA name.

        -

        return: JSON object with an error message, a warning message or a -correct delete message.

        -
        - -Expand source code - -
        def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method is responsible for deleting the PCA image plot.
        -    The delete operation is always synchronous because it is very fast,
        -    since the deletion is performed in background.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    pca_name: Represents the PCA name.
        -
        -    return: JSON object with an error message, a warning message or a
        -    correct delete message.
        -    """
        -
        -    cluster_url_pca = self.cluster_url + "/" + pca_name
        -
        -    response = requests.delete(cluster_url_pca)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def run_pca_async(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method run PCA algorithm to create an image plot -asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.

        -

        dataset_name: Name of dataset. -pca_name: Name of PCA image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns a PCA image plot.

        -
        - -Expand source code - -
        def run_pca_async(self,
        -                  dataset_name: str,
        -                  pca_name: str,
        -                  label: str,
        -                  pretty_response: bool = False) -> Union[dict, str]:
        -    """
        -    description: This method run PCA algorithm to create an image plot
        -    asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
        -
        -    dataset_name: Name of dataset.
        -    pca_name: Name of PCA image plot.
        -    label: The label is the label name of the column for machine learning
        -    datasets which has labeled tuples.
        -    pretty_response: If true open an image plot, else return link to open
        -    image plot.
        -
        -    return: A JSON object with error or warning messages. In case of
        -    success, it returns a PCA image plot.
        -    """
        -
        -    request_body = {
        -        self.INPUT_NAME: dataset_name,
        -        self.OUTPUT_NAME: pca_name,
        -        self.LABEL: label,
        -    }
        -    request_url = self.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE PCA IMAGE PLOT FROM "
        -            + dataset_name
        -            + " TO "
        -            + pca_name
        -            + " ----------"
        -        )
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def run_pca_sync(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method run PCA algorithm to create an image plot -synchronously, the caller waits until the PCA image is inserted into -the Learning Orchestra storage mechanism.

        -

        dataset_name: Name of dataset. -pca_name: Name of PCA image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns a PCA image plot.

        -
        - -Expand source code - -
        def run_pca_sync(self,
        -                 dataset_name: str,
        -                 pca_name: str,
        -                 label: str,
        -                 pretty_response: bool = False) -> Union[dict, str]:
        -    """
        -    description: This method run PCA algorithm to create an image plot
        -    synchronously, the caller waits until the PCA image is inserted into
        -    the Learning Orchestra storage mechanism.
        -
        -    dataset_name: Name of dataset.
        -    pca_name: Name of PCA image plot.
        -    label: The label is the label name of the column for machine learning
        -    datasets which has labeled tuples.
        -    pretty_response: If true open an image plot, else return link to open
        -    image plot.
        -
        -    return: A JSON object with error or warning messages. In case of
        -    success, it returns a PCA image plot.
        -    """
        -    request_body = {
        -        self.INPUT_NAME: dataset_name,
        -        self.OUTPUT_NAME: pca_name,
        -        self.LABEL: label,
        -    }
        -    request_url = self.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    self.verify_pca_exist(pca_name, pretty_response)
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE PCA IMAGE PLOT FROM "
        -            + dataset_name
        -            + " TO "
        -            + pca_name
        -            + " ----------"
        -        )
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def search_all_pca(self, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method retrieves all PCAs plot names, it does not -retrieve the image plot.

        -

        pretty_response: If true return indented string, else return dict.

        -

        return: A list with all PCAs plot names stored in Learning Orchestra -or an empty result.

        -
        - -Expand source code - -
        def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
        -    """
        -    description: This method retrieves all PCAs plot names, it does not
        -    retrieve the image plot.
        -
        -    pretty_response: If true return indented string, else return dict.
        -
        -    return: A list with all PCAs plot names stored in Learning Orchestra
        -    or an empty result.
        -    """
        -
        -    cluster_url_pca = self.cluster_url
        -
        -    response = requests.get(cluster_url_pca)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def search_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method retrieves a PCA image plot.

        -

        pca_name: Name of PCA image plot. -pretty_response: If true open an image plot, else return link to -open image plot.

        -

        return: A link to an image plot or open an image plot.

        -
        - -Expand source code - -
        def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method retrieves a PCA image plot.
        -
        -    pca_name: Name of PCA image plot.
        -    pretty_response: If true open an image plot, else return link to
        -    open image plot.
        -
        -    return: A link to an image plot or open an image plot.
        -    """
        -
        -    cluster_url_pca = self.cluster_url + "/" + pca_name
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " READ "
        -            + pca_name
        -            + " PCA IMAGE PLOT "
        -            + " ----------"
        -        )
        -        img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
        -        img.show()
        -    else:
        -        return cluster_url_pca
        -
        -
        -
        -def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method is responsible to verify if a PCA image -exist into the Learning Orchestra storage mechanism.

        -

        pca_name: Name of PCA image plot.

        -

        return: True if the PCA requested exist, false if does not.

        -
        - -Expand source code - -
        def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method is responsible to verify if a PCA image
        -    exist into the Learning Orchestra storage mechanism.
        -
        -    pca_name: Name of PCA image plot.
        -
        -    return: True if the PCA requested exist, false if does not.
        -    """
        -
        -    if pretty_response:
        -        print("\n---------- CHECKING IF " + pca_name + " FINISHED "
        -                                                       "----------")
        -
        -    exist = False
        -    pca_name += ".png"
        -
        -    while not exist:
        -        time.sleep(self.WAIT_TIME)
        -        all_pca = self.search_all_pca()
        -        exist = pca_name in all_pca.get('result')
        -
        -
        -
        -
        -
        -
        -
        - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/explore/tsne.html b/html/learning_orchestra_client/explore/tsne.html deleted file mode 100644 index b4e1b63..0000000 --- a/html/learning_orchestra_client/explore/tsne.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - - -learning_orchestra_client.explore.tsne API documentation - - - - - - - - - - - -
        -
        -
        -

        Module learning_orchestra_client.explore.tsne

        -
        -
        -
        - -Expand source code - -
        from ..response_treat import ResponseTreat
        -from ..dataset.dataset import Dataset
        -from PIL import Image
        -import requests
        -import time
        -from typing import Union
        -
        -
        -class Tsne:
        -    def __init__(self, ip_from_cluster: str):
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/explore/tsne"
        -        self.response_treat = ResponseTreat()
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.OUTPUT_NAME = "outputPlotName"
        -        self.LABEL = "label"
        -        self.dataset = Dataset(ip_from_cluster)
        -        self.WAIT_TIME = 5
        -        self.CLUSTER_IP = ip_from_cluster
        -
        -    def run_tsne_sync(self,
        -                      dataset_name: str,
        -                      tsne_name: str,
        -                      label: str,
        -                      pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method run t_SNE algorithm to create an image plot
        -        synchronously, the caller waits until the t_SNE image is inserted into
        -        the Learning Orchestra storage mechanism.
        -
        -        dataset_name: Name of dataset.
        -        tsne_name: Name of t_SNE image plot.
        -        label: The label is the label name of the column for machine learning
        -        datasets which has labeled tuples.
        -        pretty_response: If true open an image plot, else return link to open
        -        image plot.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns a t_SNE image plot.
        -        """
        -
        -        request_body = {
        -            self.INPUT_NAME: dataset_name,
        -            self.OUTPUT_NAME: tsne_name,
        -            self.LABEL: label,
        -        }
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        self.verify_tsne_exist(tsne_name, pretty_response)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE TSNE IMAGE PLOT FROM "
        -                + dataset_name
        -                + " TO "
        -                + tsne_name
        -                + " ----------"
        -            )
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def run_tsne_async(self,
        -                       dataset_name: str,
        -                       tsne_name: str,
        -                       label: str,
        -                       pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method run t_SNE algorithm to create an image plot
        -        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
        -
        -        dataset_name: Name of dataset.
        -        tsne_name: Name of t_SNE image plot.
        -        label: The label is the label name of the column for machine learning
        -        datasets which has labeled tuples.
        -        pretty_response: If true open an image plot, else return link to open
        -        image plot.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns a t_SNE image plot.
        -        """
        -
        -        request_body = {
        -            self.INPUT_NAME: dataset_name,
        -            self.OUTPUT_NAME: tsne_name,
        -            self.LABEL: label,
        -        }
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE TSNE IMAGE PLOT FROM "
        -                + dataset_name
        -                + " TO "
        -                + tsne_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_all_tsne(self, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method retrieves all t_SNE plot names, it does not
        -        retrieve the image plot.
        -
        -        pretty_response: If true return indented string, else return dict.
        -
        -        return: A list with all t_SNEs plot names stored in Learning Orchestra
        -        or an empty result.
        -        """
        -
        -        cluster_url_tsne = self.cluster_url
        -
        -        response = requests.get(cluster_url_tsne)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method retrieves a t_SNE image plot.
        -
        -        tsne_name: Name of t_SNE image plot.
        -        pretty_response: If true open an image plot, else return link to
        -        open image plot.
        -
        -        return: A link to an image plot or open an image plot.
        -        """
        -
        -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " READ"
        -                + tsne_name
        -                + " tsne IMAGE PLOT "
        -                + " ----------"
        -            )
        -            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
        -            img.show()
        -        else:
        -            return cluster_url_tsne
        -
        -    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible for deleting the t_SNE image
        -        plot. The delete operation is always synchronous because it is very
        -        fast, since the deletion is performed in background.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        tsne_name: Represents the tsne name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message.
        -        """
        -
        -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
        -
        -        response = requests.delete(cluster_url_tsne)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible to verify if a t_SNE image
        -        exist into the Learning Orchestra storage mechanism.
        -
        -        tsne_name: Name of t_SNE image plot.
        -
        -        return: True if the t_SNE requested exist, false if does not.
        -        """
        -
        -        if pretty_response:
        -            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
        -                                                            "----------")
        -
        -        exist = False
        -        tsne_name += ".png"
        -        while not exist:
        -            time.sleep(self.WAIT_TIME)
        -            all_tsne = self.search_all_tsne()
        -            exist = tsne_name in all_tsne.get('result')
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Classes

        -
        -
        -class Tsne -(ip_from_cluster: str) -
        -
        -
        -
        - -Expand source code - -
        class Tsne:
        -    def __init__(self, ip_from_cluster: str):
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/explore/tsne"
        -        self.response_treat = ResponseTreat()
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.OUTPUT_NAME = "outputPlotName"
        -        self.LABEL = "label"
        -        self.dataset = Dataset(ip_from_cluster)
        -        self.WAIT_TIME = 5
        -        self.CLUSTER_IP = ip_from_cluster
        -
        -    def run_tsne_sync(self,
        -                      dataset_name: str,
        -                      tsne_name: str,
        -                      label: str,
        -                      pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method run t_SNE algorithm to create an image plot
        -        synchronously, the caller waits until the t_SNE image is inserted into
        -        the Learning Orchestra storage mechanism.
        -
        -        dataset_name: Name of dataset.
        -        tsne_name: Name of t_SNE image plot.
        -        label: The label is the label name of the column for machine learning
        -        datasets which has labeled tuples.
        -        pretty_response: If true open an image plot, else return link to open
        -        image plot.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns a t_SNE image plot.
        -        """
        -
        -        request_body = {
        -            self.INPUT_NAME: dataset_name,
        -            self.OUTPUT_NAME: tsne_name,
        -            self.LABEL: label,
        -        }
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        self.verify_tsne_exist(tsne_name, pretty_response)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE TSNE IMAGE PLOT FROM "
        -                + dataset_name
        -                + " TO "
        -                + tsne_name
        -                + " ----------"
        -            )
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def run_tsne_async(self,
        -                       dataset_name: str,
        -                       tsne_name: str,
        -                       label: str,
        -                       pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description: This method run t_SNE algorithm to create an image plot
        -        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
        -
        -        dataset_name: Name of dataset.
        -        tsne_name: Name of t_SNE image plot.
        -        label: The label is the label name of the column for machine learning
        -        datasets which has labeled tuples.
        -        pretty_response: If true open an image plot, else return link to open
        -        image plot.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns a t_SNE image plot.
        -        """
        -
        -        request_body = {
        -            self.INPUT_NAME: dataset_name,
        -            self.OUTPUT_NAME: tsne_name,
        -            self.LABEL: label,
        -        }
        -        request_url = self.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE TSNE IMAGE PLOT FROM "
        -                + dataset_name
        -                + " TO "
        -                + tsne_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_all_tsne(self, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method retrieves all t_SNE plot names, it does not
        -        retrieve the image plot.
        -
        -        pretty_response: If true return indented string, else return dict.
        -
        -        return: A list with all t_SNEs plot names stored in Learning Orchestra
        -        or an empty result.
        -        """
        -
        -        cluster_url_tsne = self.cluster_url
        -
        -        response = requests.get(cluster_url_tsne)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method retrieves a t_SNE image plot.
        -
        -        tsne_name: Name of t_SNE image plot.
        -        pretty_response: If true open an image plot, else return link to
        -        open image plot.
        -
        -        return: A link to an image plot or open an image plot.
        -        """
        -
        -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " READ"
        -                + tsne_name
        -                + " tsne IMAGE PLOT "
        -                + " ----------"
        -            )
        -            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
        -            img.show()
        -        else:
        -            return cluster_url_tsne
        -
        -    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible for deleting the t_SNE image
        -        plot. The delete operation is always synchronous because it is very
        -        fast, since the deletion is performed in background.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        tsne_name: Represents the tsne name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message.
        -        """
        -
        -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
        -
        -        response = requests.delete(cluster_url_tsne)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method is responsible to verify if a t_SNE image
        -        exist into the Learning Orchestra storage mechanism.
        -
        -        tsne_name: Name of t_SNE image plot.
        -
        -        return: True if the t_SNE requested exist, false if does not.
        -        """
        -
        -        if pretty_response:
        -            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
        -                                                            "----------")
        -
        -        exist = False
        -        tsne_name += ".png"
        -        while not exist:
        -            time.sleep(self.WAIT_TIME)
        -            all_tsne = self.search_all_tsne()
        -            exist = tsne_name in all_tsne.get('result')
        -
        -

        Methods

        -
        -
        -def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method is responsible for deleting the t_SNE image -plot. The delete operation is always synchronous because it is very -fast, since the deletion is performed in background.

        -

        pretty_response: If true return indented string, else return dict. -tsne_name: Represents the tsne name.

        -

        return: JSON object with an error message, a warning message or a -correct delete message.

        -
        - -Expand source code - -
        def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method is responsible for deleting the t_SNE image
        -    plot. The delete operation is always synchronous because it is very
        -    fast, since the deletion is performed in background.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    tsne_name: Represents the tsne name.
        -
        -    return: JSON object with an error message, a warning message or a
        -    correct delete message.
        -    """
        -
        -    cluster_url_tsne = self.cluster_url + "/" + tsne_name
        -
        -    response = requests.delete(cluster_url_tsne)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def run_tsne_async(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method run t_SNE algorithm to create an image plot -asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.

        -

        dataset_name: Name of dataset. -tsne_name: Name of t_SNE image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns a t_SNE image plot.

        -
        - -Expand source code - -
        def run_tsne_async(self,
        -                   dataset_name: str,
        -                   tsne_name: str,
        -                   label: str,
        -                   pretty_response: bool = False) -> Union[dict, str]:
        -    """
        -    description: This method run t_SNE algorithm to create an image plot
        -    asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
        -
        -    dataset_name: Name of dataset.
        -    tsne_name: Name of t_SNE image plot.
        -    label: The label is the label name of the column for machine learning
        -    datasets which has labeled tuples.
        -    pretty_response: If true open an image plot, else return link to open
        -    image plot.
        -
        -    return: A JSON object with error or warning messages. In case of
        -    success, it returns a t_SNE image plot.
        -    """
        -
        -    request_body = {
        -        self.INPUT_NAME: dataset_name,
        -        self.OUTPUT_NAME: tsne_name,
        -        self.LABEL: label,
        -    }
        -    request_url = self.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE TSNE IMAGE PLOT FROM "
        -            + dataset_name
        -            + " TO "
        -            + tsne_name
        -            + " ----------"
        -        )
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def run_tsne_sync(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method run t_SNE algorithm to create an image plot -synchronously, the caller waits until the t_SNE image is inserted into -the Learning Orchestra storage mechanism.

        -

        dataset_name: Name of dataset. -tsne_name: Name of t_SNE image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns a t_SNE image plot.

        -
        - -Expand source code - -
        def run_tsne_sync(self,
        -                  dataset_name: str,
        -                  tsne_name: str,
        -                  label: str,
        -                  pretty_response: bool = False) -> Union[dict, str]:
        -    """
        -    description: This method run t_SNE algorithm to create an image plot
        -    synchronously, the caller waits until the t_SNE image is inserted into
        -    the Learning Orchestra storage mechanism.
        -
        -    dataset_name: Name of dataset.
        -    tsne_name: Name of t_SNE image plot.
        -    label: The label is the label name of the column for machine learning
        -    datasets which has labeled tuples.
        -    pretty_response: If true open an image plot, else return link to open
        -    image plot.
        -
        -    return: A JSON object with error or warning messages. In case of
        -    success, it returns a t_SNE image plot.
        -    """
        -
        -    request_body = {
        -        self.INPUT_NAME: dataset_name,
        -        self.OUTPUT_NAME: tsne_name,
        -        self.LABEL: label,
        -    }
        -    request_url = self.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    self.verify_tsne_exist(tsne_name, pretty_response)
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE TSNE IMAGE PLOT FROM "
        -            + dataset_name
        -            + " TO "
        -            + tsne_name
        -            + " ----------"
        -        )
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def search_all_tsne(self, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method retrieves all t_SNE plot names, it does not -retrieve the image plot.

        -

        pretty_response: If true return indented string, else return dict.

        -

        return: A list with all t_SNEs plot names stored in Learning Orchestra -or an empty result.

        -
        - -Expand source code - -
        def search_all_tsne(self, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method retrieves all t_SNE plot names, it does not
        -    retrieve the image plot.
        -
        -    pretty_response: If true return indented string, else return dict.
        -
        -    return: A list with all t_SNEs plot names stored in Learning Orchestra
        -    or an empty result.
        -    """
        -
        -    cluster_url_tsne = self.cluster_url
        -
        -    response = requests.get(cluster_url_tsne)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method retrieves a t_SNE image plot.

        -

        tsne_name: Name of t_SNE image plot. -pretty_response: If true open an image plot, else return link to -open image plot.

        -

        return: A link to an image plot or open an image plot.

        -
        - -Expand source code - -
        def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method retrieves a t_SNE image plot.
        -
        -    tsne_name: Name of t_SNE image plot.
        -    pretty_response: If true open an image plot, else return link to
        -    open image plot.
        -
        -    return: A link to an image plot or open an image plot.
        -    """
        -
        -    cluster_url_tsne = self.cluster_url + "/" + tsne_name
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " READ"
        -            + tsne_name
        -            + " tsne IMAGE PLOT "
        -            + " ----------"
        -        )
        -        img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
        -        img.show()
        -    else:
        -        return cluster_url_tsne
        -
        -
        -
        -def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method is responsible to verify if a t_SNE image -exist into the Learning Orchestra storage mechanism.

        -

        tsne_name: Name of t_SNE image plot.

        -

        return: True if the t_SNE requested exist, false if does not.

        -
        - -Expand source code - -
        def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method is responsible to verify if a t_SNE image
        -    exist into the Learning Orchestra storage mechanism.
        -
        -    tsne_name: Name of t_SNE image plot.
        -
        -    return: True if the t_SNE requested exist, false if does not.
        -    """
        -
        -    if pretty_response:
        -        print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
        -                                                        "----------")
        -
        -    exist = False
        -    tsne_name += ".png"
        -    while not exist:
        -        time.sleep(self.WAIT_TIME)
        -        all_tsne = self.search_all_tsne()
        -        exist = tsne_name in all_tsne.get('result')
        -
        -
        -
        -
        -
        -
        -
        - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/index.html b/html/learning_orchestra_client/index.html deleted file mode 100644 index 64b720b..0000000 --- a/html/learning_orchestra_client/index.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - -learning_orchestra_client API documentation - - - - - - - - - - - -
        - - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/observer.html b/html/learning_orchestra_client/observer.html deleted file mode 100644 index a7d3aee..0000000 --- a/html/learning_orchestra_client/observer.html +++ /dev/null @@ -1,375 +0,0 @@ - - - - - - -learning_orchestra_client.observer API documentation - - - - - - - - - - - -
        -
        -
        -

        Module learning_orchestra_client.observer

        -
        -
        -
        - -Expand source code - -
        from pymongo import MongoClient, change_stream
        -
        -
        -class Observer:
        -    def __init__(self, dataset_name: str, cluster_ip: str):
        -        self.dataset_name = dataset_name
        -
        -        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
        -        mongo_client = MongoClient(mongo_url)
        -        self.database = mongo_client['database']
        -
        -    def set_dataset_name(self, dataset_name: str):
        -        """
        -        :description: Changes the dataset name used in object.
        -        :param dataset_name: Name of dataset to observe.
        -
        -        :return: None.
        -        """
        -        self.dataset_name = dataset_name
        -
        -    def get_dataset_name(self) -> str:
        -        """
        -        :description: Retrieve the dataset name used in object.
        -
        -        :return: The dataset name.
        -        """
        -        return self.dataset_name
        -
        -    def observe_processing(self, pretty_response: bool = False) -> dict:
        -        """
        -        :description: Observe the finished processing status from some
        -        processing, blocking the code execution until finish processing.
        -
        -        :return: A dict with metadata file of used dataset name.
        -        """
        -        if pretty_response:
        -            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
        -                                                                    "----------")
        -        dataset_collection = self.database[self.dataset_name]
        -        metadata_query = {"_id": 0}
        -        dataset_metadata = dataset_collection.find_one(metadata_query)
        -
        -        if dataset_metadata is None:
        -            print("Dataset name or dataset URL invalid")
        -            exit()
        -
        -        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').next()['fullDocument']
        -
        -    def observe_storage(self) -> change_stream.CollectionChangeStream:
        -        """
        -        :description: Get all changes from a dataset
        -
        -        :return: A pymongo CollectionChangeStream object, use the builtin
        -        next() method to iterate over changes.
        -        """
        -
        -        observer_query = [
        -            {'$match': {
        -                '$or': [
        -                    {'operationType': 'replace'},
        -                    {'operationType': 'insert'},
        -                    {'operationType': 'update'},
        -                    {'operationType': 'delete'}
        -
        -                ]
        -            }}
        -        ]
        -        return self.database[self.dataset_name].watch(
        -            observer_query,
        -            full_document='updateLookup')
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Classes

        -
        -
        -class Observer -(dataset_name: str, cluster_ip: str) -
        -
        -
        -
        - -Expand source code - -
        class Observer:
        -    def __init__(self, dataset_name: str, cluster_ip: str):
        -        self.dataset_name = dataset_name
        -
        -        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
        -        mongo_client = MongoClient(mongo_url)
        -        self.database = mongo_client['database']
        -
        -    def set_dataset_name(self, dataset_name: str):
        -        """
        -        :description: Changes the dataset name used in object.
        -        :param dataset_name: Name of dataset to observe.
        -
        -        :return: None.
        -        """
        -        self.dataset_name = dataset_name
        -
        -    def get_dataset_name(self) -> str:
        -        """
        -        :description: Retrieve the dataset name used in object.
        -
        -        :return: The dataset name.
        -        """
        -        return self.dataset_name
        -
        -    def observe_processing(self, pretty_response: bool = False) -> dict:
        -        """
        -        :description: Observe the finished processing status from some
        -        processing, blocking the code execution until finish processing.
        -
        -        :return: A dict with metadata file of used dataset name.
        -        """
        -        if pretty_response:
        -            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
        -                                                                    "----------")
        -        dataset_collection = self.database[self.dataset_name]
        -        metadata_query = {"_id": 0}
        -        dataset_metadata = dataset_collection.find_one(metadata_query)
        -
        -        if dataset_metadata is None:
        -            print("Dataset name or dataset URL invalid")
        -            exit()
        -
        -        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').next()['fullDocument']
        -
        -    def observe_storage(self) -> change_stream.CollectionChangeStream:
        -        """
        -        :description: Get all changes from a dataset
        -
        -        :return: A pymongo CollectionChangeStream object, use the builtin
        -        next() method to iterate over changes.
        -        """
        -
        -        observer_query = [
        -            {'$match': {
        -                '$or': [
        -                    {'operationType': 'replace'},
        -                    {'operationType': 'insert'},
        -                    {'operationType': 'update'},
        -                    {'operationType': 'delete'}
        -
        -                ]
        -            }}
        -        ]
        -        return self.database[self.dataset_name].watch(
        -            observer_query,
        -            full_document='updateLookup')
        -
        -

        Methods

        -
        -
        -def get_dataset_name(self) ‑> str -
        -
        -

        :description: Retrieve the dataset name used in object.

        -

        :return: The dataset name.

        -
        - -Expand source code - -
        def get_dataset_name(self) -> str:
        -    """
        -    :description: Retrieve the dataset name used in object.
        -
        -    :return: The dataset name.
        -    """
        -    return self.dataset_name
        -
        -
        -
        -def observe_processing(self, pretty_response: bool = False) ‑> dict -
        -
        -

        :description: Observe the finished processing status from some -processing, blocking the code execution until finish processing.

        -

        :return: A dict with metadata file of used dataset name.

        -
        - -Expand source code - -
        def observe_processing(self, pretty_response: bool = False) -> dict:
        -    """
        -    :description: Observe the finished processing status from some
        -    processing, blocking the code execution until finish processing.
        -
        -    :return: A dict with metadata file of used dataset name.
        -    """
        -    if pretty_response:
        -        print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
        -                                                                "----------")
        -    dataset_collection = self.database[self.dataset_name]
        -    metadata_query = {"_id": 0}
        -    dataset_metadata = dataset_collection.find_one(metadata_query)
        -
        -    if dataset_metadata is None:
        -        print("Dataset name or dataset URL invalid")
        -        exit()
        -
        -    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').next()['fullDocument']
        -
        -
        -
        -def observe_storage(self) ‑> pymongo.change_stream.CollectionChangeStream -
        -
        -

        :description: Get all changes from a dataset

        -

        :return: A pymongo CollectionChangeStream object, use the builtin -next() method to iterate over changes.

        -
        - -Expand source code - -
        def observe_storage(self) -> change_stream.CollectionChangeStream:
        -    """
        -    :description: Get all changes from a dataset
        -
        -    :return: A pymongo CollectionChangeStream object, use the builtin
        -    next() method to iterate over changes.
        -    """
        -
        -    observer_query = [
        -        {'$match': {
        -            '$or': [
        -                {'operationType': 'replace'},
        -                {'operationType': 'insert'},
        -                {'operationType': 'update'},
        -                {'operationType': 'delete'}
        -
        -            ]
        -        }}
        -    ]
        -    return self.database[self.dataset_name].watch(
        -        observer_query,
        -        full_document='updateLookup')
        -
        -
        -
        -def set_dataset_name(self, dataset_name: str) -
        -
        -

        :description: Changes the dataset name used in object. -:param dataset_name: Name of dataset to observe.

        -

        :return: None.

        -
        - -Expand source code - -
        def set_dataset_name(self, dataset_name: str):
        -    """
        -    :description: Changes the dataset name used in object.
        -    :param dataset_name: Name of dataset to observe.
        -
        -    :return: None.
        -    """
        -    self.dataset_name = dataset_name
        -
        -
        -
        -
        -
        -
        -
        - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/response_treat.html b/html/learning_orchestra_client/response_treat.html deleted file mode 100644 index 2c8bb2a..0000000 --- a/html/learning_orchestra_client/response_treat.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - -learning_orchestra_client.response_treat API documentation - - - - - - - - - - - -
        -
        -
        -

        Module learning_orchestra_client.response_treat

        -
        -
        -
        - -Expand source code - -
        __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
        -__credits__ = "all free source developers"
        -__status__ = "Prototype"
        -
        -import json
        -
        -
        -class ResponseTreat:
        -    HTTP_CREATED = 201
        -    HTTP_SUCCESS = 200
        -    HTTP_ERROR = 500
        -
        -    def treatment(self, response, pretty_response: bool = True):
        -        """
        -        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:
        -            return response.text
        -        elif (
        -                response.status_code != self.HTTP_SUCCESS
        -                and response.status_code != self.HTTP_CREATED
        -        ):
        -            raise Exception(response.json()["result"])
        -        else:
        -            if pretty_response:
        -                return json.dumps(response.json(), indent=4, sort_keys=True)
        -            else:
        -                return response.json()
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Classes

        -
        -
        -class ResponseTreat -
        -
        -
        -
        - -Expand source code - -
        class ResponseTreat:
        -    HTTP_CREATED = 201
        -    HTTP_SUCCESS = 200
        -    HTTP_ERROR = 500
        -
        -    def treatment(self, response, pretty_response: bool = True):
        -        """
        -        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:
        -            return response.text
        -        elif (
        -                response.status_code != self.HTTP_SUCCESS
        -                and response.status_code != self.HTTP_CREATED
        -        ):
        -            raise Exception(response.json()["result"])
        -        else:
        -            if pretty_response:
        -                return json.dumps(response.json(), indent=4, sort_keys=True)
        -            else:
        -                return response.json()
        -
        -

        Class variables

        -
        -
        var HTTP_CREATED
        -
        -
        -
        -
        var HTTP_ERROR
        -
        -
        -
        -
        var HTTP_SUCCESS
        -
        -
        -
        -
        -

        Methods

        -
        -
        -def treatment(self, response, pretty_response: bool = True) -
        -
        -

        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.

        -
        - -Expand source code - -
        def treatment(self, response, pretty_response: bool = True):
        -    """
        -    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:
        -        return response.text
        -    elif (
        -            response.status_code != self.HTTP_SUCCESS
        -            and response.status_code != self.HTTP_CREATED
        -    ):
        -        raise Exception(response.json()["result"])
        -    else:
        -        if pretty_response:
        -            return json.dumps(response.json(), indent=4, sort_keys=True)
        -        else:
        -            return response.json()
        -
        -
        -
        -
        -
        -
        -
        - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/data_type.html b/html/learning_orchestra_client/transform/data_type.html deleted file mode 100644 index fcd25c1..0000000 --- a/html/learning_orchestra_client/transform/data_type.html +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - -learning_orchestra_client.transform.data_type API documentation - - - - - - - - - - - -
        -
        -
        -

        Module learning_orchestra_client.transform.data_type

        -
        -
        -
        - -Expand source code - -
        from ..response_treat import ResponseTreat
        -from ..dataset.dataset import Dataset
        -import requests
        -from typing import Union
        -
        -
        -class DataType:
        -    def __init__(self, ip_from_cluster):
        -        self.CLUSTER_IP = ip_from_cluster
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/transform/dataType"
        -        self.ResponseTreat = ResponseTreat()
        -        self.Dataset = Dataset(ip_from_cluster)
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.TYPES = "types"
        -
        -    def update_dataset_types(self,
        -                             dataset_name: str,
        -                             fields_change: dict,
        -                             pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: Change types of fields to number or string.
        -
        -        dataset_name: Represents the dataset name.
        -        fields_change: Fields to change with types. This is a dict with each
        -        key:value being field:type
        -
        -        return: A JSON object with error or warning messages.
        -        """
        -
        -        url_request = self.cluster_url
        -        body_request = {
        -            self.INPUT_NAME: dataset_name,
        -            self.TYPES: fields_change
        -        }
        -
        -        response = requests.patch(url=url_request, json=body_request)
        -
        -        return self.ResponseTreat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Classes

        -
        -
        -class DataType -(ip_from_cluster) -
        -
        -
        -
        - -Expand source code - -
        class DataType:
        -    def __init__(self, ip_from_cluster):
        -        self.CLUSTER_IP = ip_from_cluster
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/transform/dataType"
        -        self.ResponseTreat = ResponseTreat()
        -        self.Dataset = Dataset(ip_from_cluster)
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.TYPES = "types"
        -
        -    def update_dataset_types(self,
        -                             dataset_name: str,
        -                             fields_change: dict,
        -                             pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: Change types of fields to number or string.
        -
        -        dataset_name: Represents the dataset name.
        -        fields_change: Fields to change with types. This is a dict with each
        -        key:value being field:type
        -
        -        return: A JSON object with error or warning messages.
        -        """
        -
        -        url_request = self.cluster_url
        -        body_request = {
        -            self.INPUT_NAME: dataset_name,
        -            self.TYPES: fields_change
        -        }
        -
        -        response = requests.patch(url=url_request, json=body_request)
        -
        -        return self.ResponseTreat.treatment(response, pretty_response)
        -
        -

        Methods

        -
        -
        -def update_dataset_types(self, dataset_name: str, fields_change: dict, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: Change types of fields to number or string.

        -

        dataset_name: Represents the dataset name. -fields_change: Fields to change with types. This is a dict with each -key:value being field:type

        -

        return: A JSON object with error or warning messages.

        -
        - -Expand source code - -
        def update_dataset_types(self,
        -                         dataset_name: str,
        -                         fields_change: dict,
        -                         pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: Change types of fields to number or string.
        -
        -    dataset_name: Represents the dataset name.
        -    fields_change: Fields to change with types. This is a dict with each
        -    key:value being field:type
        -
        -    return: A JSON object with error or warning messages.
        -    """
        -
        -    url_request = self.cluster_url
        -    body_request = {
        -        self.INPUT_NAME: dataset_name,
        -        self.TYPES: fields_change
        -    }
        -
        -    response = requests.patch(url=url_request, json=body_request)
        -
        -    return self.ResponseTreat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/index.html b/html/learning_orchestra_client/transform/index.html deleted file mode 100644 index 271146f..0000000 --- a/html/learning_orchestra_client/transform/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - -learning_orchestra_client.transform API documentation - - - - - - - - - - - -
        - - -
        - - - \ No newline at end of file diff --git a/html/learning_orchestra_client/transform/projection.html b/html/learning_orchestra_client/transform/projection.html deleted file mode 100644 index 7e84007..0000000 --- a/html/learning_orchestra_client/transform/projection.html +++ /dev/null @@ -1,1035 +0,0 @@ - - - - - - -learning_orchestra_client.transform.projection API documentation - - - - - - - - - - - -
        -
        -
        -

        Module learning_orchestra_client.transform.projection

        -
        -
        -
        - -Expand source code - -
        from ..response_treat import ResponseTreat
        -from ..dataset.dataset import Dataset
        -from ..observer import Observer
        -import requests
        -from typing import Union
        -
        -
        -class Projection:
        -    def __init__(self, ip_from_cluster: str):
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/transform/projection"
        -        self.METADATA_INDEX = 0
        -        self.response_treat = ResponseTreat()
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.OUTPUT_NAME = "outputDatasetName"
        -        self.FIELDS = "names"
        -        self.dataset = Dataset(ip_from_cluster)
        -        self.CLUSTER_IP = ip_from_cluster
        -
        -    def insert_dataset_attributes_sync(self,
        -                                       dataset_name: str,
        -                                       projection_name: str,
        -                                       fields: list,
        -                                       pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method inserts a set of attributes into a dataset
        -        synchronously, the caller waits until the projection is inserted into
        -        the Learning Orchestra storage mechanism.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -        dataset_name: Represents the dataset name.
        -        fields: Represents the set of attributes to be inserted. This is list
        -        with all 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.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        Observer(projection_name, self.CLUSTER_IP).observe_processing(
        -            pretty_response)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE PROJECTION FROM "
        -                + dataset_name
        -                + " TO "
        -                + projection_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def insert_dataset_attributes_async(self,
        -                                        dataset_name: str,
        -                                        projection_name: str,
        -                                        fields: list,
        -                                        pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method inserts a set of attributes into a dataset
        -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -        dataset_name: Represents the dataset name.
        -        fields: Represents the set of attributes to be inserted. This is list
        -        with all 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.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE PROJECTION FROM "
        -                + dataset_name
        -                + " TO "
        -                + projection_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def delete_dataset_attributes_sync(self,
        -                                       dataset_name: str,
        -                                       projection_name: str,
        -                                       fields_to_delete: list,
        -                                       pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method delete a set of attributes on a dataset
        -        synchronously, the caller waits until the projection is inserted into
        -        the Learning Orchestra storage mechanism.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -        dataset_name: Represents the dataset name.
        -        fields_to_delete: Represents the set of attributes to be inserted.
        -        This is list with all attributes.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns the projection metadata.
        -        """
        -        dataset_metadata = self.search_projections_content(dataset_name,
        -                                                           limit=1)
        -
        -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
        -            .get('fields')
        -        for field in fields_to_delete:
        -            fields_to_insert.remove(field)
        -
        -        response = self.insert_dataset_attributes_sync(dataset_name,
        -                                                       projection_name,
        -                                                       fields_to_insert,
        -                                                       pretty_response)
        -
        -        return response
        -
        -    def delete_dataset_attributes_async(self,
        -                                        dataset_name: str,
        -                                        projection_name: str,
        -                                        fields_to_delete: list,
        -                                        pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method delete a set of attributes into a dataset
        -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -        dataset_name: Represents the dataset name.
        -        fields_to_delete: Represents the set of attributes to be inserted.
        -        This is list with all attributes.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns the projection metadata.
        -        """
        -        dataset_metadata = self.search_projections_content(dataset_name,
        -                                                           limit=1)
        -
        -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
        -            .get('fields')
        -        for field in fields_to_delete:
        -            fields_to_insert.remove(field)
        -
        -        response = self.insert_dataset_attributes_async(dataset_name,
        -                                                        projection_name,
        -                                                        fields_to_insert,
        -                                                        pretty_response)
        -
        -        return response
        -
        -    def search_all_projections(self, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method retrieves all projection metadata, it does not
        -        retrieve the projection content.
        -
        -        pretty_response: If true return indented string, else return dict.
        -
        -        return: A list with all projections metadata stored in Learning
        -        Orchestra or an empty result.
        -        """
        -        cluster_url_projection = self.cluster_url
        -
        -        response = requests.get(cluster_url_projection)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_projections(self, projection_name: str,
        -                           pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description:  This method is responsible for retrieving a specific
        -        projection.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
        -        error if there is no such projections.
        -        """
        -        pretty = pretty_response
        -
        -        response = self.search_projections_content(projection_name, limit=1,
        -                                                   pretty_response=pretty)
        -
        -        return response
        -
        -    def search_projections_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 dataset
        -        content.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        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.
        -        """
        -
        -        cluster_url_projection = self.cluster_url + "/" + projection_name + \
        -                                 "?query=" + str(query) + \
        -                                 "&limit=" + str(limit) + \
        -                                 "&skip=" + str(skip)
        -
        -        response = requests.get(cluster_url_projection)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def delete_projections(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 synchronous because it is very fast,
        -        since the deletion is performed in background. If a projection was
        -        used by another task (Ex. histogram, pca, tuning and so forth),
        -        it cannot be deleted.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message
        -        """
        -        cluster_url_projection = self.cluster_url + "/" + projection_name
        -
        -        response = requests.delete(cluster_url_projection)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        Classes

        -
        -
        -class Projection -(ip_from_cluster: str) -
        -
        -
        -
        - -Expand source code - -
        class Projection:
        -    def __init__(self, ip_from_cluster: str):
        -        self.cluster_url = "http://" + ip_from_cluster + \
        -                           "/api/learningOrchestra/v1/transform/projection"
        -        self.METADATA_INDEX = 0
        -        self.response_treat = ResponseTreat()
        -        self.INPUT_NAME = "inputDatasetName"
        -        self.OUTPUT_NAME = "outputDatasetName"
        -        self.FIELDS = "names"
        -        self.dataset = Dataset(ip_from_cluster)
        -        self.CLUSTER_IP = ip_from_cluster
        -
        -    def insert_dataset_attributes_sync(self,
        -                                       dataset_name: str,
        -                                       projection_name: str,
        -                                       fields: list,
        -                                       pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method inserts a set of attributes into a dataset
        -        synchronously, the caller waits until the projection is inserted into
        -        the Learning Orchestra storage mechanism.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -        dataset_name: Represents the dataset name.
        -        fields: Represents the set of attributes to be inserted. This is list
        -        with all 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.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        Observer(projection_name, self.CLUSTER_IP).observe_processing(
        -            pretty_response)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE PROJECTION FROM "
        -                + dataset_name
        -                + " TO "
        -                + projection_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def insert_dataset_attributes_async(self,
        -                                        dataset_name: str,
        -                                        projection_name: str,
        -                                        fields: list,
        -                                        pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method inserts a set of attributes into a dataset
        -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -        dataset_name: Represents the dataset name.
        -        fields: Represents the set of attributes to be inserted. This is list
        -        with all 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.cluster_url
        -
        -        response = requests.post(url=request_url, json=request_body)
        -
        -        if pretty_response:
        -            print(
        -                "\n----------"
        -                + " CREATE PROJECTION FROM "
        -                + dataset_name
        -                + " TO "
        -                + projection_name
        -                + " ----------"
        -            )
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def delete_dataset_attributes_sync(self,
        -                                       dataset_name: str,
        -                                       projection_name: str,
        -                                       fields_to_delete: list,
        -                                       pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method delete a set of attributes on a dataset
        -        synchronously, the caller waits until the projection is inserted into
        -        the Learning Orchestra storage mechanism.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -        dataset_name: Represents the dataset name.
        -        fields_to_delete: Represents the set of attributes to be inserted.
        -        This is list with all attributes.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns the projection metadata.
        -        """
        -        dataset_metadata = self.search_projections_content(dataset_name,
        -                                                           limit=1)
        -
        -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
        -            .get('fields')
        -        for field in fields_to_delete:
        -            fields_to_insert.remove(field)
        -
        -        response = self.insert_dataset_attributes_sync(dataset_name,
        -                                                       projection_name,
        -                                                       fields_to_insert,
        -                                                       pretty_response)
        -
        -        return response
        -
        -    def delete_dataset_attributes_async(self,
        -                                        dataset_name: str,
        -                                        projection_name: str,
        -                                        fields_to_delete: list,
        -                                        pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method delete a set of attributes into a dataset
        -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -        dataset_name: Represents the dataset name.
        -        fields_to_delete: Represents the set of attributes to be inserted.
        -        This is list with all attributes.
        -
        -        return: A JSON object with error or warning messages. In case of
        -        success, it returns the projection metadata.
        -        """
        -        dataset_metadata = self.search_projections_content(dataset_name,
        -                                                           limit=1)
        -
        -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
        -            .get('fields')
        -        for field in fields_to_delete:
        -            fields_to_insert.remove(field)
        -
        -        response = self.insert_dataset_attributes_async(dataset_name,
        -                                                        projection_name,
        -                                                        fields_to_insert,
        -                                                        pretty_response)
        -
        -        return response
        -
        -    def search_all_projections(self, pretty_response: bool = False) \
        -            -> Union[dict, str]:
        -        """
        -        description: This method retrieves all projection metadata, it does not
        -        retrieve the projection content.
        -
        -        pretty_response: If true return indented string, else return dict.
        -
        -        return: A list with all projections metadata stored in Learning
        -        Orchestra or an empty result.
        -        """
        -        cluster_url_projection = self.cluster_url
        -
        -        response = requests.get(cluster_url_projection)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def search_projections(self, projection_name: str,
        -                           pretty_response: bool = False) -> Union[dict, str]:
        -        """
        -        description:  This method is responsible for retrieving a specific
        -        projection.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
        -        error if there is no such projections.
        -        """
        -        pretty = pretty_response
        -
        -        response = self.search_projections_content(projection_name, limit=1,
        -                                                   pretty_response=pretty)
        -
        -        return response
        -
        -    def search_projections_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 dataset
        -        content.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        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.
        -        """
        -
        -        cluster_url_projection = self.cluster_url + "/" + projection_name + \
        -                                 "?query=" + str(query) + \
        -                                 "&limit=" + str(limit) + \
        -                                 "&skip=" + str(skip)
        -
        -        response = requests.get(cluster_url_projection)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -    def delete_projections(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 synchronous because it is very fast,
        -        since the deletion is performed in background. If a projection was
        -        used by another task (Ex. histogram, pca, tuning and so forth),
        -        it cannot be deleted.
        -
        -        pretty_response: If true return indented string, else return dict.
        -        projection_name: Represents the projection name.
        -
        -        return: JSON object with an error message, a warning message or a
        -        correct delete message
        -        """
        -        cluster_url_projection = self.cluster_url + "/" + projection_name
        -
        -        response = requests.delete(cluster_url_projection)
        -
        -        return self.response_treat.treatment(response, pretty_response)
        -
        -

        Methods

        -
        -
        -def delete_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method delete a set of attributes into a dataset -asynchronously, the caller does not wait until the projections 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 projection was inserted.

        -

        pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields_to_delete: Represents the set of attributes to be inserted. -This is list with all attributes.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

        -
        - -Expand source code - -
        def delete_dataset_attributes_async(self,
        -                                    dataset_name: str,
        -                                    projection_name: str,
        -                                    fields_to_delete: list,
        -                                    pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method delete a set of attributes into a dataset
        -    asynchronously, the caller does not wait until the projections 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 projection was inserted.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    projection_name: Represents the projection name.
        -    dataset_name: Represents the dataset name.
        -    fields_to_delete: Represents the set of attributes to be inserted.
        -    This is list with all attributes.
        -
        -    return: A JSON object with error or warning messages. In case of
        -    success, it returns the projection metadata.
        -    """
        -    dataset_metadata = self.search_projections_content(dataset_name,
        -                                                       limit=1)
        -
        -    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
        -        .get('fields')
        -    for field in fields_to_delete:
        -        fields_to_insert.remove(field)
        -
        -    response = self.insert_dataset_attributes_async(dataset_name,
        -                                                    projection_name,
        -                                                    fields_to_insert,
        -                                                    pretty_response)
        -
        -    return response
        -
        -
        -
        -def delete_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method delete a set of attributes on a dataset -synchronously, the caller waits until the projection is inserted into -the Learning Orchestra storage mechanism.

        -

        pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields_to_delete: Represents the set of attributes to be inserted. -This is list with all attributes.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

        -
        - -Expand source code - -
        def delete_dataset_attributes_sync(self,
        -                                   dataset_name: str,
        -                                   projection_name: str,
        -                                   fields_to_delete: list,
        -                                   pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method delete a set of attributes on a dataset
        -    synchronously, the caller waits until the projection is inserted into
        -    the Learning Orchestra storage mechanism.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    projection_name: Represents the projection name.
        -    dataset_name: Represents the dataset name.
        -    fields_to_delete: Represents the set of attributes to be inserted.
        -    This is list with all attributes.
        -
        -    return: A JSON object with error or warning messages. In case of
        -    success, it returns the projection metadata.
        -    """
        -    dataset_metadata = self.search_projections_content(dataset_name,
        -                                                       limit=1)
        -
        -    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
        -        .get('fields')
        -    for field in fields_to_delete:
        -        fields_to_insert.remove(field)
        -
        -    response = self.insert_dataset_attributes_sync(dataset_name,
        -                                                   projection_name,
        -                                                   fields_to_insert,
        -                                                   pretty_response)
        -
        -    return response
        -
        -
        -
        -def delete_projections(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 synchronous because it is very fast, -since the deletion is performed in background. If a projection was -used by another task (Ex. histogram, pca, tuning and so forth), -it cannot be deleted.

        -

        pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name.

        -

        return: JSON object with an error message, a warning message or a -correct delete message

        -
        - -Expand source code - -
        def delete_projections(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 synchronous because it is very fast,
        -    since the deletion is performed in background. If a projection was
        -    used by another task (Ex. histogram, pca, tuning and so forth),
        -    it cannot be deleted.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    projection_name: Represents the projection name.
        -
        -    return: JSON object with an error message, a warning message or a
        -    correct delete message
        -    """
        -    cluster_url_projection = self.cluster_url + "/" + projection_name
        -
        -    response = requests.delete(cluster_url_projection)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def insert_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method inserts a set of attributes into a dataset -asynchronously, the caller does not wait until the projections 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 projection was inserted.

        -

        pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields: Represents the set of attributes to be inserted. This is list -with all attributes.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

        -
        - -Expand source code - -
        def insert_dataset_attributes_async(self,
        -                                    dataset_name: str,
        -                                    projection_name: str,
        -                                    fields: list,
        -                                    pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method inserts a set of attributes into a dataset
        -    asynchronously, the caller does not wait until the projections 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 projection was inserted.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    projection_name: Represents the projection name.
        -    dataset_name: Represents the dataset name.
        -    fields: Represents the set of attributes to be inserted. This is list
        -    with all 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.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE PROJECTION FROM "
        -            + dataset_name
        -            + " TO "
        -            + projection_name
        -            + " ----------"
        -        )
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def insert_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: This method inserts a set of attributes into a dataset -synchronously, the caller waits until the projection is inserted into -the Learning Orchestra storage mechanism.

        -

        pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields: Represents the set of attributes to be inserted. This is list -with all attributes.

        -

        return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

        -
        - -Expand source code - -
        def insert_dataset_attributes_sync(self,
        -                                   dataset_name: str,
        -                                   projection_name: str,
        -                                   fields: list,
        -                                   pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method inserts a set of attributes into a dataset
        -    synchronously, the caller waits until the projection is inserted into
        -    the Learning Orchestra storage mechanism.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    projection_name: Represents the projection name.
        -    dataset_name: Represents the dataset name.
        -    fields: Represents the set of attributes to be inserted. This is list
        -    with all 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.cluster_url
        -
        -    response = requests.post(url=request_url, json=request_body)
        -
        -    Observer(projection_name, self.CLUSTER_IP).observe_processing(
        -        pretty_response)
        -
        -    if pretty_response:
        -        print(
        -            "\n----------"
        -            + " CREATE PROJECTION FROM "
        -            + dataset_name
        -            + " TO "
        -            + projection_name
        -            + " ----------"
        -        )
        -
        -    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, it does not -retrieve the projection content.

        -

        pretty_response: If true return indented string, else return dict.

        -

        return: A list with all projections metadata stored in Learning -Orchestra or an empty result.

        -
        - -Expand source code - -
        def search_all_projections(self, pretty_response: bool = False) \
        -        -> Union[dict, str]:
        -    """
        -    description: This method retrieves all projection metadata, it does not
        -    retrieve the projection content.
        -
        -    pretty_response: If true return indented string, else return dict.
        -
        -    return: A list with all projections metadata stored in Learning
        -    Orchestra or an empty result.
        -    """
        -    cluster_url_projection = self.cluster_url
        -
        -    response = requests.get(cluster_url_projection)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -def search_projections(self, projection_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
        -
        -

        description: -This method is responsible for retrieving a specific -projection.

        -

        pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an -error if there is no such projections.

        -
        - -Expand source code - -
        def search_projections(self, projection_name: str,
        -                       pretty_response: bool = False) -> Union[dict, str]:
        -    """
        -    description:  This method is responsible for retrieving a specific
        -    projection.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
        -    error if there is no such projections.
        -    """
        -    pretty = pretty_response
        -
        -    response = self.search_projections_content(projection_name, limit=1,
        -                                               pretty_response=pretty)
        -
        -    return response
        -
        -
        -
        -def search_projections_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 dataset -content.

        -

        pretty_response: If true return indented string, else return dict. -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.

        -
        - -Expand source code - -
        def search_projections_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 dataset
        -    content.
        -
        -    pretty_response: If true return indented string, else return dict.
        -    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.
        -    """
        -
        -    cluster_url_projection = self.cluster_url + "/" + projection_name + \
        -                             "?query=" + str(query) + \
        -                             "&limit=" + str(limit) + \
        -                             "&skip=" + str(skip)
        -
        -    response = requests.get(cluster_url_projection)
        -
        -    return self.response_treat.treatment(response, pretty_response)
        -
        -
        -
        -
        -
        -
        -
        - -
        - - - \ No newline at end of file From 6f671a9d897434c44d4e829d3bceb1a07d6aee49 Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Mon, 21 Dec 2020 16:47:17 -0300 Subject: [PATCH 10/28] update docs --- docs/builder.html | 790 ++++++++++++++++++++++++++++++++++++++++++++++ docs/dataset.html | 678 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 1468 insertions(+) create mode 100644 docs/builder.html create mode 100644 docs/dataset.html diff --git a/docs/builder.html b/docs/builder.html new file mode 100644 index 0000000..77f521b --- /dev/null +++ b/docs/builder.html @@ -0,0 +1,790 @@ + + + + + + +learning_orchestra_client.builder API documentation + + + + + + + + + + + +
        +
        +
        +

        Module learning_orchestra_client.builder

        +
        +
        +
        + +Expand source code + +
        from .observer import Observer
        +from .response_treat import ResponseTreat
        +from .dataset import Dataset
        +import requests
        +from typing import Union
        +
        +
        +class Builder:
        +    def __init__(self, ip_from_cluster: str):
        +        self.CLUSTER_IP = ip_from_cluster
        +        self.cluster_url = "http://" + ip_from_cluster + \
        +                           "/api/learningOrchestra/v1/builder"
        +        self.response_treat = ResponseTreat()
        +        self.TRAIN_NAME = "trainDatasetName"
        +        self.TEST_NAME = "testDatasetName"
        +        self.CODE = "modelingCode"
        +        self.CLASSIFIERS_LIST = "classifiersList"
        +        self.dataset = Dataset(ip_from_cluster)
        +        self.METADATA_INDEX = 0
        +
        +    def run_builder_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 resource join several steps of machine
        +        learning workflow (transform, tune, train and evaluate) coupling in
        +        a unique resource, builder creates several model predictions using
        +        your own modeling code using a defined set of classifiers. This is made
        +        synchronously, the caller waits until the model predictions are inserted
        +        into the Learning Orchestra storage mechanism.
        +
        +        train_dataset_name: Represent final train dataset.
        +        test_dataset_name: Represent final test dataset.
        +        modeling_code: Represent Python3 code for pyspark preprocessing model
        +        model_classifiers: list of initial classifiers to be used in model
        +        pretty_response: returns indented string for visualization if True
        +
        +        return: The resulted predictions URIs.
        +        """
        +
        +        if pretty_response:
        +            print(
        +                "\n----------"
        +                + " CREATE MODEL WITH "
        +                + train_dataset_name
        +                + " AND "
        +                + test_dataset_name
        +                + " ----------"
        +            )
        +
        +        request_body_content = {
        +            self.TRAIN_NAME: train_dataset_name,
        +            self.TEST_NAME: test_dataset_name,
        +            self.CODE: modeling_code,
        +            self.CLASSIFIERS_LIST: model_classifiers,
        +        }
        +        response = requests.post(url=self.cluster_url,
        +                                 json=request_body_content)
        +
        +        observer = Observer(test_dataset_name, self.CLUSTER_IP)
        +
        +        for model in model_classifiers:
        +            observer.set_dataset_name(test_dataset_name + model)
        +            observer.observe_processing(pretty_response)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def run_builder_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 resource join several steps of machine
        +        learning workflow (transform, tune, train and evaluate) coupling in
        +        a unique resource, builder creates several model predictions using
        +        your own modeling code using a defined set of classifiers. This is made
        +        asynchronously, the caller does not wait until the model predictions are
        +        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 model predictions are inserted.
        +
        +        train_dataset_name: Represent final train dataset.
        +        test_dataset_name: Represent final test dataset.
        +        modeling_code: Represent Python3 code for pyspark preprocessing model
        +        model_classifiers: list of initial classifiers to be used in model
        +        pretty_response: returns indented string for visualization if True
        +
        +        return: The resulted predictions URIs.
        +        """
        +        if pretty_response:
        +            print(
        +                "\n----------"
        +                + " CREATE MODEL WITH "
        +                + train_dataset_name
        +                + " AND "
        +                + test_dataset_name
        +                + " ----------"
        +            )
        +
        +        request_body_content = {
        +            self.TRAIN_NAME: train_dataset_name,
        +            self.TEST_NAME: test_dataset_name,
        +            self.CODE: modeling_code,
        +            self.CLASSIFIERS_LIST: model_classifiers,
        +        }
        +        response = requests.post(url=self.cluster_url,
        +                                 json=request_body_content)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def search_all_model(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 return indented string, else return dict.
        +
        +        return: A list with all model predictions metadata stored in Learning
        +        Orchestra or an empty result.
        +        """
        +
        +        cluster_url_tsne = self.cluster_url
        +
        +        response = requests.get(cluster_url_tsne)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def search_model_prediction(self,
        +                                model_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 return indented string, else return dict.
        +        model_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 there
        +        is no such projection. The current page is also returned to be used in
        +        future content requests.
        +        """
        +
        +        cluster_url_dataset = self.cluster_url + "/" + model_name + \
        +                              "?query=" + str(query) + \
        +                              "&limit=" + str(limit) + \
        +                              "&skip=" + str(skip)
        +
        +        response = requests.get(cluster_url_dataset)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def search_model(self, model_name: str, pretty_response: bool = False) \
        +            -> Union[dict, str]:
        +        """
        +        description:  This method is responsible for retrieving a specific
        +        model prediction metadata.
        +
        +        pretty_response: If true return indented string, else return dict.
        +        model_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_model_prediction(model_name, limit=1,
        +                                                pretty_response=pretty_response)
        +
        +        return response
        +
        +    def delete_model(self, model_name: str, pretty_response: bool = False) \
        +            -> Union[dict, str]:
        +        """
        +        description: This method is responsible for deleting a model prediction.
        +        The delete operation is always synchronous because it is very fast,
        +        since the deletion is performed in background.
        +
        +        pretty_response: If true return indented string, else return dict.
        +        model_name: Represents the projection name.
        +
        +        return: JSON object with an error message, a warning message or a
        +        correct delete message
        +        """
        +
        +        cluster_url_dataset = self.cluster_url + "/" + model_name
        +
        +        response = requests.delete(cluster_url_dataset)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Builder +(ip_from_cluster: str) +
        +
        +
        +
        + +Expand source code + +
        class Builder:
        +    def __init__(self, ip_from_cluster: str):
        +        self.CLUSTER_IP = ip_from_cluster
        +        self.cluster_url = "http://" + ip_from_cluster + \
        +                           "/api/learningOrchestra/v1/builder"
        +        self.response_treat = ResponseTreat()
        +        self.TRAIN_NAME = "trainDatasetName"
        +        self.TEST_NAME = "testDatasetName"
        +        self.CODE = "modelingCode"
        +        self.CLASSIFIERS_LIST = "classifiersList"
        +        self.dataset = Dataset(ip_from_cluster)
        +        self.METADATA_INDEX = 0
        +
        +    def run_builder_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 resource join several steps of machine
        +        learning workflow (transform, tune, train and evaluate) coupling in
        +        a unique resource, builder creates several model predictions using
        +        your own modeling code using a defined set of classifiers. This is made
        +        synchronously, the caller waits until the model predictions are inserted
        +        into the Learning Orchestra storage mechanism.
        +
        +        train_dataset_name: Represent final train dataset.
        +        test_dataset_name: Represent final test dataset.
        +        modeling_code: Represent Python3 code for pyspark preprocessing model
        +        model_classifiers: list of initial classifiers to be used in model
        +        pretty_response: returns indented string for visualization if True
        +
        +        return: The resulted predictions URIs.
        +        """
        +
        +        if pretty_response:
        +            print(
        +                "\n----------"
        +                + " CREATE MODEL WITH "
        +                + train_dataset_name
        +                + " AND "
        +                + test_dataset_name
        +                + " ----------"
        +            )
        +
        +        request_body_content = {
        +            self.TRAIN_NAME: train_dataset_name,
        +            self.TEST_NAME: test_dataset_name,
        +            self.CODE: modeling_code,
        +            self.CLASSIFIERS_LIST: model_classifiers,
        +        }
        +        response = requests.post(url=self.cluster_url,
        +                                 json=request_body_content)
        +
        +        observer = Observer(test_dataset_name, self.CLUSTER_IP)
        +
        +        for model in model_classifiers:
        +            observer.set_dataset_name(test_dataset_name + model)
        +            observer.observe_processing(pretty_response)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def run_builder_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 resource join several steps of machine
        +        learning workflow (transform, tune, train and evaluate) coupling in
        +        a unique resource, builder creates several model predictions using
        +        your own modeling code using a defined set of classifiers. This is made
        +        asynchronously, the caller does not wait until the model predictions are
        +        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 model predictions are inserted.
        +
        +        train_dataset_name: Represent final train dataset.
        +        test_dataset_name: Represent final test dataset.
        +        modeling_code: Represent Python3 code for pyspark preprocessing model
        +        model_classifiers: list of initial classifiers to be used in model
        +        pretty_response: returns indented string for visualization if True
        +
        +        return: The resulted predictions URIs.
        +        """
        +        if pretty_response:
        +            print(
        +                "\n----------"
        +                + " CREATE MODEL WITH "
        +                + train_dataset_name
        +                + " AND "
        +                + test_dataset_name
        +                + " ----------"
        +            )
        +
        +        request_body_content = {
        +            self.TRAIN_NAME: train_dataset_name,
        +            self.TEST_NAME: test_dataset_name,
        +            self.CODE: modeling_code,
        +            self.CLASSIFIERS_LIST: model_classifiers,
        +        }
        +        response = requests.post(url=self.cluster_url,
        +                                 json=request_body_content)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def search_all_model(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 return indented string, else return dict.
        +
        +        return: A list with all model predictions metadata stored in Learning
        +        Orchestra or an empty result.
        +        """
        +
        +        cluster_url_tsne = self.cluster_url
        +
        +        response = requests.get(cluster_url_tsne)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def search_model_prediction(self,
        +                                model_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 return indented string, else return dict.
        +        model_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 there
        +        is no such projection. The current page is also returned to be used in
        +        future content requests.
        +        """
        +
        +        cluster_url_dataset = self.cluster_url + "/" + model_name + \
        +                              "?query=" + str(query) + \
        +                              "&limit=" + str(limit) + \
        +                              "&skip=" + str(skip)
        +
        +        response = requests.get(cluster_url_dataset)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def search_model(self, model_name: str, pretty_response: bool = False) \
        +            -> Union[dict, str]:
        +        """
        +        description:  This method is responsible for retrieving a specific
        +        model prediction metadata.
        +
        +        pretty_response: If true return indented string, else return dict.
        +        model_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_model_prediction(model_name, limit=1,
        +                                                pretty_response=pretty_response)
        +
        +        return response
        +
        +    def delete_model(self, model_name: str, pretty_response: bool = False) \
        +            -> Union[dict, str]:
        +        """
        +        description: This method is responsible for deleting a model prediction.
        +        The delete operation is always synchronous because it is very fast,
        +        since the deletion is performed in background.
        +
        +        pretty_response: If true return indented string, else return dict.
        +        model_name: Represents the projection name.
        +
        +        return: JSON object with an error message, a warning message or a
        +        correct delete message
        +        """
        +
        +        cluster_url_dataset = self.cluster_url + "/" + model_name
        +
        +        response = requests.delete(cluster_url_dataset)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +

        Methods

        +
        +
        +def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
        +
        +

        description: This method is responsible for deleting a model prediction. +The delete operation is always synchronous because it is very fast, +since the deletion is performed in background.

        +

        pretty_response: If true return indented string, else return dict. +model_name: Represents the projection name.

        +

        return: JSON object with an error message, a warning message or a +correct delete message

        +
        + +Expand source code + +
        def delete_model(self, model_name: str, pretty_response: bool = False) \
        +        -> Union[dict, str]:
        +    """
        +    description: This method is responsible for deleting a model prediction.
        +    The delete operation is always synchronous because it is very fast,
        +    since the deletion is performed in background.
        +
        +    pretty_response: If true return indented string, else return dict.
        +    model_name: Represents the projection name.
        +
        +    return: JSON object with an error message, a warning message or a
        +    correct delete message
        +    """
        +
        +    cluster_url_dataset = self.cluster_url + "/" + model_name
        +
        +    response = requests.delete(cluster_url_dataset)
        +
        +    return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +asynchronously, the caller does not wait until the model predictions are +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 model predictions are inserted.

        +

        train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

        +

        return: The resulted predictions URIs.

        +
        + +Expand source code + +
        def run_builder_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 resource join several steps of machine
        +    learning workflow (transform, tune, train and evaluate) coupling in
        +    a unique resource, builder creates several model predictions using
        +    your own modeling code using a defined set of classifiers. This is made
        +    asynchronously, the caller does not wait until the model predictions are
        +    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 model predictions are inserted.
        +
        +    train_dataset_name: Represent final train dataset.
        +    test_dataset_name: Represent final test dataset.
        +    modeling_code: Represent Python3 code for pyspark preprocessing model
        +    model_classifiers: list of initial classifiers to be used in model
        +    pretty_response: returns indented string for visualization if True
        +
        +    return: The resulted predictions URIs.
        +    """
        +    if pretty_response:
        +        print(
        +            "\n----------"
        +            + " CREATE MODEL WITH "
        +            + train_dataset_name
        +            + " AND "
        +            + test_dataset_name
        +            + " ----------"
        +        )
        +
        +    request_body_content = {
        +        self.TRAIN_NAME: train_dataset_name,
        +        self.TEST_NAME: test_dataset_name,
        +        self.CODE: modeling_code,
        +        self.CLASSIFIERS_LIST: model_classifiers,
        +    }
        +    response = requests.post(url=self.cluster_url,
        +                             json=request_body_content)
        +
        +    return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +def run_builder_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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +synchronously, the caller waits until the model predictions are inserted +into the Learning Orchestra storage mechanism.

        +

        train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

        +

        return: The resulted predictions URIs.

        +
        + +Expand source code + +
        def run_builder_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 resource join several steps of machine
        +    learning workflow (transform, tune, train and evaluate) coupling in
        +    a unique resource, builder creates several model predictions using
        +    your own modeling code using a defined set of classifiers. This is made
        +    synchronously, the caller waits until the model predictions are inserted
        +    into the Learning Orchestra storage mechanism.
        +
        +    train_dataset_name: Represent final train dataset.
        +    test_dataset_name: Represent final test dataset.
        +    modeling_code: Represent Python3 code for pyspark preprocessing model
        +    model_classifiers: list of initial classifiers to be used in model
        +    pretty_response: returns indented string for visualization if True
        +
        +    return: The resulted predictions URIs.
        +    """
        +
        +    if pretty_response:
        +        print(
        +            "\n----------"
        +            + " CREATE MODEL WITH "
        +            + train_dataset_name
        +            + " AND "
        +            + test_dataset_name
        +            + " ----------"
        +        )
        +
        +    request_body_content = {
        +        self.TRAIN_NAME: train_dataset_name,
        +        self.TEST_NAME: test_dataset_name,
        +        self.CODE: modeling_code,
        +        self.CLASSIFIERS_LIST: model_classifiers,
        +    }
        +    response = requests.post(url=self.cluster_url,
        +                             json=request_body_content)
        +
        +    observer = Observer(test_dataset_name, self.CLUSTER_IP)
        +
        +    for model in model_classifiers:
        +        observer.set_dataset_name(test_dataset_name + model)
        +        observer.observe_processing(pretty_response)
        +
        +    return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +def search_all_model(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 return indented string, else return dict.

        +

        return: A list with all model predictions metadata stored in Learning +Orchestra or an empty result.

        +
        + +Expand source code + +
        def search_all_model(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 return indented string, else return dict.
        +
        +    return: A list with all model predictions metadata stored in Learning
        +    Orchestra or an empty result.
        +    """
        +
        +    cluster_url_tsne = self.cluster_url
        +
        +    response = requests.get(cluster_url_tsne)
        +
        +    return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
        +
        +

        description: +This method is responsible for retrieving a specific +model prediction metadata.

        +

        pretty_response: If true return indented string, else return dict. +model_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.

        +
        + +Expand source code + +
        def search_model(self, model_name: str, pretty_response: bool = False) \
        +        -> Union[dict, str]:
        +    """
        +    description:  This method is responsible for retrieving a specific
        +    model prediction metadata.
        +
        +    pretty_response: If true return indented string, else return dict.
        +    model_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_model_prediction(model_name, limit=1,
        +                                            pretty_response=pretty_response)
        +
        +    return response
        +
        +
        +
        +def search_model_prediction(self, model_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 return indented string, else return dict. +model_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 there +is no such projection. The current page is also returned to be used in +future content requests.

        +
        + +Expand source code + +
        def search_model_prediction(self,
        +                            model_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 return indented string, else return dict.
        +    model_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 there
        +    is no such projection. The current page is also returned to be used in
        +    future content requests.
        +    """
        +
        +    cluster_url_dataset = self.cluster_url + "/" + model_name + \
        +                          "?query=" + str(query) + \
        +                          "&limit=" + str(limit) + \
        +                          "&skip=" + str(skip)
        +
        +    response = requests.get(cluster_url_dataset)
        +
        +    return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/dataset.html b/docs/dataset.html new file mode 100644 index 0000000..d8435fc --- /dev/null +++ b/docs/dataset.html @@ -0,0 +1,678 @@ + + + + + + +learning_orchestra_client.dataset API documentation + + + + + + + + + + + +
        +
        +
        +

        Module learning_orchestra_client.dataset

        +
        +
        +
        + +Expand source code + +
        __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
        +__credits__ = "all free source developers"
        +__status__ = "Prototype"
        +
        +from .observer import Observer
        +from .response_treat import ResponseTreat
        +import requests
        +from typing import Union
        +
        +
        +class Dataset:
        +    def __init__(self, ip_from_cluster: str):
        +        self.cluster_url = "http://" + ip_from_cluster + \
        +                           "/api/learningOrchestra/v1/dataset"
        +        self.response_treat = ResponseTreat()
        +        self.OUTPUT_NAME = "datasetName"
        +        self.URL = "datasetURI"
        +        self.CLUSTER_IP = ip_from_cluster
        +
        +    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 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.
        +        """
        +        request_body = {self.OUTPUT_NAME: dataset_name,
        +                        self.URL: url}
        +        request_url = self.cluster_url
        +
        +        response = requests.post(url=request_url, json=request_body)
        +
        +        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
        +
        +        if pretty_response:
        +            print("\n----------" + " CREATED FILE " + 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).
        +        """
        +        request_body = {self.OUTPUT_NAME: dataset_name,
        +                        self.URL: url}
        +        request_url = self.cluster_url
        +
        +        response = requests.post(url=request_url, json=request_body)
        +
        +        if pretty_response:
        +            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
        +                                                                     "---")
        +        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 return indented string, else return dict.
        +
        +        return: All datasets metadata stored in Learning Orchestra or an empty
        +        result.
        +        """
        +        request_url = self.cluster_url
        +
        +        response = requests.get(request_url)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
        +            -> Union[dict, str]:
        +        """
        +        description: This method is responsible for retrieving a specific
        +        dataset
        +
        +        pretty_response: If true return indented string, else return dict.
        +        dataset_name: Is the name of the dataset file.
        +        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 dataset metadata stored in Learning Orchestra or an
        +        error if there is no such dataset.
        +        """
        +        response = self.search_dataset_content(dataset_name, limit=1,
        +                                               pretty_response=pretty_response)
        +
        +        return 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 return indented string, else return dict.
        +        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.
        +        """
        +
        +        request_url = self.cluster_url + "/" + dataset_name + \
        +                      "?query=" + str(query) + \
        +                      "&limit=" + str(limit) + \
        +                      "&skip=" + str(skip)
        +
        +        response = requests.get(request_url)
        +
        +        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. The
        +        delete operation is always synchronous because it is very fast, since
        +        the deletion is performed in background. If a dataset was used by
        +        another task (Ex. projection, histogram, pca, tuning and so forth), it
        +        cannot be deleted.
        +
        +        pretty_response: If true return indented string, else return dict.
        +        dataset_name: Represents the dataset name.
        +
        +        return: JSON object with an error message, a warning message or a
        +        correct delete message
        +        """
        +
        +        request_url = self.cluster_url + "/" + dataset_name
        +
        +        response = requests.delete(request_url)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Dataset +(ip_from_cluster: str) +
        +
        +
        +
        + +Expand source code + +
        class Dataset:
        +    def __init__(self, ip_from_cluster: str):
        +        self.cluster_url = "http://" + ip_from_cluster + \
        +                           "/api/learningOrchestra/v1/dataset"
        +        self.response_treat = ResponseTreat()
        +        self.OUTPUT_NAME = "datasetName"
        +        self.URL = "datasetURI"
        +        self.CLUSTER_IP = ip_from_cluster
        +
        +    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 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.
        +        """
        +        request_body = {self.OUTPUT_NAME: dataset_name,
        +                        self.URL: url}
        +        request_url = self.cluster_url
        +
        +        response = requests.post(url=request_url, json=request_body)
        +
        +        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
        +
        +        if pretty_response:
        +            print("\n----------" + " CREATED FILE " + 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).
        +        """
        +        request_body = {self.OUTPUT_NAME: dataset_name,
        +                        self.URL: url}
        +        request_url = self.cluster_url
        +
        +        response = requests.post(url=request_url, json=request_body)
        +
        +        if pretty_response:
        +            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
        +                                                                     "---")
        +        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 return indented string, else return dict.
        +
        +        return: All datasets metadata stored in Learning Orchestra or an empty
        +        result.
        +        """
        +        request_url = self.cluster_url
        +
        +        response = requests.get(request_url)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
        +            -> Union[dict, str]:
        +        """
        +        description: This method is responsible for retrieving a specific
        +        dataset
        +
        +        pretty_response: If true return indented string, else return dict.
        +        dataset_name: Is the name of the dataset file.
        +        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 dataset metadata stored in Learning Orchestra or an
        +        error if there is no such dataset.
        +        """
        +        response = self.search_dataset_content(dataset_name, limit=1,
        +                                               pretty_response=pretty_response)
        +
        +        return 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 return indented string, else return dict.
        +        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.
        +        """
        +
        +        request_url = self.cluster_url + "/" + dataset_name + \
        +                      "?query=" + str(query) + \
        +                      "&limit=" + str(limit) + \
        +                      "&skip=" + str(skip)
        +
        +        response = requests.get(request_url)
        +
        +        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. The
        +        delete operation is always synchronous because it is very fast, since
        +        the deletion is performed in background. If a dataset was used by
        +        another task (Ex. projection, histogram, pca, tuning and so forth), it
        +        cannot be deleted.
        +
        +        pretty_response: If true return indented string, else return dict.
        +        dataset_name: Represents the dataset name.
        +
        +        return: JSON object with an error message, a warning message or a
        +        correct delete message
        +        """
        +
        +        request_url = self.cluster_url + "/" + dataset_name
        +
        +        response = requests.delete(request_url)
        +
        +        return self.response_treat.treatment(response, pretty_response)
        +
        +

        Methods

        +
        +
        +def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] +
        +
        +

        description: This method is responsible for deleting the dataset. The +delete operation is always synchronous because it is very fast, since +the deletion is performed in background. If a dataset was used by +another task (Ex. projection, histogram, pca, tuning and so forth), it +cannot be deleted.

        +

        pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset name.

        +

        return: JSON object with an error message, a warning message or a +correct delete message

        +
        + +Expand source code + +
        def delete_dataset(self, dataset_name, pretty_response=False) \
        +        -> Union[dict, str]:
        +    """
        +    description: This method is responsible for deleting the dataset. The
        +    delete operation is always synchronous because it is very fast, since
        +    the deletion is performed in background. If a dataset was used by
        +    another task (Ex. projection, histogram, pca, tuning and so forth), it
        +    cannot be deleted.
        +
        +    pretty_response: If true return indented string, else return dict.
        +    dataset_name: Represents the dataset name.
        +
        +    return: JSON object with an error message, a warning message or a
        +    correct delete message
        +    """
        +
        +    request_url = self.cluster_url + "/" + dataset_name
        +
        +    response = requests.delete(request_url)
        +
        +    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).

        +
        + +Expand source code + +
        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).
        +    """
        +    request_body = {self.OUTPUT_NAME: dataset_name,
        +                    self.URL: url}
        +    request_url = self.cluster_url
        +
        +    response = requests.post(url=request_url, json=request_body)
        +
        +    if pretty_response:
        +        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
        +                                                                 "---")
        +    return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +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 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.

        +
        + +Expand source code + +
        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 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.
        +    """
        +    request_body = {self.OUTPUT_NAME: dataset_name,
        +                    self.URL: url}
        +    request_url = self.cluster_url
        +
        +    response = requests.post(url=request_url, json=request_body)
        +
        +    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
        +
        +    if pretty_response:
        +        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
        +                                                                 "---")
        +    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 return indented string, else return dict.

        +

        return: All datasets metadata stored in Learning Orchestra or an empty +result.

        +
        + +Expand source code + +
        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 return indented string, else return dict.
        +
        +    return: All datasets metadata stored in Learning Orchestra or an empty
        +    result.
        +    """
        +    request_url = self.cluster_url
        +
        +    response = requests.get(request_url)
        +
        +    return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] +
        +
        +

        description: This method is responsible for retrieving a specific +dataset

        +

        pretty_response: If true return indented string, else return dict. +dataset_name: Is the name of the dataset file. +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 dataset metadata stored in Learning Orchestra or an +error if there is no such dataset.

        +
        + +Expand source code + +
        def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
        +        -> Union[dict, str]:
        +    """
        +    description: This method is responsible for retrieving a specific
        +    dataset
        +
        +    pretty_response: If true return indented string, else return dict.
        +    dataset_name: Is the name of the dataset file.
        +    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 dataset metadata stored in Learning Orchestra or an
        +    error if there is no such dataset.
        +    """
        +    response = self.search_dataset_content(dataset_name, limit=1,
        +                                           pretty_response=pretty_response)
        +
        +    return 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 return indented string, else return dict. +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.

        +
        + +Expand source code + +
        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 return indented string, else return dict.
        +    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.
        +    """
        +
        +    request_url = self.cluster_url + "/" + dataset_name + \
        +                  "?query=" + str(query) + \
        +                  "&limit=" + str(limit) + \
        +                  "&skip=" + str(skip)
        +
        +    response = requests.get(request_url)
        +
        +    return self.response_treat.treatment(response, pretty_response)
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file From 9b8f13613f298d126cb57c56205b99e5225d3bea Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Mon, 21 Dec 2020 19:51:51 -0300 Subject: [PATCH 11/28] update docs --- docs/builder.html | 2 +- docs/dataset.html | 2 +- docs/explore/histogram.html | 2 +- docs/explore/pca.html | 2 +- docs/explore/tsne.html | 2 +- docs/index.html | 5 - docs/response_treat.html | 197 --------------------------------- docs/transform/data_type.html | 2 +- docs/transform/projection.html | 2 +- 9 files changed, 7 insertions(+), 209 deletions(-) delete mode 100644 docs/response_treat.html diff --git a/docs/builder.html b/docs/builder.html index 77f521b..77ce1c4 100644 --- a/docs/builder.html +++ b/docs/builder.html @@ -27,7 +27,7 @@

        Module learning_orchestra_client.builder

        Expand source code
        from .observer import Observer
        -from .response_treat import ResponseTreat
        +from ._response_treat import ResponseTreat
         from .dataset import Dataset
         import requests
         from typing import Union
        diff --git a/docs/dataset.html b/docs/dataset.html
        index d8435fc..b8b02a0 100644
        --- a/docs/dataset.html
        +++ b/docs/dataset.html
        @@ -31,7 +31,7 @@ 

        Module learning_orchestra_client.dataset

        __status__ = "Prototype" from .observer import Observer -from .response_treat import ResponseTreat +from ._response_treat import ResponseTreat import requests from typing import Union diff --git a/docs/explore/histogram.html b/docs/explore/histogram.html index a90cf94..d4a510e 100644 --- a/docs/explore/histogram.html +++ b/docs/explore/histogram.html @@ -27,7 +27,7 @@

        Module learning_orchestra_client.explore.histogramExpand source code
        from ..observer import Observer
        -from ..response_treat import ResponseTreat
        +from .._response_treat import ResponseTreat
         from ..dataset import Dataset
         import requests
         from typing import Union
        diff --git a/docs/explore/pca.html b/docs/explore/pca.html
        index 7dbc910..96011a2 100644
        --- a/docs/explore/pca.html
        +++ b/docs/explore/pca.html
        @@ -26,7 +26,7 @@ 

        Module learning_orchestra_client.explore.pca

        Expand source code -
        from ..response_treat import ResponseTreat
        +
        from .._response_treat import ResponseTreat
         from ..dataset import Dataset
         from PIL import Image
         import requests
        diff --git a/docs/explore/tsne.html b/docs/explore/tsne.html
        index 15569b0..e027e0a 100644
        --- a/docs/explore/tsne.html
        +++ b/docs/explore/tsne.html
        @@ -26,7 +26,7 @@ 

        Module learning_orchestra_client.explore.tsne

        Expand source code -
        from ..response_treat import ResponseTreat
        +
        from .._response_treat import ResponseTreat
         from ..dataset import Dataset
         from PIL import Image
         import requests
        diff --git a/docs/index.html b/docs/index.html
        index 9189de8..46c4a70 100644
        --- a/docs/index.html
        +++ b/docs/index.html
        @@ -42,10 +42,6 @@ 

        Sub-modules

        -
        learning_orchestra_client.response_treat
        -
        -
        -
        learning_orchestra_client.transform
        @@ -71,7 +67,6 @@

        Index

      • learning_orchestra_client.dataset
      • learning_orchestra_client.explore
      • learning_orchestra_client.observer
      • -
      • learning_orchestra_client.response_treat
      • learning_orchestra_client.transform
    • diff --git a/docs/response_treat.html b/docs/response_treat.html deleted file mode 100644 index 2c8bb2a..0000000 --- a/docs/response_treat.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - -learning_orchestra_client.response_treat API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.response_treat

      -
      -
      -
      - -Expand source code - -
      __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
      -__credits__ = "all free source developers"
      -__status__ = "Prototype"
      -
      -import json
      -
      -
      -class ResponseTreat:
      -    HTTP_CREATED = 201
      -    HTTP_SUCCESS = 200
      -    HTTP_ERROR = 500
      -
      -    def treatment(self, response, pretty_response: bool = True):
      -        """
      -        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:
      -            return response.text
      -        elif (
      -                response.status_code != self.HTTP_SUCCESS
      -                and response.status_code != self.HTTP_CREATED
      -        ):
      -            raise Exception(response.json()["result"])
      -        else:
      -            if pretty_response:
      -                return json.dumps(response.json(), indent=4, sort_keys=True)
      -            else:
      -                return response.json()
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class ResponseTreat -
      -
      -
      -
      - -Expand source code - -
      class ResponseTreat:
      -    HTTP_CREATED = 201
      -    HTTP_SUCCESS = 200
      -    HTTP_ERROR = 500
      -
      -    def treatment(self, response, pretty_response: bool = True):
      -        """
      -        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:
      -            return response.text
      -        elif (
      -                response.status_code != self.HTTP_SUCCESS
      -                and response.status_code != self.HTTP_CREATED
      -        ):
      -            raise Exception(response.json()["result"])
      -        else:
      -            if pretty_response:
      -                return json.dumps(response.json(), indent=4, sort_keys=True)
      -            else:
      -                return response.json()
      -
      -

      Class variables

      -
      -
      var HTTP_CREATED
      -
      -
      -
      -
      var HTTP_ERROR
      -
      -
      -
      -
      var HTTP_SUCCESS
      -
      -
      -
      -
      -

      Methods

      -
      -
      -def treatment(self, response, pretty_response: bool = True) -
      -
      -

      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.

      -
      - -Expand source code - -
      def treatment(self, response, pretty_response: bool = True):
      -    """
      -    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:
      -        return response.text
      -    elif (
      -            response.status_code != self.HTTP_SUCCESS
      -            and response.status_code != self.HTTP_CREATED
      -    ):
      -        raise Exception(response.json()["result"])
      -    else:
      -        if pretty_response:
      -            return json.dumps(response.json(), indent=4, sort_keys=True)
      -        else:
      -            return response.json()
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/transform/data_type.html b/docs/transform/data_type.html index 444301d..ab70288 100644 --- a/docs/transform/data_type.html +++ b/docs/transform/data_type.html @@ -26,7 +26,7 @@

      Module learning_orchestra_client.transform.data_type Expand source code -
      from ..response_treat import ResponseTreat
      +
      from .._response_treat import ResponseTreat
       from ..dataset import Dataset
       import requests
       from typing import Union
      diff --git a/docs/transform/projection.html b/docs/transform/projection.html
      index 6158b25..0ee1113 100644
      --- a/docs/transform/projection.html
      +++ b/docs/transform/projection.html
      @@ -26,7 +26,7 @@ 

      Module learning_orchestra_client.transform.projection Expand source code -
      from ..response_treat import ResponseTreat
      +
      from .._response_treat import ResponseTreat
       from ..dataset import Dataset
       from ..observer import Observer
       import requests
      
      From 396d969fcb98545223913d1de35a3c31bbc877aa Mon Sep 17 00:00:00 2001
      From: Gabriel Ribeiro 
      Date: Sat, 10 Apr 2021 08:38:43 -0300
      Subject: [PATCH 12/28] update docs
      
      ---
       docs/builder.html                         |  790 ----------------
       docs/dataset.html                         |  678 --------------
       docs/explore/histogram.html               |  676 --------------
       docs/explore/index.html                   |   75 --
       docs/explore/pca.html                     |  742 ---------------
       docs/explore/tsne.html                    |  742 ---------------
       docs/index.html                           |   80 --
       docs/observer.html                        |  375 --------
       docs/transform/data_type.html             |  199 ----
       docs/transform/index.html                 |   70 --
       docs/transform/projection.html            | 1035 ---------------------
       learning_orchestra_client/explore/pca.py  |  193 ----
       learning_orchestra_client/explore/tsne.py |  193 ----
       13 files changed, 5848 deletions(-)
       delete mode 100644 docs/builder.html
       delete mode 100644 docs/dataset.html
       delete mode 100644 docs/explore/histogram.html
       delete mode 100644 docs/explore/index.html
       delete mode 100644 docs/explore/pca.html
       delete mode 100644 docs/explore/tsne.html
       delete mode 100644 docs/index.html
       delete mode 100644 docs/observer.html
       delete mode 100644 docs/transform/data_type.html
       delete mode 100644 docs/transform/index.html
       delete mode 100644 docs/transform/projection.html
       delete mode 100644 learning_orchestra_client/explore/pca.py
       delete mode 100644 learning_orchestra_client/explore/tsne.py
      
      diff --git a/docs/builder.html b/docs/builder.html
      deleted file mode 100644
      index 77ce1c4..0000000
      --- a/docs/builder.html
      +++ /dev/null
      @@ -1,790 +0,0 @@
      -
      -
      -
      -
      -
      -
      -learning_orchestra_client.builder API documentation
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Module learning_orchestra_client.builder

      -
      -
      -
      - -Expand source code - -
      from .observer import Observer
      -from ._response_treat import ResponseTreat
      -from .dataset import Dataset
      -import requests
      -from typing import Union
      -
      -
      -class Builder:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/builder"
      -        self.response_treat = ResponseTreat()
      -        self.TRAIN_NAME = "trainDatasetName"
      -        self.TEST_NAME = "testDatasetName"
      -        self.CODE = "modelingCode"
      -        self.CLASSIFIERS_LIST = "classifiersList"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.METADATA_INDEX = 0
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        synchronously, the caller waits until the model predictions are inserted
      -        into the Learning Orchestra storage mechanism.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
      -
      -        for model in model_classifiers:
      -            observer.set_dataset_name(test_dataset_name + model)
      -            observer.observe_processing(pretty_response)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        asynchronously, the caller does not wait until the model predictions are
      -        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 model predictions are inserted.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_model(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 return indented string, else return dict.
      -
      -        return: A list with all model predictions metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model_prediction(self,
      -                                model_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 return indented string, else return dict.
      -        model_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 there
      -        is no such projection. The current page is also returned to be used in
      -        future content requests.
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
      -                              "?query=" + str(query) + \
      -                              "&limit=" + str(limit) + \
      -                              "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        model prediction metadata.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_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_model_prediction(model_name, limit=1,
      -                                                pretty_response=pretty_response)
      -
      -        return response
      -
      -    def delete_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting a model prediction.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name
      -
      -        response = requests.delete(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Builder -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Builder:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/builder"
      -        self.response_treat = ResponseTreat()
      -        self.TRAIN_NAME = "trainDatasetName"
      -        self.TEST_NAME = "testDatasetName"
      -        self.CODE = "modelingCode"
      -        self.CLASSIFIERS_LIST = "classifiersList"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.METADATA_INDEX = 0
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        synchronously, the caller waits until the model predictions are inserted
      -        into the Learning Orchestra storage mechanism.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
      -
      -        for model in model_classifiers:
      -            observer.set_dataset_name(test_dataset_name + model)
      -            observer.observe_processing(pretty_response)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        asynchronously, the caller does not wait until the model predictions are
      -        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 model predictions are inserted.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_model(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 return indented string, else return dict.
      -
      -        return: A list with all model predictions metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model_prediction(self,
      -                                model_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 return indented string, else return dict.
      -        model_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 there
      -        is no such projection. The current page is also returned to be used in
      -        future content requests.
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
      -                              "?query=" + str(query) + \
      -                              "&limit=" + str(limit) + \
      -                              "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        model prediction metadata.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_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_model_prediction(model_name, limit=1,
      -                                                pretty_response=pretty_response)
      -
      -        return response
      -
      -    def delete_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting a model prediction.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name
      -
      -        response = requests.delete(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting a model prediction. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -model_name: Represents the projection name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      def delete_model(self, model_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting a model prediction.
      -    The delete operation is always synchronous because it is very fast,
      -    since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    model_name: Represents the projection name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -
      -    cluster_url_dataset = self.cluster_url + "/" + model_name
      -
      -    response = requests.delete(cluster_url_dataset)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -asynchronously, the caller does not wait until the model predictions are -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 model predictions are inserted.

      -

      train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

      -

      return: The resulted predictions URIs.

      -
      - -Expand source code - -
      def run_builder_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 resource join several steps of machine
      -    learning workflow (transform, tune, train and evaluate) coupling in
      -    a unique resource, builder creates several model predictions using
      -    your own modeling code using a defined set of classifiers. This is made
      -    asynchronously, the caller does not wait until the model predictions are
      -    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 model predictions are inserted.
      -
      -    train_dataset_name: Represent final train dataset.
      -    test_dataset_name: Represent final test dataset.
      -    modeling_code: Represent Python3 code for pyspark preprocessing model
      -    model_classifiers: list of initial classifiers to be used in model
      -    pretty_response: returns indented string for visualization if True
      -
      -    return: The resulted predictions URIs.
      -    """
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE MODEL WITH "
      -            + train_dataset_name
      -            + " AND "
      -            + test_dataset_name
      -            + " ----------"
      -        )
      -
      -    request_body_content = {
      -        self.TRAIN_NAME: train_dataset_name,
      -        self.TEST_NAME: test_dataset_name,
      -        self.CODE: modeling_code,
      -        self.CLASSIFIERS_LIST: model_classifiers,
      -    }
      -    response = requests.post(url=self.cluster_url,
      -                             json=request_body_content)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -synchronously, the caller waits until the model predictions are inserted -into the Learning Orchestra storage mechanism.

      -

      train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

      -

      return: The resulted predictions URIs.

      -
      - -Expand source code - -
      def run_builder_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 resource join several steps of machine
      -    learning workflow (transform, tune, train and evaluate) coupling in
      -    a unique resource, builder creates several model predictions using
      -    your own modeling code using a defined set of classifiers. This is made
      -    synchronously, the caller waits until the model predictions are inserted
      -    into the Learning Orchestra storage mechanism.
      -
      -    train_dataset_name: Represent final train dataset.
      -    test_dataset_name: Represent final test dataset.
      -    modeling_code: Represent Python3 code for pyspark preprocessing model
      -    model_classifiers: list of initial classifiers to be used in model
      -    pretty_response: returns indented string for visualization if True
      -
      -    return: The resulted predictions URIs.
      -    """
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE MODEL WITH "
      -            + train_dataset_name
      -            + " AND "
      -            + test_dataset_name
      -            + " ----------"
      -        )
      -
      -    request_body_content = {
      -        self.TRAIN_NAME: train_dataset_name,
      -        self.TEST_NAME: test_dataset_name,
      -        self.CODE: modeling_code,
      -        self.CLASSIFIERS_LIST: model_classifiers,
      -    }
      -    response = requests.post(url=self.cluster_url,
      -                             json=request_body_content)
      -
      -    observer = Observer(test_dataset_name, self.CLUSTER_IP)
      -
      -    for model in model_classifiers:
      -        observer.set_dataset_name(test_dataset_name + model)
      -        observer.observe_processing(pretty_response)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_all_model(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 return indented string, else return dict.

      -

      return: A list with all model predictions metadata stored in Learning -Orchestra or an empty result.

      -
      - -Expand source code - -
      def search_all_model(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 return indented string, else return dict.
      -
      -    return: A list with all model predictions metadata stored in Learning
      -    Orchestra or an empty result.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url
      -
      -    response = requests.get(cluster_url_tsne)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: -This method is responsible for retrieving a specific -model prediction metadata.

      -

      pretty_response: If true return indented string, else return dict. -model_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.

      -
      - -Expand source code - -
      def search_model(self, model_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description:  This method is responsible for retrieving a specific
      -    model prediction metadata.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    model_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_model_prediction(model_name, limit=1,
      -                                            pretty_response=pretty_response)
      -
      -    return response
      -
      -
      -
      -def search_model_prediction(self, model_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 return indented string, else return dict. -model_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 there -is no such projection. The current page is also returned to be used in -future content requests.

      -
      - -Expand source code - -
      def search_model_prediction(self,
      -                            model_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 return indented string, else return dict.
      -    model_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 there
      -    is no such projection. The current page is also returned to be used in
      -    future content requests.
      -    """
      -
      -    cluster_url_dataset = self.cluster_url + "/" + model_name + \
      -                          "?query=" + str(query) + \
      -                          "&limit=" + str(limit) + \
      -                          "&skip=" + str(skip)
      -
      -    response = requests.get(cluster_url_dataset)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/dataset.html b/docs/dataset.html deleted file mode 100644 index b8b02a0..0000000 --- a/docs/dataset.html +++ /dev/null @@ -1,678 +0,0 @@ - - - - - - -learning_orchestra_client.dataset API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.dataset

      -
      -
      -
      - -Expand source code - -
      __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
      -__credits__ = "all free source developers"
      -__status__ = "Prototype"
      -
      -from .observer import Observer
      -from ._response_treat import ResponseTreat
      -import requests
      -from typing import Union
      -
      -
      -class Dataset:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/dataset"
      -        self.response_treat = ResponseTreat()
      -        self.OUTPUT_NAME = "datasetName"
      -        self.URL = "datasetURI"
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    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 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.
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + 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).
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                     "---")
      -        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 return indented string, else return dict.
      -
      -        return: All datasets metadata stored in Learning Orchestra or an empty
      -        result.
      -        """
      -        request_url = self.cluster_url
      -
      -        response = requests.get(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for retrieving a specific
      -        dataset
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Is the name of the dataset file.
      -        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 dataset metadata stored in Learning Orchestra or an
      -        error if there is no such dataset.
      -        """
      -        response = self.search_dataset_content(dataset_name, limit=1,
      -                                               pretty_response=pretty_response)
      -
      -        return 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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name + \
      -                      "?query=" + str(query) + \
      -                      "&limit=" + str(limit) + \
      -                      "&skip=" + str(skip)
      -
      -        response = requests.get(request_url)
      -
      -        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. The
      -        delete operation is always synchronous because it is very fast, since
      -        the deletion is performed in background. If a dataset was used by
      -        another task (Ex. projection, histogram, pca, tuning and so forth), it
      -        cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Represents the dataset name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name
      -
      -        response = requests.delete(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Dataset -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Dataset:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/dataset"
      -        self.response_treat = ResponseTreat()
      -        self.OUTPUT_NAME = "datasetName"
      -        self.URL = "datasetURI"
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    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 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.
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + 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).
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                     "---")
      -        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 return indented string, else return dict.
      -
      -        return: All datasets metadata stored in Learning Orchestra or an empty
      -        result.
      -        """
      -        request_url = self.cluster_url
      -
      -        response = requests.get(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for retrieving a specific
      -        dataset
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Is the name of the dataset file.
      -        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 dataset metadata stored in Learning Orchestra or an
      -        error if there is no such dataset.
      -        """
      -        response = self.search_dataset_content(dataset_name, limit=1,
      -                                               pretty_response=pretty_response)
      -
      -        return 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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name + \
      -                      "?query=" + str(query) + \
      -                      "&limit=" + str(limit) + \
      -                      "&skip=" + str(skip)
      -
      -        response = requests.get(request_url)
      -
      -        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. The
      -        delete operation is always synchronous because it is very fast, since
      -        the deletion is performed in background. If a dataset was used by
      -        another task (Ex. projection, histogram, pca, tuning and so forth), it
      -        cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Represents the dataset name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name
      -
      -        response = requests.delete(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting the dataset. The -delete operation is always synchronous because it is very fast, since -the deletion is performed in background. If a dataset was used by -another task (Ex. projection, histogram, pca, tuning and so forth), it -cannot be deleted.

      -

      pretty_response: If true return indented string, else return dict. -dataset_name: Represents the dataset name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      def delete_dataset(self, dataset_name, pretty_response=False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting the dataset. The
      -    delete operation is always synchronous because it is very fast, since
      -    the deletion is performed in background. If a dataset was used by
      -    another task (Ex. projection, histogram, pca, tuning and so forth), it
      -    cannot be deleted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    dataset_name: Represents the dataset name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -
      -    request_url = self.cluster_url + "/" + dataset_name
      -
      -    response = requests.delete(request_url)
      -
      -    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).

      -
      - -Expand source code - -
      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).
      -    """
      -    request_body = {self.OUTPUT_NAME: dataset_name,
      -                    self.URL: url}
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                 "---")
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -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 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.

      -
      - -Expand source code - -
      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 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.
      -    """
      -    request_body = {self.OUTPUT_NAME: dataset_name,
      -                    self.URL: url}
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      -
      -    if pretty_response:
      -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                 "---")
      -    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 return indented string, else return dict.

      -

      return: All datasets metadata stored in Learning Orchestra or an empty -result.

      -
      - -Expand source code - -
      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 return indented string, else return dict.
      -
      -    return: All datasets metadata stored in Learning Orchestra or an empty
      -    result.
      -    """
      -    request_url = self.cluster_url
      -
      -    response = requests.get(request_url)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for retrieving a specific -dataset

      -

      pretty_response: If true return indented string, else return dict. -dataset_name: Is the name of the dataset file. -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 dataset metadata stored in Learning Orchestra or an -error if there is no such dataset.

      -
      - -Expand source code - -
      def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for retrieving a specific
      -    dataset
      -
      -    pretty_response: If true return indented string, else return dict.
      -    dataset_name: Is the name of the dataset file.
      -    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 dataset metadata stored in Learning Orchestra or an
      -    error if there is no such dataset.
      -    """
      -    response = self.search_dataset_content(dataset_name, limit=1,
      -                                           pretty_response=pretty_response)
      -
      -    return 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 return indented string, else return dict. -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.

      -
      - -Expand source code - -
      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 return indented string, else return dict.
      -    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.
      -    """
      -
      -    request_url = self.cluster_url + "/" + dataset_name + \
      -                  "?query=" + str(query) + \
      -                  "&limit=" + str(limit) + \
      -                  "&skip=" + str(skip)
      -
      -    response = requests.get(request_url)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/explore/histogram.html b/docs/explore/histogram.html deleted file mode 100644 index d4a510e..0000000 --- a/docs/explore/histogram.html +++ /dev/null @@ -1,676 +0,0 @@ - - - - - - -learning_orchestra_client.explore.histogram API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.explore.histogram

      -
      -
      -
      - -Expand source code - -
      from ..observer import Observer
      -from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -import requests
      -from typing import Union
      -
      -
      -class Histogram:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/histogram"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -
      -    def run_histogram_sync(self,
      -                           dataset_name: str,
      -                           histogram_name: str,
      -                           fields: list,
      -                           pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method run histogram algorithm to create a histogram
      -        synchronously, 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 return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_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 run histogram algorithm to create a histogram
      -        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      -
      -        dataset_name: Represents the name of dataset.
      -        histogram_name: Represents the name of histogram.
      -        fields: Represents a list of attributes.
      -        pretty_response: If true return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_name
      -                + " ----------"
      -            )
      -
      -        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 names, it does not
      -        retrieve the histogram content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all histogram names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_histogram_data(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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
      -                                "?query=" + str(query) + \
      -                                "&limit=" + str(limit) + \
      -                                "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        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 synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        histogram_name: Represents the histogram name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name
      -
      -        response = requests.delete(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Histogram -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Histogram:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/histogram"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -
      -    def run_histogram_sync(self,
      -                           dataset_name: str,
      -                           histogram_name: str,
      -                           fields: list,
      -                           pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method run histogram algorithm to create a histogram
      -        synchronously, 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 return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_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 run histogram algorithm to create a histogram
      -        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      -
      -        dataset_name: Represents the name of dataset.
      -        histogram_name: Represents the name of histogram.
      -        fields: Represents a list of attributes.
      -        pretty_response: If true return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_name
      -                + " ----------"
      -            )
      -
      -        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 names, it does not
      -        retrieve the histogram content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all histogram names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_histogram_data(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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
      -                                "?query=" + str(query) + \
      -                                "&limit=" + str(limit) + \
      -                                "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        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 synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        histogram_name: Represents the histogram name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name
      -
      -        response = requests.delete(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -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 synchronous because it is very fast, -since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -histogram_name: Represents the histogram name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      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 synchronous because it is very fast,
      -    since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    histogram_name: Represents the histogram name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -
      -    cluster_url_histogram = self.cluster_url + "/" + histogram_name
      -
      -    response = requests.delete(cluster_url_histogram)
      -
      -    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 run histogram algorithm to create a histogram -asynchronously, the caller does not wait until the histogram 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 histogram was inserted.

      -

      dataset_name: Represents the name of dataset. -histogram_name: Represents the name of histogram. -fields: Represents a list of attributes. -pretty_response: If true return indented string, else return dict.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a histogram.

      -
      - -Expand source code - -
      def run_histogram_async(self,
      -                        dataset_name: str,
      -                        histogram_name: str,
      -                        fields: list,
      -                        pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method run histogram algorithm to create a histogram
      -    asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      -
      -    dataset_name: Represents the name of dataset.
      -    histogram_name: Represents the name of histogram.
      -    fields: Represents a list of attributes.
      -    pretty_response: If true return indented string, else return dict.
      -
      -    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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE HISTOGRAM FROM "
      -            + dataset_name
      -            + " TO "
      -            + histogram_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_histogram_sync(self, dataset_name: str, histogram_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run histogram algorithm to create a histogram -synchronously, 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 return indented string, else return dict.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a histogram.

      -
      - -Expand source code - -
      def run_histogram_sync(self,
      -                       dataset_name: str,
      -                       histogram_name: str,
      -                       fields: list,
      -                       pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method run histogram algorithm to create a histogram
      -    synchronously, 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 return indented string, else return dict.
      -
      -    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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    Observer(histogram_name, self.CLUSTER_IP).observe_processing(
      -        pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE HISTOGRAM FROM "
      -            + dataset_name
      -            + " TO "
      -            + histogram_name
      -            + " ----------"
      -        )
      -
      -    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 names, it does not -retrieve the histogram content.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all histogram names stored in Learning Orchestra -or an empty result.

      -
      - -Expand source code - -
      def search_all_histograms(self, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves all histogram names, it does not
      -    retrieve the histogram content.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all histogram names stored in Learning Orchestra
      -    or an empty result.
      -    """
      -
      -    cluster_url_histogram = self.cluster_url
      -
      -    response = requests.get(cluster_url_histogram)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_histogram_data(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 return indented string, else return dict. -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.

      -
      - -Expand source code - -
      def search_histogram_data(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 return indented string, else return dict.
      -    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.
      -    """
      -
      -    cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
      -                            "?query=" + str(query) + \
      -                            "&limit=" + str(limit) + \
      -                            "&skip=" + str(skip)
      -
      -    response = requests.get(cluster_url_histogram)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/explore/index.html b/docs/explore/index.html deleted file mode 100644 index d4f7495..0000000 --- a/docs/explore/index.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - -learning_orchestra_client.explore API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/docs/explore/pca.html b/docs/explore/pca.html deleted file mode 100644 index 96011a2..0000000 --- a/docs/explore/pca.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - - -learning_orchestra_client.explore.pca API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.explore.pca

      -
      -
      -
      - -Expand source code - -
      from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -from PIL import Image
      -import requests
      -import time
      -from typing import Union
      -
      -
      -class Pca:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/pca"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_pca_sync(self,
      -                     dataset_name: str,
      -                     pca_name: str,
      -                     label: str,
      -                     pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        synchronously, the caller waits until the PCA image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_pca_exist(pca_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_pca_async(self,
      -                      dataset_name: str,
      -                      pca_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method retrieves all PCAs plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all PCAs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_pca = self.cluster_url
      -
      -        response = requests.get(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a PCA image plot.
      -
      -        pca_name: Name of PCA image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ "
      -                + pca_name
      -                + " PCA IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_pca
      -
      -    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the PCA image plot.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        pca_name: Represents the PCA name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        response = requests.delete(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a PCA image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        pca_name: Name of PCA image plot.
      -
      -        return: True if the PCA requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
      -                                                           "----------")
      -
      -        exist = False
      -        pca_name += ".png"
      -
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_pca = self.search_all_pca()
      -            exist = pca_name in all_pca.get('result')
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Pca -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Pca:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/pca"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_pca_sync(self,
      -                     dataset_name: str,
      -                     pca_name: str,
      -                     label: str,
      -                     pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        synchronously, the caller waits until the PCA image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_pca_exist(pca_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_pca_async(self,
      -                      dataset_name: str,
      -                      pca_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method retrieves all PCAs plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all PCAs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_pca = self.cluster_url
      -
      -        response = requests.get(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a PCA image plot.
      -
      -        pca_name: Name of PCA image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ "
      -                + pca_name
      -                + " PCA IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_pca
      -
      -    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the PCA image plot.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        pca_name: Represents the PCA name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        response = requests.delete(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a PCA image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        pca_name: Name of PCA image plot.
      -
      -        return: True if the PCA requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
      -                                                           "----------")
      -
      -        exist = False
      -        pca_name += ".png"
      -
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_pca = self.search_all_pca()
      -            exist = pca_name in all_pca.get('result')
      -
      -

      Methods

      -
      -
      -def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting the PCA image plot. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -pca_name: Represents the PCA name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message.

      -
      - -Expand source code - -
      def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting the PCA image plot.
      -    The delete operation is always synchronous because it is very fast,
      -    since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    pca_name: Represents the PCA name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message.
      -    """
      -
      -    cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -    response = requests.delete(cluster_url_pca)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_pca_async(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run PCA algorithm to create an image plot -asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.

      -

      dataset_name: Name of dataset. -pca_name: Name of PCA image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a PCA image plot.

      -
      - -Expand source code - -
      def run_pca_async(self,
      -                  dataset_name: str,
      -                  pca_name: str,
      -                  label: str,
      -                  pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run PCA algorithm to create an image plot
      -    asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
      -
      -    dataset_name: Name of dataset.
      -    pca_name: Name of PCA image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a PCA image plot.
      -    """
      -
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: pca_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PCA IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + pca_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_pca_sync(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run PCA algorithm to create an image plot -synchronously, the caller waits until the PCA image is inserted into -the Learning Orchestra storage mechanism.

      -

      dataset_name: Name of dataset. -pca_name: Name of PCA image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a PCA image plot.

      -
      - -Expand source code - -
      def run_pca_sync(self,
      -                 dataset_name: str,
      -                 pca_name: str,
      -                 label: str,
      -                 pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run PCA algorithm to create an image plot
      -    synchronously, the caller waits until the PCA image is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    dataset_name: Name of dataset.
      -    pca_name: Name of PCA image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a PCA image plot.
      -    """
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: pca_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    self.verify_pca_exist(pca_name, pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PCA IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + pca_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_all_pca(self, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves all PCAs plot names, it does not -retrieve the image plot.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all PCAs plot names stored in Learning Orchestra -or an empty result.

      -
      - -Expand source code - -
      def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method retrieves all PCAs plot names, it does not
      -    retrieve the image plot.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all PCAs plot names stored in Learning Orchestra
      -    or an empty result.
      -    """
      -
      -    cluster_url_pca = self.cluster_url
      -
      -    response = requests.get(cluster_url_pca)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves a PCA image plot.

      -

      pca_name: Name of PCA image plot. -pretty_response: If true open an image plot, else return link to -open image plot.

      -

      return: A link to an image plot or open an image plot.

      -
      - -Expand source code - -
      def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves a PCA image plot.
      -
      -    pca_name: Name of PCA image plot.
      -    pretty_response: If true open an image plot, else return link to
      -    open image plot.
      -
      -    return: A link to an image plot or open an image plot.
      -    """
      -
      -    cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " READ "
      -            + pca_name
      -            + " PCA IMAGE PLOT "
      -            + " ----------"
      -        )
      -        img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
      -        img.show()
      -    else:
      -        return cluster_url_pca
      -
      -
      -
      -def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible to verify if a PCA image -exist into the Learning Orchestra storage mechanism.

      -

      pca_name: Name of PCA image plot.

      -

      return: True if the PCA requested exist, false if does not.

      -
      - -Expand source code - -
      def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible to verify if a PCA image
      -    exist into the Learning Orchestra storage mechanism.
      -
      -    pca_name: Name of PCA image plot.
      -
      -    return: True if the PCA requested exist, false if does not.
      -    """
      -
      -    if pretty_response:
      -        print("\n---------- CHECKING IF " + pca_name + " FINISHED "
      -                                                       "----------")
      -
      -    exist = False
      -    pca_name += ".png"
      -
      -    while not exist:
      -        time.sleep(self.WAIT_TIME)
      -        all_pca = self.search_all_pca()
      -        exist = pca_name in all_pca.get('result')
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/explore/tsne.html b/docs/explore/tsne.html deleted file mode 100644 index e027e0a..0000000 --- a/docs/explore/tsne.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - - -learning_orchestra_client.explore.tsne API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.explore.tsne

      -
      -
      -
      - -Expand source code - -
      from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -from PIL import Image
      -import requests
      -import time
      -from typing import Union
      -
      -
      -class Tsne:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/tsne"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_tsne_sync(self,
      -                      dataset_name: str,
      -                      tsne_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        synchronously, the caller waits until the t_SNE image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_tsne_exist(tsne_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_tsne_async(self,
      -                       dataset_name: str,
      -                       tsne_name: str,
      -                       label: str,
      -                       pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_tsne(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all t_SNE plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all t_SNEs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a t_SNE image plot.
      -
      -        tsne_name: Name of t_SNE image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ"
      -                + tsne_name
      -                + " tsne IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_tsne
      -
      -    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the t_SNE image
      -        plot. The delete operation is always synchronous because it is very
      -        fast, since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        tsne_name: Represents the tsne name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        response = requests.delete(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a t_SNE image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        tsne_name: Name of t_SNE image plot.
      -
      -        return: True if the t_SNE requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
      -                                                            "----------")
      -
      -        exist = False
      -        tsne_name += ".png"
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_tsne = self.search_all_tsne()
      -            exist = tsne_name in all_tsne.get('result')
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Tsne -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Tsne:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/tsne"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_tsne_sync(self,
      -                      dataset_name: str,
      -                      tsne_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        synchronously, the caller waits until the t_SNE image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_tsne_exist(tsne_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_tsne_async(self,
      -                       dataset_name: str,
      -                       tsne_name: str,
      -                       label: str,
      -                       pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_tsne(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all t_SNE plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all t_SNEs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a t_SNE image plot.
      -
      -        tsne_name: Name of t_SNE image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ"
      -                + tsne_name
      -                + " tsne IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_tsne
      -
      -    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the t_SNE image
      -        plot. The delete operation is always synchronous because it is very
      -        fast, since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        tsne_name: Represents the tsne name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        response = requests.delete(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a t_SNE image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        tsne_name: Name of t_SNE image plot.
      -
      -        return: True if the t_SNE requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
      -                                                            "----------")
      -
      -        exist = False
      -        tsne_name += ".png"
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_tsne = self.search_all_tsne()
      -            exist = tsne_name in all_tsne.get('result')
      -
      -

      Methods

      -
      -
      -def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting the t_SNE image -plot. The delete operation is always synchronous because it is very -fast, since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -tsne_name: Represents the tsne name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message.

      -
      - -Expand source code - -
      def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting the t_SNE image
      -    plot. The delete operation is always synchronous because it is very
      -    fast, since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    tsne_name: Represents the tsne name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -    response = requests.delete(cluster_url_tsne)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_tsne_async(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run t_SNE algorithm to create an image plot -asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.

      -

      dataset_name: Name of dataset. -tsne_name: Name of t_SNE image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a t_SNE image plot.

      -
      - -Expand source code - -
      def run_tsne_async(self,
      -                   dataset_name: str,
      -                   tsne_name: str,
      -                   label: str,
      -                   pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run t_SNE algorithm to create an image plot
      -    asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
      -
      -    dataset_name: Name of dataset.
      -    tsne_name: Name of t_SNE image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a t_SNE image plot.
      -    """
      -
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: tsne_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE TSNE IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + tsne_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_tsne_sync(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run t_SNE algorithm to create an image plot -synchronously, the caller waits until the t_SNE image is inserted into -the Learning Orchestra storage mechanism.

      -

      dataset_name: Name of dataset. -tsne_name: Name of t_SNE image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a t_SNE image plot.

      -
      - -Expand source code - -
      def run_tsne_sync(self,
      -                  dataset_name: str,
      -                  tsne_name: str,
      -                  label: str,
      -                  pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run t_SNE algorithm to create an image plot
      -    synchronously, the caller waits until the t_SNE image is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    dataset_name: Name of dataset.
      -    tsne_name: Name of t_SNE image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a t_SNE image plot.
      -    """
      -
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: tsne_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    self.verify_tsne_exist(tsne_name, pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE TSNE IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + tsne_name
      -            + " ----------"
      -        )
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_all_tsne(self, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves all t_SNE plot names, it does not -retrieve the image plot.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all t_SNEs plot names stored in Learning Orchestra -or an empty result.

      -
      - -Expand source code - -
      def search_all_tsne(self, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves all t_SNE plot names, it does not
      -    retrieve the image plot.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all t_SNEs plot names stored in Learning Orchestra
      -    or an empty result.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url
      -
      -    response = requests.get(cluster_url_tsne)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves a t_SNE image plot.

      -

      tsne_name: Name of t_SNE image plot. -pretty_response: If true open an image plot, else return link to -open image plot.

      -

      return: A link to an image plot or open an image plot.

      -
      - -Expand source code - -
      def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves a t_SNE image plot.
      -
      -    tsne_name: Name of t_SNE image plot.
      -    pretty_response: If true open an image plot, else return link to
      -    open image plot.
      -
      -    return: A link to an image plot or open an image plot.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " READ"
      -            + tsne_name
      -            + " tsne IMAGE PLOT "
      -            + " ----------"
      -        )
      -        img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
      -        img.show()
      -    else:
      -        return cluster_url_tsne
      -
      -
      -
      -def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible to verify if a t_SNE image -exist into the Learning Orchestra storage mechanism.

      -

      tsne_name: Name of t_SNE image plot.

      -

      return: True if the t_SNE requested exist, false if does not.

      -
      - -Expand source code - -
      def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible to verify if a t_SNE image
      -    exist into the Learning Orchestra storage mechanism.
      -
      -    tsne_name: Name of t_SNE image plot.
      -
      -    return: True if the t_SNE requested exist, false if does not.
      -    """
      -
      -    if pretty_response:
      -        print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
      -                                                        "----------")
      -
      -    exist = False
      -    tsne_name += ".png"
      -    while not exist:
      -        time.sleep(self.WAIT_TIME)
      -        all_tsne = self.search_all_tsne()
      -        exist = tsne_name in all_tsne.get('result')
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 46c4a70..0000000 --- a/docs/index.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - -learning_orchestra_client API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/docs/observer.html b/docs/observer.html deleted file mode 100644 index a7d3aee..0000000 --- a/docs/observer.html +++ /dev/null @@ -1,375 +0,0 @@ - - - - - - -learning_orchestra_client.observer API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.observer

      -
      -
      -
      - -Expand source code - -
      from pymongo import MongoClient, change_stream
      -
      -
      -class Observer:
      -    def __init__(self, dataset_name: str, cluster_ip: str):
      -        self.dataset_name = dataset_name
      -
      -        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
      -        mongo_client = MongoClient(mongo_url)
      -        self.database = mongo_client['database']
      -
      -    def set_dataset_name(self, dataset_name: str):
      -        """
      -        :description: Changes the dataset name used in object.
      -        :param dataset_name: Name of dataset to observe.
      -
      -        :return: None.
      -        """
      -        self.dataset_name = dataset_name
      -
      -    def get_dataset_name(self) -> str:
      -        """
      -        :description: Retrieve the dataset name used in object.
      -
      -        :return: The dataset name.
      -        """
      -        return self.dataset_name
      -
      -    def observe_processing(self, pretty_response: bool = False) -> dict:
      -        """
      -        :description: Observe the finished processing status from some
      -        processing, blocking the code execution until finish processing.
      -
      -        :return: A dict with metadata file of used dataset name.
      -        """
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
      -                                                                    "----------")
      -        dataset_collection = self.database[self.dataset_name]
      -        metadata_query = {"_id": 0}
      -        dataset_metadata = dataset_collection.find_one(metadata_query)
      -
      -        if dataset_metadata is None:
      -            print("Dataset name or dataset URL invalid")
      -            exit()
      -
      -        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').next()['fullDocument']
      -
      -    def observe_storage(self) -> change_stream.CollectionChangeStream:
      -        """
      -        :description: Get all changes from a dataset
      -
      -        :return: A pymongo CollectionChangeStream object, use the builtin
      -        next() method to iterate over changes.
      -        """
      -
      -        observer_query = [
      -            {'$match': {
      -                '$or': [
      -                    {'operationType': 'replace'},
      -                    {'operationType': 'insert'},
      -                    {'operationType': 'update'},
      -                    {'operationType': 'delete'}
      -
      -                ]
      -            }}
      -        ]
      -        return self.database[self.dataset_name].watch(
      -            observer_query,
      -            full_document='updateLookup')
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Observer -(dataset_name: str, cluster_ip: str) -
      -
      -
      -
      - -Expand source code - -
      class Observer:
      -    def __init__(self, dataset_name: str, cluster_ip: str):
      -        self.dataset_name = dataset_name
      -
      -        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
      -        mongo_client = MongoClient(mongo_url)
      -        self.database = mongo_client['database']
      -
      -    def set_dataset_name(self, dataset_name: str):
      -        """
      -        :description: Changes the dataset name used in object.
      -        :param dataset_name: Name of dataset to observe.
      -
      -        :return: None.
      -        """
      -        self.dataset_name = dataset_name
      -
      -    def get_dataset_name(self) -> str:
      -        """
      -        :description: Retrieve the dataset name used in object.
      -
      -        :return: The dataset name.
      -        """
      -        return self.dataset_name
      -
      -    def observe_processing(self, pretty_response: bool = False) -> dict:
      -        """
      -        :description: Observe the finished processing status from some
      -        processing, blocking the code execution until finish processing.
      -
      -        :return: A dict with metadata file of used dataset name.
      -        """
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
      -                                                                    "----------")
      -        dataset_collection = self.database[self.dataset_name]
      -        metadata_query = {"_id": 0}
      -        dataset_metadata = dataset_collection.find_one(metadata_query)
      -
      -        if dataset_metadata is None:
      -            print("Dataset name or dataset URL invalid")
      -            exit()
      -
      -        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').next()['fullDocument']
      -
      -    def observe_storage(self) -> change_stream.CollectionChangeStream:
      -        """
      -        :description: Get all changes from a dataset
      -
      -        :return: A pymongo CollectionChangeStream object, use the builtin
      -        next() method to iterate over changes.
      -        """
      -
      -        observer_query = [
      -            {'$match': {
      -                '$or': [
      -                    {'operationType': 'replace'},
      -                    {'operationType': 'insert'},
      -                    {'operationType': 'update'},
      -                    {'operationType': 'delete'}
      -
      -                ]
      -            }}
      -        ]
      -        return self.database[self.dataset_name].watch(
      -            observer_query,
      -            full_document='updateLookup')
      -
      -

      Methods

      -
      -
      -def get_dataset_name(self) ‑> str -
      -
      -

      :description: Retrieve the dataset name used in object.

      -

      :return: The dataset name.

      -
      - -Expand source code - -
      def get_dataset_name(self) -> str:
      -    """
      -    :description: Retrieve the dataset name used in object.
      -
      -    :return: The dataset name.
      -    """
      -    return self.dataset_name
      -
      -
      -
      -def observe_processing(self, pretty_response: bool = False) ‑> dict -
      -
      -

      :description: Observe the finished processing status from some -processing, blocking the code execution until finish processing.

      -

      :return: A dict with metadata file of used dataset name.

      -
      - -Expand source code - -
      def observe_processing(self, pretty_response: bool = False) -> dict:
      -    """
      -    :description: Observe the finished processing status from some
      -    processing, blocking the code execution until finish processing.
      -
      -    :return: A dict with metadata file of used dataset name.
      -    """
      -    if pretty_response:
      -        print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
      -                                                                "----------")
      -    dataset_collection = self.database[self.dataset_name]
      -    metadata_query = {"_id": 0}
      -    dataset_metadata = dataset_collection.find_one(metadata_query)
      -
      -    if dataset_metadata is None:
      -        print("Dataset name or dataset URL invalid")
      -        exit()
      -
      -    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').next()['fullDocument']
      -
      -
      -
      -def observe_storage(self) ‑> pymongo.change_stream.CollectionChangeStream -
      -
      -

      :description: Get all changes from a dataset

      -

      :return: A pymongo CollectionChangeStream object, use the builtin -next() method to iterate over changes.

      -
      - -Expand source code - -
      def observe_storage(self) -> change_stream.CollectionChangeStream:
      -    """
      -    :description: Get all changes from a dataset
      -
      -    :return: A pymongo CollectionChangeStream object, use the builtin
      -    next() method to iterate over changes.
      -    """
      -
      -    observer_query = [
      -        {'$match': {
      -            '$or': [
      -                {'operationType': 'replace'},
      -                {'operationType': 'insert'},
      -                {'operationType': 'update'},
      -                {'operationType': 'delete'}
      -
      -            ]
      -        }}
      -    ]
      -    return self.database[self.dataset_name].watch(
      -        observer_query,
      -        full_document='updateLookup')
      -
      -
      -
      -def set_dataset_name(self, dataset_name: str) -
      -
      -

      :description: Changes the dataset name used in object. -:param dataset_name: Name of dataset to observe.

      -

      :return: None.

      -
      - -Expand source code - -
      def set_dataset_name(self, dataset_name: str):
      -    """
      -    :description: Changes the dataset name used in object.
      -    :param dataset_name: Name of dataset to observe.
      -
      -    :return: None.
      -    """
      -    self.dataset_name = dataset_name
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/transform/data_type.html b/docs/transform/data_type.html deleted file mode 100644 index ab70288..0000000 --- a/docs/transform/data_type.html +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - -learning_orchestra_client.transform.data_type API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.transform.data_type

      -
      -
      -
      - -Expand source code - -
      from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -import requests
      -from typing import Union
      -
      -
      -class DataType:
      -    def __init__(self, ip_from_cluster):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/dataType"
      -        self.ResponseTreat = ResponseTreat()
      -        self.Dataset = Dataset(ip_from_cluster)
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.TYPES = "types"
      -
      -    def update_dataset_types(self,
      -                             dataset_name: str,
      -                             fields_change: dict,
      -                             pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: Change types of fields to number or string.
      -
      -        dataset_name: Represents the dataset name.
      -        fields_change: Fields to change with types. This is a dict with each
      -        key:value being field:type
      -
      -        return: A JSON object with error or warning messages.
      -        """
      -
      -        url_request = self.cluster_url
      -        body_request = {
      -            self.INPUT_NAME: dataset_name,
      -            self.TYPES: fields_change
      -        }
      -
      -        response = requests.patch(url=url_request, json=body_request)
      -
      -        return self.ResponseTreat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class DataType -(ip_from_cluster) -
      -
      -
      -
      - -Expand source code - -
      class DataType:
      -    def __init__(self, ip_from_cluster):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/dataType"
      -        self.ResponseTreat = ResponseTreat()
      -        self.Dataset = Dataset(ip_from_cluster)
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.TYPES = "types"
      -
      -    def update_dataset_types(self,
      -                             dataset_name: str,
      -                             fields_change: dict,
      -                             pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: Change types of fields to number or string.
      -
      -        dataset_name: Represents the dataset name.
      -        fields_change: Fields to change with types. This is a dict with each
      -        key:value being field:type
      -
      -        return: A JSON object with error or warning messages.
      -        """
      -
      -        url_request = self.cluster_url
      -        body_request = {
      -            self.INPUT_NAME: dataset_name,
      -            self.TYPES: fields_change
      -        }
      -
      -        response = requests.patch(url=url_request, json=body_request)
      -
      -        return self.ResponseTreat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def update_dataset_types(self, dataset_name: str, fields_change: dict, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: Change types of fields to number or string.

      -

      dataset_name: Represents the dataset name. -fields_change: Fields to change with types. This is a dict with each -key:value being field:type

      -

      return: A JSON object with error or warning messages.

      -
      - -Expand source code - -
      def update_dataset_types(self,
      -                         dataset_name: str,
      -                         fields_change: dict,
      -                         pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: Change types of fields to number or string.
      -
      -    dataset_name: Represents the dataset name.
      -    fields_change: Fields to change with types. This is a dict with each
      -    key:value being field:type
      -
      -    return: A JSON object with error or warning messages.
      -    """
      -
      -    url_request = self.cluster_url
      -    body_request = {
      -        self.INPUT_NAME: dataset_name,
      -        self.TYPES: fields_change
      -    }
      -
      -    response = requests.patch(url=url_request, json=body_request)
      -
      -    return self.ResponseTreat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/transform/index.html b/docs/transform/index.html deleted file mode 100644 index 271146f..0000000 --- a/docs/transform/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - -learning_orchestra_client.transform API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/docs/transform/projection.html b/docs/transform/projection.html deleted file mode 100644 index 0ee1113..0000000 --- a/docs/transform/projection.html +++ /dev/null @@ -1,1035 +0,0 @@ - - - - - - -learning_orchestra_client.transform.projection API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.transform.projection

      -
      -
      -
      - -Expand source code - -
      from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -from ..observer import Observer
      -import requests
      -from typing import Union
      -
      -
      -class Projection:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/projection"
      -        self.METADATA_INDEX = 0
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def insert_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(projection_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def insert_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields_to_delete: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes on a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_sync(dataset_name,
      -                                                       projection_name,
      -                                                       fields_to_insert,
      -                                                       pretty_response)
      -
      -        return response
      -
      -    def delete_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields_to_delete: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_async(dataset_name,
      -                                                        projection_name,
      -                                                        fields_to_insert,
      -                                                        pretty_response)
      -
      -        return response
      -
      -    def search_all_projections(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all projection metadata, it does not
      -        retrieve the projection content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all projections metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -        cluster_url_projection = self.cluster_url
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_projections(self, projection_name: str,
      -                           pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        projection.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
      -        error if there is no such projections.
      -        """
      -        pretty = pretty_response
      -
      -        response = self.search_projections_content(projection_name, limit=1,
      -                                                   pretty_response=pretty)
      -
      -        return response
      -
      -    def search_projections_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 dataset
      -        content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_projection = self.cluster_url + "/" + projection_name + \
      -                                 "?query=" + str(query) + \
      -                                 "&limit=" + str(limit) + \
      -                                 "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_projections(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 synchronous because it is very fast,
      -        since the deletion is performed in background. If a projection was
      -        used by another task (Ex. histogram, pca, tuning and so forth),
      -        it cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -        cluster_url_projection = self.cluster_url + "/" + projection_name
      -
      -        response = requests.delete(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Projection -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Projection:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/projection"
      -        self.METADATA_INDEX = 0
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def insert_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(projection_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def insert_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields_to_delete: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes on a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_sync(dataset_name,
      -                                                       projection_name,
      -                                                       fields_to_insert,
      -                                                       pretty_response)
      -
      -        return response
      -
      -    def delete_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields_to_delete: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_async(dataset_name,
      -                                                        projection_name,
      -                                                        fields_to_insert,
      -                                                        pretty_response)
      -
      -        return response
      -
      -    def search_all_projections(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all projection metadata, it does not
      -        retrieve the projection content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all projections metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -        cluster_url_projection = self.cluster_url
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_projections(self, projection_name: str,
      -                           pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        projection.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
      -        error if there is no such projections.
      -        """
      -        pretty = pretty_response
      -
      -        response = self.search_projections_content(projection_name, limit=1,
      -                                                   pretty_response=pretty)
      -
      -        return response
      -
      -    def search_projections_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 dataset
      -        content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_projection = self.cluster_url + "/" + projection_name + \
      -                                 "?query=" + str(query) + \
      -                                 "&limit=" + str(limit) + \
      -                                 "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_projections(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 synchronous because it is very fast,
      -        since the deletion is performed in background. If a projection was
      -        used by another task (Ex. histogram, pca, tuning and so forth),
      -        it cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -        cluster_url_projection = self.cluster_url + "/" + projection_name
      -
      -        response = requests.delete(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def delete_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method delete a set of attributes into a dataset -asynchronously, the caller does not wait until the projections 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 projection was inserted.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields_to_delete: Represents the set of attributes to be inserted. -This is list with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def delete_dataset_attributes_async(self,
      -                                    dataset_name: str,
      -                                    projection_name: str,
      -                                    fields_to_delete: list,
      -                                    pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method delete a set of attributes into a dataset
      -    asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields_to_delete: Represents the set of attributes to be inserted.
      -    This is list with all attributes.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns the projection metadata.
      -    """
      -    dataset_metadata = self.search_projections_content(dataset_name,
      -                                                       limit=1)
      -
      -    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -        .get('fields')
      -    for field in fields_to_delete:
      -        fields_to_insert.remove(field)
      -
      -    response = self.insert_dataset_attributes_async(dataset_name,
      -                                                    projection_name,
      -                                                    fields_to_insert,
      -                                                    pretty_response)
      -
      -    return response
      -
      -
      -
      -def delete_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method delete a set of attributes on a dataset -synchronously, the caller waits until the projection is inserted into -the Learning Orchestra storage mechanism.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields_to_delete: Represents the set of attributes to be inserted. -This is list with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def delete_dataset_attributes_sync(self,
      -                                   dataset_name: str,
      -                                   projection_name: str,
      -                                   fields_to_delete: list,
      -                                   pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method delete a set of attributes on a dataset
      -    synchronously, the caller waits until the projection is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields_to_delete: Represents the set of attributes to be inserted.
      -    This is list with all attributes.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns the projection metadata.
      -    """
      -    dataset_metadata = self.search_projections_content(dataset_name,
      -                                                       limit=1)
      -
      -    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -        .get('fields')
      -    for field in fields_to_delete:
      -        fields_to_insert.remove(field)
      -
      -    response = self.insert_dataset_attributes_sync(dataset_name,
      -                                                   projection_name,
      -                                                   fields_to_insert,
      -                                                   pretty_response)
      -
      -    return response
      -
      -
      -
      -def delete_projections(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 synchronous because it is very fast, -since the deletion is performed in background. If a projection was -used by another task (Ex. histogram, pca, tuning and so forth), -it cannot be deleted.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      def delete_projections(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 synchronous because it is very fast,
      -    since the deletion is performed in background. If a projection was
      -    used by another task (Ex. histogram, pca, tuning and so forth),
      -    it cannot be deleted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -    cluster_url_projection = self.cluster_url + "/" + projection_name
      -
      -    response = requests.delete(cluster_url_projection)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def insert_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method inserts a set of attributes into a dataset -asynchronously, the caller does not wait until the projections 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 projection was inserted.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields: Represents the set of attributes to be inserted. This is list -with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def insert_dataset_attributes_async(self,
      -                                    dataset_name: str,
      -                                    projection_name: str,
      -                                    fields: list,
      -                                    pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method inserts a set of attributes into a dataset
      -    asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields: Represents the set of attributes to be inserted. This is list
      -    with all 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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PROJECTION FROM "
      -            + dataset_name
      -            + " TO "
      -            + projection_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def insert_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method inserts a set of attributes into a dataset -synchronously, the caller waits until the projection is inserted into -the Learning Orchestra storage mechanism.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields: Represents the set of attributes to be inserted. This is list -with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def insert_dataset_attributes_sync(self,
      -                                   dataset_name: str,
      -                                   projection_name: str,
      -                                   fields: list,
      -                                   pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method inserts a set of attributes into a dataset
      -    synchronously, the caller waits until the projection is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields: Represents the set of attributes to be inserted. This is list
      -    with all 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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    Observer(projection_name, self.CLUSTER_IP).observe_processing(
      -        pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PROJECTION FROM "
      -            + dataset_name
      -            + " TO "
      -            + projection_name
      -            + " ----------"
      -        )
      -
      -    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, it does not -retrieve the projection content.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all projections metadata stored in Learning -Orchestra or an empty result.

      -
      - -Expand source code - -
      def search_all_projections(self, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves all projection metadata, it does not
      -    retrieve the projection content.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all projections metadata stored in Learning
      -    Orchestra or an empty result.
      -    """
      -    cluster_url_projection = self.cluster_url
      -
      -    response = requests.get(cluster_url_projection)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_projections(self, projection_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: -This method is responsible for retrieving a specific -projection.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an -error if there is no such projections.

      -
      - -Expand source code - -
      def search_projections(self, projection_name: str,
      -                       pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description:  This method is responsible for retrieving a specific
      -    projection.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
      -    error if there is no such projections.
      -    """
      -    pretty = pretty_response
      -
      -    response = self.search_projections_content(projection_name, limit=1,
      -                                               pretty_response=pretty)
      -
      -    return response
      -
      -
      -
      -def search_projections_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 dataset -content.

      -

      pretty_response: If true return indented string, else return dict. -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.

      -
      - -Expand source code - -
      def search_projections_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 dataset
      -    content.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    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.
      -    """
      -
      -    cluster_url_projection = self.cluster_url + "/" + projection_name + \
      -                             "?query=" + str(query) + \
      -                             "&limit=" + str(limit) + \
      -                             "&skip=" + str(skip)
      -
      -    response = requests.get(cluster_url_projection)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/learning_orchestra_client/explore/pca.py b/learning_orchestra_client/explore/pca.py deleted file mode 100644 index 8a9cff2..0000000 --- a/learning_orchestra_client/explore/pca.py +++ /dev/null @@ -1,193 +0,0 @@ -from .._response_treat import ResponseTreat -from ..dataset import Dataset -from PIL import Image -import requests -import time -from typing import Union - - -class Pca: - def __init__(self, ip_from_cluster: str): - self.cluster_url = "http://" + ip_from_cluster + \ - "/api/learningOrchestra/v1/explore/pca" - self.response_treat = ResponseTreat() - self.INPUT_NAME = "inputDatasetName" - self.OUTPUT_NAME = "outputPlotName" - self.LABEL = "label" - self.dataset = Dataset(ip_from_cluster) - self.WAIT_TIME = 5 - self.CLUSTER_IP = ip_from_cluster - - def run_pca_sync(self, - dataset_name: str, - pca_name: str, - label: str, - pretty_response: bool = False) -> Union[dict, str]: - """ - description: This method run PCA algorithm to create an image plot - synchronously, the caller waits until the PCA image is inserted into - the Learning Orchestra storage mechanism. - - dataset_name: Name of dataset. - pca_name: Name of PCA image plot. - label: The label is the label name of the column for machine learning - datasets which has labeled tuples. - pretty_response: If true open an image plot, else return link to open - image plot. - - return: A JSON object with error or warning messages. In case of - success, it returns a PCA image plot. - """ - request_body = { - self.INPUT_NAME: dataset_name, - self.OUTPUT_NAME: pca_name, - self.LABEL: label, - } - request_url = self.cluster_url - - response = requests.post(url=request_url, json=request_body) - - self.verify_pca_exist(pca_name, pretty_response) - - if pretty_response: - print( - "\n----------" - + " CREATE PCA IMAGE PLOT FROM " - + dataset_name - + " TO " - + pca_name - + " ----------" - ) - - return self.response_treat.treatment(response, pretty_response) - - def run_pca_async(self, - dataset_name: str, - pca_name: str, - label: str, - pretty_response: bool = False) -> Union[dict, str]: - """ - description: This method run PCA algorithm to create an image plot - asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted. - - dataset_name: Name of dataset. - pca_name: Name of PCA image plot. - label: The label is the label name of the column for machine learning - datasets which has labeled tuples. - pretty_response: If true open an image plot, else return link to open - image plot. - - return: A JSON object with error or warning messages. In case of - success, it returns a PCA image plot. - """ - - request_body = { - self.INPUT_NAME: dataset_name, - self.OUTPUT_NAME: pca_name, - self.LABEL: label, - } - request_url = self.cluster_url - - response = requests.post(url=request_url, json=request_body) - - if pretty_response: - print( - "\n----------" - + " CREATE PCA IMAGE PLOT FROM " - + dataset_name - + " TO " - + pca_name - + " ----------" - ) - - return self.response_treat.treatment(response, pretty_response) - - def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]: - """ - description: This method retrieves all PCAs plot names, it does not - retrieve the image plot. - - pretty_response: If true return indented string, else return dict. - - return: A list with all PCAs plot names stored in Learning Orchestra - or an empty result. - """ - - cluster_url_pca = self.cluster_url - - response = requests.get(cluster_url_pca) - - return self.response_treat.treatment(response, pretty_response) - - def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \ - -> Union[dict, str]: - """ - description: This method retrieves a PCA image plot. - - pca_name: Name of PCA image plot. - pretty_response: If true open an image plot, else return link to - open image plot. - - return: A link to an image plot or open an image plot. - """ - - cluster_url_pca = self.cluster_url + "/" + pca_name - - if pretty_response: - print( - "\n----------" - + " READ " - + pca_name - + " PCA IMAGE PLOT " - + " ----------" - ) - img = Image.open(requests.get(cluster_url_pca, stream=True).raw) - img.show() - else: - return cluster_url_pca - - def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \ - -> Union[dict, str]: - """ - description: This method is responsible for deleting the PCA image plot. - The delete operation is always synchronous because it is very fast, - since the deletion is performed in background. - - pretty_response: If true return indented string, else return dict. - pca_name: Represents the PCA name. - - return: JSON object with an error message, a warning message or a - correct delete message. - """ - - cluster_url_pca = self.cluster_url + "/" + pca_name - - response = requests.delete(cluster_url_pca) - - return self.response_treat.treatment(response, pretty_response) - - def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \ - -> Union[dict, str]: - """ - description: This method is responsible to verify if a PCA image - exist into the Learning Orchestra storage mechanism. - - pca_name: Name of PCA image plot. - - return: True if the PCA requested exist, false if does not. - """ - - if pretty_response: - print("\n---------- CHECKING IF " + pca_name + " FINISHED " - "----------") - - exist = False - pca_name += ".png" - - while not exist: - time.sleep(self.WAIT_TIME) - all_pca = self.search_all_pca() - exist = pca_name in all_pca.get('result') diff --git a/learning_orchestra_client/explore/tsne.py b/learning_orchestra_client/explore/tsne.py deleted file mode 100644 index d1d8448..0000000 --- a/learning_orchestra_client/explore/tsne.py +++ /dev/null @@ -1,193 +0,0 @@ -from .._response_treat import ResponseTreat -from ..dataset import Dataset -from PIL import Image -import requests -import time -from typing import Union - - -class Tsne: - def __init__(self, ip_from_cluster: str): - self.cluster_url = "http://" + ip_from_cluster + \ - "/api/learningOrchestra/v1/explore/tsne" - self.response_treat = ResponseTreat() - self.INPUT_NAME = "inputDatasetName" - self.OUTPUT_NAME = "outputPlotName" - self.LABEL = "label" - self.dataset = Dataset(ip_from_cluster) - self.WAIT_TIME = 5 - self.CLUSTER_IP = ip_from_cluster - - def run_tsne_sync(self, - dataset_name: str, - tsne_name: str, - label: str, - pretty_response: bool = False) -> Union[dict, str]: - """ - description: This method run t_SNE algorithm to create an image plot - synchronously, the caller waits until the t_SNE image is inserted into - the Learning Orchestra storage mechanism. - - dataset_name: Name of dataset. - tsne_name: Name of t_SNE image plot. - label: The label is the label name of the column for machine learning - datasets which has labeled tuples. - pretty_response: If true open an image plot, else return link to open - image plot. - - return: A JSON object with error or warning messages. In case of - success, it returns a t_SNE image plot. - """ - - request_body = { - self.INPUT_NAME: dataset_name, - self.OUTPUT_NAME: tsne_name, - self.LABEL: label, - } - request_url = self.cluster_url - - response = requests.post(url=request_url, json=request_body) - - self.verify_tsne_exist(tsne_name, pretty_response) - - if pretty_response: - print( - "\n----------" - + " CREATE TSNE IMAGE PLOT FROM " - + dataset_name - + " TO " - + tsne_name - + " ----------" - ) - return self.response_treat.treatment(response, pretty_response) - - def run_tsne_async(self, - dataset_name: str, - tsne_name: str, - label: str, - pretty_response: bool = False) -> Union[dict, str]: - """ - description: This method run t_SNE algorithm to create an image plot - asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted. - - dataset_name: Name of dataset. - tsne_name: Name of t_SNE image plot. - label: The label is the label name of the column for machine learning - datasets which has labeled tuples. - pretty_response: If true open an image plot, else return link to open - image plot. - - return: A JSON object with error or warning messages. In case of - success, it returns a t_SNE image plot. - """ - - request_body = { - self.INPUT_NAME: dataset_name, - self.OUTPUT_NAME: tsne_name, - self.LABEL: label, - } - request_url = self.cluster_url - - response = requests.post(url=request_url, json=request_body) - - if pretty_response: - print( - "\n----------" - + " CREATE TSNE IMAGE PLOT FROM " - + dataset_name - + " TO " - + tsne_name - + " ----------" - ) - - return self.response_treat.treatment(response, pretty_response) - - def search_all_tsne(self, pretty_response: bool = False) \ - -> Union[dict, str]: - """ - description: This method retrieves all t_SNE plot names, it does not - retrieve the image plot. - - pretty_response: If true return indented string, else return dict. - - return: A list with all t_SNEs plot names stored in Learning Orchestra - or an empty result. - """ - - cluster_url_tsne = self.cluster_url - - response = requests.get(cluster_url_tsne) - - return self.response_treat.treatment(response, pretty_response) - - def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \ - -> Union[dict, str]: - """ - description: This method retrieves a t_SNE image plot. - - tsne_name: Name of t_SNE image plot. - pretty_response: If true open an image plot, else return link to - open image plot. - - return: A link to an image plot or open an image plot. - """ - - cluster_url_tsne = self.cluster_url + "/" + tsne_name - - if pretty_response: - print( - "\n----------" - + " READ" - + tsne_name - + " tsne IMAGE PLOT " - + " ----------" - ) - img = Image.open(requests.get(cluster_url_tsne, stream=True).raw) - img.show() - else: - return cluster_url_tsne - - def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \ - -> Union[dict, str]: - """ - description: This method is responsible for deleting the t_SNE image - plot. The delete operation is always synchronous because it is very - fast, since the deletion is performed in background. - - pretty_response: If true return indented string, else return dict. - tsne_name: Represents the tsne name. - - return: JSON object with an error message, a warning message or a - correct delete message. - """ - - cluster_url_tsne = self.cluster_url + "/" + tsne_name - - response = requests.delete(cluster_url_tsne) - - return self.response_treat.treatment(response, pretty_response) - - def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \ - -> Union[dict, str]: - """ - description: This method is responsible to verify if a t_SNE image - exist into the Learning Orchestra storage mechanism. - - tsne_name: Name of t_SNE image plot. - - return: True if the t_SNE requested exist, false if does not. - """ - - if pretty_response: - print("\n---------- CHECKING IF " + tsne_name + " FINISHED " - "----------") - - exist = False - tsne_name += ".png" - while not exist: - time.sleep(self.WAIT_TIME) - all_tsne = self.search_all_tsne() - exist = tsne_name in all_tsne.get('result') From 3459708a50910fee146790bd3328f0a6fcc3f210 Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sat, 10 Apr 2021 08:40:49 -0300 Subject: [PATCH 13/28] update docs --- docs/builder.html | 790 ------------------------ docs/dataset.html | 678 --------------------- docs/explore/histogram.html | 676 --------------------- docs/explore/index.html | 75 --- docs/explore/pca.html | 742 ----------------------- docs/explore/tsne.html | 742 ----------------------- docs/index.html | 80 --- docs/observer.html | 375 ------------ docs/transform/data_type.html | 199 ------ docs/transform/index.html | 70 --- docs/transform/projection.html | 1035 -------------------------------- 11 files changed, 5462 deletions(-) delete mode 100644 docs/builder.html delete mode 100644 docs/dataset.html delete mode 100644 docs/explore/histogram.html delete mode 100644 docs/explore/index.html delete mode 100644 docs/explore/pca.html delete mode 100644 docs/explore/tsne.html delete mode 100644 docs/index.html delete mode 100644 docs/observer.html delete mode 100644 docs/transform/data_type.html delete mode 100644 docs/transform/index.html delete mode 100644 docs/transform/projection.html diff --git a/docs/builder.html b/docs/builder.html deleted file mode 100644 index 77ce1c4..0000000 --- a/docs/builder.html +++ /dev/null @@ -1,790 +0,0 @@ - - - - - - -learning_orchestra_client.builder API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.builder

      -
      -
      -
      - -Expand source code - -
      from .observer import Observer
      -from ._response_treat import ResponseTreat
      -from .dataset import Dataset
      -import requests
      -from typing import Union
      -
      -
      -class Builder:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/builder"
      -        self.response_treat = ResponseTreat()
      -        self.TRAIN_NAME = "trainDatasetName"
      -        self.TEST_NAME = "testDatasetName"
      -        self.CODE = "modelingCode"
      -        self.CLASSIFIERS_LIST = "classifiersList"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.METADATA_INDEX = 0
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        synchronously, the caller waits until the model predictions are inserted
      -        into the Learning Orchestra storage mechanism.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
      -
      -        for model in model_classifiers:
      -            observer.set_dataset_name(test_dataset_name + model)
      -            observer.observe_processing(pretty_response)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        asynchronously, the caller does not wait until the model predictions are
      -        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 model predictions are inserted.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_model(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 return indented string, else return dict.
      -
      -        return: A list with all model predictions metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model_prediction(self,
      -                                model_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 return indented string, else return dict.
      -        model_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 there
      -        is no such projection. The current page is also returned to be used in
      -        future content requests.
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
      -                              "?query=" + str(query) + \
      -                              "&limit=" + str(limit) + \
      -                              "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        model prediction metadata.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_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_model_prediction(model_name, limit=1,
      -                                                pretty_response=pretty_response)
      -
      -        return response
      -
      -    def delete_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting a model prediction.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name
      -
      -        response = requests.delete(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Builder -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Builder:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/builder"
      -        self.response_treat = ResponseTreat()
      -        self.TRAIN_NAME = "trainDatasetName"
      -        self.TEST_NAME = "testDatasetName"
      -        self.CODE = "modelingCode"
      -        self.CLASSIFIERS_LIST = "classifiersList"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.METADATA_INDEX = 0
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        synchronously, the caller waits until the model predictions are inserted
      -        into the Learning Orchestra storage mechanism.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        observer = Observer(test_dataset_name, self.CLUSTER_IP)
      -
      -        for model in model_classifiers:
      -            observer.set_dataset_name(test_dataset_name + model)
      -            observer.observe_processing(pretty_response)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_builder_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 resource join several steps of machine
      -        learning workflow (transform, tune, train and evaluate) coupling in
      -        a unique resource, builder creates several model predictions using
      -        your own modeling code using a defined set of classifiers. This is made
      -        asynchronously, the caller does not wait until the model predictions are
      -        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 model predictions are inserted.
      -
      -        train_dataset_name: Represent final train dataset.
      -        test_dataset_name: Represent final test dataset.
      -        modeling_code: Represent Python3 code for pyspark preprocessing model
      -        model_classifiers: list of initial classifiers to be used in model
      -        pretty_response: returns indented string for visualization if True
      -
      -        return: The resulted predictions URIs.
      -        """
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE MODEL WITH "
      -                + train_dataset_name
      -                + " AND "
      -                + test_dataset_name
      -                + " ----------"
      -            )
      -
      -        request_body_content = {
      -            self.TRAIN_NAME: train_dataset_name,
      -            self.TEST_NAME: test_dataset_name,
      -            self.CODE: modeling_code,
      -            self.CLASSIFIERS_LIST: model_classifiers,
      -        }
      -        response = requests.post(url=self.cluster_url,
      -                                 json=request_body_content)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_model(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 return indented string, else return dict.
      -
      -        return: A list with all model predictions metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model_prediction(self,
      -                                model_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 return indented string, else return dict.
      -        model_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 there
      -        is no such projection. The current page is also returned to be used in
      -        future content requests.
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name + \
      -                              "?query=" + str(query) + \
      -                              "&limit=" + str(limit) + \
      -                              "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        model prediction metadata.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_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_model_prediction(model_name, limit=1,
      -                                                pretty_response=pretty_response)
      -
      -        return response
      -
      -    def delete_model(self, model_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting a model prediction.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        model_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_dataset = self.cluster_url + "/" + model_name
      -
      -        response = requests.delete(cluster_url_dataset)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def delete_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting a model prediction. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -model_name: Represents the projection name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      def delete_model(self, model_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting a model prediction.
      -    The delete operation is always synchronous because it is very fast,
      -    since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    model_name: Represents the projection name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -
      -    cluster_url_dataset = self.cluster_url + "/" + model_name
      -
      -    response = requests.delete(cluster_url_dataset)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -asynchronously, the caller does not wait until the model predictions are -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 model predictions are inserted.

      -

      train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

      -

      return: The resulted predictions URIs.

      -
      - -Expand source code - -
      def run_builder_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 resource join several steps of machine
      -    learning workflow (transform, tune, train and evaluate) coupling in
      -    a unique resource, builder creates several model predictions using
      -    your own modeling code using a defined set of classifiers. This is made
      -    asynchronously, the caller does not wait until the model predictions are
      -    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 model predictions are inserted.
      -
      -    train_dataset_name: Represent final train dataset.
      -    test_dataset_name: Represent final test dataset.
      -    modeling_code: Represent Python3 code for pyspark preprocessing model
      -    model_classifiers: list of initial classifiers to be used in model
      -    pretty_response: returns indented string for visualization if True
      -
      -    return: The resulted predictions URIs.
      -    """
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE MODEL WITH "
      -            + train_dataset_name
      -            + " AND "
      -            + test_dataset_name
      -            + " ----------"
      -        )
      -
      -    request_body_content = {
      -        self.TRAIN_NAME: train_dataset_name,
      -        self.TEST_NAME: test_dataset_name,
      -        self.CODE: modeling_code,
      -        self.CLASSIFIERS_LIST: model_classifiers,
      -    }
      -    response = requests.post(url=self.cluster_url,
      -                             json=request_body_content)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_builder_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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -synchronously, the caller waits until the model predictions are inserted -into the Learning Orchestra storage mechanism.

      -

      train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

      -

      return: The resulted predictions URIs.

      -
      - -Expand source code - -
      def run_builder_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 resource join several steps of machine
      -    learning workflow (transform, tune, train and evaluate) coupling in
      -    a unique resource, builder creates several model predictions using
      -    your own modeling code using a defined set of classifiers. This is made
      -    synchronously, the caller waits until the model predictions are inserted
      -    into the Learning Orchestra storage mechanism.
      -
      -    train_dataset_name: Represent final train dataset.
      -    test_dataset_name: Represent final test dataset.
      -    modeling_code: Represent Python3 code for pyspark preprocessing model
      -    model_classifiers: list of initial classifiers to be used in model
      -    pretty_response: returns indented string for visualization if True
      -
      -    return: The resulted predictions URIs.
      -    """
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE MODEL WITH "
      -            + train_dataset_name
      -            + " AND "
      -            + test_dataset_name
      -            + " ----------"
      -        )
      -
      -    request_body_content = {
      -        self.TRAIN_NAME: train_dataset_name,
      -        self.TEST_NAME: test_dataset_name,
      -        self.CODE: modeling_code,
      -        self.CLASSIFIERS_LIST: model_classifiers,
      -    }
      -    response = requests.post(url=self.cluster_url,
      -                             json=request_body_content)
      -
      -    observer = Observer(test_dataset_name, self.CLUSTER_IP)
      -
      -    for model in model_classifiers:
      -        observer.set_dataset_name(test_dataset_name + model)
      -        observer.observe_processing(pretty_response)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_all_model(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 return indented string, else return dict.

      -

      return: A list with all model predictions metadata stored in Learning -Orchestra or an empty result.

      -
      - -Expand source code - -
      def search_all_model(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 return indented string, else return dict.
      -
      -    return: A list with all model predictions metadata stored in Learning
      -    Orchestra or an empty result.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url
      -
      -    response = requests.get(cluster_url_tsne)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_model(self, model_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: -This method is responsible for retrieving a specific -model prediction metadata.

      -

      pretty_response: If true return indented string, else return dict. -model_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.

      -
      - -Expand source code - -
      def search_model(self, model_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description:  This method is responsible for retrieving a specific
      -    model prediction metadata.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    model_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_model_prediction(model_name, limit=1,
      -                                            pretty_response=pretty_response)
      -
      -    return response
      -
      -
      -
      -def search_model_prediction(self, model_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 return indented string, else return dict. -model_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 there -is no such projection. The current page is also returned to be used in -future content requests.

      -
      - -Expand source code - -
      def search_model_prediction(self,
      -                            model_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 return indented string, else return dict.
      -    model_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 there
      -    is no such projection. The current page is also returned to be used in
      -    future content requests.
      -    """
      -
      -    cluster_url_dataset = self.cluster_url + "/" + model_name + \
      -                          "?query=" + str(query) + \
      -                          "&limit=" + str(limit) + \
      -                          "&skip=" + str(skip)
      -
      -    response = requests.get(cluster_url_dataset)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/dataset.html b/docs/dataset.html deleted file mode 100644 index b8b02a0..0000000 --- a/docs/dataset.html +++ /dev/null @@ -1,678 +0,0 @@ - - - - - - -learning_orchestra_client.dataset API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.dataset

      -
      -
      -
      - -Expand source code - -
      __author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro"
      -__credits__ = "all free source developers"
      -__status__ = "Prototype"
      -
      -from .observer import Observer
      -from ._response_treat import ResponseTreat
      -import requests
      -from typing import Union
      -
      -
      -class Dataset:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/dataset"
      -        self.response_treat = ResponseTreat()
      -        self.OUTPUT_NAME = "datasetName"
      -        self.URL = "datasetURI"
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    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 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.
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + 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).
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                     "---")
      -        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 return indented string, else return dict.
      -
      -        return: All datasets metadata stored in Learning Orchestra or an empty
      -        result.
      -        """
      -        request_url = self.cluster_url
      -
      -        response = requests.get(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for retrieving a specific
      -        dataset
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Is the name of the dataset file.
      -        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 dataset metadata stored in Learning Orchestra or an
      -        error if there is no such dataset.
      -        """
      -        response = self.search_dataset_content(dataset_name, limit=1,
      -                                               pretty_response=pretty_response)
      -
      -        return 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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name + \
      -                      "?query=" + str(query) + \
      -                      "&limit=" + str(limit) + \
      -                      "&skip=" + str(skip)
      -
      -        response = requests.get(request_url)
      -
      -        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. The
      -        delete operation is always synchronous because it is very fast, since
      -        the deletion is performed in background. If a dataset was used by
      -        another task (Ex. projection, histogram, pca, tuning and so forth), it
      -        cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Represents the dataset name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name
      -
      -        response = requests.delete(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Dataset -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Dataset:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/dataset"
      -        self.response_treat = ResponseTreat()
      -        self.OUTPUT_NAME = "datasetName"
      -        self.URL = "datasetURI"
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    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 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.
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + 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).
      -        """
      -        request_body = {self.OUTPUT_NAME: dataset_name,
      -                        self.URL: url}
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                     "---")
      -        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 return indented string, else return dict.
      -
      -        return: All datasets metadata stored in Learning Orchestra or an empty
      -        result.
      -        """
      -        request_url = self.cluster_url
      -
      -        response = requests.get(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for retrieving a specific
      -        dataset
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Is the name of the dataset file.
      -        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 dataset metadata stored in Learning Orchestra or an
      -        error if there is no such dataset.
      -        """
      -        response = self.search_dataset_content(dataset_name, limit=1,
      -                                               pretty_response=pretty_response)
      -
      -        return 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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name + \
      -                      "?query=" + str(query) + \
      -                      "&limit=" + str(limit) + \
      -                      "&skip=" + str(skip)
      -
      -        response = requests.get(request_url)
      -
      -        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. The
      -        delete operation is always synchronous because it is very fast, since
      -        the deletion is performed in background. If a dataset was used by
      -        another task (Ex. projection, histogram, pca, tuning and so forth), it
      -        cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        dataset_name: Represents the dataset name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        request_url = self.cluster_url + "/" + dataset_name
      -
      -        response = requests.delete(request_url)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def delete_dataset(self, dataset_name, pretty_response=False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting the dataset. The -delete operation is always synchronous because it is very fast, since -the deletion is performed in background. If a dataset was used by -another task (Ex. projection, histogram, pca, tuning and so forth), it -cannot be deleted.

      -

      pretty_response: If true return indented string, else return dict. -dataset_name: Represents the dataset name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      def delete_dataset(self, dataset_name, pretty_response=False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting the dataset. The
      -    delete operation is always synchronous because it is very fast, since
      -    the deletion is performed in background. If a dataset was used by
      -    another task (Ex. projection, histogram, pca, tuning and so forth), it
      -    cannot be deleted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    dataset_name: Represents the dataset name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -
      -    request_url = self.cluster_url + "/" + dataset_name
      -
      -    response = requests.delete(request_url)
      -
      -    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).

      -
      - -Expand source code - -
      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).
      -    """
      -    request_body = {self.OUTPUT_NAME: dataset_name,
      -                    self.URL: url}
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                 "---")
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -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 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.

      -
      - -Expand source code - -
      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 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.
      -    """
      -    request_body = {self.OUTPUT_NAME: dataset_name,
      -                    self.URL: url}
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    Observer(dataset_name, self.CLUSTER_IP).observe_processing()
      -
      -    if pretty_response:
      -        print("\n----------" + " CREATED FILE " + dataset_name + " -------"
      -                                                                 "---")
      -    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 return indented string, else return dict.

      -

      return: All datasets metadata stored in Learning Orchestra or an empty -result.

      -
      - -Expand source code - -
      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 return indented string, else return dict.
      -
      -    return: All datasets metadata stored in Learning Orchestra or an empty
      -    result.
      -    """
      -    request_url = self.cluster_url
      -
      -    response = requests.get(request_url)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_dataset(self, dataset_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for retrieving a specific -dataset

      -

      pretty_response: If true return indented string, else return dict. -dataset_name: Is the name of the dataset file. -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 dataset metadata stored in Learning Orchestra or an -error if there is no such dataset.

      -
      - -Expand source code - -
      def search_dataset(self, dataset_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for retrieving a specific
      -    dataset
      -
      -    pretty_response: If true return indented string, else return dict.
      -    dataset_name: Is the name of the dataset file.
      -    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 dataset metadata stored in Learning Orchestra or an
      -    error if there is no such dataset.
      -    """
      -    response = self.search_dataset_content(dataset_name, limit=1,
      -                                           pretty_response=pretty_response)
      -
      -    return 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 return indented string, else return dict. -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.

      -
      - -Expand source code - -
      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 return indented string, else return dict.
      -    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.
      -    """
      -
      -    request_url = self.cluster_url + "/" + dataset_name + \
      -                  "?query=" + str(query) + \
      -                  "&limit=" + str(limit) + \
      -                  "&skip=" + str(skip)
      -
      -    response = requests.get(request_url)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/explore/histogram.html b/docs/explore/histogram.html deleted file mode 100644 index d4a510e..0000000 --- a/docs/explore/histogram.html +++ /dev/null @@ -1,676 +0,0 @@ - - - - - - -learning_orchestra_client.explore.histogram API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.explore.histogram

      -
      -
      -
      - -Expand source code - -
      from ..observer import Observer
      -from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -import requests
      -from typing import Union
      -
      -
      -class Histogram:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/histogram"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -
      -    def run_histogram_sync(self,
      -                           dataset_name: str,
      -                           histogram_name: str,
      -                           fields: list,
      -                           pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method run histogram algorithm to create a histogram
      -        synchronously, 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 return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_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 run histogram algorithm to create a histogram
      -        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      -
      -        dataset_name: Represents the name of dataset.
      -        histogram_name: Represents the name of histogram.
      -        fields: Represents a list of attributes.
      -        pretty_response: If true return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_name
      -                + " ----------"
      -            )
      -
      -        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 names, it does not
      -        retrieve the histogram content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all histogram names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_histogram_data(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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
      -                                "?query=" + str(query) + \
      -                                "&limit=" + str(limit) + \
      -                                "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        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 synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        histogram_name: Represents the histogram name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name
      -
      -        response = requests.delete(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Histogram -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Histogram:
      -    def __init__(self, ip_from_cluster: str):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/histogram"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -
      -    def run_histogram_sync(self,
      -                           dataset_name: str,
      -                           histogram_name: str,
      -                           fields: list,
      -                           pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method run histogram algorithm to create a histogram
      -        synchronously, 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 return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(histogram_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_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 run histogram algorithm to create a histogram
      -        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      -
      -        dataset_name: Represents the name of dataset.
      -        histogram_name: Represents the name of histogram.
      -        fields: Represents a list of attributes.
      -        pretty_response: If true return indented string, else return dict.
      -
      -        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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE HISTOGRAM FROM "
      -                + dataset_name
      -                + " TO "
      -                + histogram_name
      -                + " ----------"
      -            )
      -
      -        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 names, it does not
      -        retrieve the histogram content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all histogram names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_histogram_data(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 return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
      -                                "?query=" + str(query) + \
      -                                "&limit=" + str(limit) + \
      -                                "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_histogram)
      -
      -        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 synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        histogram_name: Represents the histogram name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -
      -        cluster_url_histogram = self.cluster_url + "/" + histogram_name
      -
      -        response = requests.delete(cluster_url_histogram)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -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 synchronous because it is very fast, -since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -histogram_name: Represents the histogram name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      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 synchronous because it is very fast,
      -    since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    histogram_name: Represents the histogram name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -
      -    cluster_url_histogram = self.cluster_url + "/" + histogram_name
      -
      -    response = requests.delete(cluster_url_histogram)
      -
      -    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 run histogram algorithm to create a histogram -asynchronously, the caller does not wait until the histogram 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 histogram was inserted.

      -

      dataset_name: Represents the name of dataset. -histogram_name: Represents the name of histogram. -fields: Represents a list of attributes. -pretty_response: If true return indented string, else return dict.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a histogram.

      -
      - -Expand source code - -
      def run_histogram_async(self,
      -                        dataset_name: str,
      -                        histogram_name: str,
      -                        fields: list,
      -                        pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method run histogram algorithm to create a histogram
      -    asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      -
      -    dataset_name: Represents the name of dataset.
      -    histogram_name: Represents the name of histogram.
      -    fields: Represents a list of attributes.
      -    pretty_response: If true return indented string, else return dict.
      -
      -    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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE HISTOGRAM FROM "
      -            + dataset_name
      -            + " TO "
      -            + histogram_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_histogram_sync(self, dataset_name: str, histogram_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run histogram algorithm to create a histogram -synchronously, 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 return indented string, else return dict.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a histogram.

      -
      - -Expand source code - -
      def run_histogram_sync(self,
      -                       dataset_name: str,
      -                       histogram_name: str,
      -                       fields: list,
      -                       pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method run histogram algorithm to create a histogram
      -    synchronously, 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 return indented string, else return dict.
      -
      -    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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    Observer(histogram_name, self.CLUSTER_IP).observe_processing(
      -        pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE HISTOGRAM FROM "
      -            + dataset_name
      -            + " TO "
      -            + histogram_name
      -            + " ----------"
      -        )
      -
      -    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 names, it does not -retrieve the histogram content.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all histogram names stored in Learning Orchestra -or an empty result.

      -
      - -Expand source code - -
      def search_all_histograms(self, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves all histogram names, it does not
      -    retrieve the histogram content.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all histogram names stored in Learning Orchestra
      -    or an empty result.
      -    """
      -
      -    cluster_url_histogram = self.cluster_url
      -
      -    response = requests.get(cluster_url_histogram)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_histogram_data(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 return indented string, else return dict. -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.

      -
      - -Expand source code - -
      def search_histogram_data(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 return indented string, else return dict.
      -    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.
      -    """
      -
      -    cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
      -                            "?query=" + str(query) + \
      -                            "&limit=" + str(limit) + \
      -                            "&skip=" + str(skip)
      -
      -    response = requests.get(cluster_url_histogram)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/explore/index.html b/docs/explore/index.html deleted file mode 100644 index d4f7495..0000000 --- a/docs/explore/index.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - -learning_orchestra_client.explore API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/docs/explore/pca.html b/docs/explore/pca.html deleted file mode 100644 index 96011a2..0000000 --- a/docs/explore/pca.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - - -learning_orchestra_client.explore.pca API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.explore.pca

      -
      -
      -
      - -Expand source code - -
      from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -from PIL import Image
      -import requests
      -import time
      -from typing import Union
      -
      -
      -class Pca:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/pca"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_pca_sync(self,
      -                     dataset_name: str,
      -                     pca_name: str,
      -                     label: str,
      -                     pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        synchronously, the caller waits until the PCA image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_pca_exist(pca_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_pca_async(self,
      -                      dataset_name: str,
      -                      pca_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method retrieves all PCAs plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all PCAs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_pca = self.cluster_url
      -
      -        response = requests.get(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a PCA image plot.
      -
      -        pca_name: Name of PCA image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ "
      -                + pca_name
      -                + " PCA IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_pca
      -
      -    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the PCA image plot.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        pca_name: Represents the PCA name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        response = requests.delete(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a PCA image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        pca_name: Name of PCA image plot.
      -
      -        return: True if the PCA requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
      -                                                           "----------")
      -
      -        exist = False
      -        pca_name += ".png"
      -
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_pca = self.search_all_pca()
      -            exist = pca_name in all_pca.get('result')
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Pca -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Pca:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/pca"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_pca_sync(self,
      -                     dataset_name: str,
      -                     pca_name: str,
      -                     label: str,
      -                     pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        synchronously, the caller waits until the PCA image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_pca_exist(pca_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_pca_async(self,
      -                      dataset_name: str,
      -                      pca_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run PCA algorithm to create an image plot
      -        asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        pca_name: Name of PCA image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a PCA image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: pca_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PCA IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + pca_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method retrieves all PCAs plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all PCAs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_pca = self.cluster_url
      -
      -        response = requests.get(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a PCA image plot.
      -
      -        pca_name: Name of PCA image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ "
      -                + pca_name
      -                + " PCA IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_pca
      -
      -    def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the PCA image plot.
      -        The delete operation is always synchronous because it is very fast,
      -        since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        pca_name: Represents the PCA name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -        response = requests.delete(cluster_url_pca)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a PCA image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        pca_name: Name of PCA image plot.
      -
      -        return: True if the PCA requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + pca_name + " FINISHED "
      -                                                           "----------")
      -
      -        exist = False
      -        pca_name += ".png"
      -
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_pca = self.search_all_pca()
      -            exist = pca_name in all_pca.get('result')
      -
      -

      Methods

      -
      -
      -def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting the PCA image plot. -The delete operation is always synchronous because it is very fast, -since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -pca_name: Represents the PCA name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message.

      -
      - -Expand source code - -
      def delete_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting the PCA image plot.
      -    The delete operation is always synchronous because it is very fast,
      -    since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    pca_name: Represents the PCA name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message.
      -    """
      -
      -    cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -    response = requests.delete(cluster_url_pca)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_pca_async(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run PCA algorithm to create an image plot -asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.

      -

      dataset_name: Name of dataset. -pca_name: Name of PCA image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a PCA image plot.

      -
      - -Expand source code - -
      def run_pca_async(self,
      -                  dataset_name: str,
      -                  pca_name: str,
      -                  label: str,
      -                  pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run PCA algorithm to create an image plot
      -    asynchronously, the caller does not wait until the PCA image 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 PCA image was inserted.
      -
      -    dataset_name: Name of dataset.
      -    pca_name: Name of PCA image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a PCA image plot.
      -    """
      -
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: pca_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PCA IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + pca_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_pca_sync(self, dataset_name: str, pca_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run PCA algorithm to create an image plot -synchronously, the caller waits until the PCA image is inserted into -the Learning Orchestra storage mechanism.

      -

      dataset_name: Name of dataset. -pca_name: Name of PCA image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a PCA image plot.

      -
      - -Expand source code - -
      def run_pca_sync(self,
      -                 dataset_name: str,
      -                 pca_name: str,
      -                 label: str,
      -                 pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run PCA algorithm to create an image plot
      -    synchronously, the caller waits until the PCA image is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    dataset_name: Name of dataset.
      -    pca_name: Name of PCA image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a PCA image plot.
      -    """
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: pca_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    self.verify_pca_exist(pca_name, pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PCA IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + pca_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_all_pca(self, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves all PCAs plot names, it does not -retrieve the image plot.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all PCAs plot names stored in Learning Orchestra -or an empty result.

      -
      - -Expand source code - -
      def search_all_pca(self, pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method retrieves all PCAs plot names, it does not
      -    retrieve the image plot.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all PCAs plot names stored in Learning Orchestra
      -    or an empty result.
      -    """
      -
      -    cluster_url_pca = self.cluster_url
      -
      -    response = requests.get(cluster_url_pca)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_pca_plot(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves a PCA image plot.

      -

      pca_name: Name of PCA image plot. -pretty_response: If true open an image plot, else return link to -open image plot.

      -

      return: A link to an image plot or open an image plot.

      -
      - -Expand source code - -
      def search_pca_plot(self, pca_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves a PCA image plot.
      -
      -    pca_name: Name of PCA image plot.
      -    pretty_response: If true open an image plot, else return link to
      -    open image plot.
      -
      -    return: A link to an image plot or open an image plot.
      -    """
      -
      -    cluster_url_pca = self.cluster_url + "/" + pca_name
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " READ "
      -            + pca_name
      -            + " PCA IMAGE PLOT "
      -            + " ----------"
      -        )
      -        img = Image.open(requests.get(cluster_url_pca, stream=True).raw)
      -        img.show()
      -    else:
      -        return cluster_url_pca
      -
      -
      -
      -def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible to verify if a PCA image -exist into the Learning Orchestra storage mechanism.

      -

      pca_name: Name of PCA image plot.

      -

      return: True if the PCA requested exist, false if does not.

      -
      - -Expand source code - -
      def verify_pca_exist(self, pca_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible to verify if a PCA image
      -    exist into the Learning Orchestra storage mechanism.
      -
      -    pca_name: Name of PCA image plot.
      -
      -    return: True if the PCA requested exist, false if does not.
      -    """
      -
      -    if pretty_response:
      -        print("\n---------- CHECKING IF " + pca_name + " FINISHED "
      -                                                       "----------")
      -
      -    exist = False
      -    pca_name += ".png"
      -
      -    while not exist:
      -        time.sleep(self.WAIT_TIME)
      -        all_pca = self.search_all_pca()
      -        exist = pca_name in all_pca.get('result')
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/explore/tsne.html b/docs/explore/tsne.html deleted file mode 100644 index e027e0a..0000000 --- a/docs/explore/tsne.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - - -learning_orchestra_client.explore.tsne API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.explore.tsne

      -
      -
      -
      - -Expand source code - -
      from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -from PIL import Image
      -import requests
      -import time
      -from typing import Union
      -
      -
      -class Tsne:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/tsne"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_tsne_sync(self,
      -                      dataset_name: str,
      -                      tsne_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        synchronously, the caller waits until the t_SNE image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_tsne_exist(tsne_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_tsne_async(self,
      -                       dataset_name: str,
      -                       tsne_name: str,
      -                       label: str,
      -                       pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_tsne(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all t_SNE plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all t_SNEs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a t_SNE image plot.
      -
      -        tsne_name: Name of t_SNE image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ"
      -                + tsne_name
      -                + " tsne IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_tsne
      -
      -    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the t_SNE image
      -        plot. The delete operation is always synchronous because it is very
      -        fast, since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        tsne_name: Represents the tsne name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        response = requests.delete(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a t_SNE image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        tsne_name: Name of t_SNE image plot.
      -
      -        return: True if the t_SNE requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
      -                                                            "----------")
      -
      -        exist = False
      -        tsne_name += ".png"
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_tsne = self.search_all_tsne()
      -            exist = tsne_name in all_tsne.get('result')
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Tsne -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Tsne:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/explore/tsne"
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputPlotName"
      -        self.LABEL = "label"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.WAIT_TIME = 5
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def run_tsne_sync(self,
      -                      dataset_name: str,
      -                      tsne_name: str,
      -                      label: str,
      -                      pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        synchronously, the caller waits until the t_SNE image is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        self.verify_tsne_exist(tsne_name, pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def run_tsne_async(self,
      -                       dataset_name: str,
      -                       tsne_name: str,
      -                       label: str,
      -                       pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description: This method run t_SNE algorithm to create an image plot
      -        asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
      -
      -        dataset_name: Name of dataset.
      -        tsne_name: Name of t_SNE image plot.
      -        label: The label is the label name of the column for machine learning
      -        datasets which has labeled tuples.
      -        pretty_response: If true open an image plot, else return link to open
      -        image plot.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns a t_SNE image plot.
      -        """
      -
      -        request_body = {
      -            self.INPUT_NAME: dataset_name,
      -            self.OUTPUT_NAME: tsne_name,
      -            self.LABEL: label,
      -        }
      -        request_url = self.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE TSNE IMAGE PLOT FROM "
      -                + dataset_name
      -                + " TO "
      -                + tsne_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_all_tsne(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all t_SNE plot names, it does not
      -        retrieve the image plot.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all t_SNEs plot names stored in Learning Orchestra
      -        or an empty result.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url
      -
      -        response = requests.get(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves a t_SNE image plot.
      -
      -        tsne_name: Name of t_SNE image plot.
      -        pretty_response: If true open an image plot, else return link to
      -        open image plot.
      -
      -        return: A link to an image plot or open an image plot.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " READ"
      -                + tsne_name
      -                + " tsne IMAGE PLOT "
      -                + " ----------"
      -            )
      -            img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
      -            img.show()
      -        else:
      -            return cluster_url_tsne
      -
      -    def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible for deleting the t_SNE image
      -        plot. The delete operation is always synchronous because it is very
      -        fast, since the deletion is performed in background.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        tsne_name: Represents the tsne name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message.
      -        """
      -
      -        cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -        response = requests.delete(cluster_url_tsne)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method is responsible to verify if a t_SNE image
      -        exist into the Learning Orchestra storage mechanism.
      -
      -        tsne_name: Name of t_SNE image plot.
      -
      -        return: True if the t_SNE requested exist, false if does not.
      -        """
      -
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
      -                                                            "----------")
      -
      -        exist = False
      -        tsne_name += ".png"
      -        while not exist:
      -            time.sleep(self.WAIT_TIME)
      -            all_tsne = self.search_all_tsne()
      -            exist = tsne_name in all_tsne.get('result')
      -
      -

      Methods

      -
      -
      -def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible for deleting the t_SNE image -plot. The delete operation is always synchronous because it is very -fast, since the deletion is performed in background.

      -

      pretty_response: If true return indented string, else return dict. -tsne_name: Represents the tsne name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message.

      -
      - -Expand source code - -
      def delete_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible for deleting the t_SNE image
      -    plot. The delete operation is always synchronous because it is very
      -    fast, since the deletion is performed in background.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    tsne_name: Represents the tsne name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -    response = requests.delete(cluster_url_tsne)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_tsne_async(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run t_SNE algorithm to create an image plot -asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.

      -

      dataset_name: Name of dataset. -tsne_name: Name of t_SNE image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a t_SNE image plot.

      -
      - -Expand source code - -
      def run_tsne_async(self,
      -                   dataset_name: str,
      -                   tsne_name: str,
      -                   label: str,
      -                   pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run t_SNE algorithm to create an image plot
      -    asynchronously, the caller does not wait until the t_SNE image 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 t_SNE image was inserted.
      -
      -    dataset_name: Name of dataset.
      -    tsne_name: Name of t_SNE image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a t_SNE image plot.
      -    """
      -
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: tsne_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE TSNE IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + tsne_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def run_tsne_sync(self, dataset_name: str, tsne_name: str, label: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method run t_SNE algorithm to create an image plot -synchronously, the caller waits until the t_SNE image is inserted into -the Learning Orchestra storage mechanism.

      -

      dataset_name: Name of dataset. -tsne_name: Name of t_SNE image plot. -label: The label is the label name of the column for machine learning -datasets which has labeled tuples. -pretty_response: If true open an image plot, else return link to open -image plot.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns a t_SNE image plot.

      -
      - -Expand source code - -
      def run_tsne_sync(self,
      -                  dataset_name: str,
      -                  tsne_name: str,
      -                  label: str,
      -                  pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description: This method run t_SNE algorithm to create an image plot
      -    synchronously, the caller waits until the t_SNE image is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    dataset_name: Name of dataset.
      -    tsne_name: Name of t_SNE image plot.
      -    label: The label is the label name of the column for machine learning
      -    datasets which has labeled tuples.
      -    pretty_response: If true open an image plot, else return link to open
      -    image plot.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns a t_SNE image plot.
      -    """
      -
      -    request_body = {
      -        self.INPUT_NAME: dataset_name,
      -        self.OUTPUT_NAME: tsne_name,
      -        self.LABEL: label,
      -    }
      -    request_url = self.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    self.verify_tsne_exist(tsne_name, pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE TSNE IMAGE PLOT FROM "
      -            + dataset_name
      -            + " TO "
      -            + tsne_name
      -            + " ----------"
      -        )
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_all_tsne(self, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves all t_SNE plot names, it does not -retrieve the image plot.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all t_SNEs plot names stored in Learning Orchestra -or an empty result.

      -
      - -Expand source code - -
      def search_all_tsne(self, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves all t_SNE plot names, it does not
      -    retrieve the image plot.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all t_SNEs plot names stored in Learning Orchestra
      -    or an empty result.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url
      -
      -    response = requests.get(cluster_url_tsne)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method retrieves a t_SNE image plot.

      -

      tsne_name: Name of t_SNE image plot. -pretty_response: If true open an image plot, else return link to -open image plot.

      -

      return: A link to an image plot or open an image plot.

      -
      - -Expand source code - -
      def search_tsne_plot(self, tsne_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves a t_SNE image plot.
      -
      -    tsne_name: Name of t_SNE image plot.
      -    pretty_response: If true open an image plot, else return link to
      -    open image plot.
      -
      -    return: A link to an image plot or open an image plot.
      -    """
      -
      -    cluster_url_tsne = self.cluster_url + "/" + tsne_name
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " READ"
      -            + tsne_name
      -            + " tsne IMAGE PLOT "
      -            + " ----------"
      -        )
      -        img = Image.open(requests.get(cluster_url_tsne, stream=True).raw)
      -        img.show()
      -    else:
      -        return cluster_url_tsne
      -
      -
      -
      -def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method is responsible to verify if a t_SNE image -exist into the Learning Orchestra storage mechanism.

      -

      tsne_name: Name of t_SNE image plot.

      -

      return: True if the t_SNE requested exist, false if does not.

      -
      - -Expand source code - -
      def verify_tsne_exist(self, tsne_name: str, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method is responsible to verify if a t_SNE image
      -    exist into the Learning Orchestra storage mechanism.
      -
      -    tsne_name: Name of t_SNE image plot.
      -
      -    return: True if the t_SNE requested exist, false if does not.
      -    """
      -
      -    if pretty_response:
      -        print("\n---------- CHECKING IF " + tsne_name + " FINISHED "
      -                                                        "----------")
      -
      -    exist = False
      -    tsne_name += ".png"
      -    while not exist:
      -        time.sleep(self.WAIT_TIME)
      -        all_tsne = self.search_all_tsne()
      -        exist = tsne_name in all_tsne.get('result')
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 46c4a70..0000000 --- a/docs/index.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - -learning_orchestra_client API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/docs/observer.html b/docs/observer.html deleted file mode 100644 index a7d3aee..0000000 --- a/docs/observer.html +++ /dev/null @@ -1,375 +0,0 @@ - - - - - - -learning_orchestra_client.observer API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.observer

      -
      -
      -
      - -Expand source code - -
      from pymongo import MongoClient, change_stream
      -
      -
      -class Observer:
      -    def __init__(self, dataset_name: str, cluster_ip: str):
      -        self.dataset_name = dataset_name
      -
      -        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
      -        mongo_client = MongoClient(mongo_url)
      -        self.database = mongo_client['database']
      -
      -    def set_dataset_name(self, dataset_name: str):
      -        """
      -        :description: Changes the dataset name used in object.
      -        :param dataset_name: Name of dataset to observe.
      -
      -        :return: None.
      -        """
      -        self.dataset_name = dataset_name
      -
      -    def get_dataset_name(self) -> str:
      -        """
      -        :description: Retrieve the dataset name used in object.
      -
      -        :return: The dataset name.
      -        """
      -        return self.dataset_name
      -
      -    def observe_processing(self, pretty_response: bool = False) -> dict:
      -        """
      -        :description: Observe the finished processing status from some
      -        processing, blocking the code execution until finish processing.
      -
      -        :return: A dict with metadata file of used dataset name.
      -        """
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
      -                                                                    "----------")
      -        dataset_collection = self.database[self.dataset_name]
      -        metadata_query = {"_id": 0}
      -        dataset_metadata = dataset_collection.find_one(metadata_query)
      -
      -        if dataset_metadata is None:
      -            print("Dataset name or dataset URL invalid")
      -            exit()
      -
      -        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').next()['fullDocument']
      -
      -    def observe_storage(self) -> change_stream.CollectionChangeStream:
      -        """
      -        :description: Get all changes from a dataset
      -
      -        :return: A pymongo CollectionChangeStream object, use the builtin
      -        next() method to iterate over changes.
      -        """
      -
      -        observer_query = [
      -            {'$match': {
      -                '$or': [
      -                    {'operationType': 'replace'},
      -                    {'operationType': 'insert'},
      -                    {'operationType': 'update'},
      -                    {'operationType': 'delete'}
      -
      -                ]
      -            }}
      -        ]
      -        return self.database[self.dataset_name].watch(
      -            observer_query,
      -            full_document='updateLookup')
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Observer -(dataset_name: str, cluster_ip: str) -
      -
      -
      -
      - -Expand source code - -
      class Observer:
      -    def __init__(self, dataset_name: str, cluster_ip: str):
      -        self.dataset_name = dataset_name
      -
      -        mongo_url = 'mongodb://root:owl45%2321@' + cluster_ip
      -        mongo_client = MongoClient(mongo_url)
      -        self.database = mongo_client['database']
      -
      -    def set_dataset_name(self, dataset_name: str):
      -        """
      -        :description: Changes the dataset name used in object.
      -        :param dataset_name: Name of dataset to observe.
      -
      -        :return: None.
      -        """
      -        self.dataset_name = dataset_name
      -
      -    def get_dataset_name(self) -> str:
      -        """
      -        :description: Retrieve the dataset name used in object.
      -
      -        :return: The dataset name.
      -        """
      -        return self.dataset_name
      -
      -    def observe_processing(self, pretty_response: bool = False) -> dict:
      -        """
      -        :description: Observe the finished processing status from some
      -        processing, blocking the code execution until finish processing.
      -
      -        :return: A dict with metadata file of used dataset name.
      -        """
      -        if pretty_response:
      -            print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
      -                                                                    "----------")
      -        dataset_collection = self.database[self.dataset_name]
      -        metadata_query = {"_id": 0}
      -        dataset_metadata = dataset_collection.find_one(metadata_query)
      -
      -        if dataset_metadata is None:
      -            print("Dataset name or dataset URL invalid")
      -            exit()
      -
      -        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').next()['fullDocument']
      -
      -    def observe_storage(self) -> change_stream.CollectionChangeStream:
      -        """
      -        :description: Get all changes from a dataset
      -
      -        :return: A pymongo CollectionChangeStream object, use the builtin
      -        next() method to iterate over changes.
      -        """
      -
      -        observer_query = [
      -            {'$match': {
      -                '$or': [
      -                    {'operationType': 'replace'},
      -                    {'operationType': 'insert'},
      -                    {'operationType': 'update'},
      -                    {'operationType': 'delete'}
      -
      -                ]
      -            }}
      -        ]
      -        return self.database[self.dataset_name].watch(
      -            observer_query,
      -            full_document='updateLookup')
      -
      -

      Methods

      -
      -
      -def get_dataset_name(self) ‑> str -
      -
      -

      :description: Retrieve the dataset name used in object.

      -

      :return: The dataset name.

      -
      - -Expand source code - -
      def get_dataset_name(self) -> str:
      -    """
      -    :description: Retrieve the dataset name used in object.
      -
      -    :return: The dataset name.
      -    """
      -    return self.dataset_name
      -
      -
      -
      -def observe_processing(self, pretty_response: bool = False) ‑> dict -
      -
      -

      :description: Observe the finished processing status from some -processing, blocking the code execution until finish processing.

      -

      :return: A dict with metadata file of used dataset name.

      -
      - -Expand source code - -
      def observe_processing(self, pretty_response: bool = False) -> dict:
      -    """
      -    :description: Observe the finished processing status from some
      -    processing, blocking the code execution until finish processing.
      -
      -    :return: A dict with metadata file of used dataset name.
      -    """
      -    if pretty_response:
      -        print("\n---------- CHECKING IF " + self.dataset_name + " FINISHED "
      -                                                                "----------")
      -    dataset_collection = self.database[self.dataset_name]
      -    metadata_query = {"_id": 0}
      -    dataset_metadata = dataset_collection.find_one(metadata_query)
      -
      -    if dataset_metadata is None:
      -        print("Dataset name or dataset URL invalid")
      -        exit()
      -
      -    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').next()['fullDocument']
      -
      -
      -
      -def observe_storage(self) ‑> pymongo.change_stream.CollectionChangeStream -
      -
      -

      :description: Get all changes from a dataset

      -

      :return: A pymongo CollectionChangeStream object, use the builtin -next() method to iterate over changes.

      -
      - -Expand source code - -
      def observe_storage(self) -> change_stream.CollectionChangeStream:
      -    """
      -    :description: Get all changes from a dataset
      -
      -    :return: A pymongo CollectionChangeStream object, use the builtin
      -    next() method to iterate over changes.
      -    """
      -
      -    observer_query = [
      -        {'$match': {
      -            '$or': [
      -                {'operationType': 'replace'},
      -                {'operationType': 'insert'},
      -                {'operationType': 'update'},
      -                {'operationType': 'delete'}
      -
      -            ]
      -        }}
      -    ]
      -    return self.database[self.dataset_name].watch(
      -        observer_query,
      -        full_document='updateLookup')
      -
      -
      -
      -def set_dataset_name(self, dataset_name: str) -
      -
      -

      :description: Changes the dataset name used in object. -:param dataset_name: Name of dataset to observe.

      -

      :return: None.

      -
      - -Expand source code - -
      def set_dataset_name(self, dataset_name: str):
      -    """
      -    :description: Changes the dataset name used in object.
      -    :param dataset_name: Name of dataset to observe.
      -
      -    :return: None.
      -    """
      -    self.dataset_name = dataset_name
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/transform/data_type.html b/docs/transform/data_type.html deleted file mode 100644 index ab70288..0000000 --- a/docs/transform/data_type.html +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - -learning_orchestra_client.transform.data_type API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.transform.data_type

      -
      -
      -
      - -Expand source code - -
      from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -import requests
      -from typing import Union
      -
      -
      -class DataType:
      -    def __init__(self, ip_from_cluster):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/dataType"
      -        self.ResponseTreat = ResponseTreat()
      -        self.Dataset = Dataset(ip_from_cluster)
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.TYPES = "types"
      -
      -    def update_dataset_types(self,
      -                             dataset_name: str,
      -                             fields_change: dict,
      -                             pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: Change types of fields to number or string.
      -
      -        dataset_name: Represents the dataset name.
      -        fields_change: Fields to change with types. This is a dict with each
      -        key:value being field:type
      -
      -        return: A JSON object with error or warning messages.
      -        """
      -
      -        url_request = self.cluster_url
      -        body_request = {
      -            self.INPUT_NAME: dataset_name,
      -            self.TYPES: fields_change
      -        }
      -
      -        response = requests.patch(url=url_request, json=body_request)
      -
      -        return self.ResponseTreat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class DataType -(ip_from_cluster) -
      -
      -
      -
      - -Expand source code - -
      class DataType:
      -    def __init__(self, ip_from_cluster):
      -        self.CLUSTER_IP = ip_from_cluster
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/dataType"
      -        self.ResponseTreat = ResponseTreat()
      -        self.Dataset = Dataset(ip_from_cluster)
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.TYPES = "types"
      -
      -    def update_dataset_types(self,
      -                             dataset_name: str,
      -                             fields_change: dict,
      -                             pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: Change types of fields to number or string.
      -
      -        dataset_name: Represents the dataset name.
      -        fields_change: Fields to change with types. This is a dict with each
      -        key:value being field:type
      -
      -        return: A JSON object with error or warning messages.
      -        """
      -
      -        url_request = self.cluster_url
      -        body_request = {
      -            self.INPUT_NAME: dataset_name,
      -            self.TYPES: fields_change
      -        }
      -
      -        response = requests.patch(url=url_request, json=body_request)
      -
      -        return self.ResponseTreat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def update_dataset_types(self, dataset_name: str, fields_change: dict, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: Change types of fields to number or string.

      -

      dataset_name: Represents the dataset name. -fields_change: Fields to change with types. This is a dict with each -key:value being field:type

      -

      return: A JSON object with error or warning messages.

      -
      - -Expand source code - -
      def update_dataset_types(self,
      -                         dataset_name: str,
      -                         fields_change: dict,
      -                         pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: Change types of fields to number or string.
      -
      -    dataset_name: Represents the dataset name.
      -    fields_change: Fields to change with types. This is a dict with each
      -    key:value being field:type
      -
      -    return: A JSON object with error or warning messages.
      -    """
      -
      -    url_request = self.cluster_url
      -    body_request = {
      -        self.INPUT_NAME: dataset_name,
      -        self.TYPES: fields_change
      -    }
      -
      -    response = requests.patch(url=url_request, json=body_request)
      -
      -    return self.ResponseTreat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file diff --git a/docs/transform/index.html b/docs/transform/index.html deleted file mode 100644 index 271146f..0000000 --- a/docs/transform/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - -learning_orchestra_client.transform API documentation - - - - - - - - - - - -
      - - -
      - - - \ No newline at end of file diff --git a/docs/transform/projection.html b/docs/transform/projection.html deleted file mode 100644 index 0ee1113..0000000 --- a/docs/transform/projection.html +++ /dev/null @@ -1,1035 +0,0 @@ - - - - - - -learning_orchestra_client.transform.projection API documentation - - - - - - - - - - - -
      -
      -
      -

      Module learning_orchestra_client.transform.projection

      -
      -
      -
      - -Expand source code - -
      from .._response_treat import ResponseTreat
      -from ..dataset import Dataset
      -from ..observer import Observer
      -import requests
      -from typing import Union
      -
      -
      -class Projection:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/projection"
      -        self.METADATA_INDEX = 0
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def insert_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(projection_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def insert_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields_to_delete: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes on a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_sync(dataset_name,
      -                                                       projection_name,
      -                                                       fields_to_insert,
      -                                                       pretty_response)
      -
      -        return response
      -
      -    def delete_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields_to_delete: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_async(dataset_name,
      -                                                        projection_name,
      -                                                        fields_to_insert,
      -                                                        pretty_response)
      -
      -        return response
      -
      -    def search_all_projections(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all projection metadata, it does not
      -        retrieve the projection content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all projections metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -        cluster_url_projection = self.cluster_url
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_projections(self, projection_name: str,
      -                           pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        projection.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
      -        error if there is no such projections.
      -        """
      -        pretty = pretty_response
      -
      -        response = self.search_projections_content(projection_name, limit=1,
      -                                                   pretty_response=pretty)
      -
      -        return response
      -
      -    def search_projections_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 dataset
      -        content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_projection = self.cluster_url + "/" + projection_name + \
      -                                 "?query=" + str(query) + \
      -                                 "&limit=" + str(limit) + \
      -                                 "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_projections(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 synchronous because it is very fast,
      -        since the deletion is performed in background. If a projection was
      -        used by another task (Ex. histogram, pca, tuning and so forth),
      -        it cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -        cluster_url_projection = self.cluster_url + "/" + projection_name
      -
      -        response = requests.delete(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      Classes

      -
      -
      -class Projection -(ip_from_cluster: str) -
      -
      -
      -
      - -Expand source code - -
      class Projection:
      -    def __init__(self, ip_from_cluster: str):
      -        self.cluster_url = "http://" + ip_from_cluster + \
      -                           "/api/learningOrchestra/v1/transform/projection"
      -        self.METADATA_INDEX = 0
      -        self.response_treat = ResponseTreat()
      -        self.INPUT_NAME = "inputDatasetName"
      -        self.OUTPUT_NAME = "outputDatasetName"
      -        self.FIELDS = "names"
      -        self.dataset = Dataset(ip_from_cluster)
      -        self.CLUSTER_IP = ip_from_cluster
      -
      -    def insert_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        Observer(projection_name, self.CLUSTER_IP).observe_processing(
      -            pretty_response)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def insert_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method inserts a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields: Represents the set of attributes to be inserted. This is list
      -        with all 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.cluster_url
      -
      -        response = requests.post(url=request_url, json=request_body)
      -
      -        if pretty_response:
      -            print(
      -                "\n----------"
      -                + " CREATE PROJECTION FROM "
      -                + dataset_name
      -                + " TO "
      -                + projection_name
      -                + " ----------"
      -            )
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_dataset_attributes_sync(self,
      -                                       dataset_name: str,
      -                                       projection_name: str,
      -                                       fields_to_delete: list,
      -                                       pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes on a dataset
      -        synchronously, the caller waits until the projection is inserted into
      -        the Learning Orchestra storage mechanism.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_sync(dataset_name,
      -                                                       projection_name,
      -                                                       fields_to_insert,
      -                                                       pretty_response)
      -
      -        return response
      -
      -    def delete_dataset_attributes_async(self,
      -                                        dataset_name: str,
      -                                        projection_name: str,
      -                                        fields_to_delete: list,
      -                                        pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method delete a set of attributes into a dataset
      -        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -        dataset_name: Represents the dataset name.
      -        fields_to_delete: Represents the set of attributes to be inserted.
      -        This is list with all attributes.
      -
      -        return: A JSON object with error or warning messages. In case of
      -        success, it returns the projection metadata.
      -        """
      -        dataset_metadata = self.search_projections_content(dataset_name,
      -                                                           limit=1)
      -
      -        fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -            .get('fields')
      -        for field in fields_to_delete:
      -            fields_to_insert.remove(field)
      -
      -        response = self.insert_dataset_attributes_async(dataset_name,
      -                                                        projection_name,
      -                                                        fields_to_insert,
      -                                                        pretty_response)
      -
      -        return response
      -
      -    def search_all_projections(self, pretty_response: bool = False) \
      -            -> Union[dict, str]:
      -        """
      -        description: This method retrieves all projection metadata, it does not
      -        retrieve the projection content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -
      -        return: A list with all projections metadata stored in Learning
      -        Orchestra or an empty result.
      -        """
      -        cluster_url_projection = self.cluster_url
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def search_projections(self, projection_name: str,
      -                           pretty_response: bool = False) -> Union[dict, str]:
      -        """
      -        description:  This method is responsible for retrieving a specific
      -        projection.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
      -        error if there is no such projections.
      -        """
      -        pretty = pretty_response
      -
      -        response = self.search_projections_content(projection_name, limit=1,
      -                                                   pretty_response=pretty)
      -
      -        return response
      -
      -    def search_projections_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 dataset
      -        content.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        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.
      -        """
      -
      -        cluster_url_projection = self.cluster_url + "/" + projection_name + \
      -                                 "?query=" + str(query) + \
      -                                 "&limit=" + str(limit) + \
      -                                 "&skip=" + str(skip)
      -
      -        response = requests.get(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -    def delete_projections(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 synchronous because it is very fast,
      -        since the deletion is performed in background. If a projection was
      -        used by another task (Ex. histogram, pca, tuning and so forth),
      -        it cannot be deleted.
      -
      -        pretty_response: If true return indented string, else return dict.
      -        projection_name: Represents the projection name.
      -
      -        return: JSON object with an error message, a warning message or a
      -        correct delete message
      -        """
      -        cluster_url_projection = self.cluster_url + "/" + projection_name
      -
      -        response = requests.delete(cluster_url_projection)
      -
      -        return self.response_treat.treatment(response, pretty_response)
      -
      -

      Methods

      -
      -
      -def delete_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method delete a set of attributes into a dataset -asynchronously, the caller does not wait until the projections 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 projection was inserted.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields_to_delete: Represents the set of attributes to be inserted. -This is list with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def delete_dataset_attributes_async(self,
      -                                    dataset_name: str,
      -                                    projection_name: str,
      -                                    fields_to_delete: list,
      -                                    pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method delete a set of attributes into a dataset
      -    asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields_to_delete: Represents the set of attributes to be inserted.
      -    This is list with all attributes.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns the projection metadata.
      -    """
      -    dataset_metadata = self.search_projections_content(dataset_name,
      -                                                       limit=1)
      -
      -    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -        .get('fields')
      -    for field in fields_to_delete:
      -        fields_to_insert.remove(field)
      -
      -    response = self.insert_dataset_attributes_async(dataset_name,
      -                                                    projection_name,
      -                                                    fields_to_insert,
      -                                                    pretty_response)
      -
      -    return response
      -
      -
      -
      -def delete_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields_to_delete: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method delete a set of attributes on a dataset -synchronously, the caller waits until the projection is inserted into -the Learning Orchestra storage mechanism.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields_to_delete: Represents the set of attributes to be inserted. -This is list with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def delete_dataset_attributes_sync(self,
      -                                   dataset_name: str,
      -                                   projection_name: str,
      -                                   fields_to_delete: list,
      -                                   pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method delete a set of attributes on a dataset
      -    synchronously, the caller waits until the projection is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields_to_delete: Represents the set of attributes to be inserted.
      -    This is list with all attributes.
      -
      -    return: A JSON object with error or warning messages. In case of
      -    success, it returns the projection metadata.
      -    """
      -    dataset_metadata = self.search_projections_content(dataset_name,
      -                                                       limit=1)
      -
      -    fields_to_insert = dataset_metadata.get('result')[self.METADATA_INDEX] \
      -        .get('fields')
      -    for field in fields_to_delete:
      -        fields_to_insert.remove(field)
      -
      -    response = self.insert_dataset_attributes_sync(dataset_name,
      -                                                   projection_name,
      -                                                   fields_to_insert,
      -                                                   pretty_response)
      -
      -    return response
      -
      -
      -
      -def delete_projections(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 synchronous because it is very fast, -since the deletion is performed in background. If a projection was -used by another task (Ex. histogram, pca, tuning and so forth), -it cannot be deleted.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name.

      -

      return: JSON object with an error message, a warning message or a -correct delete message

      -
      - -Expand source code - -
      def delete_projections(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 synchronous because it is very fast,
      -    since the deletion is performed in background. If a projection was
      -    used by another task (Ex. histogram, pca, tuning and so forth),
      -    it cannot be deleted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -
      -    return: JSON object with an error message, a warning message or a
      -    correct delete message
      -    """
      -    cluster_url_projection = self.cluster_url + "/" + projection_name
      -
      -    response = requests.delete(cluster_url_projection)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def insert_dataset_attributes_async(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method inserts a set of attributes into a dataset -asynchronously, the caller does not wait until the projections 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 projection was inserted.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields: Represents the set of attributes to be inserted. This is list -with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def insert_dataset_attributes_async(self,
      -                                    dataset_name: str,
      -                                    projection_name: str,
      -                                    fields: list,
      -                                    pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method inserts a set of attributes into a dataset
      -    asynchronously, the caller does not wait until the projections 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 projection was inserted.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields: Represents the set of attributes to be inserted. This is list
      -    with all 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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PROJECTION FROM "
      -            + dataset_name
      -            + " TO "
      -            + projection_name
      -            + " ----------"
      -        )
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def insert_dataset_attributes_sync(self, dataset_name: str, projection_name: str, fields: list, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: This method inserts a set of attributes into a dataset -synchronously, the caller waits until the projection is inserted into -the Learning Orchestra storage mechanism.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection name. -dataset_name: Represents the dataset name. -fields: Represents the set of attributes to be inserted. This is list -with all attributes.

      -

      return: A JSON object with error or warning messages. In case of -success, it returns the projection metadata.

      -
      - -Expand source code - -
      def insert_dataset_attributes_sync(self,
      -                                   dataset_name: str,
      -                                   projection_name: str,
      -                                   fields: list,
      -                                   pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method inserts a set of attributes into a dataset
      -    synchronously, the caller waits until the projection is inserted into
      -    the Learning Orchestra storage mechanism.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection name.
      -    dataset_name: Represents the dataset name.
      -    fields: Represents the set of attributes to be inserted. This is list
      -    with all 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.cluster_url
      -
      -    response = requests.post(url=request_url, json=request_body)
      -
      -    Observer(projection_name, self.CLUSTER_IP).observe_processing(
      -        pretty_response)
      -
      -    if pretty_response:
      -        print(
      -            "\n----------"
      -            + " CREATE PROJECTION FROM "
      -            + dataset_name
      -            + " TO "
      -            + projection_name
      -            + " ----------"
      -        )
      -
      -    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, it does not -retrieve the projection content.

      -

      pretty_response: If true return indented string, else return dict.

      -

      return: A list with all projections metadata stored in Learning -Orchestra or an empty result.

      -
      - -Expand source code - -
      def search_all_projections(self, pretty_response: bool = False) \
      -        -> Union[dict, str]:
      -    """
      -    description: This method retrieves all projection metadata, it does not
      -    retrieve the projection content.
      -
      -    pretty_response: If true return indented string, else return dict.
      -
      -    return: A list with all projections metadata stored in Learning
      -    Orchestra or an empty result.
      -    """
      -    cluster_url_projection = self.cluster_url
      -
      -    response = requests.get(cluster_url_projection)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -def search_projections(self, projection_name: str, pretty_response: bool = False) ‑> Union[dict, str] -
      -
      -

      description: -This method is responsible for retrieving a specific -projection.

      -

      pretty_response: If true return indented string, else return dict. -projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an -error if there is no such projections.

      -
      - -Expand source code - -
      def search_projections(self, projection_name: str,
      -                       pretty_response: bool = False) -> Union[dict, str]:
      -    """
      -    description:  This method is responsible for retrieving a specific
      -    projection.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    projection_name: Represents the projection 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 projection metadata stored in Learning Orchestra or an
      -    error if there is no such projections.
      -    """
      -    pretty = pretty_response
      -
      -    response = self.search_projections_content(projection_name, limit=1,
      -                                               pretty_response=pretty)
      -
      -    return response
      -
      -
      -
      -def search_projections_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 dataset -content.

      -

      pretty_response: If true return indented string, else return dict. -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.

      -
      - -Expand source code - -
      def search_projections_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 dataset
      -    content.
      -
      -    pretty_response: If true return indented string, else return dict.
      -    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.
      -    """
      -
      -    cluster_url_projection = self.cluster_url + "/" + projection_name + \
      -                             "?query=" + str(query) + \
      -                             "&limit=" + str(limit) + \
      -                             "&skip=" + str(skip)
      -
      -    response = requests.get(cluster_url_projection)
      -
      -    return self.response_treat.treatment(response, pretty_response)
      -
      -
      -
      -
      -
      -
      -
      - -
      - - - \ No newline at end of file From 06a742d39ce6163431088e025e5ce39513ffddbb Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sat, 10 Apr 2021 08:42:56 -0300 Subject: [PATCH 14/28] update docs --- .gitignore | 1 - docs/index.html | 159 ++++ docs/learning_orchestra_client.html | 61 ++ .../_entity_reader.html | 212 +++++ .../_response_treat.html | 244 +++++ docs/learning_orchestra_client/builder.html | 859 ++++++++++++++++++ docs/learning_orchestra_client/dataset.html | 51 ++ .../dataset/_dataset.html | 679 ++++++++++++++ .../dataset/csv.html | 129 +++ .../dataset/generic.html | 129 +++ docs/learning_orchestra_client/evaluate.html | 51 ++ .../evaluate/_evaluate.html | 730 +++++++++++++++ .../evaluate/scikitlearn.html | 141 +++ .../evaluate/tensorflow.html | 141 +++ docs/learning_orchestra_client/explore.html | 50 + .../explore/histogram.html | 693 ++++++++++++++ docs/learning_orchestra_client/function.html | 50 + .../function/python.html | 700 ++++++++++++++ docs/learning_orchestra_client/model.html | 51 ++ .../model/_model.html | 711 +++++++++++++++ .../model/scikitlearn.html | 131 +++ .../model/tensorflow.html | 131 +++ docs/learning_orchestra_client/observer.html | 350 +++++++ docs/learning_orchestra_client/predict.html | 51 ++ .../predict/_predict.html | 738 +++++++++++++++ .../predict/scikitlearn.html | 141 +++ .../predict/tensorflow.html | 141 +++ docs/learning_orchestra_client/train.html | 51 ++ .../train/_train.html | 738 +++++++++++++++ .../train/scikitlearn.html | 141 +++ .../train/tensorflow.html | 141 +++ docs/learning_orchestra_client/transform.html | 51 ++ .../transform/data_type.html | 376 ++++++++ .../transform/projection.html | 734 +++++++++++++++ 34 files changed, 9756 insertions(+), 1 deletion(-) create mode 100644 docs/index.html create mode 100644 docs/learning_orchestra_client.html create mode 100644 docs/learning_orchestra_client/_entity_reader.html create mode 100644 docs/learning_orchestra_client/_response_treat.html create mode 100644 docs/learning_orchestra_client/builder.html create mode 100644 docs/learning_orchestra_client/dataset.html create mode 100644 docs/learning_orchestra_client/dataset/_dataset.html create mode 100644 docs/learning_orchestra_client/dataset/csv.html create mode 100644 docs/learning_orchestra_client/dataset/generic.html create mode 100644 docs/learning_orchestra_client/evaluate.html create mode 100644 docs/learning_orchestra_client/evaluate/_evaluate.html create mode 100644 docs/learning_orchestra_client/evaluate/scikitlearn.html create mode 100644 docs/learning_orchestra_client/evaluate/tensorflow.html create mode 100644 docs/learning_orchestra_client/explore.html create mode 100644 docs/learning_orchestra_client/explore/histogram.html create mode 100644 docs/learning_orchestra_client/function.html create mode 100644 docs/learning_orchestra_client/function/python.html create mode 100644 docs/learning_orchestra_client/model.html create mode 100644 docs/learning_orchestra_client/model/_model.html create mode 100644 docs/learning_orchestra_client/model/scikitlearn.html create mode 100644 docs/learning_orchestra_client/model/tensorflow.html create mode 100644 docs/learning_orchestra_client/observer.html create mode 100644 docs/learning_orchestra_client/predict.html create mode 100644 docs/learning_orchestra_client/predict/_predict.html create mode 100644 docs/learning_orchestra_client/predict/scikitlearn.html create mode 100644 docs/learning_orchestra_client/predict/tensorflow.html create mode 100644 docs/learning_orchestra_client/train.html create mode 100644 docs/learning_orchestra_client/train/_train.html create mode 100644 docs/learning_orchestra_client/train/scikitlearn.html create mode 100644 docs/learning_orchestra_client/train/tensorflow.html create mode 100644 docs/learning_orchestra_client/transform.html create mode 100644 docs/learning_orchestra_client/transform/data_type.html create mode 100644 docs/learning_orchestra_client/transform/projection.html 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/docs/index.html b/docs/index.html new file mode 100644 index 0000000..86cca31 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,159 @@ + + + + + + + module list – pdoc 6.4.2 + + + + + + + +
      + + +
      Available Modules
      + + +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client.html b/docs/learning_orchestra_client.html new file mode 100644 index 0000000..742f7e4 --- /dev/null +++ b/docs/learning_orchestra_client.html @@ -0,0 +1,61 @@ + + + + + + + learning_orchestra_client API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client

      + + + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/_entity_reader.html b/docs/learning_orchestra_client/_entity_reader.html new file mode 100644 index 0000000..7e8a2ed --- /dev/null +++ b/docs/learning_orchestra_client/_entity_reader.html @@ -0,0 +1,212 @@ + + + + + + + learning_orchestra_client._entity_reader API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client._entity_reader

      + + +
      + View Source +
      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
      +
      + +
      + +
      +
      +
      + #   + + + class + EntityReader: +
      + +
      + View Source +
      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
      +
      + +
      + + + +
      +
      #   + + + EntityReader(entity_url: str) +
      + +
      + View Source +
          def __init__(self, entity_url: str):
      +        self.__response_treat = ResponseTreat()
      +        self.__entity_url = entity_url
      +
      + +
      + + + +
      +
      +
      #   + + + def + read_all_instances_from_entity(self) -> requests.models.Response: +
      + +
      + View Source +
          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 +) -> requests.models.Response: +
      + +
      + View Source +
          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
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/_response_treat.html b/docs/learning_orchestra_client/_response_treat.html new file mode 100644 index 0000000..674397a --- /dev/null +++ b/docs/learning_orchestra_client/_response_treat.html @@ -0,0 +1,244 @@ + + + + + + + learning_orchestra_client._response_treat API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client._response_treat

      + + +
      + View Source +
      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: +
      + +
      + View Source +
      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()
      +
      + +
      + + + +
      +
      #   + + + ResponseTreat() +
      + + + + +
      +
      +
      #   + + HTTP_CREATED = 201 +
      + + + +
      +
      +
      #   + + HTTP_SUCCESS = 200 +
      + + + +
      +
      +
      #   + + HTTP_ERROR = 500 +
      + + + +
      +
      +
      #   + + + def + treatment( + self, + response: requests.models.Response, + pretty_response: bool = True +) -> Union[dict, str]: +
      + +
      + View Source +
          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.

      +
      + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/builder.html b/docs/learning_orchestra_client/builder.html new file mode 100644 index 0000000..636bdfd --- /dev/null +++ b/docs/learning_orchestra_client/builder.html @@ -0,0 +1,859 @@ + + + + + + + learning_orchestra_client.builder API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.builder

      + + +
      + View Source +
      from .observer import Observer
      +from ._response_treat import ResponseTreat
      +from ._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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        synchronously, the caller waits until the model predictions are inserted
      +        into the Learning Orchestra storage mechanism.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +
      +        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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        asynchronously, the caller does not wait until the model predictions are
      +        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 model predictions are inserted.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +
      +        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 return indented string, else return dict.
      +
      +        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 return indented string, else return dict.
      +        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 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(
      +            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 prediction 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 synchronous because it is very fast,
      +        since the deletion is performed in background.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        builder_name: Represents the projection 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) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + +
      +
      +
      + #   + + + class + BuilderSparkMl: +
      + +
      + View Source +
      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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        synchronously, the caller waits until the model predictions are inserted
      +        into the Learning Orchestra storage mechanism.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +
      +        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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        asynchronously, the caller does not wait until the model predictions are
      +        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 model predictions are inserted.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +
      +        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 return indented string, else return dict.
      +
      +        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 return indented string, else return dict.
      +        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 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(
      +            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 prediction 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 synchronous because it is very fast,
      +        since the deletion is performed in background.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        builder_name: Represents the projection 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) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + + + +
      +
      #   + + + BuilderSparkMl(cluster_ip: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        synchronously, the caller waits until the model predictions are inserted
      +        into the Learning Orchestra storage mechanism.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +
      +        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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +synchronously, the caller waits until the model predictions are inserted +into the Learning Orchestra storage mechanism.

      + +

      train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

      + +

      return: The resulted predictions URIs.

      +
      + + +
      +
      +
      #   + + + 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]: +
      + +
      + View Source +
          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 resource join several steps of machine
      +        learning workflow (transform, tune, train and evaluate) coupling in
      +        a unique resource, builder creates several model predictions using
      +        your own modeling code using a defined set of classifiers. This is made
      +        asynchronously, the caller does not wait until the model predictions are
      +        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 model predictions are inserted.
      +
      +        train_dataset_name: Represent final train dataset.
      +        test_dataset_name: Represent final test dataset.
      +        modeling_code: Represent Python3 code for pyspark preprocessing model
      +        model_classifiers: list of initial classifiers to be used in model
      +        pretty_response: returns indented string for visualization if True
      +
      +        return: The resulted predictions URIs.
      +        """
      +
      +        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 resource join several steps of machine +learning workflow (transform, tune, train and evaluate) coupling in +a unique resource, builder creates several model predictions using +your own modeling code using a defined set of classifiers. This is made +asynchronously, the caller does not wait until the model predictions are +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 model predictions are inserted.

      + +

      train_dataset_name: Represent final train dataset. +test_dataset_name: Represent final test dataset. +modeling_code: Represent Python3 code for pyspark preprocessing model +model_classifiers: list of initial classifiers to be used in model +pretty_response: returns indented string for visualization if True

      + +

      return: The resulted predictions URIs.

      +
      + + +
      +
      +
      #   + + + def + search_all_builders(self, pretty_response: bool = False) -> Union[dict, str]: +
      + +
      + View Source +
          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 return indented string, else return dict.
      +
      +        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 return indented string, else return dict.

      + +

      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]: +
      + +
      + View Source +
          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 return indented string, else return dict.
      +        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 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(
      +            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 return indented string, else return dict. +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 there +is no such projection. 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]: +
      + +
      + View Source +
          def search_builder(self, builder_name: str, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description:  This method is responsible for retrieving a specific
      +        model prediction 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 prediction 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]: +
      + +
      + View Source +
          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 synchronous because it is very fast,
      +        since the deletion is performed in background.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        builder_name: Represents the projection 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 synchronous because it is very fast, +since the deletion is performed in background.

      + +

      pretty_response: If true return indented string, else return dict. +builder_name: Represents the projection name.

      + +

      return: JSON object with an error message, a warning message or a +correct delete message

      +
      + + +
      +
      +
      #   + + + def + wait(self, dataset_name: str) -> dict: +
      + +
      + View Source +
          def wait(self, dataset_name: str) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/dataset.html b/docs/learning_orchestra_client/dataset.html new file mode 100644 index 0000000..fd8fac6 --- /dev/null +++ b/docs/learning_orchestra_client/dataset.html @@ -0,0 +1,51 @@ + + + + + + + learning_orchestra_client.dataset API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.dataset

      + + + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/dataset/_dataset.html b/docs/learning_orchestra_client/dataset/_dataset.html new file mode 100644 index 0000000..7fb1c63 --- /dev/null +++ b/docs/learning_orchestra_client/dataset/_dataset.html @@ -0,0 +1,679 @@ + + + + + + + learning_orchestra_client.dataset._dataset API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.dataset._dataset

      + + +
      + View Source +
      from ..observer import Observer
      +from .._response_treat import ResponseTreat
      +from .._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 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.
      +        """
      +        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).
      +        """
      +        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 return indented string, else return dict.
      +
      +        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_async(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 return indented string, else return dict.
      +        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 return indented string, else return dict.
      +        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) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + +
      +
      +
      + #   + + + class + Dataset: +
      + +
      + View Source +
      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 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.
      +        """
      +        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).
      +        """
      +        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 return indented string, else return dict.
      +
      +        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_async(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 return indented string, else return dict.
      +        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 return indented string, else return dict.
      +        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) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + + + +
      +
      #   + + + Dataset(cluster_ip: str, api_path: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          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 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.
      +        """
      +        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 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.

      +
      + + +
      +
      +
      #   + + + def + insert_dataset_async( + self, + dataset_name: str, + url: str, + pretty_response: bool = False +) -> Union[dict, str]: +
      + +
      + View Source +
          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).
      +        """
      +        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).

      +
      + + +
      +
      +
      #   + + + def + search_all_datasets(self, pretty_response: bool = False) -> Union[dict, str]: +
      + +
      + View Source +
          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 return indented string, else return dict.
      +
      +        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 return indented string, else return dict.

      + +

      return: All datasets metadata stored in Learning Orchestra or an empty +result.

      +
      + + +
      +
      +
      #   + + + def + delete_dataset_async(self, dataset_name, pretty_response=False) -> Union[dict, str]: +
      + +
      + View Source +
          def delete_dataset_async(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 return indented string, else return dict.
      +        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 return indented string, else return dict. +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]: +
      + +
      + View Source +
          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 return indented string, else return dict.
      +        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 return indented string, else return dict. +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) -> dict: +
      + +
      + View Source +
          def wait(self, dataset_name: str) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/dataset/csv.html b/docs/learning_orchestra_client/dataset/csv.html new file mode 100644 index 0000000..2322d71 --- /dev/null +++ b/docs/learning_orchestra_client/dataset/csv.html @@ -0,0 +1,129 @@ + + + + + + + learning_orchestra_client.dataset.csv API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.dataset.csv

      + + +
      + View Source +
      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)
      +
      + +
      + +
      +
      + + +
      + View Source +
      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)
      +
      + +
      + + + +
      +
      #   + + + DatasetCsv(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/dataset/generic.html b/docs/learning_orchestra_client/dataset/generic.html new file mode 100644 index 0000000..3c7769e --- /dev/null +++ b/docs/learning_orchestra_client/dataset/generic.html @@ -0,0 +1,129 @@ + + + + + + + learning_orchestra_client.dataset.generic API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.dataset.generic

      + + +
      + View Source +
      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(learning_orchestra_client.dataset._dataset.Dataset): +
      + +
      + View Source +
      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)
      +
      + +
      + + + +
      +
      #   + + + DatasetGeneric(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/evaluate.html b/docs/learning_orchestra_client/evaluate.html new file mode 100644 index 0000000..5599afc --- /dev/null +++ b/docs/learning_orchestra_client/evaluate.html @@ -0,0 +1,51 @@ + + + + + + + learning_orchestra_client.evaluate API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.evaluate

      + + + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/evaluate/_evaluate.html b/docs/learning_orchestra_client/evaluate/_evaluate.html new file mode 100644 index 0000000..ace57f1 --- /dev/null +++ b/docs/learning_orchestra_client/evaluate/_evaluate.html @@ -0,0 +1,730 @@ + + + + + + + learning_orchestra_client.evaluate._evaluate API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.evaluate._evaluate

      + + +
      + View Source +
      from ..observer import Observer
      +from .._response_treat import ResponseTreat
      +from .._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 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.
      +        """
      +        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: his method runs an evaluation about a model in async mode
      +
      +        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.
      +        """
      +        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 return indented string, else return dict.
      +
      +        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_async(self, name: str, pretty_response=False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for deleting an evaluation.
      +        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 return indented string, else return dict.
      +        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}/{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 return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + +
      +
      +
      + #   + + + class + Evaluate: +
      + +
      + View Source +
      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 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.
      +        """
      +        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: his method runs an evaluation about a model in async mode
      +
      +        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.
      +        """
      +        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 return indented string, else return dict.
      +
      +        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_async(self, name: str, pretty_response=False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for deleting an evaluation.
      +        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 return indented string, else return dict.
      +        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}/{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 return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + + + +
      +
      #   + + + Evaluate(cluster_ip: str, api_path: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          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 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.
      +        """
      +        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 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.

      +
      + + +
      +
      +
      #   + + + 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]: +
      + +
      + View Source +
          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: his method runs an evaluation about a model in async mode
      +
      +        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.
      +        """
      +        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: his method runs an evaluation about a model in async mode

      + +

      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.

      +
      + + +
      +
      +
      #   + + + def + search_all_evaluates(self, pretty_response: bool = False) -> Union[dict, str]: +
      + +
      + View Source +
          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 return indented string, else return dict.
      +
      +        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 return indented string, else return dict.

      + +

      return: All datasets metadata stored in Learning Orchestra or an empty +result.

      +
      + + +
      +
      +
      #   + + + def + delete_evaluate_async(self, name: str, pretty_response=False) -> Union[dict, str]: +
      + +
      + View Source +
          def delete_evaluate_async(self, name: str, pretty_response=False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for deleting an evaluation.
      +        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 return indented string, else return dict.
      +        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}/{name}'
      +
      +        response = requests.delete(request_url)
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      + +
      + +

      description: This method is responsible for deleting an evaluation. +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 return indented string, else return dict. +dataset_name: Represents the dataset 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]: +
      + +
      + View Source +
          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 return indented string, else return dict.
      +        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(
      +            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 return indented string, else return dict. +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, name: str) -> dict: +
      + +
      + View Source +
          def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/evaluate/scikitlearn.html b/docs/learning_orchestra_client/evaluate/scikitlearn.html new file mode 100644 index 0000000..d17f8ef --- /dev/null +++ b/docs/learning_orchestra_client/evaluate/scikitlearn.html @@ -0,0 +1,141 @@ + + + + + + + learning_orchestra_client.evaluate.scikitlearn API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.evaluate.scikitlearn

      + + +
      + View Source +
      from ._evaluate import Evaluate
      +
      +
      +class EvaluateScikitLearn(Evaluate):
      +    __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/evaluate/scikitlearn"
      +        self.__cluster_ip = cluster_ip
      +        super().__init__(cluster_ip, self.__api_path)
      +
      + +
      + +
      +
      +
      + #   + + + class + EvaluateScikitLearn(learning_orchestra_client.evaluate._evaluate.Evaluate): +
      + +
      + View Source +
      class EvaluateScikitLearn(Evaluate):
      +    __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/evaluate/scikitlearn"
      +        self.__cluster_ip = cluster_ip
      +        super().__init__(cluster_ip, self.__api_path)
      +
      + +
      + + + +
      +
      #   + + + EvaluateScikitLearn(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/evaluate/tensorflow.html b/docs/learning_orchestra_client/evaluate/tensorflow.html new file mode 100644 index 0000000..a274912 --- /dev/null +++ b/docs/learning_orchestra_client/evaluate/tensorflow.html @@ -0,0 +1,141 @@ + + + + + + + learning_orchestra_client.evaluate.tensorflow API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.evaluate.tensorflow

      + + +
      + View Source +
      from ._evaluate import Evaluate
      +
      +
      +class EvaluateTensorflow(Evaluate):
      +    __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/evaluate/tensorflow"
      +        self.__cluster_ip = cluster_ip
      +        super().__init__(cluster_ip, self.__api_path)
      +
      + +
      + +
      +
      +
      + #   + + + class + EvaluateTensorflow(learning_orchestra_client.evaluate._evaluate.Evaluate): +
      + +
      + View Source +
      class EvaluateTensorflow(Evaluate):
      +    __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/evaluate/tensorflow"
      +        self.__cluster_ip = cluster_ip
      +        super().__init__(cluster_ip, self.__api_path)
      +
      + +
      + + + +
      +
      #   + + + EvaluateTensorflow(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/explore.html b/docs/learning_orchestra_client/explore.html new file mode 100644 index 0000000..bfa5cad --- /dev/null +++ b/docs/learning_orchestra_client/explore.html @@ -0,0 +1,50 @@ + + + + + + + learning_orchestra_client.explore API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.explore

      + + + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/explore/histogram.html b/docs/learning_orchestra_client/explore/histogram.html new file mode 100644 index 0000000..0c2abda --- /dev/null +++ b/docs/learning_orchestra_client/explore/histogram.html @@ -0,0 +1,693 @@ + + + + + + + learning_orchestra_client.explore.histogram API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.explore.histogram

      + + +
      + View Source +
      from ..observer import Observer
      +from .._response_treat import ResponseTreat
      +import requests
      +from typing import Union
      +from .._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 run histogram algorithm to create a histogram
      +        synchronously, 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 return indented string, else return dict.
      +
      +        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 run histogram algorithm to create a histogram
      +        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      +
      +        dataset_name: Represents the name of dataset.
      +        histogram_name: Represents the name of histogram.
      +        fields: Represents a list of attributes.
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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 names, it does not
      +        retrieve the histogram content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        return: A list with all histogram names 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 return indented string, else return dict.
      +        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 synchronous because it is very fast,
      +        since the deletion is performed in background.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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)
      +
      + +
      + +
      +
      +
      + #   + + + class + ExploreHistogram: +
      + +
      + View Source +
      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 run histogram algorithm to create a histogram
      +        synchronously, 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 return indented string, else return dict.
      +
      +        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 run histogram algorithm to create a histogram
      +        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      +
      +        dataset_name: Represents the name of dataset.
      +        histogram_name: Represents the name of histogram.
      +        fields: Represents a list of attributes.
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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 names, it does not
      +        retrieve the histogram content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        return: A list with all histogram names 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 return indented string, else return dict.
      +        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 synchronous because it is very fast,
      +        since the deletion is performed in background.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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)
      +
      + +
      + + + +
      +
      #   + + + ExploreHistogram(cluster_ip: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          def run_histogram_sync(self,
      +                           dataset_name: str,
      +                           histogram_name: str,
      +                           fields: list,
      +                           pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method run histogram algorithm to create a histogram
      +        synchronously, 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 return indented string, else return dict.
      +
      +        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 run histogram algorithm to create a histogram +synchronously, 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 return indented string, else return dict.

      + +

      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]: +
      + +
      + View Source +
          def run_histogram_async(self,
      +                            dataset_name: str,
      +                            histogram_name: str,
      +                            fields: list,
      +                            pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method run histogram algorithm to create a histogram
      +        asynchronously, the caller does not wait until the histogram 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 histogram was inserted.
      +
      +        dataset_name: Represents the name of dataset.
      +        histogram_name: Represents the name of histogram.
      +        fields: Represents a list of attributes.
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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 run histogram algorithm to create a histogram +asynchronously, the caller does not wait until the histogram 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 histogram was inserted.

      + +

      dataset_name: Represents the name of dataset. +histogram_name: Represents the name of histogram. +fields: Represents a list of attributes. +pretty_response: If true return indented string, else return dict.

      + +

      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]: +
      + +
      + View Source +
          def search_all_histograms(self, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method retrieves all histogram names, it does not
      +        retrieve the histogram content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        return: A list with all histogram names 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 names, it does not +retrieve the histogram content.

      + +

      pretty_response: If true return indented string, else return dict.

      + +

      return: A list with all histogram names 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]: +
      + +
      + View Source +
          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 return indented string, else return dict.
      +        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 return indented string, else return dict. +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]: +
      + +
      + View Source +
          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 synchronous because it is very fast,
      +        since the deletion is performed in background.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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 synchronous because it is very fast, +since the deletion is performed in background.

      + +

      pretty_response: If true return indented string, else return dict. +histogram_name: Represents the histogram name.

      + +

      return: JSON object with an error message, a warning message or a +correct delete message

      +
      + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/function.html b/docs/learning_orchestra_client/function.html new file mode 100644 index 0000000..6af745e --- /dev/null +++ b/docs/learning_orchestra_client/function.html @@ -0,0 +1,50 @@ + + + + + + + learning_orchestra_client.function API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.function

      + + + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/function/python.html b/docs/learning_orchestra_client/function/python.html new file mode 100644 index 0000000..a3ce896 --- /dev/null +++ b/docs/learning_orchestra_client/function/python.html @@ -0,0 +1,700 @@ + + + + + + + learning_orchestra_client.function.python API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.function.python

      + + +
      + View Source +
      from ..observer import Observer
      +from .._response_treat import ResponseTreat
      +from .._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, being able to use
      +        created results of some service.
      +        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.
      +        """
      +        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,
      +        being able to use created results of some service.
      +
      +        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).
      +        """
      +        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 return indented string, else return dict.
      +
      +        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_execution_async(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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{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 metadata function
      +        content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, dataset_name: str) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + +
      +
      +
      + #   + + + class + FunctionPython: +
      + +
      + View Source +
      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, being able to use
      +        created results of some service.
      +        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.
      +        """
      +        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,
      +        being able to use created results of some service.
      +
      +        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).
      +        """
      +        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 return indented string, else return dict.
      +
      +        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_execution_async(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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{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 metadata function
      +        content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, dataset_name: str) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + + + +
      +
      #   + + + FunctionPython(cluster_ip: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          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, being able to use
      +        created results of some service.
      +        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.
      +        """
      +        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, being able to use +created results of some service. +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.

      +
      + + +
      +
      +
      #   + + + def + run_function_async( + self, + name: str, + parameters: dict, + code: str, + description: str = '', + pretty_response: bool = False +) -> Union[dict, str]: +
      + +
      + View Source +
          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,
      +        being able to use created results of some service.
      +
      +        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).
      +        """
      +        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, +being able to use created results of some service.

      + +

      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).

      +
      + + +
      +
      +
      #   + + + def + search_all_executions(self, pretty_response: bool = False) -> Union[dict, str]: +
      + +
      + View Source +
          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 return indented string, else return dict.
      +
      +        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 functions metadata, i.e., it does +not retrieve the function result content.

      + +

      pretty_response: If true return indented string, else return dict.

      + +

      return: All datasets metadata stored in Learning Orchestra or an empty +result.

      +
      + + +
      +
      +
      #   + + + def + delete_execution_async(self, name: str, pretty_response=False) -> Union[dict, str]: +
      + +
      + View Source +
          def delete_execution_async(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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{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. If a + dataset was used by another task (Ex. projection, histogram, pca, tune + and so forth), it cannot be deleted.

      + +

      pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset 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]: +
      + +
      + View Source +
          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 metadata function
      +        content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      + +
      + +

      description: This method is responsible for retrieving the metadata function +content

      + +

      pretty_response: If true return indented string, else return dict. +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) -> dict: +
      + +
      + View Source +
          def wait(self, dataset_name: str) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/model.html b/docs/learning_orchestra_client/model.html new file mode 100644 index 0000000..2f092f2 --- /dev/null +++ b/docs/learning_orchestra_client/model.html @@ -0,0 +1,51 @@ + + + + + + + learning_orchestra_client.model API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.model

      + + + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/model/_model.html b/docs/learning_orchestra_client/model/_model.html new file mode 100644 index 0000000..fd231b6 --- /dev/null +++ b/docs/learning_orchestra_client/model/_model.html @@ -0,0 +1,711 @@ + + + + + + + learning_orchestra_client.model._model API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.model._model

      + + +
      + View Source +
      from ..observer import Observer
      +from .._response_treat import ResponseTreat
      +from .._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 is responsible to create a model in sync mode.
      +
      +        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.
      +        """
      +        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 is responsible to create a model in async mode.
      +
      +        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.
      +        """
      +        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 metadata model content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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_model_async(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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{name}'
      +
      +        response = requests.delete(request_url)
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def search_model_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 model metadata
      +        content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + +
      +
      +
      + #   + + + class + Model: +
      + +
      + View Source +
      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 is responsible to create a model in sync mode.
      +
      +        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.
      +        """
      +        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 is responsible to create a model in async mode.
      +
      +        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.
      +        """
      +        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 metadata model content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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_model_async(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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{name}'
      +
      +        response = requests.delete(request_url)
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def search_model_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 model metadata
      +        content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + + + +
      +
      #   + + + Model(cluster_ip: str, api_path: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          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 is responsible to create a model in sync mode.
      +
      +        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.
      +        """
      +        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 is responsible to create a model in sync mode.

      + +

      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.

      +
      + + +
      +
      +
      #   + + + 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]: +
      + +
      + View Source +
          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 is responsible to create a model in async mode.
      +
      +        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.
      +        """
      +        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 is responsible to create a model in async mode.

      + +

      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.

      +
      + + +
      +
      +
      #   + + + def + search_all_models(self, pretty_response: bool = False) -> Union[dict, str]: +
      + +
      + View Source +
          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 metadata model content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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 models metadata, i.e., it does +not retrieve the metadata model content.

      + +

      pretty_response: If true return indented string, else return dict.

      + +

      return: All datasets metadata stored in Learning Orchestra or an empty +result.

      +
      + + +
      +
      +
      #   + + + def + delete_model_async(self, name: str, pretty_response=False) -> Union[dict, str]: +
      + +
      + View Source +
          def delete_model_async(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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{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. If a + dataset was used by another task (Ex. projection, histogram, pca, tune + and so forth), it cannot be deleted.

      + +

      pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset name.

      + +

      return: JSON object with an error message, a warning message or a +correct delete message

      +
      + + +
      +
      +
      #   + + + def + search_model_content( + self, + name: str, + query: dict = {}, + limit: int = 10, + skip: int = 0, + pretty_response: bool = False +) -> Union[dict, str]: +
      + +
      + View Source +
          def search_model_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 model metadata
      +        content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      + +
      + +

      description: This method is responsible for retrieving the model metadata +content

      + +

      pretty_response: If true return indented string, else return dict. +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, name: str) -> dict: +
      + +
      + View Source +
          def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/model/scikitlearn.html b/docs/learning_orchestra_client/model/scikitlearn.html new file mode 100644 index 0000000..2bac776 --- /dev/null +++ b/docs/learning_orchestra_client/model/scikitlearn.html @@ -0,0 +1,131 @@ + + + + + + + learning_orchestra_client.model.scikitlearn API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.model.scikitlearn

      + + +
      + View Source +
      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(learning_orchestra_client.model._model.Model): +
      + +
      + View Source +
      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)
      +
      + +
      + + + +
      +
      #   + + + ModelScikitLearn(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/model/tensorflow.html b/docs/learning_orchestra_client/model/tensorflow.html new file mode 100644 index 0000000..a4e3a31 --- /dev/null +++ b/docs/learning_orchestra_client/model/tensorflow.html @@ -0,0 +1,131 @@ + + + + + + + learning_orchestra_client.model.tensorflow API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.model.tensorflow

      + + +
      + View Source +
      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(learning_orchestra_client.model._model.Model): +
      + +
      + View Source +
      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)
      +
      + +
      + + + +
      +
      #   + + + ModelTensorflow(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/observer.html b/docs/learning_orchestra_client/observer.html new file mode 100644 index 0000000..5aea33a --- /dev/null +++ b/docs/learning_orchestra_client/observer.html @@ -0,0 +1,350 @@ + + + + + + + learning_orchestra_client.observer API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.observer

      + + +
      + View Source +
      from pymongo import MongoClient, change_stream
      +import logging
      +
      +
      +class Observer:
      +    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, dataset_name: str, pretty_response: bool = False) -> dict:
      +        """
      +        :description: Observe the finished processing status from some
      +        processing, blocking the code execution until finish processing.
      +
      +        :return: A dict with metadata file of used dataset name.
      +        """
      +
      +        dataset_collection = self.__database[dataset_name]
      +        metadata_query = {"_id": 0}
      +        dataset_metadata = dataset_collection.find_one(metadata_query)
      +
      +        if dataset_metadata is None:
      +            logging.warning("Dataset name or dataset URL invalid")
      +            return {}
      +
      +        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').next()['fullDocument']
      +
      +    def observe_storage(self, dataset_name: str) -> \
      +            change_stream.CollectionChangeStream:
      +        """
      +        :description: Get all changes from a dataset
      +
      +        :return: A pymongo CollectionChangeStream object, use the builtin
      +        next() method to iterate over changes.
      +        """
      +
      +        observer_query = [
      +            {'$match': {
      +                '$or': [
      +                    {'operationType': 'replace'},
      +                    {'operationType': 'insert'},
      +                    {'operationType': 'update'},
      +                    {'operationType': 'delete'}
      +
      +                ]
      +            }}
      +        ]
      +        return self.__database[dataset_name].watch(
      +            observer_query,
      +            full_document='updateLookup')
      +
      + +
      + +
      +
      +
      + #   + + + class + Observer: +
      + +
      + View Source +
      class Observer:
      +    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, dataset_name: str, pretty_response: bool = False) -> dict:
      +        """
      +        :description: Observe the finished processing status from some
      +        processing, blocking the code execution until finish processing.
      +
      +        :return: A dict with metadata file of used dataset name.
      +        """
      +
      +        dataset_collection = self.__database[dataset_name]
      +        metadata_query = {"_id": 0}
      +        dataset_metadata = dataset_collection.find_one(metadata_query)
      +
      +        if dataset_metadata is None:
      +            logging.warning("Dataset name or dataset URL invalid")
      +            return {}
      +
      +        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').next()['fullDocument']
      +
      +    def observe_storage(self, dataset_name: str) -> \
      +            change_stream.CollectionChangeStream:
      +        """
      +        :description: Get all changes from a dataset
      +
      +        :return: A pymongo CollectionChangeStream object, use the builtin
      +        next() method to iterate over changes.
      +        """
      +
      +        observer_query = [
      +            {'$match': {
      +                '$or': [
      +                    {'operationType': 'replace'},
      +                    {'operationType': 'insert'},
      +                    {'operationType': 'update'},
      +                    {'operationType': 'delete'}
      +
      +                ]
      +            }}
      +        ]
      +        return self.__database[dataset_name].watch(
      +            observer_query,
      +            full_document='updateLookup')
      +
      + +
      + + + +
      +
      #   + + + Observer(cluster_ip: str) +
      + +
      + View Source +
          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, dataset_name: str, pretty_response: bool = False) -> dict: +
      + +
      + View Source +
          def wait(self, dataset_name: str, pretty_response: bool = False) -> dict:
      +        """
      +        :description: Observe the finished processing status from some
      +        processing, blocking the code execution until finish processing.
      +
      +        :return: A dict with metadata file of used dataset name.
      +        """
      +
      +        dataset_collection = self.__database[dataset_name]
      +        metadata_query = {"_id": 0}
      +        dataset_metadata = dataset_collection.find_one(metadata_query)
      +
      +        if dataset_metadata is None:
      +            logging.warning("Dataset name or dataset URL invalid")
      +            return {}
      +
      +        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').next()['fullDocument']
      +
      + +
      + +

      :description: Observe the finished processing status from some +processing, blocking the code execution until finish processing.

      + +

      :return: A dict with metadata file of used dataset name.

      +
      + + +
      +
      +
      #   + + + def + observe_storage( + self, + dataset_name: str +) -> pymongo.change_stream.CollectionChangeStream: +
      + +
      + View Source +
          def observe_storage(self, dataset_name: str) -> \
      +            change_stream.CollectionChangeStream:
      +        """
      +        :description: Get all changes from a dataset
      +
      +        :return: A pymongo CollectionChangeStream object, use the builtin
      +        next() method to iterate over changes.
      +        """
      +
      +        observer_query = [
      +            {'$match': {
      +                '$or': [
      +                    {'operationType': 'replace'},
      +                    {'operationType': 'insert'},
      +                    {'operationType': 'update'},
      +                    {'operationType': 'delete'}
      +
      +                ]
      +            }}
      +        ]
      +        return self.__database[dataset_name].watch(
      +            observer_query,
      +            full_document='updateLookup')
      +
      + +
      + +

      :description: Get all changes from a dataset

      + +

      :return: A pymongo CollectionChangeStream object, use the builtin +next() method to iterate over changes.

      +
      + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/predict.html b/docs/learning_orchestra_client/predict.html new file mode 100644 index 0000000..8bc3b7e --- /dev/null +++ b/docs/learning_orchestra_client/predict.html @@ -0,0 +1,51 @@ + + + + + + + learning_orchestra_client.predict API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.predict

      + + + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/predict/_predict.html b/docs/learning_orchestra_client/predict/_predict.html new file mode 100644 index 0000000..fc51187 --- /dev/null +++ b/docs/learning_orchestra_client/predict/_predict.html @@ -0,0 +1,738 @@ + + + + + + + learning_orchestra_client.predict._predict API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.predict._predict

      + + +
      + View Source +
      from ..observer import Observer
      +from .._response_treat import ResponseTreat
      +from .._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 results in sync mode
      +        using a created model
      +
      +        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.
      +        """
      +        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 results in async mode
      +        using a created model
      +
      +        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.
      +        """
      +        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 metadata content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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_prediction_async(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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{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 the prediction
      +        metadata content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + +
      +
      +
      + #   + + + class + Predict: +
      + +
      + View Source +
      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 results in sync mode
      +        using a created model
      +
      +        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.
      +        """
      +        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 results in async mode
      +        using a created model
      +
      +        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.
      +        """
      +        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 metadata content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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_prediction_async(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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{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 the prediction
      +        metadata content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + + + +
      +
      #   + + + Predict(cluster_ip: str, api_path: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          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 results in sync mode
      +        using a created model
      +
      +        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.
      +        """
      +        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 results in sync mode +using a created model

      + +

      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.

      +
      + + +
      +
      +
      #   + + + 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]: +
      + +
      + View Source +
          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 results in async mode
      +        using a created model
      +
      +        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.
      +        """
      +        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 results in async mode +using a created model

      + +

      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.

      +
      + + +
      +
      +
      #   + + + def + search_all_predictions(self, pretty_response: bool = False) -> Union[dict, str]: +
      + +
      + View Source +
          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 metadata content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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 predictions metadata, i.e., it does +not retrieve the prediction metadata content.

      + +

      pretty_response: If true return indented string, else return dict.

      + +

      return: All datasets metadata stored in Learning Orchestra or an empty +result.

      +
      + + +
      +
      +
      #   + + + def + delete_prediction_async(self, name: str, pretty_response=False) -> Union[dict, str]: +
      + +
      + View Source +
          def delete_prediction_async(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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{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. If a + dataset was used by another task (Ex. projection, histogram, pca, tune + and so forth), it cannot be deleted.

      + +

      pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset 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]: +
      + +
      + View Source +
          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 the prediction
      +        metadata content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      + +
      + +

      description: This method is responsible for retrieving the prediction +metadata content

      + +

      pretty_response: If true return indented string, else return dict. +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, name: str) -> dict: +
      + +
      + View Source +
          def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/predict/scikitlearn.html b/docs/learning_orchestra_client/predict/scikitlearn.html new file mode 100644 index 0000000..d1d8aff --- /dev/null +++ b/docs/learning_orchestra_client/predict/scikitlearn.html @@ -0,0 +1,141 @@ + + + + + + + learning_orchestra_client.predict.scikitlearn API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.predict.scikitlearn

      + + +
      + View Source +
      from ._predict import Predict
      +
      +
      +class PredictScikitLearn(Predict):
      +    __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/predict/scikitlearn"
      +        self.__cluster_ip = cluster_ip
      +        super().__init__(cluster_ip, self.__api_path)
      +
      + +
      + +
      +
      +
      + #   + + + class + PredictScikitLearn(learning_orchestra_client.predict._predict.Predict): +
      + +
      + View Source +
      class PredictScikitLearn(Predict):
      +    __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/predict/scikitlearn"
      +        self.__cluster_ip = cluster_ip
      +        super().__init__(cluster_ip, self.__api_path)
      +
      + +
      + + + +
      +
      #   + + + PredictScikitLearn(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/predict/tensorflow.html b/docs/learning_orchestra_client/predict/tensorflow.html new file mode 100644 index 0000000..3f8f649 --- /dev/null +++ b/docs/learning_orchestra_client/predict/tensorflow.html @@ -0,0 +1,141 @@ + + + + + + + learning_orchestra_client.predict.tensorflow API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.predict.tensorflow

      + + +
      + View Source +
      from ._predict import Predict
      +
      +
      +class PredictTensorflow(Predict):
      +    __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/predict/tensorflow"
      +        self.__cluster_ip = cluster_ip
      +        super().__init__(cluster_ip, self.__api_path)
      +
      + +
      + +
      +
      +
      + #   + + + class + PredictTensorflow(learning_orchestra_client.predict._predict.Predict): +
      + +
      + View Source +
      class PredictTensorflow(Predict):
      +    __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/predict/tensorflow"
      +        self.__cluster_ip = cluster_ip
      +        super().__init__(cluster_ip, self.__api_path)
      +
      + +
      + + + +
      +
      #   + + + PredictTensorflow(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/train.html b/docs/learning_orchestra_client/train.html new file mode 100644 index 0000000..d67d98b --- /dev/null +++ b/docs/learning_orchestra_client/train.html @@ -0,0 +1,51 @@ + + + + + + + learning_orchestra_client.train API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.train

      + + + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/train/_train.html b/docs/learning_orchestra_client/train/_train.html new file mode 100644 index 0000000..ff4fe95 --- /dev/null +++ b/docs/learning_orchestra_client/train/_train.html @@ -0,0 +1,738 @@ + + + + + + + learning_orchestra_client.train._train API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.train._train

      + + +
      + View Source +
      from ..observer import Observer
      +from .._response_treat import ResponseTreat
      +from .._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 a created model in
      +        sync mode.
      +
      +        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.
      +        """
      +        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 a created model in
      +        async mode.
      +
      +        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.
      +        """
      +        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 trainings metadata, i.e., it does
      +        not retrieve the training metadata content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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_training_async(self, name: str, pretty_response=False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for deleting the trained 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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{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 the training
      +        metadata content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + +
      +
      +
      + #   + + + class + Train: +
      + +
      + View Source +
      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 a created model in
      +        sync mode.
      +
      +        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.
      +        """
      +        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 a created model in
      +        async mode.
      +
      +        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.
      +        """
      +        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 trainings metadata, i.e., it does
      +        not retrieve the training metadata content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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_training_async(self, name: str, pretty_response=False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for deleting the trained 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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{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 the training
      +        metadata content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      +    def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + + + +
      +
      #   + + + Train(cluster_ip: str, api_path: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          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 a created model in
      +        sync mode.
      +
      +        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.
      +        """
      +        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 a created model in +sync mode.

      + +

      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.

      +
      + + +
      +
      +
      #   + + + 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]: +
      + +
      + View Source +
          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 a created model in
      +        async mode.
      +
      +        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.
      +        """
      +        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 a created model in +async mode.

      + +

      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.

      +
      + + +
      +
      +
      #   + + + def + search_all_trainings(self, pretty_response: bool = False) -> Union[dict, str]: +
      + +
      + View Source +
          def search_all_trainings(self, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method retrieves all trainings metadata, i.e., it does
      +        not retrieve the training metadata content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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 trainings metadata, i.e., it does +not retrieve the training metadata content.

      + +

      pretty_response: If true return indented string, else return dict.

      + +

      return: All datasets metadata stored in Learning Orchestra or an empty +result.

      +
      + + +
      +
      +
      #   + + + def + delete_training_async(self, name: str, pretty_response=False) -> Union[dict, str]: +
      + +
      + View Source +
          def delete_training_async(self, name: str, pretty_response=False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method is responsible for deleting the trained 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. If a
      +         dataset was used by another task (Ex. projection, histogram, pca, tune
      +         and so forth), it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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}/{name}'
      +
      +        response = requests.delete(request_url)
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      + +
      + +

      description: This method is responsible for deleting the trained 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. If a + dataset was used by another task (Ex. projection, histogram, pca, tune + and so forth), it cannot be deleted.

      + +

      pretty_response: If true return indented string, else return dict. +dataset_name: Represents the dataset 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]: +
      + +
      + View Source +
          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 the training
      +        metadata content
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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(
      +            name, query, limit, skip)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      + +
      + +

      description: This method is responsible for retrieving the training +metadata content

      + +

      pretty_response: If true return indented string, else return dict. +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, name: str) -> dict: +
      + +
      + View Source +
          def wait(self, name: str) -> dict:
      +        return self.__observer.wait(name)
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/train/scikitlearn.html b/docs/learning_orchestra_client/train/scikitlearn.html new file mode 100644 index 0000000..1d7a6a4 --- /dev/null +++ b/docs/learning_orchestra_client/train/scikitlearn.html @@ -0,0 +1,141 @@ + + + + + + + learning_orchestra_client.train.scikitlearn API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.train.scikitlearn

      + + +
      + View Source +
      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(learning_orchestra_client.train._train.Train): +
      + +
      + View Source +
      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)
      +
      + +
      + + + +
      +
      #   + + + TrainScikitLearn(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/train/tensorflow.html b/docs/learning_orchestra_client/train/tensorflow.html new file mode 100644 index 0000000..fe79f9e --- /dev/null +++ b/docs/learning_orchestra_client/train/tensorflow.html @@ -0,0 +1,141 @@ + + + + + + + learning_orchestra_client.train.tensorflow API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.train.tensorflow

      + + +
      + View Source +
      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(learning_orchestra_client.train._train.Train): +
      + +
      + View Source +
      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)
      +
      + +
      + + + +
      +
      #   + + + TrainTensorflow(cluster_ip: str) +
      + +
      + View Source +
          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)
      +
      + +
      + + + +
      + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/transform.html b/docs/learning_orchestra_client/transform.html new file mode 100644 index 0000000..ae9436e --- /dev/null +++ b/docs/learning_orchestra_client/transform.html @@ -0,0 +1,51 @@ + + + + + + + learning_orchestra_client.transform API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.transform

      + + + +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/transform/data_type.html b/docs/learning_orchestra_client/transform/data_type.html new file mode 100644 index 0000000..e1381b9 --- /dev/null +++ b/docs/learning_orchestra_client/transform/data_type.html @@ -0,0 +1,376 @@ + + + + + + + learning_orchestra_client.transform.data_type API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.transform.data_type

      + + +
      + View Source +
      from .._response_treat import ResponseTreat
      +from .._entity_reader import EntityReader
      +from ..observer 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 types of fields to number or string.
      +
      +        dataset_name: Represents the dataset name.
      +        fields_change: Fields to change with types. This is a dict with each
      +        key:value being field:type
      +
      +        return: A JSON object with error or warning messages.
      +        """
      +
      +        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 types of fields to number or string.
      +
      +        dataset_name: Represents the dataset name.
      +        fields_change: Fields to change with types. This is a dict with each
      +        key:value being field:type
      +
      +        return: A JSON object with error or warning messages.
      +        """
      +
      +        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 wait(self, dataset_name: str) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + +
      +
      +
      + #   + + + class + TransformDataType: +
      + +
      + View Source +
      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 types of fields to number or string.
      +
      +        dataset_name: Represents the dataset name.
      +        fields_change: Fields to change with types. This is a dict with each
      +        key:value being field:type
      +
      +        return: A JSON object with error or warning messages.
      +        """
      +
      +        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 types of fields to number or string.
      +
      +        dataset_name: Represents the dataset name.
      +        fields_change: Fields to change with types. This is a dict with each
      +        key:value being field:type
      +
      +        return: A JSON object with error or warning messages.
      +        """
      +
      +        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 wait(self, dataset_name: str) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + + + +
      +
      #   + + + TransformDataType(cluster_ip: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          def update_dataset_type_sync(self,
      +                             dataset_name: str,
      +                             types: dict,
      +                             pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: Change types of fields to number or string.
      +
      +        dataset_name: Represents the dataset name.
      +        fields_change: Fields to change with types. This is a dict with each
      +        key:value being field:type
      +
      +        return: A JSON object with error or warning messages.
      +        """
      +
      +        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 types of fields to number or string.

      + +

      dataset_name: Represents the dataset name. +fields_change: Fields to change with types. This is a dict with each +key:value being field:type

      + +

      return: A JSON object with error or warning messages.

      +
      + + +
      +
      +
      #   + + + def + update_dataset_type_async( + self, + dataset_name: str, + types: dict, + pretty_response: bool = False +) -> Union[dict, str]: +
      + +
      + View Source +
          def update_dataset_type_async(self,
      +                             dataset_name: str,
      +                             types: dict,
      +                             pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: Change types of fields to number or string.
      +
      +        dataset_name: Represents the dataset name.
      +        fields_change: Fields to change with types. This is a dict with each
      +        key:value being field:type
      +
      +        return: A JSON object with error or warning messages.
      +        """
      +
      +        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 types of fields to number or string.

      + +

      dataset_name: Represents the dataset name. +fields_change: Fields to change with types. This is a dict with each +key:value being field:type

      + +

      return: A JSON object with error or warning messages.

      +
      + + +
      +
      +
      #   + + + def + wait(self, dataset_name: str) -> dict: +
      + +
      + View Source +
          def wait(self, dataset_name: str) -> dict:
      +        return self.__observer.wait(dataset_name)
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/transform/projection.html b/docs/learning_orchestra_client/transform/projection.html new file mode 100644 index 0000000..67e2ee4 --- /dev/null +++ b/docs/learning_orchestra_client/transform/projection.html @@ -0,0 +1,734 @@ + + + + + + + learning_orchestra_client.transform.projection API documentation + + + + + + + + +
      +
      +

      +learning_orchestra_client.transform.projection

      + + +
      + View Source +
      from .._response_treat import ResponseTreat
      +from ..observer import Observer
      +from .._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 inserts a set of attributes into a dataset
      +        synchronously, the caller waits until the projection is inserted into
      +        the Learning Orchestra storage mechanism.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        projection_name: Represents the projection name.
      +        dataset_name: Represents the dataset name.
      +        fields: Represents the set of attributes to be inserted. This is list
      +        with all 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 inserts a set of attributes into a dataset
      +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        projection_name: Represents the projection name.
      +        dataset_name: Represents the dataset name.
      +        fields: Represents the set of attributes to be inserted. This is list
      +        with all 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)
      +
      +        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, it does not
      +        retrieve the projection content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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 dataset
      +        content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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_async(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 synchronous because it is very fast,
      +        since the deletion is performed in background. If a projection was
      +        used by another task (Ex. histogram, pca, tuning and so forth),
      +        it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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) -> dict:
      +        return self.__observer.wait(projection_name)
      +
      + +
      + +
      +
      +
      + #   + + + class + TransformProjection: +
      + +
      + View Source +
      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 inserts a set of attributes into a dataset
      +        synchronously, the caller waits until the projection is inserted into
      +        the Learning Orchestra storage mechanism.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        projection_name: Represents the projection name.
      +        dataset_name: Represents the dataset name.
      +        fields: Represents the set of attributes to be inserted. This is list
      +        with all 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 inserts a set of attributes into a dataset
      +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        projection_name: Represents the projection name.
      +        dataset_name: Represents the dataset name.
      +        fields: Represents the set of attributes to be inserted. This is list
      +        with all 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)
      +
      +        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, it does not
      +        retrieve the projection content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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 dataset
      +        content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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_async(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 synchronous because it is very fast,
      +        since the deletion is performed in background. If a projection was
      +        used by another task (Ex. histogram, pca, tuning and so forth),
      +        it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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) -> dict:
      +        return self.__observer.wait(projection_name)
      +
      + +
      + + + +
      +
      #   + + + TransformProjection(cluster_ip: str) +
      + +
      + View Source +
          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]: +
      + +
      + View Source +
          def remove_dataset_attributes_sync(self,
      +                                       dataset_name: str,
      +                                       projection_name: str,
      +                                       fields: list,
      +                                       pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method inserts a set of attributes into a dataset
      +        synchronously, the caller waits until the projection is inserted into
      +        the Learning Orchestra storage mechanism.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        projection_name: Represents the projection name.
      +        dataset_name: Represents the dataset name.
      +        fields: Represents the set of attributes to be inserted. This is list
      +        with all 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 inserts a set of attributes into a dataset +synchronously, the caller waits until the projection is inserted into +the Learning Orchestra storage mechanism.

      + +

      pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all 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]: +
      + +
      + View Source +
          def remove_dataset_attributes_async(self,
      +                                        dataset_name: str,
      +                                        projection_name: str,
      +                                        fields: list,
      +                                        pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method inserts a set of attributes into a dataset
      +        asynchronously, the caller does not wait until the projections 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 projection was inserted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        projection_name: Represents the projection name.
      +        dataset_name: Represents the dataset name.
      +        fields: Represents the set of attributes to be inserted. This is list
      +        with all 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)
      +
      +        return self.__response_treat.treatment(response, pretty_response)
      +
      + +
      + +

      description: This method inserts a set of attributes into a dataset +asynchronously, the caller does not wait until the projections 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 projection was inserted.

      + +

      pretty_response: If true return indented string, else return dict. +projection_name: Represents the projection name. +dataset_name: Represents the dataset name. +fields: Represents the set of attributes to be inserted. This is list +with all attributes.

      + +

      return: A JSON object with error or warning messages. In case of +success, it returns the projection metadata.

      +
      + + +
      +
      +
      #   + + + def + search_all_projections(self, pretty_response: bool = False) -> Union[dict, str]: +
      + +
      + View Source +
          def search_all_projections(self, pretty_response: bool = False) \
      +            -> Union[dict, str]:
      +        """
      +        description: This method retrieves all projection metadata, it does not
      +        retrieve the projection content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +
      +        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, it does not +retrieve the projection content.

      + +

      pretty_response: If true return indented string, else return dict.

      + +

      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]: +
      + +
      + View Source +
          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 dataset
      +        content.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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 dataset +content.

      + +

      pretty_response: If true return indented string, else return dict. +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_async( + self, + projection_name: str, + pretty_response: bool = False +) -> Union[dict, str]: +
      + +
      + View Source +
          def delete_projection_async(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 synchronous because it is very fast,
      +        since the deletion is performed in background. If a projection was
      +        used by another task (Ex. histogram, pca, tuning and so forth),
      +        it cannot be deleted.
      +
      +        pretty_response: If true return indented string, else return dict.
      +        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 synchronous because it is very fast, +since the deletion is performed in background. If a projection was +used by another task (Ex. histogram, pca, tuning and so forth), +it cannot be deleted.

      + +

      pretty_response: If true return indented string, else return dict. +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) -> dict: +
      + +
      + View Source +
          def wait(self, projection_name: str) -> dict:
      +        return self.__observer.wait(projection_name)
      +
      + +
      + + + +
      +
      +
      + + \ No newline at end of file From dbbbde2ef41021ae043d067aea9d2975a6abb712 Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sat, 10 Apr 2021 12:22:01 -0300 Subject: [PATCH 15/28] fix --- docs/.nojekyll | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/.nojekyll diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e69de29 From 1c1480e0c3cf98a0066cd4b4f7260467314b920e Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sun, 4 Apr 2021 11:13:30 -0300 Subject: [PATCH 16/28] Create mnist.py --- examples/mnist.py | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/examples/mnist.py b/examples/mnist.py index 73283d2..8747bf1 100644 --- a/examples/mnist.py +++ b/examples/mnist.py @@ -217,39 +217,26 @@ def treat_dataset(dataset: dict) -> tuple: "x": "$mnist_datasets_normalized.test_images" } ) +predict_tensorflow.wait("mnist_model_predicted") evaluate_tensorflow = EvaluateTensorflow(CLUSTER_IP) evaluate_tensorflow.create_evaluate_async( name="mnist_model_evaluated", model_name="mnist_model", - parent_name="mnist_model_trained", + parent_name="mnist_model_predicted", method_name="evaluate", parameters={ - "x": "$mnist_datasets_normalized.test_images", - "y": "$mnist_datasets_normalized.test_labels" + "x": "$mnist_model_predicted", + "y": "$$mnist_datasets_normalized.test_labels" } ) - -predict_tensorflow.wait("mnist_model_predicted") evaluate_tensorflow.wait("mnist_model_evaluated") -show_mnist_predict = ''' -print(mnist_predicted) -response = None -''' -function_python.run_function_async( - name="mnist_model_predicted_print", - parameters={ - "mnist_predicted": "$mnist_model_predicted" - }, - code=show_mnist_predict -) - - show_mnist_evaluate = ''' print(mnist_evaluated) response = None ''' + function_python.run_function_async( name="mnist_model_evaluated_print", parameters={ @@ -257,15 +244,7 @@ def treat_dataset(dataset: dict) -> tuple: }, code=show_mnist_evaluate ) - function_python.wait("mnist_model_evaluated_print") -function_python.wait("mnist_model_predicted_print") - -print(function_python.search_execution_content( - name="mnist_model_predicted_print", - limit=1, - skip=1, - pretty_response=True)) print(function_python.search_execution_content( name="mnist_model_evaluated_print", From 2d3d972653ecb7fb3ef9b001329e9c1e39cbd670 Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Mon, 5 Apr 2021 08:29:59 -0300 Subject: [PATCH 17/28] Update mnist.py --- examples/mnist.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/examples/mnist.py b/examples/mnist.py index 8747bf1..73283d2 100644 --- a/examples/mnist.py +++ b/examples/mnist.py @@ -217,26 +217,39 @@ def treat_dataset(dataset: dict) -> tuple: "x": "$mnist_datasets_normalized.test_images" } ) -predict_tensorflow.wait("mnist_model_predicted") evaluate_tensorflow = EvaluateTensorflow(CLUSTER_IP) evaluate_tensorflow.create_evaluate_async( name="mnist_model_evaluated", model_name="mnist_model", - parent_name="mnist_model_predicted", + parent_name="mnist_model_trained", method_name="evaluate", parameters={ - "x": "$mnist_model_predicted", - "y": "$$mnist_datasets_normalized.test_labels" + "x": "$mnist_datasets_normalized.test_images", + "y": "$mnist_datasets_normalized.test_labels" } ) + +predict_tensorflow.wait("mnist_model_predicted") evaluate_tensorflow.wait("mnist_model_evaluated") +show_mnist_predict = ''' +print(mnist_predicted) +response = None +''' +function_python.run_function_async( + name="mnist_model_predicted_print", + parameters={ + "mnist_predicted": "$mnist_model_predicted" + }, + code=show_mnist_predict +) + + show_mnist_evaluate = ''' print(mnist_evaluated) response = None ''' - function_python.run_function_async( name="mnist_model_evaluated_print", parameters={ @@ -244,7 +257,15 @@ def treat_dataset(dataset: dict) -> tuple: }, code=show_mnist_evaluate ) + function_python.wait("mnist_model_evaluated_print") +function_python.wait("mnist_model_predicted_print") + +print(function_python.search_execution_content( + name="mnist_model_predicted_print", + limit=1, + skip=1, + pretty_response=True)) print(function_python.search_execution_content( name="mnist_model_evaluated_print", From 75bde6d667b3c3e6f98de4739c74d304abd4bf3c Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sat, 10 Apr 2021 12:33:59 -0300 Subject: [PATCH 18/28] Update docs --- README.md | 180 +----------------------------------------------------- 1 file changed, 3 insertions(+), 177 deletions(-) diff --git a/README.md b/README.md index d656ac2..1f9f04f 100644 --- a/README.md +++ b/README.md @@ -23,182 +23,8 @@ Each functionality in learningOrchestra is contained in its own class. Check the # Example -Shown below is an example usage of learning-orchestra-client using the [Titanic Dataset](https://www.kaggle.com/c/titanic/overview): +* [Here](examples/titanic.py) has an example using the [Titanic Dataset](https://www.kaggle.com/c/titanic/overview): +* [Here](examples/sentiment_analysis.py) has an example using the [Sentiment Analysis On IMDb reviews](https://www.kaggle.com/avnika22/imdb-perform-sentiment-analysis-with-scikit-learn): +* [Here](examples/mnist.py) has an example using the [MNIST Dataset](http://yann.lecun.com/exdb/mnist/): -```python -from learning_orchestra_client import ( - dataset, - builder, - transform, -) -cluster_ip = "34.95.187.26" - - -dataset = Dataset(cluster_ip) - -print(dataset.insert_dataset_sync( - "titanic_training", - "https://filebin.net/rpfdy8clm5984a4c/titanic_training.csv?t=gcnjz1yo")) -print(dataset.insert_dataset_sync( - "titanic_testing", - "https://filebin.net/mguee52ke97k0x9h/titanic_testing.csv?t=ub4nc1rc")) - -print(dataset.search_all_datasets()) - - -projection = Projection(cluster_ip) -required_columns = [ - "PassengerId", - "Pclass", - "Age", - "SibSp", - "Parch", - "Fare", - "Name", - "Sex", - "Embarked", - "Survived" - ] -print(projection.insert_dataset_attributes_sync( - "titanic_training", - "titanic_training_projection", - required_columns)) - -required_columns.remove("Survived") - -print(projection.insert_dataset_attributes_sync( - "titanic_testing", - "titanic_testing_projection", - required_columns)) - - -data_type_handler = DataType(cluster_ip) -type_fields = { - "Age": "number", - "Fare": "number", - "Parch": "number", - "PassengerId": "number", - "Pclass": "number", - "SibSp": "number" -} - -print(data_type_handler.update_dataset_types( - "titanic_testing_projection", - type_fields)) - -type_fields["Survived"] = "number" - -print(data_type_handler.update_dataset_types( - "titanic_training_projection", - type_fields)) - - -modeling_code = ''' -from pyspark.ml import Pipeline -from pyspark.sql.functions import ( - mean, col, split, - regexp_extract, when, lit) - -from pyspark.ml.feature import ( - VectorAssembler, - StringIndexer -) - -TRAINING_DF_INDEX = 0 -TESTING_DF_INDEX = 1 - -training_df = training_df.withColumnRenamed('Survived', 'label') -testing_df = testing_df.withColumn('label', lit(0)) -datasets_list = [training_df, testing_df] - -for index, dataset in enumerate(datasets_list): - dataset = dataset.withColumn( - "Initial", - regexp_extract(col("Name"), "([A-Za-z]+)\.", 1)) - datasets_list[index] = dataset - -misspelled_initials = [ - 'Mlle', 'Mme', 'Ms', 'Dr', - 'Major', 'Lady', 'Countess', - 'Jonkheer', 'Col', 'Rev', - 'Capt', 'Sir', 'Don' -] -correct_initials = [ - 'Miss', 'Miss', 'Miss', 'Mr', - 'Mr', 'Mrs', 'Mrs', - 'Other', 'Other', 'Other', - 'Mr', 'Mr', 'Mr' -] -for index, dataset in enumerate(datasets_list): - dataset = dataset.replace(misspelled_initials, correct_initials) - datasets_list[index] = dataset - - -initials_age = {"Miss": 22, - "Other": 46, - "Master": 5, - "Mr": 33, - "Mrs": 36} -for index, dataset in enumerate(datasets_list): - for initial, initial_age in initials_age.items(): - dataset = dataset.withColumn( - "Age", - when((dataset["Initial"] == initial) & - (dataset["Age"].isNull()), initial_age).otherwise( - dataset["Age"])) - datasets_list[index] = dataset - - -for index, dataset in enumerate(datasets_list): - dataset = dataset.na.fill({"Embarked": 'S'}) - datasets_list[index] = dataset - - -for index, dataset in enumerate(datasets_list): - dataset = dataset.withColumn("Family_Size", col('SibSp')+col('Parch')) - dataset = dataset.withColumn('Alone', lit(0)) - dataset = dataset.withColumn( - "Alone", - when(dataset["Family_Size"] == 0, 1).otherwise(dataset["Alone"])) - datasets_list[index] = dataset - - -text_fields = ["Sex", "Embarked", "Initial"] -for column in text_fields: - for index, dataset in enumerate(datasets_list): - dataset = StringIndexer( - inputCol=column, outputCol=column+"_index").\ - fit(dataset).\ - transform(dataset) - datasets_list[index] = dataset - - -non_required_columns = ["Name", "Embarked", "Sex", "Initial"] -for index, dataset in enumerate(datasets_list): - dataset = dataset.drop(*non_required_columns) - datasets_list[index] = dataset - - -training_df = datasets_list[TRAINING_DF_INDEX] -testing_df = datasets_list[TESTING_DF_INDEX] - -assembler = VectorAssembler( - inputCols=training_df.columns[:], - outputCol="features") -assembler.setHandleInvalid('skip') - -features_training = assembler.transform(training_df) -(features_training, features_evaluation) =\ - features_training.randomSplit([0.8, 0.2], seed=33) -features_testing = assembler.transform(testing_df) -''' - -builder = Builder(cluster_ip) - -print(builder.run_builder_sync( - "titanic_training_projection", - "titanic_testing_projection", - modeling_code, - ["lr", "dt", "gb", "rf", "nb"])) -``` From 16d78f32787d7622786be371c8bc2a4138c1843c Mon Sep 17 00:00:00 2001 From: Gabriel Ribeiro Date: Sun, 11 Apr 2021 07:19:14 -0300 Subject: [PATCH 19/28] Update docs --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1042f00..ccdd895 100644 --- a/setup.py +++ b/setup.py @@ -18,5 +18,5 @@ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", ], - python_requires=">=3.6", + python_requires=">=3.8", ) From 231231f5944f5b87437ecce9a20c48c6c1f7b918 Mon Sep 17 00:00:00 2001 From: riibeirogabriel Date: Mon, 26 Apr 2021 15:06:23 -0300 Subject: [PATCH 20/28] bug fixes --- Pipfile | 1 - examples/titanic.py | 24 ++++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Pipfile b/Pipfile index c2a7b1e..14983cc 100644 --- a/Pipfile +++ b/Pipfile @@ -7,7 +7,6 @@ verify_ssl = true [packages] requests = "2.4.2" -Pillow = "8.0.1" pymongo = "3.11.1" [requires] diff --git a/examples/titanic.py b/examples/titanic.py index 3e32264..5c85fcd 100644 --- a/examples/titanic.py +++ b/examples/titanic.py @@ -3,16 +3,16 @@ from learning_orchestra_client.transform.data_type import TransformDataType from learning_orchestra_client.builder import BuilderSparkMl -CLUSTER_IP = "http://34.66.75.31" +CLUSTER_IP = "http://35.193.116.104" dataset_csv = DatasetCsv(CLUSTER_IP) dataset_csv.insert_dataset_async( - url="https://filebin.net/r4b6z6sganz2opsh/train.csv?t=9d3lp7jm", + url="https://filebin.net/boniydu54k710l54/train.csv?t=s350xryf", dataset_name="titanic_training", ) dataset_csv.insert_dataset_async( - url="https://filebin.net/r0c41p538us5fcrz/test.csv?t=td68r02h", + url="https://filebin.net/udtf7eogfgasqnx5/test.csv?t=h79pcy0l", dataset_name="titanic_testing" ) @@ -41,7 +41,7 @@ transform_projection.remove_dataset_attributes_async( dataset_name="titanic_training", - projection_name="titanic_training_projection4", + projection_name="titanic_training_projection", fields=required_columns) required_columns.remove("Survived") @@ -174,8 +174,11 @@ training_df = datasets_list[TRAINING_DF_INDEX] testing_df = datasets_list[TESTING_DF_INDEX] +columns_without_label = training_df.columns.copy() +columns_without_label.remove("label") + assembler = VectorAssembler( - inputCols=training_df.columns[:], + inputCols=columns_without_label, outputCol="features") assembler.setHandleInvalid('skip') @@ -192,7 +195,12 @@ modeling_code=modeling_code, model_classifiers=["LR", "DT", "GB", "RF", "NB"]) -for prediction in result["result"]: - builder.wait(dataset_name=prediction) +PREDICTION_NAME_INDEX_IN_URL = 6 +INDEX_TO_REMOVE_URI_PARAMETERS = 0 +for prediction_url in result["result"]: + prediction_name = prediction_url. \ + split("/")[PREDICTION_NAME_INDEX_IN_URL]. \ + split("?")[INDEX_TO_REMOVE_URI_PARAMETERS] + builder.wait(dataset_name=prediction_name) print(builder.search_builder_register_predictions( - builder_name=prediction, limit=1, pretty_response=True)) + builder_name=prediction_name, limit=1, pretty_response=True)) From 2450bcb7c26a74257bfe10c90704a962c15c489a Mon Sep 17 00:00:00 2001 From: riibeirogabriel Date: Wed, 28 Apr 2021 17:13:02 -0300 Subject: [PATCH 21/28] bug fixes --- README.md | 2 +- examples/mnist.py | 4 ++-- examples/sentiment_analysis.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1f9f04f..f256f39 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,6 @@ Each functionality in learningOrchestra is contained in its own class. Check the * [Here](examples/titanic.py) has an example using the [Titanic Dataset](https://www.kaggle.com/c/titanic/overview): * [Here](examples/sentiment_analysis.py) has an example using the [Sentiment Analysis On IMDb reviews](https://www.kaggle.com/avnika22/imdb-perform-sentiment-analysis-with-scikit-learn): -* [Here](examples/mnist.py) has an example using the [MNIST Dataset](http://yann.lecun.com/exdb/mnist/): +* [Here](examples/mnist_async.py) has an example using the [MNIST Dataset](http://yann.lecun.com/exdb/mnist/): diff --git a/examples/mnist.py b/examples/mnist.py index 73283d2..0103a61 100644 --- a/examples/mnist.py +++ b/examples/mnist.py @@ -247,8 +247,8 @@ def treat_dataset(dataset: dict) -> tuple: show_mnist_evaluate = ''' - print(mnist_evaluated) - response = None +print(mnist_evaluated) +response = None ''' function_python.run_function_async( name="mnist_model_evaluated_print", diff --git a/examples/sentiment_analysis.py b/examples/sentiment_analysis.py index 0fbcbd2..5c54e16 100644 --- a/examples/sentiment_analysis.py +++ b/examples/sentiment_analysis.py @@ -4,7 +4,7 @@ from learning_orchestra_client.train.scikitlearn import TrainScikitLearn from learning_orchestra_client.predict.scikitlearn import PredictScikitLearn -CLUSTER_IP = "http://34.68.100.96" +CLUSTER_IP = "http://34.123.167.241" dataset_csv = DatasetCsv(CLUSTER_IP) @@ -107,12 +107,12 @@ def tokenizer_porter(text): module_path="sklearn.linear_model", class_name="LogisticRegressionCV", class_parameters={ - "cv": 6, + "cv": 5, "scoring": "accuracy", "random_state": 0, "n_jobs": -1, "verbose": 3, - "max_iter": 500 + "max_iter": 100 } ) From 397c7c2543eb0349f722e2fffd88baf2d9b5c270 Mon Sep 17 00:00:00 2001 From: joubert Date: Fri, 7 May 2021 08:53:25 -0300 Subject: [PATCH 22/28] several text and structural updates --- README.md | 6 +- learning_orchestra_client/builder/__init__.py | 0 .../{ => builder}/builder.py | 78 ++++---- learning_orchestra_client/dataset.py | 169 ------------------ learning_orchestra_client/dataset/_dataset.py | 33 ++-- .../evaluate/_evaluate.py | 57 +++--- learning_orchestra_client/explore/_explore.py | 161 +++++++++++++++++ .../explore/histogram.py | 48 +++-- .../explore/scikitlearn.py | 14 ++ .../explore/tensorflow.py | 14 ++ learning_orchestra_client/function/python.py | 83 +++++---- learning_orchestra_client/model/_model.py | 88 ++++----- learning_orchestra_client/observe/__init__.py | 0 .../{observer.py => observe/observe.py} | 29 ++- learning_orchestra_client/predict/_predict.py | 75 ++++---- learning_orchestra_client/train/_train.py | 78 ++++---- .../transform/_transform.py | 166 +++++++++++++++++ .../transform/data_type.py | 101 +++++++++-- .../transform/projection.py | 64 ++++--- .../transform/scikitlearn.py | 14 ++ .../transform/tensorflow.py | 14 ++ learning_orchestra_client/util/__init__.py | 0 .../{ => util}/_entity_reader.py | 0 .../{ => util}/_response_treat.py | 0 .../sentiment_analysis.py => pipeline/imdb.py | 0 {examples => pipeline}/mnist.py | 0 {examples => pipeline}/titanic.py | 0 27 files changed, 839 insertions(+), 453 deletions(-) create mode 100644 learning_orchestra_client/builder/__init__.py rename learning_orchestra_client/{ => builder}/builder.py (70%) delete mode 100644 learning_orchestra_client/dataset.py create mode 100644 learning_orchestra_client/explore/_explore.py create mode 100644 learning_orchestra_client/explore/scikitlearn.py create mode 100644 learning_orchestra_client/explore/tensorflow.py create mode 100644 learning_orchestra_client/observe/__init__.py rename learning_orchestra_client/{observer.py => observe/observe.py} (55%) create mode 100644 learning_orchestra_client/transform/_transform.py create mode 100644 learning_orchestra_client/transform/scikitlearn.py create mode 100644 learning_orchestra_client/transform/tensorflow.py create mode 100644 learning_orchestra_client/util/__init__.py rename learning_orchestra_client/{ => util}/_entity_reader.py (100%) rename learning_orchestra_client/{ => util}/_response_treat.py (100%) rename examples/sentiment_analysis.py => pipeline/imdb.py (100%) rename {examples => pipeline}/mnist.py (100%) rename {examples => pipeline}/titanic.py (100%) diff --git a/README.md b/README.md index f256f39..fb76e03 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ Each functionality in learningOrchestra is contained in its own class. Check the # Example -* [Here](examples/titanic.py) has an example using the [Titanic Dataset](https://www.kaggle.com/c/titanic/overview): -* [Here](examples/sentiment_analysis.py) has an example using the [Sentiment Analysis On IMDb reviews](https://www.kaggle.com/avnika22/imdb-perform-sentiment-analysis-with-scikit-learn): -* [Here](examples/mnist_async.py) has an example using the [MNIST Dataset](http://yann.lecun.com/exdb/mnist/): +* [Here](pipeline/titanic.py) has an example using the [Titanic Dataset](https://www.kaggle.com/c/titanic/overview): +* [Here](pipeline/imdb.py) has an example using the [Sentiment Analysis On IMDb reviews](https://www.kaggle.com/avnika22/imdb-perform-sentiment-analysis-with-scikit-learn): +* [Here](pipeline/mnist_async.py) has an example using the [MNIST Dataset](http://yann.lecun.com/exdb/mnist/): diff --git a/learning_orchestra_client/builder/__init__.py b/learning_orchestra_client/builder/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/learning_orchestra_client/builder.py b/learning_orchestra_client/builder/builder.py similarity index 70% rename from learning_orchestra_client/builder.py rename to learning_orchestra_client/builder/builder.py index 9c9b323..9b9d819 100644 --- a/learning_orchestra_client/builder.py +++ b/learning_orchestra_client/builder/builder.py @@ -1,6 +1,6 @@ -from .observer import Observer -from ._response_treat import ResponseTreat -from ._entity_reader import EntityReader +from learning_orchestra_client.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 @@ -26,20 +26,18 @@ def run_spark_ml_sync(self, model_classifiers: list, pretty_response: bool = False) -> Union[dict, str]: """ - description: This method resource join several steps of machine - learning workflow (transform, tune, train and evaluate) coupling in - a unique resource, builder creates several model predictions using - your own modeling code using a defined set of classifiers. This is made - synchronously, the caller waits until the model predictions are inserted - into the Learning Orchestra storage mechanism. + 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 preprocessing model - model_classifiers: list of initial classifiers to be used in model - pretty_response: returns indented string for visualization if True + 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 resulted predictions URIs. + return: The set of predictions (URIs of them). """ request_body_content = { @@ -63,22 +61,18 @@ def run_spark_ml_async(self, model_classifiers: list, pretty_response: bool = False) -> Union[dict, str]: """ - description: This method resource join several steps of machine - learning workflow (transform, tune, train and evaluate) coupling in - a unique resource, builder creates several model predictions using - your own modeling code using a defined set of classifiers. This is made - asynchronously, the caller does not wait until the model predictions are - 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 model predictions are inserted. + 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 preprocessing model - model_classifiers: list of initial classifiers to be used in model - pretty_response: returns indented string for visualization if True + 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 resulted predictions URIs. + return: the URL to retrieve the Spark pipeline result """ request_body_content = { @@ -95,10 +89,10 @@ def run_spark_ml_async(self, def search_all_builders(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method retrieves all model predictions metadata, it + description: This method retrieves all model predictions metadata. It does not retrieve the model predictions content. - pretty_response: If true return indented string, else return dict. + 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. @@ -119,15 +113,15 @@ def search_builder_register_predictions(self, description: This method is responsible for retrieving the model predictions content. - pretty_response: If true return indented string, else return dict. + 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 there - is no such projection. The current page is also returned to be used in + 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. """ @@ -140,7 +134,7 @@ def search_builder(self, builder_name: str, pretty_response: bool = False) \ -> Union[dict, str]: """ description: This method is responsible for retrieving a specific - model prediction metadata. + model metadata. pretty_response: If true return indented string, else return dict. builder_name: Represents the model predictions name. @@ -161,11 +155,11 @@ 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 synchronous because it is very fast, + The delete operation is always asynchronous, since the deletion is performed in background. - pretty_response: If true return indented string, else return dict. - builder_name: Represents the projection name. + 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 @@ -177,5 +171,17 @@ def delete_builder(self, builder_name: str, pretty_response: bool = False) \ return self.__response_treat.treatment(response, pretty_response) - def wait(self, dataset_name: str) -> dict: - return self.__observer.wait(dataset_name) + def wait(self, dataset_name: str, timeout: str) -> 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. The -1 value + waits until the builder finishes. + + return: JSON object with an error message, a warning message or a + correct execution of a pipeline + """ + return self.__observer.wait(dataset_name, timeout) + diff --git a/learning_orchestra_client/dataset.py b/learning_orchestra_client/dataset.py deleted file mode 100644 index c1e40fc..0000000 --- a/learning_orchestra_client/dataset.py +++ /dev/null @@ -1,169 +0,0 @@ -__author__ = "Otavio Henrique Rodrigues Mapa & Matheus Goncalves Ribeiro" -__credits__ = "all free source developers" -__status__ = "Prototype" - -from .observer import Observer -from ._response_treat import ResponseTreat -import requests -from typing import Union - - -class Dataset: - def __init__(self, ip_from_cluster: str): - self.cluster_url = "http://" + ip_from_cluster + \ - "/api/learningOrchestra/v1/dataset" - self.response_treat = ResponseTreat() - self.OUTPUT_NAME = "datasetName" - self.URL = "datasetURI" - self.CLUSTER_IP = ip_from_cluster - - 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 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. - """ - request_body = {self.OUTPUT_NAME: dataset_name, - self.URL: url} - request_url = self.cluster_url - - response = requests.post(url=request_url, json=request_body) - - Observer(dataset_name, self.CLUSTER_IP).observe_processing() - - if pretty_response: - print("\n----------" + " CREATED FILE " + 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). - """ - request_body = {self.OUTPUT_NAME: dataset_name, - self.URL: url} - request_url = self.cluster_url - - response = requests.post(url=request_url, json=request_body) - - if pretty_response: - print("\n----------" + " CREATED FILE " + dataset_name + " -------" - "---") - 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 return indented string, else return dict. - - return: All datasets metadata stored in Learning Orchestra or an empty - result. - """ - request_url = self.cluster_url - - response = requests.get(request_url) - - return self.response_treat.treatment(response, pretty_response) - - def search_dataset(self, dataset_name: str, pretty_response: bool = False) \ - -> Union[dict, str]: - """ - description: This method is responsible for retrieving a specific - dataset - - pretty_response: If true return indented string, else return dict. - dataset_name: Is the name of the dataset file. - 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 dataset metadata stored in Learning Orchestra or an - error if there is no such dataset. - """ - response = self.search_dataset_content(dataset_name, limit=1, - pretty_response=pretty_response) - - return 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 return indented string, else return dict. - 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. - """ - - request_url = self.cluster_url + "/" + dataset_name + \ - "?query=" + str(query) + \ - "&limit=" + str(limit) + \ - "&skip=" + str(skip) - - response = requests.get(request_url) - - 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. The - delete operation is always synchronous because it is very fast, since - the deletion is performed in background. If a dataset was used by - another task (Ex. projection, histogram, pca, tuning and so forth), it - cannot be deleted. - - pretty_response: If true return indented string, else return dict. - dataset_name: Represents the dataset name. - - return: JSON object with an error message, a warning message or a - correct delete message - """ - - request_url = self.cluster_url + "/" + dataset_name - - response = requests.delete(request_url) - - return self.response_treat.treatment(response, pretty_response) diff --git a/learning_orchestra_client/dataset/_dataset.py b/learning_orchestra_client/dataset/_dataset.py index 76a1f5d..70567c8 100644 --- a/learning_orchestra_client/dataset/_dataset.py +++ b/learning_orchestra_client/dataset/_dataset.py @@ -1,6 +1,6 @@ -from ..observer import Observer -from .._response_treat import ResponseTreat -from .._entity_reader import EntityReader +from ..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 @@ -25,7 +25,7 @@ def insert_dataset_sync(self, synchronously, i.e., the caller waits until the dataset is inserted into the Learning Orchestra storage mechanism. - pretty_response: If true return indented string, else return dict. + 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. @@ -59,7 +59,7 @@ def insert_dataset_async(self, 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). + proceed future checks to verify if the dataset is inserted - using wait method). """ request_body = {self.__DATASET_NAME: dataset_name, self.__URL: url} @@ -74,7 +74,7 @@ def search_all_datasets(self, pretty_response: bool = False) \ description: This method retrieves all datasets metadata, i.e., it does not retrieve the dataset content. - pretty_response: If true return indented string, else return dict. + pretty_response: If true it returns a string, otherwise a dictionary. return: All datasets metadata stored in Learning Orchestra or an empty result. @@ -82,7 +82,7 @@ def search_all_datasets(self, pretty_response: bool = False) \ response = self.__entity_reader.read_all_instances_from_entity() return self.__response_treat.treatment(response, pretty_response) - def delete_dataset_async(self, dataset_name, pretty_response=False) \ + def delete_dataset(self, dataset_name, pretty_response=False) \ -> Union[dict, str]: """ description: This method is responsible for deleting the dataset. @@ -92,7 +92,7 @@ def delete_dataset_async(self, dataset_name, pretty_response=False) \ dataset was used by another task (Ex. projection, histogram, pca, tune and so forth), it cannot be deleted. - pretty_response: If true return indented string, else return dict. + 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 @@ -115,7 +115,7 @@ def search_dataset_content(self, description: This method is responsible for retrieving the dataset content - pretty_response: If true return indented string, else return dict. + 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 @@ -132,5 +132,16 @@ def search_dataset_content(self, return self.__response_treat.treatment(response, pretty_response) - def wait(self, dataset_name: str) -> dict: - return self.__observer.wait(dataset_name) + def wait(self, dataset_name: str, timeout: str) -> 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. The -1 value + waits until the download finishes. + + return: JSON object with an error message, a warning message or a + correct execution of a pipeline + """ + return self.__observer.wait(dataset_name, timeout) diff --git a/learning_orchestra_client/evaluate/_evaluate.py b/learning_orchestra_client/evaluate/_evaluate.py index 31a8db2..8abf440 100644 --- a/learning_orchestra_client/evaluate/_evaluate.py +++ b/learning_orchestra_client/evaluate/_evaluate.py @@ -1,6 +1,6 @@ -from ..observer import Observer -from .._response_treat import ResponseTreat -from .._entity_reader import EntityReader +from ..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 @@ -32,9 +32,11 @@ def create_evaluate_sync(self, """ description: This method runs an evaluation about a model in sync mode - 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. + 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. @@ -64,11 +66,13 @@ def create_evaluate_async(self, pretty_response: bool = False) -> \ Union[dict, str]: """ - description: his method runs an evaluation about a model in async mode + description: This method runs an evaluation about a model in async mode - 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. + 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. @@ -92,7 +96,7 @@ def search_all_evaluates(self, pretty_response: bool = False) \ description: This method retrieves all created evaluations, i.e., it does not retrieve the specific evaluation content. - pretty_response: If true return indented string, else return dict. + pretty_response: If true it returns a string, otherwise a dictionary. return: All datasets metadata stored in Learning Orchestra or an empty result. @@ -100,18 +104,18 @@ def search_all_evaluates(self, pretty_response: bool = False) \ response = self.__entity_reader.read_all_instances_from_entity() return self.__response_treat.treatment(response, pretty_response) - def delete_evaluate_async(self, name: str, pretty_response=False) \ + def delete_evaluate(self, name: str, pretty_response=False) \ -> Union[dict, str]: """ - description: This method is responsible for deleting an evaluation. + 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 URL for delete checks. If 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, pca, tune and so forth), it cannot be deleted. - pretty_response: If true return indented string, else return dict. - dataset_name: Represents the dataset name. + 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 @@ -133,14 +137,14 @@ def search_evaluate_content(self, description: This method is responsible for retrieving the evaluation content - pretty_response: If true return indented string, else return dict. - dataset_name: Is the name of the dataset file. + 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 tuples or registers inside or an error if there + 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. """ @@ -150,5 +154,16 @@ def search_evaluate_content(self, return self.__response_treat.treatment(response, pretty_response) - def wait(self, name: str) -> dict: - return self.__observer.wait(name) + def wait(self, name: str, timeout: str) -> 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. The -1 value + waits until the evaluation finishes. + + return: JSON object with an error message, a warning message or a + correct evaluation result + """ + return self.__observer.wait(name, timeout) diff --git a/learning_orchestra_client/explore/_explore.py b/learning_orchestra_client/explore/_explore.py new file mode 100644 index 0000000..3efe338 --- /dev/null +++ b/learning_orchestra_client/explore/_explore.py @@ -0,0 +1,161 @@ +from ..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, pca, 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 model. + + 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 wait(self, name: str, timeout: str) -> 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. The -1 value + waits until the explore finishes. + + 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) diff --git a/learning_orchestra_client/explore/histogram.py b/learning_orchestra_client/explore/histogram.py index 0c1f44b..25018b5 100644 --- a/learning_orchestra_client/explore/histogram.py +++ b/learning_orchestra_client/explore/histogram.py @@ -1,8 +1,8 @@ -from ..observer import Observer -from .._response_treat import ResponseTreat +from ..observe import Observer +from learning_orchestra_client.util._response_treat import ResponseTreat import requests from typing import Union -from .._entity_reader import EntityReader +from learning_orchestra_client.util._entity_reader import EntityReader class ExploreHistogram: @@ -25,14 +25,14 @@ def run_histogram_sync(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method run histogram algorithm to create a histogram - synchronously, the caller waits until the histogram is inserted into + 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 return indented string, else return dict. + 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. @@ -57,16 +57,14 @@ def run_histogram_async(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method run histogram algorithm to create a histogram - asynchronously, the caller does not wait until the histogram 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 histogram was inserted. + 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 return indented string, else return dict. + 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. @@ -86,12 +84,12 @@ def run_histogram_async(self, def search_all_histograms(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method retrieves all histogram names, it does not + description: This method retrieves all histogram metadata, it does not retrieve the histogram content. - pretty_response: If true return indented string, else return dict. + pretty_response: If true it returns a string, otherwise a dictionary. - return: A list with all histogram names stored in Learning Orchestra + return: A list with all histogram metadata stored in Learning Orchestra or an empty result. """ @@ -109,7 +107,7 @@ def search_histogram_content(self, description: This method is responsible for retrieving the histogram content. - pretty_response: If true return indented string, else return dict. + 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 @@ -130,10 +128,10 @@ 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 synchronous because it is very fast, + The delete operation is always asynchronous, since the deletion is performed in background. - pretty_response: If true return indented string, else return dict. + 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 @@ -144,3 +142,17 @@ def delete_histogram(self, histogram_name: str, response = requests.delete(cluster_url_histogram) return self.__response_treat.treatment(response, pretty_response) + + def wait(self, name: str, timeout: str) -> 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. The -1 value + waits until the histogram finishes. + + return: JSON object with an error message, a warning message or a + correct histogram result + """ + return self.__observer.wait(name, timeout) \ No newline at end of file diff --git a/learning_orchestra_client/explore/scikitlearn.py b/learning_orchestra_client/explore/scikitlearn.py new file mode 100644 index 0000000..4445fd6 --- /dev/null +++ b/learning_orchestra_client/explore/scikitlearn.py @@ -0,0 +1,14 @@ +from ._explore import Evaluate + + +class EvaluateScikitLearn(Evaluate): + __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/explore/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) diff --git a/learning_orchestra_client/explore/tensorflow.py b/learning_orchestra_client/explore/tensorflow.py new file mode 100644 index 0000000..3c8cf28 --- /dev/null +++ b/learning_orchestra_client/explore/tensorflow.py @@ -0,0 +1,14 @@ +from ._explore import Evaluate + + +class EvaluateTensorflow(Evaluate): + __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/explore/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) \ No newline at end of file diff --git a/learning_orchestra_client/function/python.py b/learning_orchestra_client/function/python.py index cc048d6..77d813e 100644 --- a/learning_orchestra_client/function/python.py +++ b/learning_orchestra_client/function/python.py @@ -1,6 +1,6 @@ -from ..observer import Observer -from .._response_treat import ResponseTreat -from .._entity_reader import EntityReader +from ..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 @@ -26,14 +26,14 @@ def run_function_sync(self, description: str = "", pretty_response: bool = False) -> Union[dict, str]: """ - description: This method runs a python 3 code in sync mode, being able to use - created results of some service. - pretty_response: If true return indented string, else return dict. - dataset_name: Is the name of the dataset file that will be created. + 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 a URL - indicating the correct operation. + return: A JSON object with an error or warning message or the correct operation result. """ request_body = { self.__NAME_FIELD: name, @@ -53,17 +53,17 @@ def run_function_async(self, code: str, description: str = "", pretty_response: bool = False) -> Union[dict, str]: - """ - description: This method runs a python 3 code in async mode, - being able to use created results of some service. - - 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). + """ + 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, @@ -82,26 +82,24 @@ def search_all_executions(self, pretty_response: bool = False) \ description: This method retrieves all created functions metadata, i.e., it does not retrieve the function result content. - pretty_response: If true return indented string, else return dict. + pretty_response: If true it returns a string, otherwise a dictionary. - return: All datasets metadata stored in Learning Orchestra or an empty + 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_async(self, name: str, pretty_response=False) \ + 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. If a - dataset was used by another task (Ex. projection, histogram, pca, tune - and so forth), it cannot be deleted. + URL for a future use. The caller uses the URL for delete checks. - pretty_response: If true return indented string, else return dict. - dataset_name: Represents the dataset name. + 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 @@ -120,18 +118,20 @@ def search_execution_content(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method is responsible for retrieving the metadata function - content + 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 return indented string, else return dict. - dataset_name: Is the name of the dataset file. + 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 tuples or registers inside or an error if there - is no such dataset. The current page is also returned to be used in + 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. """ @@ -140,5 +140,16 @@ def search_execution_content(self, return self.__response_treat.treatment(response, pretty_response) - def wait(self, dataset_name: str) -> dict: - return self.__observer.wait(dataset_name) + def wait(self, dataset_name: str, timeout: str) -> 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. The -1 value + waits until the function finishes. + + return: JSON object with an error message, a warning message or a + correct function result + """ + return self.__observer.wait(dataset_name, timeout) diff --git a/learning_orchestra_client/model/_model.py b/learning_orchestra_client/model/_model.py index c5d0f6b..2f4d5d6 100644 --- a/learning_orchestra_client/model/_model.py +++ b/learning_orchestra_client/model/_model.py @@ -1,6 +1,6 @@ -from ..observer import Observer -from .._response_treat import ResponseTreat -from .._entity_reader import EntityReader +from ..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 @@ -27,11 +27,13 @@ def create_model_sync(self, description: str = "", pretty_response: bool = False) -> Union[dict, str]: """ - description: This method is responsible to create a model in sync mode. + description: This method runs a model creation in sync mode - 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. + 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. @@ -58,14 +60,17 @@ def create_model_async(self, description: str = "", pretty_response: bool = False) -> Union[dict, str]: """ - description: This method is responsible to create a model in async mode. + description: This method runs a model creation in async mode, thus it requires a + wait method call - 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. + 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. + indicating the future correct operation. """ request_body = { self.__NAME_FIELD: name, @@ -84,28 +89,26 @@ 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 metadata model content. + not retrieve the model content. - pretty_response: If true return indented string, else return dict. + pretty_response: If true it returns a string, otherwise a dictionary. - return: All datasets metadata stored in Learning Orchestra or an empty + 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_async(self, name: str, pretty_response=False) \ + 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. If a - dataset was used by another task (Ex. projection, histogram, pca, tune - and so forth), it cannot be deleted. + URL for a future use. The caller uses the URL for delete checks. - pretty_response: If true return indented string, else return dict. - dataset_name: Represents the dataset name. + 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 @@ -116,33 +119,36 @@ def delete_model_async(self, name: str, pretty_response=False) \ response = requests.delete(request_url) return self.__response_treat.treatment(response, pretty_response) - def search_model_content(self, + def search_model(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 model metadata - content - - pretty_response: If true return indented string, else return dict. - 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. + 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, query, limit, skip) + name) return self.__response_treat.treatment(response, pretty_response) - def wait(self, name: str) -> dict: - return self.__observer.wait(name) + def wait(self, name: str, timeout: str) -> 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. The -1 value + waits until the creation finishes. + + return: JSON object with an error message, a warning message or a + correct model result + """ + return self.__observer.wait(name, timeout) diff --git a/learning_orchestra_client/observe/__init__.py b/learning_orchestra_client/observe/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/learning_orchestra_client/observer.py b/learning_orchestra_client/observe/observe.py similarity index 55% rename from learning_orchestra_client/observer.py rename to learning_orchestra_client/observe/observe.py index 61df32a..fe39bc3 100644 --- a/learning_orchestra_client/observer.py +++ b/learning_orchestra_client/observe/observe.py @@ -13,15 +13,22 @@ def __init__(self, cluster_ip: str): self.__database = mongo_client.database - def wait(self, dataset_name: str, pretty_response: bool = False) -> dict: + #aqui deve ter duas threads sempre. uma com mongo e outra q dorme por timeout + #segundos e depois verifica se a thread mongo acabou. caso não, esta a mata e + #retorna que a task ainda nao acabou + def wait(self, name: str, timeout: str, pretty_response: bool = False) -> dict: """ - :description: Observe the finished processing status from some - processing, blocking the code execution until finish processing. + :description: Observe the end of a pipe for a timeout seconds or + until the pipe finishes its execution. - :return: A dict with metadata file of used dataset name. + name: Represents the pipe name. Any tune, train, predict service can wait its finish with a + wait method call. + + :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[dataset_name] + dataset_collection = self.__database[name] metadata_query = {"_id": 0} dataset_metadata = dataset_collection.find_one(metadata_query) @@ -45,12 +52,16 @@ def wait(self, dataset_name: str, pretty_response: bool = False) -> dict: observer_query, full_document='updateLookup').next()['fullDocument'] - def observe_storage(self, dataset_name: str) -> \ + def observe_pipe(self, name: str) -> \ change_stream.CollectionChangeStream: """ - :description: Get all changes from a dataset + :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. - :return: A pymongo CollectionChangeStream object, use the builtin + :return: A pymongo CollectionChangeStream object. You must use the builtin next() method to iterate over changes. """ @@ -65,6 +76,6 @@ def observe_storage(self, dataset_name: str) -> \ ] }} ] - return self.__database[dataset_name].watch( + return self.__database[name].watch( observer_query, full_document='updateLookup') diff --git a/learning_orchestra_client/predict/_predict.py b/learning_orchestra_client/predict/_predict.py index 2abf0b6..0c5591e 100644 --- a/learning_orchestra_client/predict/_predict.py +++ b/learning_orchestra_client/predict/_predict.py @@ -1,6 +1,6 @@ -from ..observer import Observer -from .._response_treat import ResponseTreat -from .._entity_reader import EntityReader +from ..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 @@ -30,12 +30,14 @@ def create_prediction_sync(self, pretty_response: bool = False) -> \ Union[dict, str]: """ - description: This method is responsible to predict results in sync mode - using a created model + description: This method is responsible to predict models in sync mode - 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. + + 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. @@ -65,12 +67,14 @@ def create_prediction_async(self, pretty_response: bool = False) -> \ Union[dict, str]: """ - description: This method is responsible to predict results in async mode - using a created model + 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 return indented string, else return dict. - dataset_name: Is the name of the dataset file that will be created. - url: Url to CSV file. + 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. @@ -92,33 +96,30 @@ 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 metadata content. + not retrieve the prediction content. - pretty_response: If true return indented string, else return dict. + pretty_response: If true it returns a string, otherwise a dictionary. - return: All datasets metadata stored in Learning Orchestra or an empty + 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_async(self, name: str, pretty_response=False) \ + 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. If a - dataset was used by another task (Ex. projection, histogram, pca, tune - and so forth), it cannot be deleted. + URL for a future use. The caller uses the URL for delete checks. - pretty_response: If true return indented string, else return dict. - dataset_name: Represents the dataset name. + 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) @@ -132,25 +133,35 @@ def search_prediction_content(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method is responsible for retrieving the prediction - metadata content + description: This method is responsible for retrieving all the prediction + tuples or registers, as well as the metadata content - pretty_response: If true return indented string, else return dict. - dataset_name: Is the name of the dataset file. + 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 tuples or registers inside or an error if there - is no such dataset. The current page is also returned to be used in + 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) -> dict: - return self.__observer.wait(name) + def wait(self, name: str, timeout: str) -> 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. The -1 value + waits until the prediction finishes. + + return: JSON object with an error message, a warning message or a + correct prediction result + """ + return self.__observer.wait(name, timeout) diff --git a/learning_orchestra_client/train/_train.py b/learning_orchestra_client/train/_train.py index 7177e42..069acba 100644 --- a/learning_orchestra_client/train/_train.py +++ b/learning_orchestra_client/train/_train.py @@ -1,6 +1,6 @@ -from ..observer import Observer -from .._response_treat import ResponseTreat -from .._entity_reader import EntityReader +from ..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 @@ -30,12 +30,13 @@ def create_training_sync(self, pretty_response: bool = False) -> \ Union[dict, str]: """ - description: This method is responsible to train a created model in - sync mode. + description: This method is responsible to train models in sync mode - 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. + 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. @@ -65,12 +66,14 @@ def create_training_async(self, pretty_response: bool = False) -> \ Union[dict, str]: """ - description: This method is responsible to train a created model in - async mode. + 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 return indented string, else return dict. - dataset_name: Is the name of the dataset file that will be created. - url: Url to CSV file. + 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. @@ -91,34 +94,31 @@ def create_training_async(self, def search_all_trainings(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method retrieves all trainings metadata, i.e., it does - not retrieve the training metadata content. + description: This method retrieves all train metadata, i.e., it does + not retrieve the train content. - pretty_response: If true return indented string, else return dict. + pretty_response: If true it returns a string, otherwise a dictionary. - return: All datasets metadata stored in Learning Orchestra or an empty + 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_async(self, name: str, pretty_response=False) \ + def delete_training(self, name: str, pretty_response=False) \ -> Union[dict, str]: """ - description: This method is responsible for deleting the trained model. + 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. If a - dataset was used by another task (Ex. projection, histogram, pca, tune - and so forth), it cannot be deleted. + URL for a future use. The caller uses the URL for delete checks. - pretty_response: If true return indented string, else return dict. - dataset_name: Represents the dataset name. + 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) @@ -132,25 +132,35 @@ def search_training_content(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method is responsible for retrieving the training - metadata content + description: This method is responsible for retrieving all the train + tuples or registers, as well as the metadata content - pretty_response: If true return indented string, else return dict. - dataset_name: Is the name of the dataset file. + 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 tuples or registers inside or an error if there - is no such dataset. The current page is also returned to be used in + 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) -> dict: - return self.__observer.wait(name) + def wait(self, name: str, timeout: str) -> 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. The -1 value + waits until the train finishes. + + return: JSON object with an error message, a warning message or a + correct train result + """ + return self.__observer.wait(name, timeout) diff --git a/learning_orchestra_client/transform/_transform.py b/learning_orchestra_client/transform/_transform.py new file mode 100644 index 0000000..40e3f41 --- /dev/null +++ b/learning_orchestra_client/transform/_transform.py @@ -0,0 +1,166 @@ +from ..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: str) -> 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. The -1 value + waits until the transformation finishes. + + return: JSON object with an error message, a warning message or a + correct transform result + """ + return self.__observer.wait(name, timeout) diff --git a/learning_orchestra_client/transform/data_type.py b/learning_orchestra_client/transform/data_type.py index 99c02b1..52e3876 100644 --- a/learning_orchestra_client/transform/data_type.py +++ b/learning_orchestra_client/transform/data_type.py @@ -1,6 +1,6 @@ -from .._response_treat import ResponseTreat -from .._entity_reader import EntityReader -from ..observer import Observer +from learning_orchestra_client.util._response_treat import ResponseTreat +from learning_orchestra_client.util._entity_reader import EntityReader +from ..observe import Observer import requests from typing import Union @@ -23,15 +23,14 @@ def update_dataset_type_sync(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: Change types of fields to number or string. + 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. - fields_change: Fields to change with types. This is a dict with each - key:value being field:type + types: Represents a map, where the pair key:value is a field:type - return: A JSON object with error or warning messages. + 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, @@ -49,15 +48,16 @@ def update_dataset_type_async(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: Change types of fields to number or string. + 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. - fields_change: Fields to change with types. This is a dict with each - key:value being field:type + types: Represents a map, where the pair key:value is a field:type - return: A JSON object with error or warning messages. + 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, @@ -67,5 +67,76 @@ def update_dataset_type_async(self, response = requests.patch(url=url_request, json=body_request) return self.__response_treat.treatment(response, pretty_response) - def wait(self, dataset_name: str) -> dict: - return self.__observer.wait(dataset_name) \ No newline at end of file + 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: str) -> 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. The -1 value + waits until the datatype operation finishes. + + return: JSON object with an error message, a warning message or a + correct datatype result + """ + return self.__observer.wait(dataset_name, timeout) \ No newline at end of file diff --git a/learning_orchestra_client/transform/projection.py b/learning_orchestra_client/transform/projection.py index f99852b..2d4d1f3 100644 --- a/learning_orchestra_client/transform/projection.py +++ b/learning_orchestra_client/transform/projection.py @@ -1,6 +1,6 @@ -from .._response_treat import ResponseTreat -from ..observer import Observer -from .._entity_reader import EntityReader +from learning_orchestra_client.util._response_treat import ResponseTreat +from ..observe import Observer +from learning_orchestra_client.util._entity_reader import EntityReader import requests from typing import Union @@ -25,15 +25,15 @@ def remove_dataset_attributes_sync(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method inserts a set of attributes into a dataset + 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 true return indented string, else return dict. + 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 inserted. This is list - with all attributes. + 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. @@ -57,20 +57,19 @@ def remove_dataset_attributes_async(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method inserts a set of attributes into a dataset - asynchronously, the caller does not wait until the projections 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 projection was inserted. + 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 true return indented string, else return dict. + 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 inserted. This is list - with all attributes. + 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. + success, it returns the projection URL to be obtained latter with a wait method call. """ request_body = { @@ -86,10 +85,10 @@ def remove_dataset_attributes_async(self, def search_all_projections(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method retrieves all projection metadata, it does not + description: This method retrieves all projection metadata, i.e., it does not retrieve the projection content. - pretty_response: If true return indented string, else return dict. + 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. @@ -105,10 +104,10 @@ def search_projection_content(self, pretty_response: bool = False) \ -> Union[dict, str]: """ - description: This method is responsible for retrieving the dataset + description: This method is responsible for retrieving the projection content. - pretty_response: If true return indented string, else return dict. + 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 @@ -125,17 +124,15 @@ def search_projection_content(self, return self.__response_treat.treatment(response, pretty_response) - def delete_projection_async(self, projection_name: str, + 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 synchronous because it is very fast, - since the deletion is performed in background. If a projection was - used by another task (Ex. histogram, pca, tuning and so forth), - it cannot be deleted. + The delete operation is always asynchronous and performed in background. + - pretty_response: If true return indented string, else return dict. + 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 @@ -148,5 +145,16 @@ def delete_projection_async(self, projection_name: str, return self.__response_treat.treatment(response, pretty_response) - def wait(self, projection_name: str) -> dict: - return self.__observer.wait(projection_name) \ No newline at end of file + def wait(self, projection_name: str, timeout: str) -> 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. The -1 value + waits until the projection operation finishes. + + return: JSON object with an error message, a warning message or a + correct projection result + """ + return self.__observer.wait(projection_name, timeout) \ No newline at end of file diff --git a/learning_orchestra_client/transform/scikitlearn.py b/learning_orchestra_client/transform/scikitlearn.py new file mode 100644 index 0000000..5b48209 --- /dev/null +++ b/learning_orchestra_client/transform/scikitlearn.py @@ -0,0 +1,14 @@ +from ._transform 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/transform/scikitlearn" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) diff --git a/learning_orchestra_client/transform/tensorflow.py b/learning_orchestra_client/transform/tensorflow.py new file mode 100644 index 0000000..692208e --- /dev/null +++ b/learning_orchestra_client/transform/tensorflow.py @@ -0,0 +1,14 @@ +from ._transform 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/transform/tensorflow" + self.__cluster_ip = cluster_ip + super().__init__(cluster_ip, self.__api_path) \ No newline at end of file diff --git a/learning_orchestra_client/util/__init__.py b/learning_orchestra_client/util/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/learning_orchestra_client/_entity_reader.py b/learning_orchestra_client/util/_entity_reader.py similarity index 100% rename from learning_orchestra_client/_entity_reader.py rename to learning_orchestra_client/util/_entity_reader.py diff --git a/learning_orchestra_client/_response_treat.py b/learning_orchestra_client/util/_response_treat.py similarity index 100% rename from learning_orchestra_client/_response_treat.py rename to learning_orchestra_client/util/_response_treat.py diff --git a/examples/sentiment_analysis.py b/pipeline/imdb.py similarity index 100% rename from examples/sentiment_analysis.py rename to pipeline/imdb.py diff --git a/examples/mnist.py b/pipeline/mnist.py similarity index 100% rename from examples/mnist.py rename to pipeline/mnist.py diff --git a/examples/titanic.py b/pipeline/titanic.py similarity index 100% rename from examples/titanic.py rename to pipeline/titanic.py From 65f7c0013ed7a35d9712ce2f47d56c0c699f75d4 Mon Sep 17 00:00:00 2001 From: riibeirogabriel Date: Sat, 15 May 2021 08:31:25 -0300 Subject: [PATCH 23/28] Finishing the refactoring --- README.md | 9 +- learning_orchestra_client/builder/builder.py | 29 +++--- learning_orchestra_client/dataset/_dataset.py | 13 +-- .../evaluate/_evaluate.py | 29 +++--- .../evaluate/scikitlearn.py | 6 -- .../evaluate/tensorflow.py | 8 +- learning_orchestra_client/explore/_explore.py | 88 ++++++++++++------- .../explore/histogram.py | 17 ++-- .../explore/scikitlearn.py | 10 +-- .../explore/tensorflow.py | 12 +-- learning_orchestra_client/function/python.py | 53 ++++++----- learning_orchestra_client/model/_model.py | 28 +++--- .../model/scikitlearn.py | 1 - learning_orchestra_client/model/tensorflow.py | 1 - learning_orchestra_client/observe/observe.py | 41 +++++---- learning_orchestra_client/predict/_predict.py | 31 ++++--- .../predict/scikitlearn.py | 6 -- .../predict/tensorflow.py | 6 -- learning_orchestra_client/train/_train.py | 18 ++-- .../transform/_transform.py | 74 +++++++++------- .../transform/data_type.py | 50 ++++++----- .../transform/projection.py | 38 ++++---- .../transform/scikitlearn.py | 10 +-- .../transform/tensorflow.py | 12 +-- .../util/_entity_reader.py | 14 ++- .../util/_response_treat.py | 1 + pipeline/mnist.py | 1 - 27 files changed, 316 insertions(+), 290 deletions(-) diff --git a/README.md b/README.md index fb76e03..b012e27 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,14 @@ pip install learning-orchestra-client # Usage -Each functionality in learningOrchestra is contained in its own class. Check the [python client docs](https://learningorchestra.github.io/pythonClient/) for all the available. +Each interoperable REST API service described in Learning Orchestra is translated +into Python. Details at [python client docs](https://learningorchestra.github.io/pythonClient/). +Furthermore, some extra method calls are included into Python client API to simplify +even more the Machine Learning services. For instance, the REST API is asynchronous, +except for GET HTTP requests, but the Python client enables also the synchronous API calls. +The wait API method, useful to receive notifications from ML pipes, is another important +example to ilustrate an extension of the original REST API. + # Example diff --git a/learning_orchestra_client/builder/builder.py b/learning_orchestra_client/builder/builder.py index 9b9d819..5d8fc86 100644 --- a/learning_orchestra_client/builder/builder.py +++ b/learning_orchestra_client/builder/builder.py @@ -1,4 +1,4 @@ -from learning_orchestra_client.observe import Observer +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 @@ -27,9 +27,10 @@ def run_spark_ml_sync(self, 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. + 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. @@ -62,9 +63,10 @@ def run_spark_ml_async(self, 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. + 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. @@ -120,9 +122,9 @@ def search_builder_register_predictions(self, 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. + 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( @@ -171,17 +173,16 @@ def delete_builder(self, builder_name: str, pretty_response: bool = False) \ return self.__response_treat.treatment(response, pretty_response) - def wait(self, dataset_name: str, timeout: str) -> dict: + 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. The -1 value - waits until the builder finishes. + 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) - diff --git a/learning_orchestra_client/dataset/_dataset.py b/learning_orchestra_client/dataset/_dataset.py index 70567c8..a8a3a8f 100644 --- a/learning_orchestra_client/dataset/_dataset.py +++ b/learning_orchestra_client/dataset/_dataset.py @@ -1,4 +1,4 @@ -from ..observe import Observer +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 @@ -59,7 +59,8 @@ def insert_dataset_async(self, 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). + proceed future checks to verify if the dataset is inserted - using wait + method). """ request_body = {self.__DATASET_NAME: dataset_name, self.__URL: url} @@ -122,7 +123,7 @@ def search_dataset_content(self, 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 + 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. """ @@ -132,14 +133,14 @@ def search_dataset_content(self, return self.__response_treat.treatment(response, pretty_response) - def wait(self, dataset_name: str, timeout: str) -> dict: + 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. The -1 value - waits until the download finishes. + 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 diff --git a/learning_orchestra_client/evaluate/_evaluate.py b/learning_orchestra_client/evaluate/_evaluate.py index 8abf440..f00f478 100644 --- a/learning_orchestra_client/evaluate/_evaluate.py +++ b/learning_orchestra_client/evaluate/_evaluate.py @@ -1,4 +1,4 @@ -from ..observe import Observer +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 @@ -93,8 +93,8 @@ def create_evaluate_async(self, 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. + 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. @@ -107,12 +107,12 @@ def search_all_evaluates(self, pretty_response: bool = False) \ 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, pca, tune - and so forth), it cannot be deleted. + 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. @@ -144,7 +144,7 @@ def search_evaluate_content(self, 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 + 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. """ @@ -154,14 +154,15 @@ def search_evaluate_content(self, return self.__response_treat.treatment(response, pretty_response) - def wait(self, name: str, timeout: str) -> dict: + 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. + 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. The -1 value - waits until the evaluation finishes. + 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 diff --git a/learning_orchestra_client/evaluate/scikitlearn.py b/learning_orchestra_client/evaluate/scikitlearn.py index e878692..cb9d79a 100644 --- a/learning_orchestra_client/evaluate/scikitlearn.py +++ b/learning_orchestra_client/evaluate/scikitlearn.py @@ -2,12 +2,6 @@ class EvaluateScikitLearn(Evaluate): - __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/evaluate/scikitlearn" self.__cluster_ip = cluster_ip diff --git a/learning_orchestra_client/evaluate/tensorflow.py b/learning_orchestra_client/evaluate/tensorflow.py index 0464267..940d2fc 100644 --- a/learning_orchestra_client/evaluate/tensorflow.py +++ b/learning_orchestra_client/evaluate/tensorflow.py @@ -2,13 +2,7 @@ class EvaluateTensorflow(Evaluate): - __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/evaluate/tensorflow" self.__cluster_ip = cluster_ip - super().__init__(cluster_ip, self.__api_path) \ No newline at end of file + super().__init__(cluster_ip, self.__api_path) diff --git a/learning_orchestra_client/explore/_explore.py b/learning_orchestra_client/explore/_explore.py index 3efe338..6dce7e8 100644 --- a/learning_orchestra_client/explore/_explore.py +++ b/learning_orchestra_client/explore/_explore.py @@ -1,4 +1,4 @@ -from ..observe import Observer +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 @@ -21,13 +21,13 @@ def __init__(self, cluster_ip: str, api_path: str): 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) -> \ + 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 @@ -57,16 +57,17 @@ def create_explore_sync(self, 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) -> \ + 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 + 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. @@ -93,8 +94,8 @@ def create_explore_async(self, 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. + 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. @@ -110,9 +111,9 @@ def delete_explore(self, name: str, pretty_response=False) \ 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, pca, tune - and so forth), it cannot be deleted. + 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. @@ -127,17 +128,17 @@ def delete_explore(self, name: str, pretty_response=False) \ return self.__response_treat.treatment(response, pretty_response) def search_explore_image(self, - name: str, - pretty_response: bool = False) \ + 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 model. + name: Is the name of the explore instance. - return An URL with a link for an image or an error if there + return: An URL with a link for an image or an error if there is no such result. """ @@ -146,16 +147,37 @@ def search_explore_image(self, return self.__response_treat.treatment(response, pretty_response) - def wait(self, name: str, timeout: str) -> dict: + 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. + 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. The -1 value - waits until the explore finishes. + 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: 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) diff --git a/learning_orchestra_client/explore/histogram.py b/learning_orchestra_client/explore/histogram.py index 25018b5..50b85f5 100644 --- a/learning_orchestra_client/explore/histogram.py +++ b/learning_orchestra_client/explore/histogram.py @@ -1,4 +1,4 @@ -from ..observe import Observer +from learning_orchestra_client.observe.observe import Observer from learning_orchestra_client.util._response_treat import ResponseTreat import requests from typing import Union @@ -58,8 +58,8 @@ def run_histogram_async(self, -> 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. + 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. @@ -143,16 +143,17 @@ def delete_histogram(self, histogram_name: str, return self.__response_treat.treatment(response, pretty_response) - def wait(self, name: str, timeout: str) -> dict: + 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. + 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. The -1 value - waits until the histogram finishes. + 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) \ No newline at end of file + return self.__observer.wait(name, timeout) diff --git a/learning_orchestra_client/explore/scikitlearn.py b/learning_orchestra_client/explore/scikitlearn.py index 4445fd6..04e201d 100644 --- a/learning_orchestra_client/explore/scikitlearn.py +++ b/learning_orchestra_client/explore/scikitlearn.py @@ -1,13 +1,7 @@ -from ._explore import Evaluate +from ._explore import Explore -class EvaluateScikitLearn(Evaluate): - __PARENT_NAME_FIELD = "parentName" - __METHOD_NAME_FIELD = "method" - __ClASS_PARAMETERS_FIELD = "methodParameters" - __NAME_FIELD = "name" - __DESCRIPTION_FIELD = "description" - +class ExploreScikitLearn(Explore): def __init__(self, cluster_ip: str): self.__api_path = "/api/learningOrchestra/v1/explore/scikitlearn" self.__cluster_ip = cluster_ip diff --git a/learning_orchestra_client/explore/tensorflow.py b/learning_orchestra_client/explore/tensorflow.py index 3c8cf28..e13a0c3 100644 --- a/learning_orchestra_client/explore/tensorflow.py +++ b/learning_orchestra_client/explore/tensorflow.py @@ -1,14 +1,8 @@ -from ._explore import Evaluate +from ._explore import Explore -class EvaluateTensorflow(Evaluate): - __PARENT_NAME_FIELD = "parentName" - __METHOD_NAME_FIELD = "method" - __ClASS_PARAMETERS_FIELD = "methodParameters" - __NAME_FIELD = "name" - __DESCRIPTION_FIELD = "description" - +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) \ No newline at end of file + super().__init__(cluster_ip, self.__api_path) diff --git a/learning_orchestra_client/function/python.py b/learning_orchestra_client/function/python.py index 77d813e..64e6f3a 100644 --- a/learning_orchestra_client/function/python.py +++ b/learning_orchestra_client/function/python.py @@ -1,4 +1,4 @@ -from ..observe import Observer +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 @@ -26,14 +26,18 @@ def run_function_sync(self, 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). + 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. + return: A JSON object with an error or warning message or the correct + operation result. """ request_body = { self.__NAME_FIELD: name, @@ -53,17 +57,20 @@ def run_function_async(self, 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. + """ + 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. + return: A JSON object with an error or warning message or the correct + operation result. """ request_body = { self.__NAME_FIELD: name, @@ -79,13 +86,13 @@ def run_function_async(self, 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. + 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. + 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) @@ -119,7 +126,8 @@ def search_execution_content(self, -> Union[dict, str]: """ description: This method is responsible for retrieving the function - results, including metadata. A function is executed many times, using different parameters, + results, including metadata. A function is executed many times, using + different parameters, thus many results are stored in Learning Orchestra. @@ -130,7 +138,8 @@ def search_execution_content(self, 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 + 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. """ @@ -140,14 +149,14 @@ def search_execution_content(self, return self.__response_treat.treatment(response, pretty_response) - def wait(self, dataset_name: str, timeout: str) -> dict: + 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. The -1 value - waits until the function finishes. + 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 diff --git a/learning_orchestra_client/model/_model.py b/learning_orchestra_client/model/_model.py index 2f4d5d6..f031149 100644 --- a/learning_orchestra_client/model/_model.py +++ b/learning_orchestra_client/model/_model.py @@ -1,4 +1,4 @@ -from ..observe import Observer +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 @@ -32,8 +32,10 @@ def create_model_sync(self, 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 + 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. @@ -60,14 +62,16 @@ def create_model_async(self, 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 + 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 + 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. @@ -119,9 +123,7 @@ def delete_model(self, name: str, pretty_response=False) \ response = requests.delete(request_url) return self.__response_treat.treatment(response, pretty_response) - def search_model(self, - name: str, - pretty_response: bool = False) \ + def search_model(self, name: str, pretty_response: bool = False) \ -> Union[dict, str]: """ description: This method retrieves a model metadata, i.e., it does @@ -139,14 +141,14 @@ def search_model(self, return self.__response_treat.treatment(response, pretty_response) - def wait(self, name: str, timeout: str) -> dict: + 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. The -1 value - waits until the creation finishes. + 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 diff --git a/learning_orchestra_client/model/scikitlearn.py b/learning_orchestra_client/model/scikitlearn.py index 4f9e0cf..6e03d06 100644 --- a/learning_orchestra_client/model/scikitlearn.py +++ b/learning_orchestra_client/model/scikitlearn.py @@ -2,7 +2,6 @@ class ModelScikitLearn(Model): - def __init__(self, cluster_ip: str): self.__api_path = "/api/learningOrchestra/v1/model/scikitlearn" self.__cluster_ip = cluster_ip diff --git a/learning_orchestra_client/model/tensorflow.py b/learning_orchestra_client/model/tensorflow.py index bf90d3a..d6828e4 100644 --- a/learning_orchestra_client/model/tensorflow.py +++ b/learning_orchestra_client/model/tensorflow.py @@ -2,7 +2,6 @@ class ModelTensorflow(Model): - def __init__(self, cluster_ip: str): self.__api_path = "/api/learningOrchestra/v1/model/tensorflow" self.__cluster_ip = cluster_ip diff --git a/learning_orchestra_client/observe/observe.py b/learning_orchestra_client/observe/observe.py index fe39bc3..08e3ca7 100644 --- a/learning_orchestra_client/observe/observe.py +++ b/learning_orchestra_client/observe/observe.py @@ -1,41 +1,37 @@ from pymongo import MongoClient, change_stream -import logging class Observer: - def __init__(self, cluster_ip: str): + __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 - #aqui deve ter duas threads sempre. uma com mongo e outra q dorme por timeout - #segundos e depois verifica se a thread mongo acabou. caso não, esta a mata e - #retorna que a task ainda nao acabou - def wait(self, name: str, timeout: str, pretty_response: bool = False) -> dict: + 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 + 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 + 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 is None: - logging.warning("Dataset name or dataset URL invalid") - return {} - if dataset_metadata["finished"]: return dataset_metadata @@ -50,19 +46,25 @@ def wait(self, name: str, timeout: str, pretty_response: bool = False) -> dict: ] return dataset_collection.watch( observer_query, - full_document='updateLookup').next()['fullDocument'] + full_document='updateLookup', + max_await_time_ms=timeout * self.__TIMEOUT_TIME_MULTIPLICATION + ).next()['fullDocument'] - def observe_pipe(self, name: str) -> \ + 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 + (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 + + :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. + :return: A pymongo CollectionChangeStream object. You must use the + builtin next() method to iterate over changes. """ observer_query = [ @@ -78,4 +80,5 @@ def observe_pipe(self, name: str) -> \ ] return self.__database[name].watch( observer_query, + max_await_time_ms=timeout * self.__TIMEOUT_TIME_MULTIPLICATION, full_document='updateLookup') diff --git a/learning_orchestra_client/predict/_predict.py b/learning_orchestra_client/predict/_predict.py index 0c5591e..528fad7 100644 --- a/learning_orchestra_client/predict/_predict.py +++ b/learning_orchestra_client/predict/_predict.py @@ -1,4 +1,4 @@ -from ..observe import Observer +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 @@ -36,7 +36,8 @@ def create_prediction_sync(self, 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) + 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 @@ -73,7 +74,8 @@ def create_prediction_async(self, 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) + 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 @@ -95,8 +97,8 @@ def create_prediction_async(self, 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. + 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. @@ -133,8 +135,8 @@ def search_prediction_content(self, 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 + 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 @@ -143,23 +145,24 @@ def search_prediction_content(self, 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. + 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: str) -> dict: + 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. + 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. The -1 value - waits until the prediction finishes. + 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 diff --git a/learning_orchestra_client/predict/scikitlearn.py b/learning_orchestra_client/predict/scikitlearn.py index a25ea66..6d367a4 100644 --- a/learning_orchestra_client/predict/scikitlearn.py +++ b/learning_orchestra_client/predict/scikitlearn.py @@ -2,12 +2,6 @@ class PredictScikitLearn(Predict): - __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/predict/scikitlearn" self.__cluster_ip = cluster_ip diff --git a/learning_orchestra_client/predict/tensorflow.py b/learning_orchestra_client/predict/tensorflow.py index 960e06a..cde1a69 100644 --- a/learning_orchestra_client/predict/tensorflow.py +++ b/learning_orchestra_client/predict/tensorflow.py @@ -2,12 +2,6 @@ class PredictTensorflow(Predict): - __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/predict/tensorflow" self.__cluster_ip = cluster_ip diff --git a/learning_orchestra_client/train/_train.py b/learning_orchestra_client/train/_train.py index 069acba..ed3d7b7 100644 --- a/learning_orchestra_client/train/_train.py +++ b/learning_orchestra_client/train/_train.py @@ -1,4 +1,4 @@ -from ..observe import Observer +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 @@ -22,7 +22,7 @@ def __init__(self, cluster_ip: str, api_path: str): def create_training_sync(self, name: str, - model_name:str, + model_name: str, parent_name: str, method_name: str, parameters: dict, @@ -35,7 +35,8 @@ def create_training_sync(self, 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) + 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 @@ -72,7 +73,8 @@ def create_training_async(self, 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) + 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 @@ -142,7 +144,7 @@ def search_training_content(self, 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 + 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. """ @@ -151,14 +153,14 @@ def search_training_content(self, return self.__response_treat.treatment(response, pretty_response) - def wait(self, name: str, timeout: str) -> dict: + 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. The -1 value - waits until the train finishes. + 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 diff --git a/learning_orchestra_client/transform/_transform.py b/learning_orchestra_client/transform/_transform.py index 40e3f41..dadf909 100644 --- a/learning_orchestra_client/transform/_transform.py +++ b/learning_orchestra_client/transform/_transform.py @@ -1,4 +1,4 @@ -from ..observe import Observer +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 @@ -21,21 +21,23 @@ def __init__(self, cluster_ip: str, api_path: str): 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) -> \ + 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 + 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) + 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 @@ -57,22 +59,24 @@ def create_transform_sync(self, 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) -> \ + 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 + 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) + 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 @@ -125,15 +129,16 @@ def delete_transform(self, name: str, pretty_response=False) \ 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) \ + 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 + 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 @@ -142,23 +147,24 @@ def search_transform_content(self, 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. + 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: str) -> dict: + 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. + 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. The -1 value - waits until the transformation finishes. + 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 diff --git a/learning_orchestra_client/transform/data_type.py b/learning_orchestra_client/transform/data_type.py index 52e3876..1be4dfe 100644 --- a/learning_orchestra_client/transform/data_type.py +++ b/learning_orchestra_client/transform/data_type.py @@ -1,6 +1,6 @@ from learning_orchestra_client.util._response_treat import ResponseTreat from learning_orchestra_client.util._entity_reader import EntityReader -from ..observe import Observer +from learning_orchestra_client.observe.observe import Observer import requests from typing import Union @@ -18,18 +18,20 @@ def __init__(self, cluster_ip: str): self.__observer = Observer(self.__cluster_ip) def update_dataset_type_sync(self, - dataset_name: str, - types: dict, - pretty_response: bool = False) \ + 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. + 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. + return: A JSON object with error or warning messages or a correct + datatype result. """ url_request = self.__service_url body_request = { @@ -43,20 +45,21 @@ def update_dataset_type_sync(self, return self.__response_treat.treatment(response, pretty_response) def update_dataset_type_async(self, - dataset_name: str, - types: dict, - pretty_response: bool = False) \ + 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. + 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. + return: A JSON object with error or warning messages or a correct + datatype result. """ url_request = self.__service_url body_request = { @@ -118,25 +121,26 @@ def search_datatype_content(self, 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. + 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: str) -> dict: + 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. + 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. The -1 value - waits until the datatype operation finishes. + 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) \ No newline at end of file + return self.__observer.wait(dataset_name, timeout) diff --git a/learning_orchestra_client/transform/projection.py b/learning_orchestra_client/transform/projection.py index 2d4d1f3..b4bb8d1 100644 --- a/learning_orchestra_client/transform/projection.py +++ b/learning_orchestra_client/transform/projection.py @@ -1,5 +1,5 @@ from learning_orchestra_client.util._response_treat import ResponseTreat -from ..observe import Observer +from learning_orchestra_client.observe.observe import Observer from learning_orchestra_client.util._entity_reader import EntityReader import requests from typing import Union @@ -58,9 +58,9 @@ def remove_dataset_attributes_async(self, -> 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. + 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. @@ -69,7 +69,8 @@ def remove_dataset_attributes_async(self, 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. + success, it returns the projection URL to be obtained latter with a + wait method call. """ request_body = { @@ -85,8 +86,8 @@ def remove_dataset_attributes_async(self, 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. + 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. @@ -97,11 +98,11 @@ def search_all_projections(self, pretty_response: bool = False) \ 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) \ + 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 @@ -125,7 +126,7 @@ def search_projection_content(self, return self.__response_treat.treatment(response, pretty_response) def delete_projection(self, projection_name: str, - pretty_response: bool = False) \ + pretty_response: bool = False) \ -> Union[dict, str]: """ description: This method is responsible for deleting a projection. @@ -145,16 +146,17 @@ def delete_projection(self, projection_name: str, return self.__response_treat.treatment(response, pretty_response) - def wait(self, projection_name: str, timeout: str) -> dict: + 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. + 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. The -1 value - waits until the projection operation finishes. + 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) \ No newline at end of file + return self.__observer.wait(projection_name, timeout) diff --git a/learning_orchestra_client/transform/scikitlearn.py b/learning_orchestra_client/transform/scikitlearn.py index 5b48209..dc38665 100644 --- a/learning_orchestra_client/transform/scikitlearn.py +++ b/learning_orchestra_client/transform/scikitlearn.py @@ -1,13 +1,7 @@ -from ._transform import Train +from ._transform import Transform -class TrainScikitLearn(Train): - __PARENT_NAME_FIELD = "parentName" - __METHOD_NAME_FIELD = "method" - __ClASS_PARAMETERS_FIELD = "methodParameters" - __NAME_FIELD = "name" - __DESCRIPTION_FIELD = "description" - +class TransformScikitLearn(Transform): def __init__(self, cluster_ip: str): self.__api_path = "/api/learningOrchestra/v1/transform/scikitlearn" self.__cluster_ip = cluster_ip diff --git a/learning_orchestra_client/transform/tensorflow.py b/learning_orchestra_client/transform/tensorflow.py index 692208e..b3ed5db 100644 --- a/learning_orchestra_client/transform/tensorflow.py +++ b/learning_orchestra_client/transform/tensorflow.py @@ -1,14 +1,8 @@ -from ._transform import Train +from ._transform import Transform -class TrainTensorflow(Train): - __PARENT_NAME_FIELD = "parentName" - __METHOD_NAME_FIELD = "method" - __ClASS_PARAMETERS_FIELD = "methodParameters" - __NAME_FIELD = "name" - __DESCRIPTION_FIELD = "description" - +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) \ No newline at end of file + super().__init__(cluster_ip, self.__api_path) diff --git a/learning_orchestra_client/util/_entity_reader.py b/learning_orchestra_client/util/_entity_reader.py index 1154d5c..9b063bf 100644 --- a/learning_orchestra_client/util/_entity_reader.py +++ b/learning_orchestra_client/util/_entity_reader.py @@ -24,4 +24,16 @@ def read_entity_content(self, f'?query={query}&limit={limit}&skip={skip}' response = requests.get(request_url) - return response \ No newline at end of file + 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 diff --git a/learning_orchestra_client/util/_response_treat.py b/learning_orchestra_client/util/_response_treat.py index 83bb78e..7400e6c 100644 --- a/learning_orchestra_client/util/_response_treat.py +++ b/learning_orchestra_client/util/_response_treat.py @@ -3,6 +3,7 @@ import logging from typing import Union + class ResponseTreat: HTTP_CREATED = 201 HTTP_SUCCESS = 200 diff --git a/pipeline/mnist.py b/pipeline/mnist.py index 0103a61..b097480 100644 --- a/pipeline/mnist.py +++ b/pipeline/mnist.py @@ -245,7 +245,6 @@ def treat_dataset(dataset: dict) -> tuple: code=show_mnist_predict ) - show_mnist_evaluate = ''' print(mnist_evaluated) response = None From cd6d946f18f8e284a7ac302a4f777d1e2bc37b34 Mon Sep 17 00:00:00 2001 From: riibeirogabriel Date: Sat, 15 May 2021 08:31:55 -0300 Subject: [PATCH 24/28] fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b012e27..89cd9d8 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Furthermore, some extra method calls are included into Python client API to simp even more the Machine Learning services. For instance, the REST API is asynchronous, except for GET HTTP requests, but the Python client enables also the synchronous API calls. The wait API method, useful to receive notifications from ML pipes, is another important -example to ilustrate an extension of the original REST API. +example to illustrate an extension of the original REST API. # Example From f80dbdf609320ffcb87d4675b9755f448dfadb40 Mon Sep 17 00:00:00 2001 From: riibeirogabriel Date: Sat, 15 May 2021 18:14:21 -0300 Subject: [PATCH 25/28] fixes --- learning_orchestra_client/{util => _util}/__init__.py | 0 learning_orchestra_client/{util => _util}/_entity_reader.py | 0 learning_orchestra_client/{util => _util}/_response_treat.py | 0 learning_orchestra_client/builder/builder.py | 4 ++-- learning_orchestra_client/dataset/_dataset.py | 4 ++-- learning_orchestra_client/evaluate/_evaluate.py | 4 ++-- learning_orchestra_client/explore/_explore.py | 4 ++-- learning_orchestra_client/explore/histogram.py | 4 ++-- learning_orchestra_client/function/python.py | 4 ++-- learning_orchestra_client/model/_model.py | 4 ++-- learning_orchestra_client/predict/_predict.py | 4 ++-- learning_orchestra_client/train/_train.py | 4 ++-- learning_orchestra_client/transform/_transform.py | 4 ++-- learning_orchestra_client/transform/data_type.py | 4 ++-- learning_orchestra_client/transform/projection.py | 4 ++-- 15 files changed, 24 insertions(+), 24 deletions(-) rename learning_orchestra_client/{util => _util}/__init__.py (100%) rename learning_orchestra_client/{util => _util}/_entity_reader.py (100%) rename learning_orchestra_client/{util => _util}/_response_treat.py (100%) diff --git a/learning_orchestra_client/util/__init__.py b/learning_orchestra_client/_util/__init__.py similarity index 100% rename from learning_orchestra_client/util/__init__.py rename to learning_orchestra_client/_util/__init__.py diff --git a/learning_orchestra_client/util/_entity_reader.py b/learning_orchestra_client/_util/_entity_reader.py similarity index 100% rename from learning_orchestra_client/util/_entity_reader.py rename to learning_orchestra_client/_util/_entity_reader.py diff --git a/learning_orchestra_client/util/_response_treat.py b/learning_orchestra_client/_util/_response_treat.py similarity index 100% rename from learning_orchestra_client/util/_response_treat.py rename to learning_orchestra_client/_util/_response_treat.py diff --git a/learning_orchestra_client/builder/builder.py b/learning_orchestra_client/builder/builder.py index 5d8fc86..ae229cc 100644 --- a/learning_orchestra_client/builder/builder.py +++ b/learning_orchestra_client/builder/builder.py @@ -1,6 +1,6 @@ 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 +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union diff --git a/learning_orchestra_client/dataset/_dataset.py b/learning_orchestra_client/dataset/_dataset.py index a8a3a8f..ff01bf2 100644 --- a/learning_orchestra_client/dataset/_dataset.py +++ b/learning_orchestra_client/dataset/_dataset.py @@ -1,6 +1,6 @@ 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 +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union diff --git a/learning_orchestra_client/evaluate/_evaluate.py b/learning_orchestra_client/evaluate/_evaluate.py index f00f478..3b7a7cf 100644 --- a/learning_orchestra_client/evaluate/_evaluate.py +++ b/learning_orchestra_client/evaluate/_evaluate.py @@ -1,6 +1,6 @@ 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 +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union diff --git a/learning_orchestra_client/explore/_explore.py b/learning_orchestra_client/explore/_explore.py index 6dce7e8..0a9ceb1 100644 --- a/learning_orchestra_client/explore/_explore.py +++ b/learning_orchestra_client/explore/_explore.py @@ -1,6 +1,6 @@ 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 +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union diff --git a/learning_orchestra_client/explore/histogram.py b/learning_orchestra_client/explore/histogram.py index 50b85f5..ff42b04 100644 --- a/learning_orchestra_client/explore/histogram.py +++ b/learning_orchestra_client/explore/histogram.py @@ -1,8 +1,8 @@ from learning_orchestra_client.observe.observe import Observer -from learning_orchestra_client.util._response_treat import ResponseTreat +from learning_orchestra_client._util._response_treat import ResponseTreat import requests from typing import Union -from learning_orchestra_client.util._entity_reader import EntityReader +from learning_orchestra_client._util._entity_reader import EntityReader class ExploreHistogram: diff --git a/learning_orchestra_client/function/python.py b/learning_orchestra_client/function/python.py index 64e6f3a..b51df30 100644 --- a/learning_orchestra_client/function/python.py +++ b/learning_orchestra_client/function/python.py @@ -1,6 +1,6 @@ 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 +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union diff --git a/learning_orchestra_client/model/_model.py b/learning_orchestra_client/model/_model.py index f031149..a9a79fd 100644 --- a/learning_orchestra_client/model/_model.py +++ b/learning_orchestra_client/model/_model.py @@ -1,6 +1,6 @@ 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 +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union diff --git a/learning_orchestra_client/predict/_predict.py b/learning_orchestra_client/predict/_predict.py index 528fad7..33a46ac 100644 --- a/learning_orchestra_client/predict/_predict.py +++ b/learning_orchestra_client/predict/_predict.py @@ -1,6 +1,6 @@ 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 +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union diff --git a/learning_orchestra_client/train/_train.py b/learning_orchestra_client/train/_train.py index ed3d7b7..f8fd2f0 100644 --- a/learning_orchestra_client/train/_train.py +++ b/learning_orchestra_client/train/_train.py @@ -1,6 +1,6 @@ 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 +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union diff --git a/learning_orchestra_client/transform/_transform.py b/learning_orchestra_client/transform/_transform.py index dadf909..46aeb47 100644 --- a/learning_orchestra_client/transform/_transform.py +++ b/learning_orchestra_client/transform/_transform.py @@ -1,6 +1,6 @@ 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 +from learning_orchestra_client._util._response_treat import ResponseTreat +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union diff --git a/learning_orchestra_client/transform/data_type.py b/learning_orchestra_client/transform/data_type.py index 1be4dfe..6fb9f67 100644 --- a/learning_orchestra_client/transform/data_type.py +++ b/learning_orchestra_client/transform/data_type.py @@ -1,5 +1,5 @@ -from learning_orchestra_client.util._response_treat import ResponseTreat -from learning_orchestra_client.util._entity_reader import EntityReader +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 diff --git a/learning_orchestra_client/transform/projection.py b/learning_orchestra_client/transform/projection.py index b4bb8d1..5c02de5 100644 --- a/learning_orchestra_client/transform/projection.py +++ b/learning_orchestra_client/transform/projection.py @@ -1,6 +1,6 @@ -from learning_orchestra_client.util._response_treat import ResponseTreat +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 +from learning_orchestra_client._util._entity_reader import EntityReader import requests from typing import Union From e265d8e1191d1052aa15927a4c1ca14b3283e36c Mon Sep 17 00:00:00 2001 From: riibeirogabriel Date: Sat, 15 May 2021 18:17:17 -0300 Subject: [PATCH 26/28] updating branch --- docs/index.html | 386 ++++--- docs/learning_orchestra_client.html | 203 +++- docs/learning_orchestra_client/builder.html | 1020 ++++------------- docs/learning_orchestra_client/dataset.html | 203 +++- .../dataset/_dataset.html | 334 +++++- .../dataset/csv.html | 207 +++- .../dataset/generic.html | 207 +++- docs/learning_orchestra_client/evaluate.html | 203 +++- .../evaluate/_evaluate.html | 470 ++++++-- .../evaluate/scikitlearn.html | 219 +++- .../evaluate/tensorflow.html | 219 +++- docs/learning_orchestra_client/explore.html | 205 +++- .../explore/histogram.html | 396 +++++-- docs/learning_orchestra_client/function.html | 203 +++- .../function/python.html | 576 +++++++--- docs/learning_orchestra_client/model.html | 203 +++- .../model/_model.html | 568 ++++++--- .../model/scikitlearn.html | 211 +++- .../model/tensorflow.html | 211 +++- docs/learning_orchestra_client/predict.html | 203 +++- .../predict/_predict.html | 515 ++++++--- .../predict/scikitlearn.html | 219 +++- .../predict/tensorflow.html | 219 +++- docs/learning_orchestra_client/train.html | 203 +++- .../train/_train.html | 514 ++++++--- .../train/scikitlearn.html | 207 +++- .../train/tensorflow.html | 207 +++- docs/learning_orchestra_client/transform.html | 205 +++- .../transform/data_type.html | 675 +++++++++-- .../transform/projection.html | 497 +++++--- 30 files changed, 7767 insertions(+), 2141 deletions(-) diff --git a/docs/index.html b/docs/index.html index 86cca31..0b7bc20 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3,157 +3,277 @@ - - module list – pdoc 6.4.2 + + Module List – pdoc 7.0.0 - - - + + + + + + +
      + + pdoc logo + + +
      +
      +
      + + - + + if (getSearchTerm()) { + initialize(); + searchBox.value = getSearchTerm(); + onInput(); + } else { + searchBox.addEventListener("focus", initialize, {once: true}); + } + + searchBox.addEventListener("keydown", e => { + if (["ArrowDown", "ArrowUp", "Enter"].includes(e.key)) { + let focused = currentContent.querySelector(".search-result.focused"); + if (!focused) { + currentContent.querySelector(".search-result").classList.add("focused"); + } else if ( + e.key === "ArrowDown" + && focused.nextElementSibling + && focused.nextElementSibling.classList.contains("search-result") + ) { + focused.classList.remove("focused"); + focused.nextElementSibling.classList.add("focused"); + focused.nextElementSibling.scrollIntoView({ + behavior: "smooth", + block: "nearest", + inline: "nearest" + }); + } else if ( + e.key === "ArrowUp" + && focused.previousElementSibling + && focused.previousElementSibling.classList.contains("search-result") + ) { + focused.classList.remove("focused"); + focused.previousElementSibling.classList.add("focused"); + focused.previousElementSibling.scrollIntoView({ + behavior: "smooth", + block: "nearest", + inline: "nearest" + }); + } else if ( + e.key === "Enter" + ) { + focused.querySelector("a").click(); + } + } + }); + \ No newline at end of file diff --git a/docs/learning_orchestra_client.html b/docs/learning_orchestra_client.html index 742f7e4..cdcbec4 100644 --- a/docs/learning_orchestra_client.html +++ b/docs/learning_orchestra_client.html @@ -3,14 +3,14 @@ - + learning_orchestra_client API documentation - - - + + +

    + + \ No newline at end of file diff --git a/docs/learning_orchestra_client/builder.html b/docs/learning_orchestra_client/builder.html index 636bdfd..e00059d 100644 --- a/docs/learning_orchestra_client/builder.html +++ b/docs/learning_orchestra_client/builder.html @@ -3,14 +3,14 @@ - + learning_orchestra_client.builder API documentation - - - + + +

    -
    - View Source -
    from .observer import Observer
    -from ._response_treat import ResponseTreat
    -from ._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 resource join several steps of machine
    -        learning workflow (transform, tune, train and evaluate) coupling in
    -        a unique resource, builder creates several model predictions using
    -        your own modeling code using a defined set of classifiers. This is made
    -        synchronously, the caller waits until the model predictions are inserted
    -        into the Learning Orchestra storage mechanism.
    -
    -        train_dataset_name: Represent final train dataset.
    -        test_dataset_name: Represent final test dataset.
    -        modeling_code: Represent Python3 code for pyspark preprocessing model
    -        model_classifiers: list of initial classifiers to be used in model
    -        pretty_response: returns indented string for visualization if True
    -
    -        return: The resulted predictions URIs.
    -        """
    -
    -        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 resource join several steps of machine
    -        learning workflow (transform, tune, train and evaluate) coupling in
    -        a unique resource, builder creates several model predictions using
    -        your own modeling code using a defined set of classifiers. This is made
    -        asynchronously, the caller does not wait until the model predictions are
    -        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 model predictions are inserted.
    -
    -        train_dataset_name: Represent final train dataset.
    -        test_dataset_name: Represent final test dataset.
    -        modeling_code: Represent Python3 code for pyspark preprocessing model
    -        model_classifiers: list of initial classifiers to be used in model
    -        pretty_response: returns indented string for visualization if True
    -
    -        return: The resulted predictions URIs.
    -        """
    -
    -        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 return indented string, else return dict.
    -
    -        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 return indented string, else return dict.
    -        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 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(
    -            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 prediction 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 synchronous because it is very fast,
    -        since the deletion is performed in background.
    -
    -        pretty_response: If true return indented string, else return dict.
    -        builder_name: Represents the projection 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) -> dict:
    -        return self.__observer.wait(dataset_name)
    -
    - -
    - +

-
-
- #   - - - class - BuilderSparkMl: -
- -
- View Source -
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 resource join several steps of machine
-        learning workflow (transform, tune, train and evaluate) coupling in
-        a unique resource, builder creates several model predictions using
-        your own modeling code using a defined set of classifiers. This is made
-        synchronously, the caller waits until the model predictions are inserted
-        into the Learning Orchestra storage mechanism.
-
-        train_dataset_name: Represent final train dataset.
-        test_dataset_name: Represent final test dataset.
-        modeling_code: Represent Python3 code for pyspark preprocessing model
-        model_classifiers: list of initial classifiers to be used in model
-        pretty_response: returns indented string for visualization if True
-
-        return: The resulted predictions URIs.
-        """
-
-        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 resource join several steps of machine
-        learning workflow (transform, tune, train and evaluate) coupling in
-        a unique resource, builder creates several model predictions using
-        your own modeling code using a defined set of classifiers. This is made
-        asynchronously, the caller does not wait until the model predictions are
-        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 model predictions are inserted.
-
-        train_dataset_name: Represent final train dataset.
-        test_dataset_name: Represent final test dataset.
-        modeling_code: Represent Python3 code for pyspark preprocessing model
-        model_classifiers: list of initial classifiers to be used in model
-        pretty_response: returns indented string for visualization if True
-
-        return: The resulted predictions URIs.
-        """
-
-        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 return indented string, else return dict.
-
-        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 return indented string, else return dict.
-        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 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(
-            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 prediction 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 synchronous because it is very fast,
-        since the deletion is performed in background.
-
-        pretty_response: If true return indented string, else return dict.
-        builder_name: Represents the projection 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) -> dict:
-        return self.__observer.wait(dataset_name)
-
- -
- - - -
-
#   - - - BuilderSparkMl(cluster_ip: str) -
- -
- View Source -
    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]: -
- -
- View Source -
    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 resource join several steps of machine
-        learning workflow (transform, tune, train and evaluate) coupling in
-        a unique resource, builder creates several model predictions using
-        your own modeling code using a defined set of classifiers. This is made
-        synchronously, the caller waits until the model predictions are inserted
-        into the Learning Orchestra storage mechanism.
-
-        train_dataset_name: Represent final train dataset.
-        test_dataset_name: Represent final test dataset.
-        modeling_code: Represent Python3 code for pyspark preprocessing model
-        model_classifiers: list of initial classifiers to be used in model
-        pretty_response: returns indented string for visualization if True
-
-        return: The resulted predictions URIs.
-        """
-
-        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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -synchronously, the caller waits until the model predictions are inserted -into the Learning Orchestra storage mechanism.

- -

train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

- -

return: The resulted predictions URIs.

-
- - -
-
-
#   - - - 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]: -
- -
- View Source -
    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 resource join several steps of machine
-        learning workflow (transform, tune, train and evaluate) coupling in
-        a unique resource, builder creates several model predictions using
-        your own modeling code using a defined set of classifiers. This is made
-        asynchronously, the caller does not wait until the model predictions are
-        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 model predictions are inserted.
-
-        train_dataset_name: Represent final train dataset.
-        test_dataset_name: Represent final test dataset.
-        modeling_code: Represent Python3 code for pyspark preprocessing model
-        model_classifiers: list of initial classifiers to be used in model
-        pretty_response: returns indented string for visualization if True
-
-        return: The resulted predictions URIs.
-        """
-
-        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 resource join several steps of machine -learning workflow (transform, tune, train and evaluate) coupling in -a unique resource, builder creates several model predictions using -your own modeling code using a defined set of classifiers. This is made -asynchronously, the caller does not wait until the model predictions are -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 model predictions are inserted.

- -

train_dataset_name: Represent final train dataset. -test_dataset_name: Represent final test dataset. -modeling_code: Represent Python3 code for pyspark preprocessing model -model_classifiers: list of initial classifiers to be used in model -pretty_response: returns indented string for visualization if True

- -

return: The resulted predictions URIs.

-
- - -
-
-
#   - - - def - search_all_builders(self, pretty_response: bool = False) -> Union[dict, str]: -
- -
- View Source -
    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 return indented string, else return dict.
-
-        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 return indented string, else return dict.

- -

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]: -
- -
- View Source -
    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 return indented string, else return dict.
-        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 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(
-            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 return indented string, else return dict. -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 there -is no such projection. 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]: -
- -
- View Source -
    def search_builder(self, builder_name: str, pretty_response: bool = False) \
-            -> Union[dict, str]:
-        """
-        description:  This method is responsible for retrieving a specific
-        model prediction 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 prediction 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]: -
- -
- View Source -
    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 synchronous because it is very fast,
-        since the deletion is performed in background.
-
-        pretty_response: If true return indented string, else return dict.
-        builder_name: Represents the projection 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 synchronous because it is very fast, -since the deletion is performed in background.

- -

pretty_response: If true return indented string, else return dict. -builder_name: Represents the projection name.

- -

return: JSON object with an error message, a warning message or a -correct delete message

-
- - -
-
-
#   - - - def - wait(self, dataset_name: str) -> dict: -
- -
- View Source -
    def wait(self, dataset_name: str) -> dict:
-        return self.__observer.wait(dataset_name)
-
- -
- - - -
-
+ + \ No newline at end of file diff --git a/docs/learning_orchestra_client/dataset.html b/docs/learning_orchestra_client/dataset.html index fd8fac6..b8e0f65 100644 --- a/docs/learning_orchestra_client/dataset.html +++ b/docs/learning_orchestra_client/dataset.html @@ -3,14 +3,14 @@ - + learning_orchestra_client.dataset API documentation - - - + + +

+ + \ No newline at end of file diff --git a/docs/learning_orchestra_client/dataset/_dataset.html b/docs/learning_orchestra_client/dataset/_dataset.html index 7fb1c63..55b3113 100644 --- a/docs/learning_orchestra_client/dataset/_dataset.html +++ b/docs/learning_orchestra_client/dataset/_dataset.html @@ -3,14 +3,14 @@ - + learning_orchestra_client.dataset._dataset API documentation - - - + + +