Skip to content

Consolidate fl-tutorials dataset tooling into a shared datasets/ tree - #1070

Merged
atriaybagur merged 6 commits into
developfrom
1069-fl-tutorials-datasets-tree
Aug 28, 2026
Merged

Consolidate fl-tutorials dataset tooling into a shared datasets/ tree#1070
atriaybagur merged 6 commits into
developfrom
1069-fl-tutorials-datasets-tree

Conversation

@atriaybagur

@atriaybagur atriaybagur commented Aug 27, 2026

Copy link
Copy Markdown
Member

What

Consolidates the tutorial datasets' download/derive/enrich tooling into a shared fl-tutorials/datasets/ tree, with all outputs in one shared gitignored fl-tutorials/data/ root. Closes #1069.

Datasets are backend-agnostic (a tutorial's NVFLARE and Flower twins train on the same data) and many-to-one (spleen alone backs segmentation, evaluation and diffusion), but the tooling was scattered per backend and drifting: near-identical xray recipes in both backend Makefiles (different output CSV names, separate .hf caches — testing both backends downloaded the same data twice), and the spleen scripts living under one tutorial's utils/ with the Flower Makefile delegating cross-tree behind an apologetic comment.

How

  • fl-tutorials/datasets/Makefile owns every dataset target (single copy): download-xray-data, download-spleen-data (FL_BACKEND-dispatched to the explicit download-spleen-msd-data / download-spleen-flip-format-data variants), download-arkplus-{finetuning,eval}-data, upload-spleen-labels. The fl-tutorials root Makefile forwards these there, so every documented entrypoint is unchanged (make -C fl-tutorials download-spleen-data NUM_CASES=41 [FL_BACKEND=flower], etc.).
  • fl-tutorials/datasets/spleen/ takes the three spleen scripts and their uv project (moved from nvflare/image_segmentation/3d_spleen_segmentation/{utils/,pyproject.toml}; the project env existed solely for these utilities), plus a new download_spleen_flip_format_dataset.py for the FLIP-format variant. datasets/README.md documents each dataset's source, layout and consumers.
  • Every download is a script, not an inline python -c: the xray, arkplus and FLIP-format spleen fetches each live in their dataset folder (xrays_mini_300/, arkplus/, spleen/) and run via uv run --no-project --with huggingface_hub; the Makefile targets just invoke them.
  • One shared data root: both backends now read fl-tutorials/data/; one download serves both. The xray CSV gets one canonical name (dataframe.csv); the two spleen variants (MSD build: images/ + dataframe.csv; FLIP-format: accession-resources/ + sample_get_dataframe_response.csv + checkpoint) coexist under data/spleen/ — the FLIP-format download now removes only its own outputs instead of rm -rf data/spleen.
  • Consumers re-pointed: the 7 nvflare .env.app files, flower/run-tutorial.sh (which now also fail-fasts on a missing dataframe file, not just the images dir), flip-api's e2e_smoke_spleen* enrichment wiring (SPLEEN_ENRICHMENT_CWD/CMD/LABELS_DIR), root CLAUDE.md/AGENTS.md, tutorial READMEs, fl-services/flower/README.md, the demo-video docs and the arkplus user guide. The upload script's remediation text now names the two variants instead of the two backends.
  • Removes the accidentally committed self-referencing fl-tutorials/nvflare/data symlink.
  • Strips the leftover Flower example-gallery frontmatter (tags/dataset/framework) from the two Flower spleen tutorial READMEs — it is metadata for Flower's examples website and renders on GitHub as a stray horizontal rule plus literal text.
  • A side-effect fix: the create-flip-app-from-flower.rst local-testing example (../../data/spleen/... from the tutorial root) pointed at a path that didn't exist under the old layout — it is exactly right under the new one.

Verification

  • make -C fl-tutorials download-xray-data and make -C fl-tutorials download-spleen-data FL_BACKEND=flower run end-to-end into the shared root, with the expected layouts, and git status stays clean afterwards (gitignore covers the new root).
  • Target dispatch, NUM_CASES forwarding, and the per-variant SPLEEN_LABELS_DIR defaults verified via make -n command expansion; bash -n on run-tutorial.sh; list-tutorials works on both backends.
  • make -C fl-tutorials test green (ruff + 112 passed, 12 expected skips — the count grew when develop was merged in: its new FLIP#1060 spleen case-selection tests were re-pointed at the moved datasets/spleen/ downloader as part of the merge).
  • scripts/check_tutorial_sync.sh green; a repo-wide grep finds zero references to the old paths.
  • Not run (large downloads, unchanged recipes beyond path prefixes): the MSD spleen and arkplus downloads; a live upload-spleen-labels against XNAT.

Sequencing

Merge before #1068 — the EHR risk-prediction tutorial then rebases onto this and moves its build_synthea_dataframe.py into datasets/synthea/, instead of adding a second cross-tree delegation.

Acceptance Criteria

Imported from issue #1069

  • fl-tutorials/datasets/<name>/ owns each dataset's scripts + Make targets; no dataset scripts remain under per-tutorial utils/ and no duplicated download recipes remain in the per-backend Makefiles.
  • Existing entry points keep working unchanged: make -C fl-tutorials download-xray-data|download-spleen-data|download-arkplus-*|upload-spleen-labels [FL_BACKEND=flower].
  • One shared gitignored data root — downloading a dataset once serves both backends' tutorials (per-backend variants, e.g. the Flower pre-built FLIP-format spleen tree vs the NVFLARE MSD build, remain available as distinct targets/outputs).
  • All consumers re-pointed: per-tutorial .env.app paths, flower/run-tutorial.sh mappings, flip-api e2e_smoke_spleen* defaults, root CLAUDE.md/AGENTS.md, READMEs, docs.
  • make -C fl-tutorials test green; tutorial-sync CI green; downloads verified to land in the layout the tutorials expect.

Datasets are backend-agnostic (a tutorial's NVFLARE and Flower twins train
on the same data) and many-to-one (spleen alone backs segmentation,
evaluation and diffusion), but their tooling was scattered per backend and
drifting: near-identical xray recipes in both backend Makefiles with
different output names and separate .hf caches, and the spleen scripts
living under one tutorial's utils/ with the Flower Makefile delegating
cross-tree.

- fl-tutorials/datasets/ now owns every download/derive/enrich target
  (single copy); the spleen scripts and their uv project move to
  datasets/spleen/. The root fl-tutorials Makefile forwards the dataset
  targets there, so the documented entrypoints are unchanged.
- Outputs land in one shared gitignored fl-tutorials/data/ root — one
  download serves both backends. The xray CSV gets one canonical name
  (dataframe.csv); the two spleen variants (MSD build vs FLIP-format
  tree) coexist under data/spleen/, selected by FL_BACKEND as before.
- All consumers re-pointed: nvflare .env.app files, flower
  run-tutorial.sh (which now also checks the dataframe exists),
  flip-api's e2e_smoke_spleen enrichment wiring, CLAUDE/AGENTS.md,
  READMEs and docs. Removes the accidentally committed self-referencing
  fl-tutorials/nvflare/data symlink.

Verified: download-xray-data and download-spleen-data FL_BACKEND=flower
run end-to-end into the shared root (git-clean afterwards); target
dispatch, NUM_CASES forwarding and per-variant SPLEEN_LABELS_DIR checked
via make -n; make -C fl-tutorials test green (lint + 107 passed).

Closes #1069

Signed-off-by: at24_bioeng625-pc <alexandre.triay_bagur@kcl.ac.uk>
@github-actions

Copy link
Copy Markdown

✅ Acceptance criteria have been automatically imported from the linked issue(s) and added to the PR description.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Move the inline `python -c` snapshot_download one-liners for xray and
arkplus into per-dataset script folders (xrays_mini_300/, arkplus/),
mirroring the spleen/ pattern. arkplus/download_arkplus_dataset.py is
shared by both the finetuning and eval targets, parameterised by
--sites.

Signed-off-by: at24_bioeng625-pc <alexandre.triay_bagur@kcl.ac.uk>
…READMEs

The tags/dataset/framework block is metadata for Flower's own examples
website; in plain rendered markdown it shows up as a stray horizontal
rule plus literal text.

Signed-off-by: at24_bioeng625-pc <alexandre.triay_bagur@kcl.ac.uk>
Comment thread fl-tutorials/datasets/Makefile Outdated
garciadias
garciadias previously approved these changes Aug 28, 2026

@garciadias garciadias left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, mechanical, thoroughly self-verified refactor consolidating dataset tooling; all path rewrites across .env.app files, Makefiles, run-tutorial.sh, flip-api/Makefile, and the CLAUDE.md/AGENTS.md twin-file pair check out, no stale references remain, CI is green. One optional non-blocking nit left inline. Approving.

@garciadias garciadias assigned atriaybagur and unassigned garciadias Aug 28, 2026
Move the last inline `python -c` snapshot_download one-liner —
download-spleen-flip-format-data, which also copies the tree and the
evaluation checkpoint into place — into
datasets/spleen/download_spleen_flip_format_dataset.py, on the same
pattern as the xray and arkplus scripts. It stays a
`uv run --no-project --with huggingface_hub` call rather than adopting
spleen/'s env, which exists for the MSD scripts' MONAI/torch stack. The
script still replaces only its own outputs, so an MSD build beside them
in data/spleen/ survives a re-download.

Signed-off-by: at24_bioeng625-pc <alexandre.triay_bagur@kcl.ac.uk>
Signed-off-by: at24_bioeng625-pc <alexandre.triay_bagur@kcl.ac.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate fl-tutorials dataset tooling into a shared datasets/ tree

3 participants