Akash Garg commited on
Commit
f8e1542
·
1 Parent(s): cb88aea

adding logging to persistent file

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -7,6 +7,8 @@ import trimesh
7
  import sys
8
  from pathlib import Path
9
  import numpy as np
 
 
10
 
11
  pathdir = Path(__file__).parent / 'cube'
12
  sys.path.append(pathdir.as_posix())
@@ -51,6 +53,25 @@ def gen_save_folder(max_size=200):
51
 
52
  @spaces.GPU
53
  def handle_text_prompt(input_prompt, use_bbox = True, bbox_x=1.0, bbox_y=1.0, bbox_z=1.0, hi_res=False):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  print(f"prompt: {input_prompt}, use_bbox: {use_bbox}, bbox_x: {bbox_x}, bbox_y: {bbox_y}, bbox_z: {bbox_z}, hi_res: {hi_res}")
55
 
56
  if "engine_fast" not in GLOBAL_STATE:
 
7
  import sys
8
  from pathlib import Path
9
  import numpy as np
10
+ import json
11
+ from datetime import datetime
12
 
13
  pathdir = Path(__file__).parent / 'cube'
14
  sys.path.append(pathdir.as_posix())
 
53
 
54
  @spaces.GPU
55
  def handle_text_prompt(input_prompt, use_bbox = True, bbox_x=1.0, bbox_y=1.0, bbox_z=1.0, hi_res=False):
56
+ # Create debug info
57
+ debug_info = {
58
+ "timestamp": datetime.now().isoformat(),
59
+ "prompt": input_prompt,
60
+ "use_bbox": use_bbox,
61
+ "bbox_x": bbox_x,
62
+ "bbox_y": bbox_y,
63
+ "bbox_z": bbox_z,
64
+ "hi_res": hi_res
65
+ }
66
+
67
+ # Save to persistent storage
68
+ data_dir = "/data"
69
+ os.makedirs(data_dir, exist_ok=True)
70
+
71
+ prompt_file = os.path.join(data_dir, "prompt_log.jsonl")
72
+ with open(prompt_file, "a") as f:
73
+ f.write(json.dumps(debug_info) + "\n")
74
+
75
  print(f"prompt: {input_prompt}, use_bbox: {use_bbox}, bbox_x: {bbox_x}, bbox_y: {bbox_y}, bbox_z: {bbox_z}, hi_res: {hi_res}")
76
 
77
  if "engine_fast" not in GLOBAL_STATE: