Spaces:
Sleeping
Sleeping
Updated app at mån 20 nov 2023 07:49:02 CET
Browse files
app.py
CHANGED
@@ -43,8 +43,8 @@ def download_and_refresh():
|
|
43 |
error_during_exec = False
|
44 |
for image in hopsworks_images:
|
45 |
# Only execute when no error has currently occurred (so we don't end up in an infinite loop)
|
46 |
-
if not error_during_exec and len(error) > 0 and error['name'] != image['name']:
|
47 |
-
print(f"Skipping {image} to only retry failed images.")
|
48 |
continue
|
49 |
elif not error_during_exec:
|
50 |
# Pop current image
|
@@ -54,18 +54,19 @@ def download_and_refresh():
|
|
54 |
try:
|
55 |
print(f"Downloading {hopsworks_images[image]['name']} from Hopsworks...")
|
56 |
hopsworks_images[image]['local_path'] = dataset_api.download(
|
57 |
-
f"{hopsworks_images_location}/{hopsworks_images[image]['name']}"
|
|
|
58 |
print(f"Saved in: {hopsworks_images[image]['local_path']}")
|
59 |
|
60 |
last_refresh_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
61 |
print(f"Image refreshed at {last_refresh_time}")
|
62 |
|
63 |
except Exception as e:
|
64 |
-
print(f"An error occurred when trying to refresh {image}: {e}")
|
65 |
error_during_exec = True
|
66 |
|
67 |
# Make sure images are not added twice if re-added when retrying to download
|
68 |
-
error = [cur_error for cur_error in error if cur_error['name'] != image['name']]
|
69 |
|
70 |
error.append(image)
|
71 |
|
@@ -80,11 +81,13 @@ def download_and_refresh():
|
|
80 |
|
81 |
def download_and_refresh_scheduled():
|
82 |
while True:
|
83 |
-
|
84 |
|
85 |
# Sleep for 12 hours (12 hours * 60 minutes * 60 seconds)
|
86 |
time.sleep(43200)
|
87 |
|
|
|
|
|
88 |
|
89 |
def get_label_text():
|
90 |
if last_refresh_time:
|
|
|
43 |
error_during_exec = False
|
44 |
for image in hopsworks_images:
|
45 |
# Only execute when no error has currently occurred (so we don't end up in an infinite loop)
|
46 |
+
if not error_during_exec and len(error) > 0 and error['name'] != hopsworks_images[image]['name']:
|
47 |
+
print(f"Skipping {hopsworks_images[image]['name']} to only retry failed images.")
|
48 |
continue
|
49 |
elif not error_during_exec:
|
50 |
# Pop current image
|
|
|
54 |
try:
|
55 |
print(f"Downloading {hopsworks_images[image]['name']} from Hopsworks...")
|
56 |
hopsworks_images[image]['local_path'] = dataset_api.download(
|
57 |
+
f"{hopsworks_images_location}/{hopsworks_images[image]['name']}",
|
58 |
+
overwrite=True)
|
59 |
print(f"Saved in: {hopsworks_images[image]['local_path']}")
|
60 |
|
61 |
last_refresh_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
62 |
print(f"Image refreshed at {last_refresh_time}")
|
63 |
|
64 |
except Exception as e:
|
65 |
+
print(f"An error occurred when trying to refresh {hopsworks_images[image]['name']}: {e}")
|
66 |
error_during_exec = True
|
67 |
|
68 |
# Make sure images are not added twice if re-added when retrying to download
|
69 |
+
error = [cur_error for cur_error in error if cur_error['name'] != hopsworks_images[image]['name']]
|
70 |
|
71 |
error.append(image)
|
72 |
|
|
|
81 |
|
82 |
def download_and_refresh_scheduled():
|
83 |
while True:
|
84 |
+
print(f"Refreshing in 12 hours...")
|
85 |
|
86 |
# Sleep for 12 hours (12 hours * 60 minutes * 60 seconds)
|
87 |
time.sleep(43200)
|
88 |
|
89 |
+
download_and_refresh()
|
90 |
+
|
91 |
|
92 |
def get_label_text():
|
93 |
if last_refresh_time:
|