AbstractPhil commited on
Commit
015802c
·
verified ·
1 Parent(s): b493b91

anima_closeout v6: CELL 1's shard loop variable was `sh`, clobbering CELL 0's sh() shell helper in the shared notebook namespace -> CELL 2 smoke crashed with 'str' object is not callable. Renamed + builder now AST-checks every cell for cross-cell function-name clobbering (proven to flag the exact bug).

Browse files
Files changed (1) hide show
  1. colab/anima_closeout.ipynb +7 -7
colab/anima_closeout.ipynb CHANGED
@@ -243,13 +243,13 @@
243
  " n_seen = n_dropped = n_dup = 0\n",
244
  " shards_used, local_paths = [], {}\n",
245
  " THIN = [\"id\", \"caption_joycaption\", \"prompt_fused\", \"age_audit\", \"audit\"]\n",
246
- " for sh in shard_order:\n",
247
  " if len(pool_ids) >= TARGET:\n",
248
  " break\n",
249
- " local = hf_hub_download(ANIMA[\"DATASET\"], sh, repo_type=\"dataset\",\n",
250
  " local_dir=str(SRC))\n",
251
- " local_paths[sh] = local\n",
252
- " shards_used.append(sh)\n",
253
  " pf = pq.ParquetFile(local)\n",
254
  " cols = [c for c in THIN if c in pf.schema_arrow.names]\n",
255
  " for rg in range(pf.num_row_groups):\n",
@@ -266,7 +266,7 @@
266
  " elif len(pool_ids) < TARGET:\n",
267
  " seen.add(rid)\n",
268
  " pool_ids.append(rid)\n",
269
- " print(f\"[scan] {sh}: pool {len(pool_ids)}/{TARGET} \"\n",
270
  " f\"(seen {n_seen}, dropped {n_dropped}, dup {n_dup})\",\n",
271
  " flush=True)\n",
272
  "\n",
@@ -304,8 +304,8 @@
304
  " if name in t.schema.names\n",
305
  " else pa.array([\"\"] * t.num_rows))\n",
306
  "\n",
307
- " for sh in shards_used:\n",
308
- " pf = pq.ParquetFile(local_paths[sh])\n",
309
  " cols = [c for c in HEAVY if c in pf.schema_arrow.names]\n",
310
  " for rg in range(pf.num_row_groups):\n",
311
  " tbl = pf.read_row_group(rg, columns=cols)\n",
 
243
  " n_seen = n_dropped = n_dup = 0\n",
244
  " shards_used, local_paths = [], {}\n",
245
  " THIN = [\"id\", \"caption_joycaption\", \"prompt_fused\", \"age_audit\", \"audit\"]\n",
246
+ " for shard in shard_order: # NOT `sh` \u2014 that is the shell fn\n",
247
  " if len(pool_ids) >= TARGET:\n",
248
  " break\n",
249
+ " local = hf_hub_download(ANIMA[\"DATASET\"], shard, repo_type=\"dataset\",\n",
250
  " local_dir=str(SRC))\n",
251
+ " local_paths[shard] = local\n",
252
+ " shards_used.append(shard)\n",
253
  " pf = pq.ParquetFile(local)\n",
254
  " cols = [c for c in THIN if c in pf.schema_arrow.names]\n",
255
  " for rg in range(pf.num_row_groups):\n",
 
266
  " elif len(pool_ids) < TARGET:\n",
267
  " seen.add(rid)\n",
268
  " pool_ids.append(rid)\n",
269
+ " print(f\"[scan] {shard}: pool {len(pool_ids)}/{TARGET} \"\n",
270
  " f\"(seen {n_seen}, dropped {n_dropped}, dup {n_dup})\",\n",
271
  " flush=True)\n",
272
  "\n",
 
304
  " if name in t.schema.names\n",
305
  " else pa.array([\"\"] * t.num_rows))\n",
306
  "\n",
307
+ " for shard in shards_used:\n",
308
+ " pf = pq.ParquetFile(local_paths[shard])\n",
309
  " cols = [c for c in HEAVY if c in pf.schema_arrow.names]\n",
310
  " for rg in range(pf.num_row_groups):\n",
311
  " tbl = pf.read_row_group(rg, columns=cols)\n",