davanstrien HF staff commited on
Commit
d977997
1 Parent(s): 14c6f3f

check set membership before function call

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -47,12 +47,16 @@ class HubIDCell(Preprocessor):
47
  resources.setdefault("model_matches", set())
48
  if match := re.search(hub_id_regex, cell["source"]):
49
  hub_id_match = match.groups(0)[0]
50
- if hub_check := check_hub_item(hub_id_match):
51
- hub_id_match, repo_item_type = hub_check
52
- if repo_item_type == "model":
53
- resources["model_matches"].add(hub_id_match)
54
- if repo_item_type == "dataset":
55
- resources["dataset_matches"].add(hub_id_match)
 
 
 
 
56
  return cell, resources
57
 
58
 
 
47
  resources.setdefault("model_matches", set())
48
  if match := re.search(hub_id_regex, cell["source"]):
49
  hub_id_match = match.groups(0)[0]
50
+ if (
51
+ hub_id_match not in resources["model_matches"]
52
+ or resources["dataset_matches"]
53
+ ):
54
+ if hub_check := check_hub_item(hub_id_match):
55
+ hub_id_match, repo_item_type = hub_check
56
+ if repo_item_type == "model":
57
+ resources["model_matches"].add(hub_id_match)
58
+ if repo_item_type == "dataset":
59
+ resources["dataset_matches"].add(hub_id_match)
60
  return cell, resources
61
 
62