Skip to content

Lazyfying - #239

Open
nikbpetrov wants to merge 2 commits into
forecastingresearch:mainfrom
nikbpetrov:refactor/lazy-imports
Open

nikbpetrov wants to merge 2 commits into
forecastingresearch:mainfrom
nikbpetrov:refactor/lazy-imports

Conversation

@nikbpetrov

@nikbpetrov nikbpetrov commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator

meant to be merged as separate commits, just grouped here in the same PR

7de71bd is not lazy-related, sorry for sneaking it in, but it's a 1-line print -> logger.debug, change (preps the testing framework work)

@nikbpetrov
nikbpetrov force-pushed the refactor/lazy-imports branch from 0a2dc33 to d0914f1 Compare June 30, 2026 17:41
@nikbpetrov
nikbpetrov force-pushed the refactor/lazy-imports branch from 7de71bd to ee90d58 Compare September 10, 2026 02:04
Comment thread src/helpers/keys.py Outdated
Comment thread src/leaderboard/main.py Outdated
Comment thread src/curate_questions/create_question_set/main.py Outdated
# Optional reproducibility: when QUESTION_SET_SEED is set, thread a single RandomState through
# both sampling passes so the published set is deterministic. Unset (the default) preserves the
# historical unseeded behaviour.
seed_env = os.getenv("QUESTION_SET_SEED")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we also check that seed_env is None when we're in prod to ensure it isn't accidentally ever set in deployment?

Comment thread src/helpers/env.py Outdated
Comment thread src/curate_questions/create_question_set/main.py Outdated
@nikbpetrov
nikbpetrov force-pushed the refactor/lazy-imports branch from ee90d58 to 5c4c4ec Compare September 22, 2026 10:45
@houtanb
houtanb force-pushed the refactor/lazy-imports branch 2 times, most recently from 7ac2754 to 69da6cf Compare September 24, 2026 12:14

@houtanb houtanb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I picked out 5479728 0e09584 and c09ad91 and will likely merge them after the test run on dev.

Can you make the _SECRET_NAMES change and squash the other deterministic seed commits into one?

Comment thread src/helpers/keys.py
…aderboard bootstrapping

Add an optional `RANDOM_SEED` environment variable, exposed as `env.RANDOM_SEED` (`int`, `None` when
unset). When set, it seeds the question sampling in `create_question_set` (the human and LLM
samplers, threading a single `np.random.RandomState` so successive draws decorrelate) and the
question-level bootstrap behind the simulated leaderboards, making both testable and reproducible.

It is for testing only: deployments leave it unset, so production behaviour stays unseeded, and a
test ensures the root `Makefile` never ships it to Cloud Run.
Importing `helpers.keys` used to fetch every secret from Secret Manager at module load, so any
module that imported it, even indirectly, needed GCP credentials and paid for network calls it
might never use. Secrets are now listed in the `_SECRET_NAMES` set and resolved through a module
`__getattr__` (PEP 562) on first attribute access, then memoized; the attribute name is the secret
name. Callers keep using `keys.API_*` unchanged.
@nikbpetrov
nikbpetrov force-pushed the refactor/lazy-imports branch from 69da6cf to 803d0a4 Compare September 25, 2026 09:34
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