Skip to content

feat(connectors): let a Hub connector declare a source part by file pattern - #770

Open
masquare wants to merge 2 commits into
mainfrom
feature/hub-base-patterns
Open

masquare wants to merge 2 commits into
mainfrom
feature/hub-base-patterns

Conversation

@masquare

@masquare masquare commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Description
BaseHuggingFaceConnector downloads the files that SOURCE_FILES names, with one filename per
part. Some releases hold many files of one kind. For example, ARFBench holds 748 series files and
414 charts. Such a release cannot list its files in SOURCE_FILES. Thus the ARFBench connector
used hub_snapshot directly instead of the base.

hub_snapshot is now the only Hub helper. It sends the patterns directly to snapshot_download,
which matches the patterns itself. It returns the snapshot directory. Thus this PR removes the
listing call, the pattern matching, and download_hub_files. The base uses hub_snapshot to
download its parts. Thus a filename can end in a pattern, for example data/*.parquet. The
HubFileRef of that part is the directory of the matching files. If a part matches no file, the
download fails with the name of the part. A missing file gave the same result before.

Test plan

  • Command: make check
  • Coverage: formatting, lint, generated schemas, and types pass
  • Command: uv run pytest packages/timenet-connectors/tests
  • Coverage: 320 tests pass. They include a pattern part and a pattern without a match. The tests
    use a fake Hub that applies the patterns.
  • Command: pytest for the tsqa, tsaqa_benchmark, sensorcaps, and arfbench connectors, which call
    the base or the helper
  • Coverage: their 81 tests pass, with no changes to these tests

masquare added a commit that referenced this pull request Nov 10, 2026
… on the series

Description
The review of #615 asked for two more changes, and the plots dataset can
now use TimeNet's own parent mechanism instead of subclassing:

* Both connectors build on `BaseHuggingFaceConnector`, whose source parts
  can now be file patterns (#770). The series connector declares the
  question table and `arfbench-ts-data/*.parquet`; the plots connector the
  table and `arfbench-images/*.png`.
* Three categories (presence, correlation, indicator: 444 of the 750
  questions) offer the same options in every question. Each is now a
  label set, and their questions are classification tasks over it. The
  other questions offer their own options, such as timestamps or tag
  groups, and stay answer tasks with the `answer_options` annotation. A
  release whose options differ from a label set fails the conversion.
* `datadog/arfbench-plots` declares `datadog/arfbench@1.0.0` as its parent
  `series`. Its `compose` imports the parent's tasks with the metric
  records they cite and adds the charts and the chart tasks. The imported
  series keep reading the parent's Parquet release, so the child stores
  only the charts, with Zarr.

Test plan
- Command: pytest and ty for both connectors in their own environments,
  as `make test-connectors` runs them
- Coverage: 15 series tests (label-set and answer tasks, the Parquet round
  trip, a fixed category with other options) and 4 plots tests (the parent
  declaration, the imported and added tasks, a child that stores only the
  charts and reads the series through its parent, a missing chart)
- Command: `make check`
- Coverage: formatting, lint, generated schemas, and types pass
- Command: `timenet-build build datadog/arfbench-plots --build-parents`
  into a local registry
- Coverage: `datadog/arfbench` holds 142 records, 38,032 series, and 444
  classification and 306 answer tasks; `datadog/arfbench-plots` holds 556
  records and 1,500 tasks, names `datadog/arfbench@1.0.0` as its payload
  source, and stores 40 MB of charts
@masquare
masquare force-pushed the feature/hub-base-patterns branch from 9fbf821 to 0f96460 Compare November 10, 2026 15:52
masquare added a commit that referenced this pull request Nov 10, 2026
…e the plots on the series

Description
The review of #615 asked for two more changes, and the plots dataset can
now use TimeNet's own parent mechanism instead of subclassing:

* Both connectors build on `BaseHuggingFaceConnector`, whose source parts
  can now be file patterns (#770). The series connector declares the
  question table and `arfbench-ts-data/*.parquet`; the plots connector the
  table and `arfbench-images/*.png`.
* Every question asks to pick one of its released options, so each task
  is a classification task whose label set holds those options, named
  after the question's row. The series task and the chart task of a
  question share it. The `answer_options` annotation goes.
* `datadog/arfbench-plots` declares `datadog/arfbench@1.0.0` as its parent
  `series`. Its `compose` imports the parent's tasks with the metric
  records they cite and adds the charts and the chart tasks. The imported
  series keep reading the parent's Parquet release, so the child stores
  only the charts, with Zarr.

Test plan
- Command: pytest and ty for both connectors in their own environments,
  as `make test-connectors` runs them
- Coverage: 14 series tests (the classification tasks and their label
  sets, the Parquet round trip) and 4 plots tests (the parent declaration,
  the imported and added tasks, a child that stores only the charts and
  reads the series through its parent, a missing chart)
- Command: `make check`
- Coverage: formatting, lint, generated schemas, and types pass
- Command: `timenet-build build datadog/arfbench-plots --build-parents`
  into a local registry
- Coverage: `datadog/arfbench` holds 142 records, 38,032 series, and 750
  classification tasks; `datadog/arfbench-plots` holds 556 records and
  1,500 tasks over the same 750 label sets, names
  `datadog/arfbench@1.0.0` as its payload source, and stores the charts
@masquare
masquare added this pull request to stack #771 November 10, 2026 15:54
@masquare
masquare marked this pull request as ready for review November 10, 2026 15:55

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Beyond the inline findings, I checked for callers left behind by the removal of download_hub_files and the change to hub_snapshot's signature. Nothing still uses download_hub_files. The ARFBench connector (datasets/datadog/arfbench/connector.py:97) already calls hub_snapshot(repo, revision, cache_dir, patterns) with the new signature, so it isn't affected.

Extended reasoning...

A search of the repo found no remaining references to download_hub_files. The only callers of hub_snapshot are the base connector and ARFBench, and both pass the new four-argument signature.

Findings marked 🟡 are optional suggestions and need no follow-up push.

masquare added a commit that referenced this pull request Nov 10, 2026
…e the plots on the series

Description
The review of #615 asked for two more changes, and the plots dataset can
now use TimeNet's own parent mechanism instead of subclassing:

* Both connectors build on `BaseHuggingFaceConnector`, whose source parts
  can now be file patterns (#770). The series connector declares the
  question table and `arfbench-ts-data/*.parquet`; the plots connector the
  table and `arfbench-images/*.png`.
* Every question asks to pick one of its released options, so each task
  is a classification task whose label set holds those options, named
  after the question's row. The series task and the chart task of a
  question share it. The `answer_options` annotation goes.
* `datadog/arfbench-plots` declares `datadog/arfbench@1.0.0` as its parent
  `series`. Its `compose` imports the parent's tasks with the metric
  records they cite and adds the charts and the chart tasks. The imported
  series keep reading the parent's Parquet release, so the child stores
  only the charts, with Zarr.

Test plan
- Command: pytest and ty for both connectors in their own environments,
  as `make test-connectors` runs them
- Coverage: 14 series tests (the classification tasks and their label
  sets, the Parquet round trip) and 4 plots tests (the parent declaration,
  the imported and added tasks, a child that stores only the charts and
  reads the series through its parent, a missing chart)
- Command: `make check`
- Coverage: formatting, lint, generated schemas, and types pass
- Command: `timenet-build build datadog/arfbench-plots --build-parents`
  into a local registry
- Coverage: `datadog/arfbench` holds 142 records, 38,032 series, and 750
  classification tasks; `datadog/arfbench-plots` holds 556 records and
  1,500 tasks over the same 750 label sets, names
  `datadog/arfbench@1.0.0` as its payload source, and stores the charts

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Code review skipped: your organization has reached its API usage limit, so Code Review can't run right now.

An organization admin can review the limit in your organization's usage and billing settings.

Once the limit resets or is raised, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@masquare
masquare requested a review from TimoStoff November 10, 2026 16:55
"""An immutable commit: a mutable branch can silently change rebuilt datasets."""
SOURCE_FILES: ClassVar[Mapping[str, str]]
"""Each part's repository-relative filename, in the order ``download()`` returns them."""
"""Each part's repository-relative filename, in the order ``download()`` returns them. A filename can end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still quite claudey. Better would be e.g

Suggested change
"""Each part's repository-relative filename, in the order ``download()`` returns them. A filename can end
"""The repo-relative filename of each part, in download-order. A filename can end

@TimoStoff TimoStoff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm!

Base automatically changed from feature/standalone-arfbench to main November 10, 2026 20:10
…attern

Description
`BaseHuggingFaceConnector` downloads the files that `SOURCE_FILES` names,
one filename per part. A release that holds many files of one kind, such
as ARFBench with 748 series files and 414 charts, cannot list them, so its
connector used `hub_snapshot` directly instead of the base.

`hub_snapshot` is now the one Hub helper. It passes the patterns straight
to `snapshot_download`, which matches globs itself, and returns the
snapshot directory, so the listing call, the pattern matching, and
`download_hub_files` go. The base downloads its parts with it, so a
filename can end in a glob, such as `data/*.parquet`. That part's
`HubFileRef` is the directory of the matching files. A part that matches
no file fails with its name, as a missing file did before.

Test plan
- Command: `make check`
- Coverage: formatting, lint, generated schemas, and types pass
- Command: `uv run pytest packages/timenet-connectors/tests`
- Coverage: 320 tests pass, including a pattern part and a pattern
  without a match, against a fake Hub that applies the patterns
- Command: pytest for the tsqa, tsaqa_benchmark, sensorcaps, and arfbench
  connectors, which call the base or the helper
- Coverage: their 81 tests pass unchanged
…English

Description
The docstrings that this PR adds now follow the rules of simplified technical
English: one fact per sentence, sentences of 25 words or fewer, and no
semicolons. No code changes.

Test plan
- Command: `make check`
- Coverage: formatting, lint, generated schemas, and types pass
- Command: `uv run pytest packages/timenet-connectors/tests`
- Coverage: 320 tests pass
@TimoStoff
TimoStoff force-pushed the feature/hub-base-patterns branch from 75a0e9a to a3d5e5f Compare November 10, 2026 20:10
TimoStoff pushed a commit that referenced this pull request Nov 10, 2026
…e the plots on the series

Description
The review of #615 asked for two more changes, and the plots dataset can
now use TimeNet's own parent mechanism instead of subclassing:

* Both connectors build on `BaseHuggingFaceConnector`, whose source parts
  can now be file patterns (#770). The series connector declares the
  question table and `arfbench-ts-data/*.parquet`; the plots connector the
  table and `arfbench-images/*.png`.
* Every question asks to pick one of its released options, so each task
  is a classification task whose label set holds those options, named
  after the question's row. The series task and the chart task of a
  question share it. The `answer_options` annotation goes.
* `datadog/arfbench-plots` declares `datadog/arfbench@1.0.0` as its parent
  `series`. Its `compose` imports the parent's tasks with the metric
  records they cite and adds the charts and the chart tasks. The imported
  series keep reading the parent's Parquet release, so the child stores
  only the charts, with Zarr.

Test plan
- Command: pytest and ty for both connectors in their own environments,
  as `make test-connectors` runs them
- Coverage: 14 series tests (the classification tasks and their label
  sets, the Parquet round trip) and 4 plots tests (the parent declaration,
  the imported and added tasks, a child that stores only the charts and
  reads the series through its parent, a missing chart)
- Command: `make check`
- Coverage: formatting, lint, generated schemas, and types pass
- Command: `timenet-build build datadog/arfbench-plots --build-parents`
  into a local registry
- Coverage: `datadog/arfbench` holds 142 records, 38,032 series, and 750
  classification tasks; `datadog/arfbench-plots` holds 556 records and
  1,500 tasks over the same 750 label sets, names
  `datadog/arfbench@1.0.0` as its payload source, and stores the charts
@github-actions

Copy link
Copy Markdown

⚠️ CI checks failed

Check Status
Quick checks ❌ Failed
Tests (Python 3.13) ⏭️ Did not run
Tests (Python 3.11) ⏭️ Did not run

Full output is in the job logs. Reproduce locally:

make lint-fix   # auto-fix
make check-ci   # the hooks, plus ty on 3.13 and 3.11
make test-unit  # the quick job's tests
make test       # the full suite

Updated for a3d5e5f · run #8370

This branch has not been deployed

No deployments
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