-
Notifications
You must be signed in to change notification settings - Fork 44
Add (exclude_)where args to workload directive [AI] #1642
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
Merged
rfbgo
merged 1 commit into
GoogleCloudPlatform:develop
from
douglasjacobsen:workload-filters
Aug 3, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
120 changes: 120 additions & 0 deletions
120
lib/ramble/ramble/test/end_to_end/workload_where_clauses.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # Copyright 2022-2026 The Ramble Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
| # https://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
| # <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your | ||
| # option. This file may not be copied, modified, or distributed | ||
| # except according to those terms. | ||
|
|
||
| import pytest | ||
|
|
||
| from ramble.main import RambleCommand | ||
|
|
||
| # everything here should be mocked if possible | ||
| pytestmark = pytest.mark.usefixtures("mutable_config", "mutable_mock_workspace_path") | ||
|
|
||
| workspace = RambleCommand("workspace") | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "workload,experiments,expected_generated,expected_dropped", | ||
| [ | ||
| ("always", [("test1", "foo")], ["test1"], []), | ||
| ( | ||
| "only_when_var_is_foo", | ||
| [("test_foo", "foo"), ("test_bar", "bar")], | ||
| ["test_foo"], | ||
| ["test_bar"], | ||
| ), | ||
| ( | ||
| "exclude_when_var_is_bar", | ||
| [("test_foo", "foo"), ("test_bar", "bar")], | ||
| ["test_foo"], | ||
| ["test_bar"], | ||
| ), | ||
| ], | ||
| ) | ||
| def test_workload_where_clauses( | ||
| workload, | ||
| experiments, | ||
| expected_generated, | ||
| expected_dropped, | ||
| mutable_config, | ||
| mutable_mock_workspace_path, | ||
| mutable_mock_apps_repo, | ||
| ): | ||
|
douglasjacobsen marked this conversation as resolved.
|
||
| """Test workload where and exclude_where clauses.""" | ||
|
|
||
| import ramble.workspace | ||
|
|
||
| workspace_name = f"test_workload_where_clauses_{workload}" | ||
| ws = ramble.workspace.create(workspace_name) | ||
| ws.write() | ||
|
|
||
| for exp, var in experiments: | ||
| workspace( | ||
| "manage", | ||
| "experiments", | ||
| "workload-where-mock", | ||
| "--workload-filter", | ||
| workload, | ||
| "--experiment-name", | ||
| exp, | ||
| "-v", | ||
| f"test_var={var}", | ||
| global_args=["-D", ws.root], | ||
| ) | ||
|
|
||
| out = workspace("setup", "--dry-run", global_args=["-D", ws.root]) | ||
|
|
||
| for exp in expected_generated: | ||
| assert f"workload-where-mock.{workload}.{exp}" in out | ||
|
|
||
| for exp in expected_dropped: | ||
| assert f"workload-where-mock.{workload}.{exp}" not in out | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "workload,experiments,expected_warning", | ||
| [ | ||
| ( | ||
| "only_when_var_is_foo", | ||
| [("test_bar", "bar"), ("test_baz", "baz")], | ||
| "Workload only_when_var_is_foo generated zero valid experiments because they were " | ||
| "all filtered out by the workload's internal clauses.", | ||
| ), | ||
| ], | ||
| ) | ||
| def test_workload_where_clauses_warnings( | ||
| workload, | ||
| experiments, | ||
| expected_warning, | ||
| mutable_config, | ||
| mutable_mock_workspace_path, | ||
| mutable_mock_apps_repo, | ||
| ): | ||
| """Test workload where and exclude_where clauses.""" | ||
|
|
||
| import ramble.workspace | ||
|
|
||
| workspace_name = f"test_workload_where_clauses_warnings_{workload}" | ||
| ws = ramble.workspace.create(workspace_name) | ||
| ws.write() | ||
|
|
||
| for exp, var in experiments: | ||
| workspace( | ||
| "manage", | ||
| "experiments", | ||
| "workload-where-mock", | ||
| "--workload-filter", | ||
| workload, | ||
| "--experiment-name", | ||
| exp, | ||
| "-v", | ||
| f"test_var={var}", | ||
| global_args=["-D", ws.root], | ||
| ) | ||
|
|
||
| out = workspace("setup", "--dry-run", global_args=["-D", ws.root]) | ||
|
|
||
| assert expected_warning in out | ||
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
29 changes: 29 additions & 0 deletions
29
var/ramble/repos/builtin.mock/applications/workload-where-mock/application.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Copyright 2022-2026 The Ramble Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
| # https://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
| # <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your | ||
| # option. This file may not be copied, modified, or distributed | ||
| # except according to those terms. | ||
|
|
||
| from ramble.appkit import * | ||
|
|
||
|
|
||
| class WorkloadWhereMock(ExecutableApplication): | ||
| name = "workload-where-mock" | ||
|
|
||
| executable("test_exec", "echo '{test_var}'", use_mpi=False) | ||
|
|
||
| workload_variable("test_var", default="foo", workloads=["*"]) | ||
|
|
||
| workload("always", executable="test_exec") | ||
| workload( | ||
| "only_when_var_is_foo", | ||
| executable="test_exec", | ||
| where=["'{test_var}' == 'foo'"], | ||
| ) | ||
| workload( | ||
| "exclude_when_var_is_bar", | ||
| executable="test_exec", | ||
| exclude_where=["'{test_var}' == 'bar'"], | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.