Spaces:
Running on Zero
Running on Zero
Commit ·
0ce14db
1
Parent(s): b59fe84
Add per-section timing to log_inference
Browse filesCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- logging_utils.py +15 -1
logging_utils.py
CHANGED
|
@@ -159,19 +159,33 @@ def log_inference(pil_inputs, output_pil, prompt, seed, steps, guidance_scale,
|
|
| 159 |
from huggingface_hub import HfApi
|
| 160 |
|
| 161 |
now = datetime.now(timezone.utc)
|
|
|
|
|
|
|
| 162 |
table = _build_table(pil_inputs, output_pil, prompt, seed, steps, guidance_scale,
|
| 163 |
input_width, input_height, duration_seconds, success, error_message, now)
|
|
|
|
| 164 |
|
| 165 |
uid = uuid.uuid4().hex[:8]
|
| 166 |
path_in_repo = _make_path(now, uid)
|
| 167 |
|
|
|
|
| 168 |
api = HfApi(token=HF_TOKEN)
|
| 169 |
api.create_repo(repo_id=DATASET_REPO, repo_type="dataset", private=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
| 170 |
_upload_parquet(api, DATASET_REPO, table, path_in_repo)
|
|
|
|
|
|
|
|
|
|
| 171 |
_prune_old_files(api, DATASET_REPO, MAX_LOG_DAYS, now)
|
|
|
|
|
|
|
|
|
|
| 172 |
_maybe_squash_history(api, DATASET_REPO, now)
|
|
|
|
| 173 |
except Exception as log_err:
|
| 174 |
import traceback as _tb
|
| 175 |
print(f"[log] WARNING: {log_err}\n{_tb.format_exc()}")
|
| 176 |
finally:
|
| 177 |
-
print(f"[log] log_inference
|
|
|
|
| 159 |
from huggingface_hub import HfApi
|
| 160 |
|
| 161 |
now = datetime.now(timezone.utc)
|
| 162 |
+
|
| 163 |
+
_t1 = _time.perf_counter()
|
| 164 |
table = _build_table(pil_inputs, output_pil, prompt, seed, steps, guidance_scale,
|
| 165 |
input_width, input_height, duration_seconds, success, error_message, now)
|
| 166 |
+
print(f"[log] build_table: {_time.perf_counter() - _t1:.3f}s")
|
| 167 |
|
| 168 |
uid = uuid.uuid4().hex[:8]
|
| 169 |
path_in_repo = _make_path(now, uid)
|
| 170 |
|
| 171 |
+
_t2 = _time.perf_counter()
|
| 172 |
api = HfApi(token=HF_TOKEN)
|
| 173 |
api.create_repo(repo_id=DATASET_REPO, repo_type="dataset", private=True, exist_ok=True)
|
| 174 |
+
print(f"[log] create_repo: {_time.perf_counter() - _t2:.3f}s")
|
| 175 |
+
|
| 176 |
+
_t3 = _time.perf_counter()
|
| 177 |
_upload_parquet(api, DATASET_REPO, table, path_in_repo)
|
| 178 |
+
print(f"[log] upload_parquet: {_time.perf_counter() - _t3:.3f}s")
|
| 179 |
+
|
| 180 |
+
_t4 = _time.perf_counter()
|
| 181 |
_prune_old_files(api, DATASET_REPO, MAX_LOG_DAYS, now)
|
| 182 |
+
print(f"[log] prune_old_files: {_time.perf_counter() - _t4:.3f}s")
|
| 183 |
+
|
| 184 |
+
_t5 = _time.perf_counter()
|
| 185 |
_maybe_squash_history(api, DATASET_REPO, now)
|
| 186 |
+
print(f"[log] squash_history: {_time.perf_counter() - _t5:.3f}s")
|
| 187 |
except Exception as log_err:
|
| 188 |
import traceback as _tb
|
| 189 |
print(f"[log] WARNING: {log_err}\n{_tb.format_exc()}")
|
| 190 |
finally:
|
| 191 |
+
print(f"[log] log_inference total: {_time.perf_counter() - _t0:.3f}s")
|