Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 8918c78

Browse files
committed
update
1 parent b4843a5 commit 8918c78

19 files changed

Lines changed: 71 additions & 67 deletions

mljar/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
API_VERSION = 'v1'
44
MLJAR_ENDPOINT = 'https://mljar.com/api'
55

6-
from mljar import Mljar
6+
from .mljar import Mljar

mljar/client/dataset.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from builtins import range
12
import numpy as np
23
import pandas as pd
34
import uuid
@@ -8,11 +9,11 @@
89
import tempfile
910
from zipfile import ZipFile, ZIP_DEFLATED
1011
from os.path import basename
11-
from base import MljarHttpClient
12+
from .base import MljarHttpClient
1213
from ..model.dataset import Dataset
1314
from ..exceptions import NotFoundException, MljarException, CreateDatasetException, DatasetUnknownException
1415

15-
from dataupload import DataUploadClient
16+
from .dataupload import DataUploadClient
1617
from ..log import logger
1718

1819
from ..utils import make_hash
@@ -64,7 +65,7 @@ def _prepare_data(self, X, y):
6465
cols = {}
6566
col_names = []
6667
X_cpy = copy.deepcopy(X)
67-
for i in xrange(X_cpy.shape[1]):
68+
for i in range(X_cpy.shape[1]):
6869
c = 'attribute_'+str(i+1)
6970
cols[c] = X_cpy[:,i]
7071
col_names += [c]
@@ -92,7 +93,7 @@ def _wait_till_all_datasets_are_valid(self):
9293
'''
9394
logger.info('Wait till all datasets are valid')
9495
total_checks = 120
95-
for i in xrange(total_checks):
96+
for i in range(total_checks):
9697
datasets = self.get_datasets()
9798
if datasets is not None:
9899
logger.info('There are %s datasets' % len(datasets))

mljar/client/dataupload.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from base import MljarHttpClient
1+
from .base import MljarHttpClient
22
from ..model.dataset import Dataset
33
from ..exceptions import FileUploadException
44

@@ -22,10 +22,10 @@ def upload_file(self, project_hid, file_path):
2222
url_data = self._get_signed_url(project_hid, file_path)
2323
signed_url = url_data['signed_url']
2424
dst_path = url_data['destination_path']
25-
response = self.request("PUT", signed_url, data=open(file_path, 'rb').read(),
25+
with open(file_path, 'rb') as fin:
26+
response = self.request("PUT", signed_url, data=fin.read(),
2627
with_header=False, url_outside_mljar=True,
2728
parse_json=False)
28-
29-
if response.status_code != 200:
30-
raise FileUploadException('There was a problem with data upload into MLJAR')
29+
if response.status_code != 200:
30+
raise FileUploadException('There was a problem with data upload into MLJAR')
3131
return dst_path

mljar/client/experiment.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from __future__ import print_function
12
import json
23
import warnings
3-
from base import MljarHttpClient
4+
from .base import MljarHttpClient
45
from ..model.experiment import Experiment
56
from ..exceptions import NotFoundException, MljarException, CreateExperimentException
67
from ..exceptions import UndefinedExperimentException
78

8-
from dataupload import DataUploadClient
9+
from .dataupload import DataUploadClient
910
from ..log import logger
1011

1112
from ..utils import make_hash
@@ -115,12 +116,12 @@ def add_experiment_if_not_exists(self, train_dataset, vald_dataset, experiment_t
115116
# check if experiment with the same title has different parameters
116117
for expt in experiments:
117118
if not expt.equal(new_expt):
118-
print 'The experiment with specified title already exists, but it has different parameters than you specified.'
119-
print 'Existing experiment'
120-
print str(expt)
121-
print 'New experiment'
122-
print str(new_expt)
123-
print 'Please rename your new experiment with new parameters setup.'
119+
print('The experiment with specified title already exists, but it has different parameters than you specified.')
120+
print('Existing experiment')
121+
print(str(expt))
122+
print('New experiment')
123+
print(str(new_expt))
124+
print('Please rename your new experiment with new parameters setup.')
124125
return None
125126
# there is only one experiment with selected title and has the same parameters
126127
# this is our experiment :)

mljar/client/prediction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from base import MljarHttpClient
1+
from .base import MljarHttpClient
22
from ..model.prediction import Prediction
33
from ..exceptions import NotFoundException
44

mljar/client/prediction_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import uuid
33
import tempfile
44
import pandas as pd
5-
from base import MljarHttpClient
5+
from .base import MljarHttpClient
66
from ..exceptions import PredictionDownloadException
77

88
from ..log import logger

mljar/client/predictjob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from base import MljarHttpClient
2+
from .base import MljarHttpClient
33
from ..exceptions import FileUploadException
44

55
from ..log import logger

mljar/client/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from base import MljarHttpClient
1+
from .base import MljarHttpClient
22
from ..model.project import Project
33
from ..exceptions import NotFoundException, CreateProjectException
44

mljar/client/result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from base import MljarHttpClient
1+
from .base import MljarHttpClient
22
from ..model.result import Result
33
from ..exceptions import NotFoundException
44

mljar/mljar.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1+
from __future__ import print_function
12
import os
23
import uuid
34
import sys
45
import json, requests
56
import time
67
import numpy as np
78

8-
from utils import *
9-
from exceptions import IncorrectInputDataException, UndefinedExperimentException
10-
from exceptions import MljarException, BadValueException
9+
from .utils import *
10+
from .exceptions import IncorrectInputDataException, UndefinedExperimentException
11+
from .exceptions import MljarException, BadValueException
1112

12-
from client.project import ProjectClient
13-
from client.dataset import DatasetClient
14-
from client.experiment import ExperimentClient
15-
from client.result import ResultClient
16-
from client.prediction import PredictionClient
17-
from client.predictjob import PredictJobClient
18-
from client.prediction_download import PredictionDownloadClient
13+
from .client.project import ProjectClient
14+
from .client.dataset import DatasetClient
15+
from .client.experiment import ExperimentClient
16+
from .client.result import ResultClient
17+
from .client.prediction import PredictionClient
18+
from .client.predictjob import PredictJobClient
19+
from .client.prediction_download import PredictionDownloadClient
1920

20-
from log import logger
21+
from .log import logger
2122

2223
class Mljar(object):
2324
'''
@@ -145,7 +146,7 @@ def fit(self, X, y, validation_data = None, wait_till_all_done = True, dataset_t
145146
try:
146147
self._start_experiment(X, y, validation_data, dataset_title)
147148
except Exception as e:
148-
print 'Ups, %s' % str(e)
149+
print('Ups, {0}'.format(str(e)))
149150

150151

151152
def _start_experiment(self, X, y, validation_data = None, dataset_title = None):
@@ -228,7 +229,7 @@ def _wait_till_all_models_trained(self):
228229
if current_error_cnt >= max_error_cnt:
229230
break
230231
logger.info('Get the best result')
231-
print '' # add new line
232+
print('') # add new line
232233
# get the best result!
233234
return self._get_the_best_result(results)
234235

@@ -274,21 +275,21 @@ def _get_the_best_result(self, results):
274275

275276
def predict(self, X):
276277
if self.project is None or self.experiment is None:
277-
print 'Can not run prediction.'
278-
print 'Please run fit method first, to start models training and to retrieve them ;)'
278+
print('Can not run prediction.')
279+
print('Please run fit method first, to start models training and to retrieve them ;)')
279280
return None
280281
if self.selected_algorithm is None:
281282
results = ResultClient(self.project.hid).get_results(self.experiment.hid)
282283
self.selected_algorithm = self._get_the_best_result(results)
283284
if self.experiment.compute_now != 2:
284285
if self.selected_algorithm is not None:
285-
print 'DISCLAIMER:'
286-
print 'Your experiment is not yet finished.'
287-
print 'You will use the best model up to now.'
288-
print 'You can obtain better results if you wait till experiment is finished.'
286+
print('DISCLAIMER:')
287+
print('Your experiment is not yet finished.')
288+
print('You will use the best model up to now.')
289+
print('You can obtain better results if you wait till experiment is finished.')
289290
else:
290-
print 'There is no ready model to use for prediction.'
291-
print 'Please wait and try in a moment'
291+
print('There is no ready model to use for prediction.')
292+
print('Please wait and try in a moment')
292293
return None
293294

294295
if self.selected_algorithm is not None:

0 commit comments

Comments
 (0)