Spaces:
Running on Zero
Running on Zero
Commit ·
b59fe84
1
Parent(s): 34c8646
Time log_inference and print elapsed duration
Browse filesCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- logging_utils.py +4 -0
logging_utils.py
CHANGED
|
@@ -150,6 +150,8 @@ def _prune_old_files(api, repo_id, keep_days, now):
|
|
| 150 |
|
| 151 |
def log_inference(pil_inputs, output_pil, prompt, seed, steps, guidance_scale,
|
| 152 |
input_width, input_height, duration_seconds, success, error_message=""):
|
|
|
|
|
|
|
| 153 |
if not HF_TOKEN or not DATASET_REPO:
|
| 154 |
print(f"[log] skipped — HF_TOKEN={'set' if HF_TOKEN else 'missing'}, DATASET_REPO={'set' if DATASET_REPO else 'missing'}")
|
| 155 |
return
|
|
@@ -171,3 +173,5 @@ def log_inference(pil_inputs, output_pil, prompt, seed, steps, guidance_scale,
|
|
| 171 |
except Exception as log_err:
|
| 172 |
import traceback as _tb
|
| 173 |
print(f"[log] WARNING: {log_err}\n{_tb.format_exc()}")
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
def log_inference(pil_inputs, output_pil, prompt, seed, steps, guidance_scale,
|
| 152 |
input_width, input_height, duration_seconds, success, error_message=""):
|
| 153 |
+
import time as _time
|
| 154 |
+
_t0 = _time.perf_counter()
|
| 155 |
if not HF_TOKEN or not DATASET_REPO:
|
| 156 |
print(f"[log] skipped — HF_TOKEN={'set' if HF_TOKEN else 'missing'}, DATASET_REPO={'set' if DATASET_REPO else 'missing'}")
|
| 157 |
return
|
|
|
|
| 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 took {_time.perf_counter() - _t0:.3f}s")
|