Skip to content

Commit 4d9fc9c

Browse files
fixes
1 parent 16af26b commit 4d9fc9c

File tree

9 files changed

+37
-85
lines changed

9 files changed

+37
-85
lines changed

learning_orchestra_client/_entity_reader.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from ._response_treat import ResponseTreat
22
import requests
3-
from typing import Union
43
from requests import Response
54

65

@@ -13,7 +12,6 @@ def read_all_instances_from_entity(self) -> Response:
1312
request_url = self.__entity_url
1413

1514
response = requests.get(request_url)
16-
response.raise_for_status()
1715
return response
1816

1917
def read_entity_content(self,
@@ -26,5 +24,4 @@ def read_entity_content(self,
2624
f'?query={query}&limit={limit}&skip={skip}'
2725

2826
response = requests.get(request_url)
29-
response.raise_for_status()
3027
return response

learning_orchestra_client/builder.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def run_spark_ml_sync(self,
5050
}
5151
response = requests.post(url=self.__service_url,
5252
json=request_body_content)
53-
response.raise_for_status()
5453

5554
for classifier in model_classifiers:
5655
self.__observer.wait(f'{test_dataset_name}{classifier}')
@@ -175,7 +174,6 @@ def delete_builder(self, builder_name: str, pretty_response: bool = False) \
175174
cluster_url_dataset = f'{self.__service_url}/{builder_name}'
176175

177176
response = requests.delete(cluster_url_dataset)
178-
response.raise_for_status()
179177

180178
return self.__response_treat.treatment(response, pretty_response)
181179

learning_orchestra_client/dataset/_dataset.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def insert_dataset_sync(self,
3737
request_url = self.__service_url
3838

3939
response = requests.post(url=request_url, json=request_body)
40-
response.raise_for_status()
4140
self.__observer.wait(dataset_name)
4241

4342
return self.__response_treat.treatment(response, pretty_response)
@@ -67,7 +66,6 @@ def insert_dataset_async(self,
6766
request_url = self.__service_url
6867

6968
response = requests.post(url=request_url, json=request_body)
70-
response.raise_for_status()
7169
return self.__response_treat.treatment(response, pretty_response)
7270

7371
def search_all_datasets(self, pretty_response: bool = False) \
@@ -102,9 +100,7 @@ def delete_dataset_async(self, dataset_name, pretty_response=False) \
102100
"""
103101

104102
request_url = f'{self.__service_url}/{dataset_name}'
105-
106103
response = requests.delete(request_url)
107-
response.raise_for_status()
108104

109105
return self.__response_treat.treatment(response, pretty_response)
110106

learning_orchestra_client/evaluate/_evaluate.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def create_evaluate_sync(self,
5050
request_url = self.__service_url
5151

5252
response = requests.post(url=request_url, json=request_body)
53-
response.raise_for_status()
5453
self.__observer.wait(name)
5554

5655
return self.__response_treat.treatment(response, pretty_response)
@@ -85,7 +84,6 @@ def create_evaluate_async(self,
8584
request_url = self.__service_url
8685

8786
response = requests.post(url=request_url, json=request_body)
88-
response.raise_for_status()
8987
return self.__response_treat.treatment(response, pretty_response)
9088

9189
def search_all_evaluates(self, pretty_response: bool = False) \
@@ -122,7 +120,6 @@ def delete_evaluate_async(self, name: str, pretty_response=False) \
122120
request_url = f'{self.__service_url}/{name}'
123121

124122
response = requests.delete(request_url)
125-
response.raise_for_status()
126123
return self.__response_treat.treatment(response, pretty_response)
127124

128125
def search_evaluate_content(self,
Lines changed: 37 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
from ..observer import Observer
22
from .._response_treat import ResponseTreat
3-
from ..dataset import Dataset
43
import requests
54
from typing import Union
5+
from .._entity_reader import EntityReader
66

77

8-
class Histogram:
9-
def __init__(self, ip_from_cluster: str):
10-
self.CLUSTER_IP = ip_from_cluster
11-
self.cluster_url = "http://" + ip_from_cluster + \
12-
"/api/learningOrchestra/v1/explore/histogram"
13-
self.response_treat = ResponseTreat()
14-
self.INPUT_NAME = "inputDatasetName"
15-
self.OUTPUT_NAME = "outputDatasetName"
16-
self.FIELDS = "names"
17-
self.dataset = Dataset(ip_from_cluster)
8+
class ExploreHistogram:
9+
__INPUT_NAME = "inputDatasetName"
10+
__OUTPUT_NAME = "outputDatasetName"
11+
__FIELDS = "names"
12+
13+
def __init__(self, cluster_ip: str):
14+
self.__cluster_ip = cluster_ip
15+
self.__api_path = "/api/learningOrchestra/v1/explore/histogram"
16+
self.__service_url = f'{cluster_ip}{self.__api_path}'
17+
self.__response_treat = ResponseTreat()
18+
self.__observer = Observer(self.__cluster_ip)
19+
self.__entity_reader = EntityReader(self.__service_url)
1820

1921
def run_histogram_sync(self,
2022
dataset_name: str,
@@ -37,28 +39,16 @@ def run_histogram_sync(self,
3739
"""
3840

3941
request_body = {
40-
self.INPUT_NAME: dataset_name,
41-
self.OUTPUT_NAME: histogram_name,
42-
self.FIELDS: fields,
42+
self.__INPUT_NAME: dataset_name,
43+
self.__OUTPUT_NAME: histogram_name,
44+
self.__FIELDS: fields,
4345
}
44-
request_url = self.cluster_url
46+
request_url = self.__service_url
4547

4648
response = requests.post(url=request_url, json=request_body)
49+
self.__observer.wait(dataset_name)
4750

48-
Observer(histogram_name, self.CLUSTER_IP).observe_processing(
49-
pretty_response)
50-
51-
if pretty_response:
52-
print(
53-
"\n----------"
54-
+ " CREATE HISTOGRAM FROM "
55-
+ dataset_name
56-
+ " TO "
57-
+ histogram_name
58-
+ " ----------"
59-
)
60-
61-
return self.response_treat.treatment(response, pretty_response)
51+
return self.__response_treat.treatment(response, pretty_response)
6252

6353
def run_histogram_async(self,
6454
dataset_name: str,
@@ -83,25 +73,15 @@ def run_histogram_async(self,
8373
"""
8474

8575
request_body = {
86-
self.INPUT_NAME: dataset_name,
87-
self.OUTPUT_NAME: histogram_name,
88-
self.FIELDS: fields,
76+
self.__INPUT_NAME: dataset_name,
77+
self.__OUTPUT_NAME: histogram_name,
78+
self.__FIELDS: fields,
8979
}
90-
request_url = self.cluster_url
80+
request_url = self.__service_url
9181

9282
response = requests.post(url=request_url, json=request_body)
9383

94-
if pretty_response:
95-
print(
96-
"\n----------"
97-
+ " CREATE HISTOGRAM FROM "
98-
+ dataset_name
99-
+ " TO "
100-
+ histogram_name
101-
+ " ----------"
102-
)
103-
104-
return self.response_treat.treatment(response, pretty_response)
84+
return self.__response_treat.treatment(response, pretty_response)
10585

10686
def search_all_histograms(self, pretty_response: bool = False) \
10787
-> Union[dict, str]:
@@ -115,18 +95,15 @@ def search_all_histograms(self, pretty_response: bool = False) \
11595
or an empty result.
11696
"""
11797

118-
cluster_url_histogram = self.cluster_url
98+
response = self.__entity_reader.read_all_instances_from_entity()
99+
return self.__response_treat.treatment(response, pretty_response)
119100

120-
response = requests.get(cluster_url_histogram)
121-
122-
return self.response_treat.treatment(response, pretty_response)
123-
124-
def search_histogram_data(self,
125-
histogram_name: str,
126-
query: dict = {},
127-
limit: int = 10,
128-
skip: int = 0,
129-
pretty_response: bool = False) \
101+
def search_histogram_content(self,
102+
histogram_name: str,
103+
query: dict = {},
104+
limit: int = 10,
105+
skip: int = 0,
106+
pretty_response: bool = False) \
130107
-> Union[dict, str]:
131108
"""
132109
description: This method is responsible for retrieving the histogram
@@ -144,14 +121,10 @@ def search_histogram_data(self,
144121
future content requests.
145122
"""
146123

147-
cluster_url_histogram = self.cluster_url + "/" + histogram_name + \
148-
"?query=" + str(query) + \
149-
"&limit=" + str(limit) + \
150-
"&skip=" + str(skip)
124+
response = self.__entity_reader.read_entity_content(
125+
histogram_name, query, limit, skip)
151126

152-
response = requests.get(cluster_url_histogram)
153-
154-
return self.response_treat.treatment(response, pretty_response)
127+
return self.__response_treat.treatment(response, pretty_response)
155128

156129
def delete_histogram(self, histogram_name: str,
157130
pretty_response: bool = False) -> Union[dict, str]:
@@ -167,8 +140,7 @@ def delete_histogram(self, histogram_name: str,
167140
correct delete message
168141
"""
169142

170-
cluster_url_histogram = self.cluster_url + "/" + histogram_name
171-
143+
cluster_url_histogram = f'{self.__service_url}/{histogram_name}'
172144
response = requests.delete(cluster_url_histogram)
173145

174-
return self.response_treat.treatment(response, pretty_response)
146+
return self.__response_treat.treatment(response, pretty_response)

learning_orchestra_client/function/python.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def run_function_async(self,
7474
request_url = self.__service_url
7575

7676
response = requests.post(url=request_url, json=request_body)
77-
response.raise_for_status()
7877
return self.__response_treat.treatment(response, pretty_response)
7978

8079
def search_all_executions(self, pretty_response: bool = False) \
@@ -111,7 +110,6 @@ def delete_execution_async(self, name: str, pretty_response=False) \
111110
request_url = f'{self.__service_url}/{name}'
112111

113112
response = requests.delete(request_url)
114-
response.raise_for_status()
115113
return self.__response_treat.treatment(response, pretty_response)
116114

117115
def search_execution_content(self,

learning_orchestra_client/train/_train.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def create_training_async(self,
8686
request_url = self.__service_url
8787

8888
response = requests.post(url=request_url, json=request_body)
89-
response.raise_for_status()
9089
return self.__response_treat.treatment(response, pretty_response)
9190

9291
def search_all_trainings(self, pretty_response: bool = False) \
@@ -123,7 +122,6 @@ def delete_training_async(self, name: str, pretty_response=False) \
123122
request_url = f'{self.__service_url}/{name}'
124123

125124
response = requests.delete(request_url)
126-
response.raise_for_status()
127125
return self.__response_treat.treatment(response, pretty_response)
128126

129127
def search_training_content(self,

learning_orchestra_client/transform/data_type.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def update_dataset_type_sync(self,
3939
}
4040

4141
response = requests.patch(url=url_request, json=body_request)
42-
response.raise_for_status()
4342
self.__observer.wait(dataset_name)
4443

4544
return self.__response_treat.treatment(response, pretty_response)
@@ -66,7 +65,6 @@ def update_dataset_type_async(self,
6665
}
6766

6867
response = requests.patch(url=url_request, json=body_request)
69-
response.raise_for_status()
7068
return self.__response_treat.treatment(response, pretty_response)
7169

7270
def wait(self, dataset_name: str) -> dict:

learning_orchestra_client/transform/projection.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def remove_dataset_attributes_sync(self,
4646
}
4747
request_url = self.__service_url
4848
response = requests.post(url=request_url, json=request_body)
49-
response.raise_for_status()
5049
self.__observer.wait(dataset_name)
5150

5251
return self.__response_treat.treatment(response, pretty_response)
@@ -81,7 +80,6 @@ def remove_dataset_attributes_async(self,
8180
}
8281
request_url = self.__service_url
8382
response = requests.post(url=request_url, json=request_body)
84-
response.raise_for_status()
8583

8684
return self.__response_treat.treatment(response, pretty_response)
8785

0 commit comments

Comments
 (0)