Skip to content

refactor(src): standardize os.environ usage in inference upload script#194

Merged
WilliamBerryiii merged 2 commits intomainfrom
refactor/issue-130-standardize-env-usage
Feb 18, 2026
Merged

refactor(src): standardize os.environ usage in inference upload script#194
WilliamBerryiii merged 2 commits intomainfrom
refactor/issue-130-standardize-env-usage

Conversation

@WilliamBerryiii
Copy link
Member

Summary

Resolves #130

Standardizes os.environ.get() usage in src/inference/scripts/upload_artifacts.py by adopting set_env_defaults from training.utils.env.

Changes

  • Import set_env_defaults from training.utils inside main() after sys.path setup
  • Centralize 8 environment variable defaults via set_env_defaults(): TASK, EXPORT_DIR, ONNX_SUCCESS, JIT_SUCCESS, NUM_ENVS, MAX_STEPS, VIDEO_LENGTH, INFERENCE_FORMAT
  • Replace os.environ.get("KEY", default) with os.environ["KEY"] for variables covered by set_env_defaults (safe because setdefault guarantees the key exists)
  • Preserve os.environ.get() for truly optional variables (SRC_ROOT, CHECKPOINT_URI, BLOB_STORAGE_ACCOUNT, BLOB_CONTAINER) and dependent defaults (METRICS_DIR depends on computed EXPORT_DIR)

Intentional Exclusions

  • infer.sh heredocs — The 3 os.environ.get() calls in embedded Python heredocs are left unchanged. Azure ML variables are genuinely optional for checkpoint download, and the script gracefully degrades with a warning when they are missing. Adding imports to heredocs increases complexity without functional benefit.
  • upload_to_blob_fallback()AZURE_STORAGE_ACCOUNT_NAME and AZURE_STORAGE_CONTAINER_NAME remain as os.environ.get() since they are optional fallback paths.

Behavior

No functional behavior change. set_env_defaults uses os.environ.setdefault, which preserves any existing values. All default values match the originals exactly.

- add set_env_defaults import from training.utils in main()
- centralize default values for 8 environment variables
- replace os.environ.get with os.environ[] for defaulted vars
- keep os.environ.get for optional and dependent vars

🔧 - Generated by Copilot
Copilot AI review requested due to automatic review settings February 17, 2026 04:57
@github-actions
Copy link

github-actions bot commented Feb 17, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors environment variable handling in src/inference/scripts/upload_artifacts.py to align with the pattern used in training scripts. It centralizes default values using set_env_defaults from training.utils.env, eliminating scattered inline defaults and making the distinction between required-with-defaults and truly-optional variables more explicit.

Changes:

  • Import and use set_env_defaults to centralize 8 environment variable defaults (TASK, EXPORT_DIR, ONNX_SUCCESS, JIT_SUCCESS, NUM_ENVS, MAX_STEPS, VIDEO_LENGTH, INFERENCE_FORMAT)
  • Replace os.environ.get("KEY", default) with os.environ["KEY"] for variables now managed by set_env_defaults
  • Preserve os.environ.get() for truly optional variables and dependent defaults

@WilliamBerryiii WilliamBerryiii added this to the v0.3.0 milestone Feb 17, 2026
@WilliamBerryiii WilliamBerryiii merged commit 5a82581 into main Feb 18, 2026
12 checks passed
@WilliamBerryiii WilliamBerryiii modified the milestones: v0.3.0, v0.11.0 Mar 1, 2026
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.

refactor(src): standardize os.environ usage in inference scripts

3 participants