Skip to content

Add experimental delivery ratio metrics for DANDI assets - #86

Closed
CodyCBakerPhD wants to merge 14 commits into
mainfrom
claude/serene-fermat-p7uo8t
Closed

Add experimental delivery ratio metrics for DANDI assets#86
CodyCBakerPhD wants to merge 14 commits into
mainfrom
claude/serene-fermat-p7uo8t

Conversation

@CodyCBakerPhD

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces an experimental delivery ratio feature that measures streaming versus download intensity for DANDI assets. The delivery ratio is calculated as total bytes delivered divided by the asset's true DANDI metadata size, providing insights into access patterns across the archive.

Key Changes

  • Asset Size Resolution: Added _load_asset_sizes() function that fetches and caches DANDI asset sizes from the API, with persistent caching in asset_sizes.json to avoid repeated API calls at archive scale.

  • Per-Asset Delivery Ratios: Extended _summarize_dandiset_by_asset() to compute and output a delivery_ratio column in by_asset.tsv for each asset where size information is available.

  • Percentile Aggregation: Implemented _compute_delivery_ratio_percentiles() to calculate asset-weighted percentiles (p10, p25, p50, p75, p90) using linear interpolation, and _compute_delivery_ratio_fields() to compute both percentile-based and volume-weighted delivery ratios.

  • Per-Dandiset Totals: Added generate_dandiset_totals() function that augments per-Dandiset totals with delivery ratio fields derived from each Dandiset's by_asset.tsv.

  • Archive-Level Aggregation: Added generate_archive_summaries() and generate_archive_totals() functions that pool delivery ratios across all Dandisets and output archive-wide delivery ratio metrics in archive/delivery_ratio.tsv and archive_totals.json.

  • CLI Integration: Added new update totals command with --mode option to generate either per-Dandiset or archive-wide totals, with delivery ratio fields automatically included.

  • Comprehensive Testing: Added test_delivery_ratio.py with 11 test cases covering percentile computation, asset filtering, field calculation, and archive pooling logic.

Implementation Details

  • Asset sizes are cached persistently to avoid repeated API calls; missing or unresolvable sizes are cached as None to prevent re-fetching.
  • The delivery_ratio column uses NaN for assets with unresolved sizes, which are excluded from percentile calculations.
  • The "undetermined" catch-all row is explicitly excluded from delivery ratio aggregations since it represents multiple blobs, not a single asset.
  • Volume-weighted delivery ratio is computed separately from asset-weighted percentiles to signal heterogeneity in access patterns.
  • JSON serialization converts NaN values to null for valid JSON output.

https://claude.ai/code/session_012EXym6jB7G8NCt6vFMC8Gr

claude added 2 commits June 22, 2026 05:04
Computed a per-asset delivery ratio (total bytes delivered over the asset's
true DANDI size) and emitted it as a new column in by_asset.tsv. Added a
per-Dandiset delivery_ratio.tsv with the asset-weighted percentiles
(p10, p25, p50, p75, p90) plus a volume-weighted ratio. Asset sizes are
fetched from the DANDI API and cached locally in asset_sizes.json, reused
across runs. Assets with missing or zero size are excluded from the
percentile computation and the skipped count is logged.

Co-Authored-By: Claude Code / Claude Opus 4.8 <noreply@anthropic.com>
Reworked the experimental delivery ratio feature so the per-Dandiset and
archive percentiles live in the totals and archive outputs rather than a
standalone per-Dandiset file. Added DANDI-specific wrappers
generate_dandiset_totals, generate_archive_totals, and generate_archive_summaries
that call the upstream s3_log_extraction methods and then inject the
asset-weighted delivery ratio percentiles plus the volume-weighted ratio,
sourced from each by_asset.tsv delivery_ratio column. Per-Dandiset fields are
written into totals.json, archive-wide fields into archive_totals.json, and an
archive delivery_ratio.tsv. Added the update totals CLI command and routed
update summaries --mode archive through the DANDI wrapper.

Co-Authored-By: Claude Code / Claude Opus 4.8 <noreply@anthropic.com>
@CodyCBakerPhD CodyCBakerPhD self-assigned this Jun 22, 2026
claude and others added 3 commits June 22, 2026 17:25
Co-Authored-By: Claude Code / Claude Opus 4.8 <noreply@anthropic.com>
Removed the asset_sizes.json on-disk cache so asset sizes are looked up live
from the DANDI API on every run; a persistent cache can be added later.
Also reworded the README delivery ratio description to avoid implying the
same byte ranges are re-served, since the logs do not distinguish ranges.

Co-Authored-By: Claude Code / Claude Opus 4.8 <noreply@anthropic.com>
Comment thread README.md Outdated
claude and others added 3 commits June 22, 2026 17:32
Added a note to the README clarifying that per-asset delivery ratios are
highly skewed, so the Dandiset and archive levels report distribution
percentiles rather than a single average, while the per-asset values remain
in by_asset.tsv.

Co-Authored-By: Claude Code / Claude Opus 4.8 <noreply@anthropic.com>
Comment thread README.md Outdated
CodyCBakerPhD and others added 4 commits June 22, 2026 13:34
Co-Authored-By: Claude Code / Claude Opus 4.8 <noreply@anthropic.com>
…olumn

The archive delivery_ratio.tsv now reports the five percentiles in a single
"delivery_ratio(p10,p25,p50,p75,p90)" column with a comma-separated value
rather than five separate columns, alongside the delivery_ratio_weighted
scalar. The JSON totals keep individual keys.

Co-Authored-By: Claude Code / Claude Opus 4.8 <noreply@anthropic.com>
Pulled 1/s_a out of the per-asset equation and forced the summation indices
below the sigma with \limits so they render aligned.

Co-Authored-By: Claude Code / Claude Opus 4.8 <noreply@anthropic.com>
Comment thread README.md Outdated
CodyCBakerPhD and others added 2 commits June 22, 2026 13:50
Co-Authored-By: Claude Code / Claude Opus 4.8 <noreply@anthropic.com>
@CodyCBakerPhD
CodyCBakerPhD marked this pull request as draft July 13, 2026 18:43
@CodyCBakerPhD

Copy link
Copy Markdown
Collaborator Author

Better researched and more conclusive strategy outlined on dandi/s3-log-extraction#284

@CodyCBakerPhD
CodyCBakerPhD deleted the claude/serene-fermat-p7uo8t branch August 2, 2026 15:57
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.

2 participants