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

[MAINTENANCE] Ensure that changes made to env vars / config vars are recognized within subsequent calls of the same process #5410

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 48 additions & 0 deletions tests/data_context/test_data_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2879,3 +2879,51 @@ def test_stores_evaluation_parameters_resolve_correctly(data_context_with_query_
)
checkpoint_result = checkpoint.run()
assert checkpoint_result.get("success") is True


def test_modifications_to_env_vars_is_recognized_within_same_program_execution(
empty_data_context: DataContext, monkeypatch
) -> None:
"""
What does this test do and why?

Great Expectations recognizes changes made to environment variables within a program execution
and ensures that these changes are recognized in subsequent calls within the same process.

This is particularly relevant when performing substitutions within a user's project config.
"""
Comment on lines +2887 to +2894
Copy link
Contributor

Choose a reason for hiding this comment

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

love the note. Thank you

context: DataContext = empty_data_context
env_var_name: str = "MY_PLUGINS_DIRECTORY"
env_var_value: str = "my_patched_value"

context.config.plugins_directory = f"${env_var_name}"
monkeypatch.setenv(env_var_name, env_var_value)

assert context.plugins_directory and context.plugins_directory.endswith(
env_var_value
)


def test_modifications_to_config_vars_is_recognized_within_same_program_execution(
empty_data_context: DataContext,
) -> None:
"""
What does this test do and why?

Great Expectations recognizes changes made to config variables within a program execution
and ensures that these changes are recognized in subsequent calls within the same process.

This is particularly relevant when performing substitutions within a user's project config.
"""
context: DataContext = empty_data_context
config_var_name: str = "my_plugins_dir"
config_var_value: str = "my_patched_value"

context.config.plugins_directory = f"${config_var_name}"
context.save_config_variable(
config_variable_name=config_var_name, value=config_var_value
)

assert context.plugins_directory and context.plugins_directory.endswith(
config_var_value
)