Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
8df4053
1
Parent(s):
0d4640a
zip speed increase
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import uuid
|
2 |
import os
|
3 |
import logging
|
|
|
|
|
4 |
import sentry_sdk
|
5 |
from sentry_sdk import capture_exception, push_scope, capture_message
|
6 |
from sentry_sdk.integrations.logging import LoggingIntegration
|
@@ -125,6 +127,19 @@ def rgba_to_hex(col: str) -> str:
|
|
125 |
r, g, b = (int(float(x)) for x in m.groups()[:3])
|
126 |
return "#{:02X}{:02X}{:02X}".format(r, g, b)
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
# --- Helper Functions ---
|
130 |
def get_script_args_info(exclude_args=None):
|
@@ -810,7 +825,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
810 |
zip_base = os.path.join(
|
811 |
run_output_dir_val, "autoforge_results"
|
812 |
) # ### ZIP PATCH
|
813 |
-
zip_path =
|
|
|
|
|
|
|
814 |
|
815 |
# 4. Prepare output file paths
|
816 |
png_path = os.path.join(run_output_dir_val, "final_model.png")
|
|
|
1 |
import uuid
|
2 |
import os
|
3 |
import logging
|
4 |
+
import zipfile
|
5 |
+
|
6 |
import sentry_sdk
|
7 |
from sentry_sdk import capture_exception, push_scope, capture_message
|
8 |
from sentry_sdk.integrations.logging import LoggingIntegration
|
|
|
127 |
r, g, b = (int(float(x)) for x in m.groups()[:3])
|
128 |
return "#{:02X}{:02X}{:02X}".format(r, g, b)
|
129 |
|
130 |
+
def zip_dir_no_compress(src_dir: str, dest_zip: str) -> str:
|
131 |
+
"""Create *dest_zip* from *src_dir* using no compression (ZIP_STORED)."""
|
132 |
+
t0 = time.time()
|
133 |
+
with zipfile.ZipFile(dest_zip, "w",
|
134 |
+
compression=zipfile.ZIP_STORED,
|
135 |
+
allowZip64=True) as zf:
|
136 |
+
for root, _, files in os.walk(src_dir):
|
137 |
+
for fname in files:
|
138 |
+
fpath = os.path.join(root, fname)
|
139 |
+
# keep folder structure inside the archive but drop the leading path
|
140 |
+
zf.write(fpath, os.path.relpath(fpath, src_dir))
|
141 |
+
print(f"Zipping finished in {time.time() - t0:.1f}s")
|
142 |
+
return dest_zip
|
143 |
|
144 |
# --- Helper Functions ---
|
145 |
def get_script_args_info(exclude_args=None):
|
|
|
825 |
zip_base = os.path.join(
|
826 |
run_output_dir_val, "autoforge_results"
|
827 |
) # ### ZIP PATCH
|
828 |
+
zip_path = zip_dir_no_compress(
|
829 |
+
run_output_dir_val,
|
830 |
+
os.path.join(run_output_dir_val, "autoforge_results.zip"),
|
831 |
+
)
|
832 |
|
833 |
# 4. Prepare output file paths
|
834 |
png_path = os.path.join(run_output_dir_val, "final_model.png")
|