Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add unit tests for run_flow_from_json with fake environment variables #4015

Merged
merged 24 commits into from
Jan 31, 2025

Conversation

edwinjosechittilappilly
Copy link
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly commented Oct 3, 2024

Added Tests for run_flow_from_json Functionality

Description

This PR introduces new unit tests for the run_flow_from_json function to ensure it correctly handles environment variables. The following tests have been added:

  • test_run_flow_with_fake_env: Validates the flow execution using a fake .env file, ensuring that the expected output is returned.
  • test_run_flow_with_fake_env_TWEAKS: Checks the flow execution when environment variables are loaded from the fake .env file, confirming that the output matches the expected result.

Motivation

These tests enhance the reliability of the run_flow_from_json function by verifying its behavior with different configurations of environment variables, which is crucial for maintaining functionality in various deployment scenarios.

Changes

  • Added test_run_flow_with_fake_env to test flow execution with a fake environment.
  • Added test_run_flow_with_fake_env_TWEAKS to test flow execution with environment variables loaded from a fake .env file.
  • Implemented a function to recursively replace keys in the tweaks dictionary with values from the provided environment variables. This Fixes the issue of ENV variables not loading when using run_flow_from_json

- Implemented test_run_flow_with_fake_env to validate flow execution with a fake .env file.
- Added test_run_flow_with_fake_env_TWEAKS to check flow execution using environment variables loaded from the fake .env file.
@github-actions github-actions bot added the enhancement New feature or request label Oct 3, 2024
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-4015.dmtpw4p5recq1.amplifyapp.com

…values

- Implemented a function to recursively replace keys in the tweaks dictionary with values from the provided environment variables.
@edwinjosechittilappilly edwinjosechittilappilly marked this pull request as ready for review October 3, 2024 21:51
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 3, 2024
@edwinjosechittilappilly edwinjosechittilappilly added the bug Something isn't working label Oct 3, 2024
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request bug Something isn't working labels Oct 3, 2024
Copy link
Member

@italojohnny italojohnny left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 4, 2024
@edwinjosechittilappilly edwinjosechittilappilly enabled auto-merge (squash) October 4, 2024 17:09
Copy link
Contributor

github-actions bot commented Oct 8, 2024

Cannot auto-update because of conflicts.

- Renamed variable `TWEAKS` to `tweaks_dict` for clarity and consistency across tests.
- Updated test function names to follow a consistent naming convention.
- Enhanced comments for better understanding of test intentions.
- Minor formatting adjustments to improve code readability.
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 20, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 30, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 31, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 31, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 31, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 31, 2025
@ogabrielluiz ogabrielluiz disabled auto-merge January 31, 2025 18:26
@ogabrielluiz ogabrielluiz added this pull request to the merge queue Jan 31, 2025
@ogabrielluiz ogabrielluiz removed this pull request from the merge queue due to a manual request Jan 31, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jan 31, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 31, 2025
@ogabrielluiz ogabrielluiz added this pull request to the merge queue Jan 31, 2025
Merged via the queue into main with commit 0514d11 Jan 31, 2025
24 of 32 checks passed
@ogabrielluiz ogabrielluiz deleted the fix-run_flow_json_env branch January 31, 2025 19:02
edwinjosechittilappilly added a commit that referenced this pull request Jan 31, 2025
…iables (#4015)

* Add tests for run_flow_from_json with fake environment variables

- Implemented test_run_flow_with_fake_env to validate flow execution with a fake .env file.
- Added test_run_flow_with_fake_env_TWEAKS to check flow execution using environment variables loaded from the fake .env file.

* Replace keys in tweaks with their corresponding environment variable values

- Implemented a function to recursively replace keys in the tweaks dictionary with values from the provided environment variables.

* updated to use better way to load test  json file

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* refactor: improve test readability and consistency in load tests

- Renamed variable `TWEAKS` to `tweaks_dict` for clarity and consistency across tests.
- Updated test function names to follow a consistent naming convention.
- Enhanced comments for better understanding of test intentions.
- Minor formatting adjustments to improve code readability.

* feat: add aload_flow_from_json and arun_flow_from_json to module exports

* fix: correct file path handling in aload_flow_from_json function

* fix: improve environment variable handling in aload_flow_from_json function

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants