|
7 | 7 | from os.path import join as pjoin
|
8 | 8 | import numpy as np
|
9 | 9 | import numpy.testing as npt
|
| 10 | +from cesium_app.config import cfg |
| 11 | +import json |
| 12 | +import requests |
10 | 13 | from cesium_app.tests.fixtures import (create_test_project, create_test_dataset,
|
11 | 14 | create_test_featureset, create_test_model,
|
12 | 15 | create_test_prediction)
|
@@ -204,3 +207,34 @@ def test_download_prediction_csv_regr(driver):
|
204 | 207 | [4, 3.1, 3.1]])
|
205 | 208 | finally:
|
206 | 209 | os.remove('/tmp/cesium_prediction_results.csv')
|
| 210 | + |
| 211 | + |
| 212 | +def test_predict_specific_ts_name(): |
| 213 | + with create_test_project() as p, create_test_dataset(p) as ds,\ |
| 214 | + create_test_featureset(p) as fs, create_test_model(fs) as m: |
| 215 | + ts_data = [[1, 2, 3, 4], [32.2, 53.3, 32.3, 32.52], [0.2, 0.3, 0.6, 0.3]] |
| 216 | + impute_kwargs = {'strategy': 'constant', 'value': None} |
| 217 | + data = {'datasetID': ds.id, |
| 218 | + 'ts_names': ['217801'], |
| 219 | + 'modelID': m.id} |
| 220 | + print('data:', data) |
| 221 | + response = requests.post('{}/predictions'.format(cfg['server']['url']), |
| 222 | + data=json.dumps(data)).json() |
| 223 | + print('response dict:', response) |
| 224 | + assert response['status'] == 'success' |
| 225 | + |
| 226 | + n_secs = 0 |
| 227 | + while n_secs < 5: |
| 228 | + pred_info = requests.get('{}/predictions/{}'.format( |
| 229 | + cfg['server']['url'], response['data']['id'])).json() |
| 230 | + print(pred_info) |
| 231 | + if pred_info['status'] == 'success' and pred_info['data']['finished']: |
| 232 | + assert isinstance(pred_info['data']['results']['217801'] |
| 233 | + ['features']['total_time'], |
| 234 | + float) |
| 235 | + assert 'Mira' in pred_info['data']['results']['217801']['prediction'] |
| 236 | + break |
| 237 | + n_secs += 1 |
| 238 | + time.sleep(1) |
| 239 | + else: |
| 240 | + raise Exception('test_predict_specific_ts_name timed out') |
0 commit comments