1- from . observer import Observer
2- from ._response_treat import ResponseTreat
3- from ._entity_reader import EntityReader
1+ from learning_orchestra_client . observe import Observer
2+ from learning_orchestra_client . util ._response_treat import ResponseTreat
3+ from learning_orchestra_client . util ._entity_reader import EntityReader
44import requests
55from typing import Union
66
@@ -26,20 +26,18 @@ def run_spark_ml_sync(self,
2626 model_classifiers : list ,
2727 pretty_response : bool = False ) -> Union [dict , str ]:
2828 """
29- description: This method resource join several steps of machine
30- learning workflow (transform, tune, train and evaluate) coupling in
31- a unique resource, builder creates several model predictions using
32- your own modeling code using a defined set of classifiers. This is made
33- synchronously, the caller waits until the model predictions are inserted
34- into the Learning Orchestra storage mechanism.
29+ description: This method call runs several steps of a machine
30+ learning pipeline (transform, tune, train and evaluate, for instance) using
31+ a model code and several classifiers. It represents a way to run an entire pipeline.
32+ The caller waits until the method execution ends, since it is a synchronous method.
3533
3634 train_dataset_name: Represent final train dataset.
3735 test_dataset_name: Represent final test dataset.
38- modeling_code: Represent Python3 code for pyspark preprocessing model
39- model_classifiers: list of initial classifiers to be used in model
40- pretty_response: returns indented string for visualization if True
36+ modeling_code: Represent Python3 code for pyspark pre-processing model
37+ model_classifiers: list of initial classifiers to be used in the model
38+ pretty_response: if True it represents a result useful for visualization
4139
42- return: The resulted predictions URIs.
40+ return: The set of predictions ( URIs of them) .
4341 """
4442
4543 request_body_content = {
@@ -63,22 +61,18 @@ def run_spark_ml_async(self,
6361 model_classifiers : list ,
6462 pretty_response : bool = False ) -> Union [dict , str ]:
6563 """
66- description: This method resource join several steps of machine
67- learning workflow (transform, tune, train and evaluate) coupling in
68- a unique resource, builder creates several model predictions using
69- your own modeling code using a defined set of classifiers. This is made
70- asynchronously, the caller does not wait until the model predictions are
71- inserted into the Learning Orchestra storage mechanism. Instead, the
72- caller receives a JSON object with a URL to proceed future calls to
73- verify if the model predictions are inserted.
64+ description: This method call runs several steps of a machine
65+ learning pipeline (transform, tune, train and evaluate, for instance) using
66+ a model code and several classifiers. It represents a way to run an entire pipeline.
67+ The caller does not wait until the method execution ends, since it is an asynchronous method.
7468
7569 train_dataset_name: Represent final train dataset.
7670 test_dataset_name: Represent final test dataset.
77- modeling_code: Represent Python3 code for pyspark preprocessing model
78- model_classifiers: list of initial classifiers to be used in model
79- pretty_response: returns indented string for visualization if True
71+ modeling_code: Represent Python3 code for pyspark pre-processing model
72+ model_classifiers: list of initial classifiers to be used in the model
73+ pretty_response: if True it represents a result useful for visualization
8074
81- return: The resulted predictions URIs.
75+ return: the URL to retrieve the Spark pipeline result
8276 """
8377
8478 request_body_content = {
@@ -95,10 +89,10 @@ def run_spark_ml_async(self,
9589 def search_all_builders (self , pretty_response : bool = False ) \
9690 -> Union [dict , str ]:
9791 """
98- description: This method retrieves all model predictions metadata, it
92+ description: This method retrieves all model predictions metadata. It
9993 does not retrieve the model predictions content.
10094
101- pretty_response: If true return indented string, else return dict .
95+ pretty_response: If true it returns a string, otherwise a dictionary .
10296
10397 return: A list with all model predictions metadata stored in Learning
10498 Orchestra or an empty result.
@@ -119,15 +113,15 @@ def search_builder_register_predictions(self,
119113 description: This method is responsible for retrieving the model
120114 predictions content.
121115
122- pretty_response: If true return indented string, else return dict .
116+ pretty_response: If true it returns a string, otherwise a dictionary .
123117 builder_name: Represents the model predictions name.
124118 query: Query to make in MongoDB(default: empty query)
125119 limit: Number of rows to return in pagination(default: 10) (maximum is
126120 set at 20 rows per request)
127121 skip: Number of rows to skip in pagination(default: 0)
128122
129- return: A page with some tuples or registers inside or an error if there
130- is no such projection . The current page is also returned to be used in
123+ return: A page with some tuples or registers inside or an error if the pipeline runs
124+ incorrectly . The current page is also returned to be used in
131125 future content requests.
132126 """
133127
@@ -140,7 +134,7 @@ def search_builder(self, builder_name: str, pretty_response: bool = False) \
140134 -> Union [dict , str ]:
141135 """
142136 description: This method is responsible for retrieving a specific
143- model prediction metadata.
137+ model metadata.
144138
145139 pretty_response: If true return indented string, else return dict.
146140 builder_name: Represents the model predictions name.
@@ -161,11 +155,11 @@ def delete_builder(self, builder_name: str, pretty_response: bool = False) \
161155 -> Union [dict , str ]:
162156 """
163157 description: This method is responsible for deleting a model prediction.
164- The delete operation is always synchronous because it is very fast ,
158+ The delete operation is always asynchronous ,
165159 since the deletion is performed in background.
166160
167- pretty_response: If true return indented string, else return dict .
168- builder_name: Represents the projection name.
161+ pretty_response: If true it returns a string, otherwise a dictionary .
162+ builder_name: Represents the pipeline name.
169163
170164 return: JSON object with an error message, a warning message or a
171165 correct delete message
@@ -177,5 +171,17 @@ def delete_builder(self, builder_name: str, pretty_response: bool = False) \
177171
178172 return self .__response_treat .treatment (response , pretty_response )
179173
180- def wait (self , dataset_name : str ) -> dict :
181- return self .__observer .wait (dataset_name )
174+ def wait (self , dataset_name : str , timeout : str ) -> dict :
175+ """
176+ description: This method is responsible to create a synchronization
177+ barrier for the run_spark_ml_async method.
178+
179+ dataset_name: Represents the pipeline name.
180+ timeout: Represents the time in seconds to wait for a builder to finish its run. The -1 value
181+ waits until the builder finishes.
182+
183+ return: JSON object with an error message, a warning message or a
184+ correct execution of a pipeline
185+ """
186+ return self .__observer .wait (dataset_name , timeout )
187+
0 commit comments