-
Notifications
You must be signed in to change notification settings - Fork 1
/
predict.py
50 lines (43 loc) · 2 KB
/
predict.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
import os
from typing import List
sys.path.append(
os.path.abspath(os.path.join(os.path.dirname(__file__), "src", "predictions"))
)
# If path starts with the "src" directory, Snowflake throws an error: No module named 'src'
from profiles_mlcorelib.predict import _predict
from profiles_mlcorelib.utils import constants
from src.predictions.profiles_mlcorelib.wht.pythonWHT import PythonWHT
def predict(
creds: dict,
_: dict, # s3_config is not being populated for some reason. Using site_config to get its value
model_path: str,
input_selector_sqls: List[str],
output_tablename: str,
config: dict,
runtime_info: dict = None,
) -> None:
"""Generates the prediction probabilities and save results for given model_path
Args:
creds (dict): credentials to access the data warehouse - in same format as site_config.yaml from profiles
s3_config (dict): aws credentials - not required for snowflake. only used for redshift
model_path (str): path to the file where the model details including model id etc are present. Created in training step
input_selector_sqls: (List[str]), containing sql queries such as "select * from <feature_table_name>"
output_tablename (str): name of output table where prediction results are written
config (dict): configs from profiles.yaml which should overwrite corresponding values from model_configs.yaml file
runtime_info (dict): Whether the code is running on rudder infra or local. Useful to decide if redshift processor should run locally or in k8s
Returns:
None: save the prediction results but returns nothing
"""
wht = PythonWHT(None, None)
_predict(
creds,
model_path,
# Skipping compile when computing inputs since the information derived from it is not used in the predict step
wht.get_inputs(input_selector_sqls, True),
output_tablename,
config,
runtime_info,
constants.ML_CORE_PYTHON_PATH,
wht,
)