Skip to content

refactor: 6-hourly collect-stats again; high-res samples from a run-anywhere sampler - #31

Merged
ErikBjare merged 6 commits into
masterfrom
feat/launch-sampler-workflow
Oct 6, 2026
Merged

ErikBjare merged 6 commits into
masterfrom
feat/launch-sampler-workflow

Conversation

@ErikBjare

@ErikBjare ErikBjare commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #30, per Erik: no high-frequency Actions schedule at all.

  • collect-stats.yml back to plain 0 */6 * * * (removes feat: 10-minute stats during the v0.14.0 launch; exclude updater assets from totals #30's */10 cron and cadence step). Keeps feat: 10-minute stats during the v0.14.0 launch; exclude updater assets from totals #30's push-with-retry and the updater-asset exclusion.
  • New sample_hf.py: run it anywhere during a launch (laptop, server, VM), then submit data/hf/*.csv in a PR. Polls every 60 s (--interval), with ETag conditional requests (unchanged responses are 304s, which don't count against the rate limit), and appends change-only rows in the same schemas as stats.csv / stats-assets.csv, so quiet minutes cost nothing. Downloads exclude updater assets like collect_stats.downloads(). Resumes from the files after a restart; --until stops it; --trim MINUTES coarsens to the last row per series per bucket before submitting.
  • Tests for change-only appends, updater exclusion, resume, and trim.
GITHUB_TOKEN=$(gh auth token) uv run python3 sample_hf.py --until 2026-10-20

…-stats back to 6-hourly

collect-stats.yml returns to its plain 6-hourly schedule. collect-launch.yml
samples every ~10 min (best effort) until WINDOW_END (2026-10-20), then runs
'gh workflow disable' on itself, so nothing keeps firing between launches.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@ErikBjare

Copy link
Copy Markdown
Member Author

@greptileai review

…h workflow

Drop collect-launch.yml; collect-stats stays plain 6-hourly. sample_hf.py polls
every 60 s with ETag conditional requests, appends change-only rows to data/hf/,
resumes from the files, and --trim coarsens before submitting in a PR.
@ErikBjare ErikBjare changed the title refactor: self-disabling launch-window sampler; collect-stats back to 6-hourly refactor: 6-hourly collect-stats again; high-res samples from a run-anywhere sampler Oct 6, 2026
@ErikBjare

Copy link
Copy Markdown
Member Author

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Refactors stats collection from scheduled polling to manual sampling.

The PR appears safe to merge, with no new actionable issues or outstanding previous findings.

What we checked:

  • Public releases remain included: The filter checks only draft. It leaves cached responses unchanged, and sample_once() writes assets whose counts are not already saved.

Summary

Restores six-hourly Actions collection and adds sample_hf.py for change-only launch samples collected outside Actions.

  • The latest change excludes draft releases and adds a draft to the cached-page test.
  • All six previous findings are addressed or no longer apply.
  • ErikBjare explained that the second workflow was removed; Greptile agreed that the earlier race finding no longer applies.
  • No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Six-hourly Actions run] --> B[collect_stats.py]
  B --> C[Main CSV files]
  D[External sampler] --> E[Conditional GitHub requests]
  E --> F[Skip draft releases]
  F --> G[Append changed counts to data/hf]
  G --> H[Stop sampler]
  H --> I[Optional trim]
  I --> J[Submit CSV files in a PR]
Loading

Reviews (6) · Last reviewed commit: "fix(sample_hf): skip draft releases (onl..."

Comment thread .github/workflows/collect-launch.yml Outdated
Comment on lines +41 to +42
- uses: actions/checkout@v4
if: steps.window.outputs.open == 'true'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Queued collections lose samples

When both schedules fire at a six-hour boundary, one run can wait behind the other in collect-stats. Checkout without ref uses the run’s original SHA, not the latest master. If the first run pushes while the second waits, the second appends to an old copy of data/stats.csv. Its push is rejected, and git pull --rebase conflicts because both commits appended different rows at the same end of the file. That sample never reaches master.

The new second schedule makes this possible even when collection takes less than ten minutes. Set ref: master on both workflows’ checkouts so each run reads the latest files after it gets its turn.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Moot: collect-launch.yml was removed in this PR (the sampler runs outside Actions), so only the 6-hourly collect-stats checks out and pushes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You’re right — this finding is moot. collect-launch.yml is not part of the current diff, and the only scheduled workflow now runs at 0 */6 * * *; the external sampler does not create a second Actions checkout/push race. No change is needed for this comment.

Comment thread sample_hf.py
Comment on lines +160 to +163
with open(path, "w", newline="") as f:
w = csv.DictWriter(f, fieldnames=fields)
w.writeheader()
w.writerows(out)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Trimming can delete new samples

Running --trim while the sampler is collecting can silently delete samples. trim() reads the files, then truncates and rewrites them. Rows appended between those steps are lost, while the sampler still remembers their counts and skips writing them again. Use a shared lock for sampling and trimming, or refuse to trim while a sampler is active.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 424390e.

Comment thread sample_hf.py Outdated
Comment on lines +189 to +192
until = (
datetime.fromisoformat(args.until).replace(tzinfo=timezone.utc)
if args.until
else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Time offsets change stopping time

--until silently changes the meaning of ISO times with an offset. 2026-10-20T02:00:00+02:00 means midnight UTC, but .replace(tzinfo=timezone.utc) makes it 02:00 UTC instead. Convert aware times with .astimezone(timezone.utc) and attach UTC only to times without an offset, or reject non-UTC offsets explicitly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 424390e.

Comment thread sample_hf.py
Comment on lines +179 to +185
args = p.parse_args()

if args.trim:
trim(args.trim)
return
token = os.getenv("GITHUB_TOKEN")
if not token and args.interval < 120:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Bad options start unwanted collection

With a token, --interval 0 or a negative interval sends requests continuously because the sleep becomes zero. --trim 0 skips trimming and unexpectedly starts collecting instead. Reject non-positive values for both options before starting either operation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 424390e.

Comment thread test_sample_hf.py
Comment on lines +35 to +38
client = FakeClient(assets)
state = sample_hf.load_state()
assert sample_hf.sample_once(client, state) == (2, 1)
assert sample_hf.sample_once(client, state) == (0, 0) # nothing changed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Key sampler paths lack tests

The tests bypass ConditionalClient, and the trim test skips the assets file. Add mocked HTTP tests for a successful response followed by a 304, including cached next-page links. Also test trimming two different assets in the same bucket. The current tests cannot catch broken cached requests, skipped release pages, or dropped asset series.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 424390e.

…ts to UTC, reject non-positive intervals; test client caching and per-asset trim
@ErikBjare

Copy link
Copy Markdown
Member Author

@greptileai review

Comment thread sample_hf.py Outdated

import argparse
import csv
import fcntl

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Sampler cannot start on Windows

The new unconditional import fcntl prevents sample_hf.py from starting on Windows. Python only provides fcntl on Unix, so Windows users get ModuleNotFoundError before they can sample, trim, or view help. This breaks the documented run-anywhere use. Use a cross-platform lock or provide a Windows locking branch.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 12c581e: msvcrt.locking on Windows, fcntl.flock elsewhere, imported lazily; test covers a second holder being refused.

@ErikBjare

Copy link
Copy Markdown
Member Author

@greptileai review

@ErikBjare

Copy link
Copy Markdown
Member Author

@greptileai review

@ErikBjare

Copy link
Copy Markdown
Member Author

@greptileai review

@ErikBjare
ErikBjare merged commit 2ed77c5 into master Oct 6, 2026
2 checks passed
@ErikBjare
ErikBjare deleted the feat/launch-sampler-workflow branch October 6, 2026 22:15
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.

1 participant