Spaces:
Runtime error
Runtime error
Campfireman
commited on
Commit
·
c7ce2ca
1
Parent(s):
bd2b6ac
Update app.py
Browse files
app.py
CHANGED
@@ -13,44 +13,44 @@ from functions import decode_features
|
|
13 |
#import functions
|
14 |
|
15 |
def greet(total_pred_days):
|
16 |
-
|
17 |
|
18 |
-
print("hi")
|
19 |
project = hopsworks.login()
|
20 |
print("connected")
|
21 |
-
#api = project.get_dataset_api()
|
22 |
-
|
23 |
-
|
24 |
-
# The latest available data timestamp
|
25 |
-
start_time =
|
26 |
-
|
27 |
-
# end_time = 1670972400000
|
28 |
-
|
29 |
-
#start_date = datetime.now() - timedelta(days=1)
|
30 |
-
#start_time = int(start_date.timestamp()) * 1000
|
31 |
-
|
32 |
-
print("Time Stamp Set. ")
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
print("latest_date")
|
37 |
-
|
38 |
-
mr=project.get_model_registry()
|
39 |
-
model = mr.get_model("temp_model", version=2)
|
40 |
-
model_dir=model.download()
|
41 |
-
|
42 |
-
model1 = mr.get_model("tempmax_model", version=2)
|
43 |
-
model_dir1=model1.download()
|
44 |
-
|
45 |
-
model2 = mr.get_model("tempmin_model", version=2)
|
46 |
-
model_dir2=model2.download()
|
47 |
-
|
48 |
-
model = joblib.load(model_dir + "/model_temp.pkl")
|
49 |
-
model1 = joblib.load(model_dir1 + "/model_tempmax.pkl")
|
50 |
-
model2 = joblib.load(model_dir2+ "/model_tempmin.pkl")
|
51 |
-
|
52 |
-
print("temp_model is now right")
|
53 |
-
|
54 |
fs = project.get_feature_store()
|
55 |
print("get the store")
|
56 |
feature_view = fs.get_feature_view(
|
@@ -59,38 +59,39 @@ def greet(total_pred_days):
|
|
59 |
)
|
60 |
print("get the fv")
|
61 |
X = feature_view.get_batch_data(start_time=start_time)
|
62 |
-
print(
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
94 |
return str1
|
95 |
|
96 |
|
|
|
13 |
#import functions
|
14 |
|
15 |
def greet(total_pred_days):
|
16 |
+
str1 = ""
|
17 |
|
18 |
+
# print("hi")
|
19 |
project = hopsworks.login()
|
20 |
print("connected")
|
21 |
+
# #api = project.get_dataset_api()
|
22 |
+
#
|
23 |
+
#
|
24 |
+
# # The latest available data timestamp
|
25 |
+
start_time = 20221201
|
26 |
+
#
|
27 |
+
# # end_time = 1670972400000
|
28 |
+
#
|
29 |
+
# #start_date = datetime.now() - timedelta(days=1)
|
30 |
+
# #start_time = int(start_date.timestamp()) * 1000
|
31 |
+
#
|
32 |
+
# print("Time Stamp Set. ")
|
33 |
+
#
|
34 |
+
#
|
35 |
+
#
|
36 |
+
# print("latest_date")
|
37 |
+
#
|
38 |
+
# mr=project.get_model_registry()
|
39 |
+
# model = mr.get_model("temp_model", version=2)
|
40 |
+
# model_dir=model.download()
|
41 |
+
#
|
42 |
+
# model1 = mr.get_model("tempmax_model", version=2)
|
43 |
+
# model_dir1=model1.download()
|
44 |
+
#
|
45 |
+
# model2 = mr.get_model("tempmin_model", version=2)
|
46 |
+
# model_dir2=model2.download()
|
47 |
+
#
|
48 |
+
# model = joblib.load(model_dir + "/model_temp.pkl")
|
49 |
+
# model1 = joblib.load(model_dir1 + "/model_tempmax.pkl")
|
50 |
+
# model2 = joblib.load(model_dir2+ "/model_tempmin.pkl")
|
51 |
+
#
|
52 |
+
# print("temp_model is now right")
|
53 |
+
#
|
54 |
fs = project.get_feature_store()
|
55 |
print("get the store")
|
56 |
feature_view = fs.get_feature_view(
|
|
|
59 |
)
|
60 |
print("get the fv")
|
61 |
X = feature_view.get_batch_data(start_time=start_time)
|
62 |
+
print(X)
|
63 |
+
# print("Data batched")
|
64 |
+
# latest_date_unix = str(X.datetime.values[0])[:10]
|
65 |
+
# latest_date = time.ctime(int(latest_date_unix))
|
66 |
+
# X = X.drop(columns=["datetime"]).fillna(0)
|
67 |
+
# preds = model.predict(X)
|
68 |
+
# preds1= model1.predict(X)
|
69 |
+
# preds2= model2.predict(X)
|
70 |
+
#
|
71 |
+
#
|
72 |
+
#
|
73 |
+
# # cities = [city_tuple[0] for city_tuple in cities_coords.keys()]
|
74 |
+
#
|
75 |
+
# next_day_date = datetime.today() + timedelta(days=1)
|
76 |
+
# next_day = next_day_date.strftime ('%d/%m/%Y')
|
77 |
+
# str1 = ""
|
78 |
+
#
|
79 |
+
# if(total_pred_days == ""):
|
80 |
+
# return "Empty input"
|
81 |
+
#
|
82 |
+
# count = int(total_pred_days)
|
83 |
+
# if count > 20:
|
84 |
+
# str1 += "Warning: 20 days at most. " + '\n'
|
85 |
+
# count = 20
|
86 |
+
# if count <0:
|
87 |
+
# str1 = "Invalid input."
|
88 |
+
# return str1
|
89 |
+
#
|
90 |
+
# for x in range(count):
|
91 |
+
# if (x != 0):
|
92 |
+
# str1 += (datetime.now() + timedelta(days=x)).strftime('%Y-%m-%d') + " predicted temperature: " +str(int(preds[len(preds) - count + x]))+ " predicted max temperature: " +str(int(preds1[len(preds1) - count + x]))+ " predicted min temperature: " +str(int(preds2[len(preds2) - count + x]))+"\n"
|
93 |
+
#
|
94 |
+
# #print(str1)
|
95 |
return str1
|
96 |
|
97 |
|