Skip to content
This repository was archived by the owner on Jul 15, 2024. It is now read-only.

Commit 62afe23

Browse files
committed
some small fixes for predictor path
1 parent 41b9366 commit 62afe23

File tree

10 files changed

+12
-529
lines changed

10 files changed

+12
-529
lines changed

__init__.py

Whitespace-only changes.

example/__init__.py

Whitespace-only changes.

mindsdb_forecast_visualizer/example/example.py renamed to example/example.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
- train_native.py: for training a predictor using MindsDB Native
55
- TODO: train_sdk.py: for training a predictor using the MindsDB Python SDK
66
"""
7-
import pandas as pd
8-
import mindsdb_native
97
from mindsdb_forecast_visualizer.core.dispatch import visualize
8+
import pandas as pd
109

1110

1211
if __name__ == '__main__':
@@ -17,16 +16,15 @@
1716
predictor_name = 'arrival_forecast_example'
1817

1918
# Specify a DataFrame that has your queries (make sure there are enough rows for each group!)
20-
query_df = pd.read_csv('./arrivals_test.csv')
19+
query_df = pd.read_csv('arrivals_test.csv')
2120

22-
# None predicts for all groups
2321
# Examples: [{'col1': 'val1'}, {'col1': 'val1', 'col2': 'val2', ...}]
24-
subset = None
22+
subset = None # None predicts for all groups
2523

2624
# Set rolling amount of predictions (1 if predictor was trained for t+N with N>1)
2725
rolling = 1
2826

29-
# Set other predictor parameters (NOTE: this will be automatically retrieved soon)
27+
# Set other predictor parameters
3028
params = {
3129
'order': ['T'],
3230
'target': 'Traffic',
@@ -36,14 +34,8 @@
3634
'pred_name': predictor_name
3735
}
3836

39-
pred_path = None # set if predictor was saved in a non-default location (or e.g. a previous native version)
40-
if pred_path is None and mode == 'Native':
41-
pred_path = '/mindsdb_native/mindsdb_native/mindsdb_storage/' + \
42-
mindsdb_native.__version__.replace('.', '_')
43-
elif pred_path is None and mode == 'SDK':
44-
pred_path = '/storage/predictors'
37+
pred_path = None # set this if the predictor was saved in a non-default location
4538

46-
# Plot!
4739
visualize(predictor_name,
4840
query_df,
4941
params=params,

mindsdb_forecast_visualizer/example/train_native.py renamed to example/train_native.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
if __name__ == '__main__':
66
p_name = 'arrival_forecast_example'
7-
87
train_df = pd.read_csv('./arrivals_train.csv')
98

109
predictor = mindsdb_native.Predictor(name=p_name)

mindsdb_forecast_visualizer/__about__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
__email__ = "[email protected]"
66
__author__ = 'MindsDB Inc'
77
__github__ = 'https://github.com/mindsdb/mindsdb_forecast_visualizer'
8-
# __pypi__ = 'https://pypi.org/project/mindsdb'
98
__license__ = 'GPL-3.0'
109
__copyright__ = 'Copyright 2021- mindsdb'
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
from mindsdb_forecast_visualizer.__about__ import __package_name__ as name, __version__

mindsdb_forecast_visualizer/core/dispatch.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import os
2-
3-
import pandas as pd
42
import mindsdb
5-
from mindsdb_native import CONFIG, Predictor
3+
from mindsdb_native import CONFIG, Predictor, __version__, __file__
64

75
from mindsdb_forecast_visualizer.core.forecaster import forecast
86

97

108
def visualize(predictor_name, df, params=None, subset=None, mode='Native', pred_path=None, rolling=1):
9+
if pred_path is None and mode == 'Native':
10+
native_path = os.path.dirname(__file__)
11+
pred_path = os.path.join(native_path, 'mindsdb_storage', __version__.replace('.', '_'))
12+
elif pred_path is None and mode == 'SDK':
13+
pred_path = '/storage/predictors'
14+
1115
if mode == 'Native':
1216
# Path configuration
1317
mdb_path = mindsdb.root_storage_dir if not pred_path else pred_path
@@ -17,7 +21,6 @@ def visualize(predictor_name, df, params=None, subset=None, mode='Native', pred_
1721
mdb_predictor = Predictor(name=predictor_name)
1822

1923
# TODO: fetch params automatically from training params
20-
2124
forecast(mdb_predictor,
2225
df,
2326
params,

0 commit comments

Comments
 (0)