feat: Add support for passing env vars to run command by edwinjosechittilappilly · Pull Request #10986 · langflow-ai/langflow (original) (raw)
The run CLI command now accepts --env-var KEY=VALUE options to inject global variables into the graph context. Includes validation for variable format and unit tests to verify correct injection and error handling. Also improves script loading to register modules by script name for better inspection.
changed the title
Add support for passing env vars to run command feat:Add support for passing env vars to run command
Updated environment variable loading logic to prioritize CLI-provided variables (request_variables in context) over OS environment variables for load_from_db fields. Added unit tests to verify correct precedence and fallback behavior.
Copilot AI review requested due to automatic review settings
Add a pytest fixture to configure structlog before tests to prevent AttributeError when mocking logger.configure. Update unit tests to patch the actual logger module using sys.modules, ensuring correct patching and avoiding issues with module references.
Adam-Aghili changed the title
feat:Add support for passing env vars to run command feat: Add support for passing env vars to run command
Wallgau pushed a commit that referenced this pull request
- Add support for passing env vars to run command
The run CLI command now accepts --env-var KEY=VALUE options to inject global variables into the graph context. Includes validation for variable format and unit tests to verify correct injection and error handling. Also improves script loading to register modules by script name for better inspection.
[autofix.ci] apply automated fixes
Support CLI env var precedence over OS env vars
Updated environment variable loading logic to prioritize CLI-provided variables (request_variables in context) over OS environment variables for load_from_db fields. Added unit tests to verify correct precedence and fallback behavior.
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
fix ruff
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
[autofix.ci] apply automated fixes (attempt 3/3)
Refactor run CLI to delegate execution to run module
Refactors the run CLI command to delegate execution logic to a new lfx.run.base module, improving separation of concerns and maintainability. Moves core run logic and error handling into lfx.run.base, introduces a RunError exception, and updates tests to target the new structure. Removes the --env-var option from the CLI and migrates related tests to the run module.
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
[autofix.ci] apply automated fixes (attempt 3/3)
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
[autofix.ci] apply automated fixes (attempt 3/3)
Update src/lfx/src/lfx/interface/initialize/loading.py
Co-authored-by: Gabriel Luiz Freitas Almeida gabriel@langflow.org
- Update src/lfx/src/lfx/interface/initialize/loading.py
Co-authored-by: Gabriel Luiz Freitas Almeida gabriel@langflow.org
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
[autofix.ci] apply automated fixes (attempt 3/3)
Update loading.py
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
[autofix.ci] apply automated fixes (attempt 3/3)
Reorder import of PydanticDeprecatedSince20
Moved the import of PydanticDeprecatedSince20 to group it with other pydantic imports, improving code organization.
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
[autofix.ci] apply automated fixes (attempt 3/3)
fix ruff
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
[autofix.ci] apply automated fixes (attempt 3/3)
Update test_base.py
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
[autofix.ci] apply automated fixes (attempt 3/3)
Fix structlog setup and logger patching in tests
Add a pytest fixture to configure structlog before tests to prevent AttributeError when mocking logger.configure. Update unit tests to patch the actual logger module using sys.modules, ensuring correct patching and avoiding issues with module references.
[autofix.ci] apply automated fixes
[autofix.ci] apply automated fixes (attempt 2/3)
[autofix.ci] apply automated fixes (attempt 3/3)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida gabriel@langflow.org
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
[ Show hidden characters]({{ revealButtonHref }})