diff --git a/mindsdb/interfaces/model/model_controller.py b/mindsdb/interfaces/model/model_controller.py index 62ab7c3754a..1f4ceb3ede6 100644 --- a/mindsdb/interfaces/model/model_controller.py +++ b/mindsdb/interfaces/model/model_controller.py @@ -126,6 +126,7 @@ def learn(self, name: str, from_data: dict, to_predict: str, datasource_id: int, p.join() if not IS_PY36: p.close() + db.session.refresh(predictor_record) @mark_process(name='predict') def predict(self, name: str, when_data: Union[dict, list, pd.DataFrame], pred_format: str, company_id: int): diff --git a/mindsdb/streams/stream_controller.py b/mindsdb/streams/stream_controller.py index bf371ee26fc..37b656428b0 100644 --- a/mindsdb/streams/stream_controller.py +++ b/mindsdb/streams/stream_controller.py @@ -35,8 +35,8 @@ def __init__(self, name, predictor, stream_in, stream_out, anomaly_stream=None, self.target = p.to_predict[0] - ts_settings = p.learn_args.get('timeseries_settings', {}) - if ts_settings.get('is_timeseries', False) is False: + ts_settings = p.learn_args.get('timeseries_settings') + if isinstance(ts_settings, dict) is False or len(ts_settings) == 0: ts_settings = None if ts_settings is None: diff --git a/tests/integration_tests/flows/test_redis.py b/tests/integration_tests/flows/test_redis.py index ec7e73209b4..be34143f020 100644 --- a/tests/integration_tests/flows/test_redis.py +++ b/tests/integration_tests/flows/test_redis.py @@ -108,7 +108,7 @@ def train_ts_predictor(self, ds_name, predictor_name, with_gb=True): "order_by": ["order"], "nr_predictions": 1, "use_previous_target": True, - "window": 5} + "window": 10} if with_gb: ts_settings["group_by"] = ["group"] @@ -143,7 +143,6 @@ def test_2_create_redis_stream(self): print(f"\nExecuting {self._testMethodName}") self.upload_ds(DS_NAME) self.train_predictor(DS_NAME, DEFAULT_PREDICTOR) - time.sleep(30) url = f'{HTTP_API_ROOT}/streams/{NORMAL_STREAM_NAME}' res = requests.put(url, json={ @@ -194,8 +193,7 @@ def test_5_making_ts_stream_prediction(self): time.sleep(0.01) time.sleep(10) - # FIXME pass - # self.assertEqual(len(list(stream_out.read())), 2) + self.assertEqual(len(list(stream_out.read())), 2) def test_6_create_stream_redis_native_api(self): print(f"\nExecuting {self._testMethodName}") @@ -266,8 +264,7 @@ def test_9_making_ts_stream_prediction_no_group(self): stream_in.write({'x1': x, 'x2': 2*x, 'order': x, 'y': 3 * x}) time.sleep(5) - # FIXME pass - # self.assertEqual(len(list(stream_out.read())), 2) + self.assertEqual(len(list(stream_out.read())), 2) def test_delete_stream_http_api(self): print(f"\nExecuting {self._testMethodName}")