openclimatefix / openclimatefix/quartz-api

Module-level os.getenv bypasses server.conf

Open
#376 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10
Forks
32
Avg merge
1d 3h
Merged PRs (30d)
13

Description

server.conf is the documented list of the service's env vars, but only cmd/main.py reads it. Modules that need a var call os.getenv at import time instead, so those vars appear nowhere in the config schema.

Peter's TODO in time_utils.py:11 says the same thing, from Feb 2026.

Cause: conf is created at the bottom of cmd/main.py, so importing it from internal/ is a cycle (and a layering inversion). Fix is to move the ConfigFactory.parse_file call into its own module that both main and other modules can import.

Current sites:

uk_national/status_router.pySTATUS_API_URL v0, retires
uk_national/time_utils.pyINTRADAY_LIMIT_HOURS v0, retires

Does v0 retirement make this moot? Mostly. Two of the three go away with v0, and v1 has no os.getenv at all today. What's left is the precedent — v1 will eventually need a settled way of doing env vars, and right now the path of least resistance is another module-level os.getenv. So this is worth doing to set the pattern before v1 grows one, not to rescue v0.

Low priority. Raised from review of #375.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in cmd/main.py to trace how server.conf is created, then inspect uk_national/status_router.py and uk_national/time_utils.py, including the TODO at time_utils.py:11. Move the ConfigFactory.parse_file setup into a shared module that main and internal modules can import without a cycle. Done means these current sites no longer use module-level os.getenv and the shared configuration pattern is established for future v1 variables.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.