Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions .github/workflows/push-to-clickhouse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
# and a separate ingest one.
#
# At top_k=10000 per mode, a single job processing the whole list serially
# would take far too long, so the fetch itself IS split out: generate-matrix
# fetches the top-K list once (no Spyre hardware needed), shards it, and
# weekly-model-scan fans out over those shards in parallel (mirrors
# torch-spyre's generate_matrix -> matrix job pattern).
# would take far too long, so the fetch is done once up-front and the actual
# scan is fanned out: the generate-shards job fetches the top-K list once
# on ubuntu-latest, splits it into per-tier shard files, uploads them as
# the `weekly-shards` artifact, and emits matrix_x1 / matrix_x2 / matrix_x4
# JSON pointing at those shard files. The three weekly-model-scan-x{1,2,4}
# jobs then fan out across the Spyre runners, each downloading only its
# own shard.
# =============================================================================
name: push-to-clickhouse

Expand Down Expand Up @@ -73,10 +76,9 @@ jobs:
# job below. No Spyre hardware needed — utils/hf_model_catalog.py's import
# chain (via hf_adapters/auto_spyre_model.py) has no module-level
# torch_spyre dependency; it's lazily imported inside a device-guarded
# function body in hf_common.py. The now-deprecated test_weekly_DEPRECATED
# .yaml is existing proof this exact fetch path runs fine on ubuntu-latest.
# function body in hf_common.py.
# ---------------------------------------------------------------------------
generate-matrix:
generate-shards:
name: Generate weekly shards
runs-on: ubuntu-latest
# At top_k=10000+, fetching 2x oversampled raw candidates per mode (each
Expand Down Expand Up @@ -184,14 +186,14 @@ jobs:
# 10*1 + 4*2 + 1*4 = 22 cards (~2 nodes), so PR/daily CI isn't starved.
weekly-model-scan-x1:
name: Weekly model scan x1 (${{ matrix.mode }} shard ${{ matrix.shard_index }})
needs: generate-matrix
needs: generate-shards
runs-on: [x86_64, spyre_pf_x1, linux, image_torch_spyre]
timeout-minutes: 4320
strategy:
fail-fast: false
max-parallel: 20 # 20 shards x 1 card = 20 cards
matrix:
include: ${{ fromJSON(needs.generate-matrix.outputs.matrix_x1) }}
include: ${{ fromJSON(needs.generate-shards.outputs.matrix_x1) }}
env:
CLICKHOUSE_HOST: ${{ secrets.CLICKHOUSE_HOST }}
CLICKHOUSE_PORT: ${{ secrets.CLICKHOUSE_PORT }}
Expand Down Expand Up @@ -261,14 +263,14 @@ jobs:

weekly-model-scan-x2:
name: Weekly model scan x2 (${{ matrix.mode }} shard ${{ matrix.shard_index }})
needs: generate-matrix
needs: generate-shards
runs-on: [x86_64, spyre_pf_x2, linux, image_torch_spyre]
timeout-minutes: 4320
strategy:
fail-fast: false
max-parallel: 4 # 4 shards x 2 cards = 8 cards
matrix:
include: ${{ fromJSON(needs.generate-matrix.outputs.matrix_x2) }}
include: ${{ fromJSON(needs.generate-shards.outputs.matrix_x2) }}
env:
CLICKHOUSE_HOST: ${{ secrets.CLICKHOUSE_HOST }}
CLICKHOUSE_PORT: ${{ secrets.CLICKHOUSE_PORT }}
Expand Down Expand Up @@ -338,14 +340,14 @@ jobs:

weekly-model-scan-x4:
name: Weekly model scan x4 (${{ matrix.mode }} shard ${{ matrix.shard_index }})
needs: generate-matrix
needs: generate-shards
runs-on: [x86_64, spyre_pf_x4, linux, image_torch_spyre]
timeout-minutes: 4320
strategy:
fail-fast: false
max-parallel: 1 # 1 shard x 4 cards = 4 cards
matrix:
include: ${{ fromJSON(needs.generate-matrix.outputs.matrix_x4) }}
include: ${{ fromJSON(needs.generate-shards.outputs.matrix_x4) }}
env:
CLICKHOUSE_HOST: ${{ secrets.CLICKHOUSE_HOST }}
CLICKHOUSE_PORT: ${{ secrets.CLICKHOUSE_PORT }}
Expand Down
58 changes: 0 additions & 58 deletions .github/workflows/test_weekly_DEPRECATED.yaml

This file was deleted.

35 changes: 32 additions & 3 deletions tests/spyre/weekly_generation/clickhouse_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"""

import os
from datetime import date
from datetime import date, datetime
from pathlib import Path

import clickhouse_connect
Expand Down Expand Up @@ -179,9 +179,38 @@ def _parse_bool(value: str) -> bool:
return value.strip().lower() in ("1", "true", "yes")


# Accepted date input formats. ISO first (canonical), then European day-first
# variants we've seen in exported CSVs. We deliberately do NOT accept ambiguous
# US month-first strings — a slash-separated date is always day-first here.
_DATE_INPUT_FORMATS: tuple[str, ...] = (
"%d/%m/%Y",
"%d-%m-%Y",
"%d.%m.%Y",
)


def _parse_date(value: str) -> date:
"""Parse *value* into a ``date``, tolerating DD/MM/YYYY as well as ISO.

Raises ``ValueError`` if the input doesn't match any accepted format,
so import_csv's existing try/except still reports the row as malformed.
"""
v = value.strip()
try:
return date.fromisoformat(v)
except ValueError:
pass
for fmt in _DATE_INPUT_FORMATS:
try:
return datetime.strptime(v, fmt).date()
except ValueError:
continue
raise ValueError(f"unrecognized date format: {value!r}")


def _parse_nullable_date(value: str | None) -> date | None:
v = (value or "").strip()
return date.fromisoformat(v) if v else None
return _parse_date(v) if v else None


def _parse_nullable_str(value: str | None) -> str | None:
Expand Down Expand Up @@ -212,7 +241,7 @@ def import_csv(sink, csv_path: str) -> tuple[int, int]:
)
continue
try:
snapshot_date_val: date = date.fromisoformat(snapshot_raw)
snapshot_date_val: date = _parse_date(snapshot_raw)
except ValueError:
malformed += 1
print(
Expand Down
Loading
Loading