@@ -43,7 +43,6 @@ def request(self, method, url, data=None, with_header=True, url_outside_mljar=Fa
4343 if response .status_code != 204 :
4444 logger .debug ("Response content: {}, headers: {}" .format (response .json (), response .headers ))
4545 except Exception as e :
46- print 'Failed' , request_url
4746 logger .error ("Request failed: {} {}" .format (response .content , str (e )))
4847 self ._check_response_status (response )
4948 return response
@@ -68,69 +67,3 @@ def _check_response_status(self, response):
6867 raise BadRequestException ()
6968 else :
7069 response .raise_for_status ()
71-
72-
73- '''
74- def _get_data(self, response):
75- if response is None:
76- return None
77-
78- try:
79- data = response.json()
80- except ValueError as e:
81- raise JSONReadException('Get data failed, %s' % str(e) )
82-
83- if not response.ok:
84- msg = [data[m] for m in ("id", "message") if m in data][1]
85- raise DataReadException(msg)
86-
87- return data
88- '''
89-
90- '''
91-
92- self._urls = {
93- 'project': '/'.join([self.API_ENDPOINT, API_VERSION, 'projects']),
94- 'dataset': '/'.join([self.API_ENDPOINT, API_VERSION, 'datasets']),
95- 'experiment': '/'.join([self.API_ENDPOINT, API_VERSION, 'experiments']),
96- 'result': '/'.join([self.API_ENDPOINT, API_VERSION, 'results/']),
97- 'predict': '/'.join([self.API_ENDPOINT, API_VERSION, 'predict/']),
98- 'predictions': '/'.join([self.API_ENDPOINT, API_VERSION, 'predictions']), # it is not a bug, we don't need here '/'
99- 'download_prediction': '/'.join([self.API_ENDPOINT, API_VERSION, 'download/prediction/']),
100- 's3policy': '/'.join([self.API_ENDPOINT, API_VERSION, 's3policy/']),
101- 'accept_column_usage': '/'.join([self.API_ENDPOINT, API_VERSION, 'accept_column_usage/']),
102- }
103-
104-
105- def _make_request(self, url_name = '', custom_url = '', request_type = 'get', url_additional = '', input_json = {}, with_header = True):
106- try:
107- response = None
108- headers = {'Authorization': 'Token '+self.TOKEN } #'Content-Type': 'application/json'
109- my_url = ''
110- if url_name in self._urls:
111- if my_url == '':
112- raise Exception('Wrong URL address')
113- if url_additional != '':
114- my_url += url_additional
115-
116- #print 'request', my_url, request_type, input_json, with_header, headers
117-
118- if request_type == 'get':
119- response = requests.get(my_url, headers=headers)
120- elif request_type == 'post':
121- if with_header:
122- response = requests.post(my_url, data=input_json, headers=headers)
123- else:
124- response = requests.post(my_url, data=input_json)
125- elif request_type == 'put':
126- if with_header:
127- print my_url, 'with header', input_json
128- response = requests.put(my_url, data=input_json, headers=headers)
129- else:
130- response = requests.put(my_url, data=input_json)
131-
132- except MljarException as e:
133- print 'There was an error during API call, %s' % str(e)
134- finally:
135- return response
136- '''
0 commit comments