Repository navigation
refactor: metadata tag - #345
Open
nikbpetrov wants to merge 2 commits into
Open
nikbpetrov wants to merge 2 commits into
nikbpetrov wants to merge 2 commits into
Conversation
nikbpetrov
force-pushed
the
p1-metadata-tag
branch
from
October 30, 2026 08:23
c6f796e to
800d845
Compare
nikbpetrov
marked this pull request as ready for review
October 30, 2026 08:24
nikbpetrov
force-pushed
the
p1-metadata-tag
branch
2 times, most recently
from
November 1, 2026 09:54
04db21a to
d8aaec9
Compare
houtanb
force-pushed
the
p1-metadata-tag
branch
2 times, most recently
from
November 9, 2026 09:08
03b27c4 to
a64616d
Compare
pyfixest 0.70.0 (released 2026-11-08) rejects a fixed-effect column of object dtype, and
`two_way_fixed_effects` passes `question_pk` and `model_pk` as plain object columns:
FixedEffectEvaluationError: Fixed-effect column `model_pk` has unsupported object dtype.
The requirement had no upper bound, so every fresh install, CI and the next leaderboard deploy
alike, picks up 0.70.0 and the fit fails. Cap it at the last version the code was run with; casting
the key columns to `string` and lifting the cap is a separate change.
Port `src/metadata/tag_questions/main.py` to `src/metadata/_tag.py`, exported as `metadata.tag` (the domain logic: category from the metadata model or fixed per source, English flag from Jev, merge into the metadata frame; function bodies verbatim) and `src/orchestration/func_metadata_tag/` (the Cloud Run job `func-metadata-tag-questions`: download the metadata, then one `tag()` call and one upload per sampled source with the 2 s GCS write-rate sleep). `orchestration._io` gains `load_question_metadata()` and `upload_question_metadata()`; `_schemas` gains `MetadataFrame`, which types `valid_question` and `english` as bool or "" because the file carries the placeholder until validate runs or when a Jev call failed. `tag()` and the two `_io` helpers take and return `DataFrame[MetadataFrame]` / `DataFrame[QuestionFrame]` under `@pa.check_types`, so a malformed metadata or question file fails the job instead of being written; `load_question_metadata()` fills the columns a file written before they existed lacks. The module is private (`_tag.py`) because a public `tag.py` would be shadowed by the re-exported function. The package exports `tag` through a module `__getattr__` rather than an eager import, so a job that imports `metadata` for another function does not load `_tag`'s Jev SDK, which only the tag job ships; a contract test pins that. `src/metadata/tag_questions/` is removed and the root `Makefile` target `tag-questions` repointed. Requirements drop `functions-framework` (the job runs `python3 main.py`) and `scipy` (nothing in the staged import chain loads it). Tests pin the two production fixes the job carries, the 512-token category budget (`c0d475e`) and the one-time key fetch before the concurrent calls (`1fb7ddd`), and the (source, id) merge key. Parity: on a mirror of the dev question bank, with the same deterministic model and Jev fakes on both sides, the old and new jobs write a byte-identical `question_metadata.jsonl` (final and every per-source upload) and send the same rows to the model and to Jev, in the as-is, perturbed and empty-file scenarios. Tests: `unit/metadata/test_tag.py`, `unit/orchestration/test_metadata_tag_job.py` and `integration/test_metadata_io.py`, superseding `unit/metadata/test_tag_questions.py` and `test_tag_questions_english.py`; `integration/test_metadata_drivers.py`, `e2e/test_question_set_pipeline.py`, `contract/test_offline_imports.py` and `contract/test_runtime_requirements.py` follow the moved modules.
nikbpetrov
force-pushed
the
p1-metadata-tag
branch
from
November 9, 2026 12:07
a64616d to
7bff2fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On top of #344
__init__.pyis to set up the nicer looking import, namelyfrom metadata import tagrather than something likefrom metadata._tag import tagor equivalent; tests import ugly the specific funcs but they'll be okaymetadata/__init__.pyas it gets fixed with Python 3.15'slazykeywordExisting/legacy bug: a non-404 download error yields an empty frame and the job re-tags everything and overwrites the bucket file. Either file an issue and fix in a separate PR or fix here - @houtanb , wdyt?