borso271 commited on
Commit
7f45a02
·
1 Parent(s): 1f6a2dc

Fix items.json path issue when path is empty

Browse files
Files changed (1) hide show
  1. handler.py +2 -1
handler.py CHANGED
@@ -49,7 +49,8 @@ class EndpointHandler:
49
  with contextlib.suppress(Exception):
50
  loaded = self._load_snapshot_from_hub_latest()
51
  if not loaded:
52
- with open(f"{path}/items.json", "r", encoding="utf-8") as f:
 
53
  items = json.load(f)
54
  prompts = [it["prompt"] for it in items]
55
  self.class_ids = [int(it["id"]) for it in items]
 
49
  with contextlib.suppress(Exception):
50
  loaded = self._load_snapshot_from_hub_latest()
51
  if not loaded:
52
+ items_path = "items.json" if not path else f"{path}/items.json"
53
+ with open(items_path, "r", encoding="utf-8") as f:
54
  items = json.load(f)
55
  prompts = [it["prompt"] for it in items]
56
  self.class_ids = [int(it["id"]) for it in items]