Skip to content

fix(gpu): respect dotenv override precedence and export prefix in env reader - #5877

Closed
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/gpu-env-override-precedence
Closed

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/gpu-env-override-precedence

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/extensions/services/dashboard-api/gpu.py, _read_env_var_from_file_state() reads environment variables (such as GPU_ASSIGNMENT_JSON_B64 and GPU_BACKEND) from the live .env file by returning immediately upon the first matching prefix (return True, ...). This breaks standard dotenv and POSIX override semantics where assignments appended later in .env override baseline defaults defined earlier. Furthermore, lines formatted with shell export prefixes were not recognized, and reading without explicit UTF-8 decoding combined with except OSError: failed to catch UnicodeDecodeError when .env contained non-ASCII characters.

This patch updates _read_env_var_from_file_state() to scan the entire .env file so that later overrides take precedence, adds support for export prefixes, and enforces safe UTF-8 decoding with Unicode error handling.

Validation

  • Repro baseline: Created .env with default GPU_BACKEND=cpu followed by override GPU_BACKEND=nvidia; confirmed baseline returned cpu. Provided export GPU_ACCELERATOR=cuda; confirmed baseline returned found=False.
  • Post-fix: Verified ods/tests/test_gpu_env_precedence.py passes with exit code 0; _read_env_var_from_file_state returns nvidia and cuda respectively, and handles Unicode characters safely.
  • GPU management suites: 52 passed (51 existing pytest, 1 new regression). New-test syntax and diff checks pass; new regressions wired into Linux CI.

Overlap check

Risk / AI disclosure

AI-assisted investigation, implementation and CLI regressions. This strengthens dotenv reading and override precedence in GPU configuration discovery, not driver or kernel execution. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.

Follow-up integration evidence

Composed with #5871 at 81b881c without conflicts. Production and test diffs passed together; GPU detection and assignment contracts remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

@Lightheartdevs

Copy link
Copy Markdown
Collaborator

Thanks for this contribution. public-beta was promoted into main on 2026-09-24 and no longer receives changes, so we're closing pull requests that target it. This isn't a judgment on the change itself. If it's still needed, please rebase onto main and open a focused PR. See #7253 for details and the contribution policy.

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