-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(sdk): make component names more unique when merging specs #9969
Changes from 5 commits
ddbf4c8
954a9f3
15e9d33
5ac37df
c2c2f16
5ac4203
ae8495b
294403f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -792,6 +792,55 @@ def my_pipeline() -> NamedTuple('Outputs', [ | |
]): | ||
task = print_op(msg='Hello') | ||
|
||
def test_nested_conditions_with_for_loops_in_nested_pipelines(self): | ||
|
||
@dsl.pipeline() | ||
def pipeline_2(): | ||
with dsl.ParallelFor([1, 2, 3]): | ||
print_op(message='1') | ||
|
||
@dsl.pipeline() | ||
def pipeline_3(run_pipeline_2: int = 1): | ||
with dsl.ParallelFor([1, 2, 3]): | ||
print_op(message='1') | ||
|
||
with dsl.Condition(run_pipeline_2 == run_pipeline_2): | ||
with dsl.Condition(run_pipeline_2 == 1): | ||
pipeline_2() | ||
|
||
@dsl.pipeline() | ||
def pipeline_1(run_pipeline_2: int = 1, run_pipeline_3: int = 1): | ||
with dsl.Condition(run_pipeline_2 == run_pipeline_2): | ||
with dsl.Condition(run_pipeline_2 == 1): | ||
pipeline_2() | ||
|
||
with dsl.Condition(run_pipeline_3 == run_pipeline_3): | ||
with dsl.Condition(run_pipeline_3 == 1): | ||
pipeline_3() | ||
|
||
with tempfile.TemporaryDirectory() as tmpdir: | ||
output_yaml = os.path.join(tmpdir, 'result.yaml') | ||
compiler.Compiler().compile( | ||
pipeline_func=pipeline_1, package_path=output_yaml) | ||
self.assertTrue(os.path.exists(output_yaml)) | ||
|
||
with open(output_yaml, 'r') as f: | ||
pipeline_spec = yaml.safe_load(f) | ||
tasks = [ | ||
comp.get('dag', {}).get('tasks', {}) | ||
for comp in pipeline_spec['components'].values() | ||
] | ||
component_refs = [[ | ||
x.get('componentRef', {}).get('name') | ||
for x in task.values() | ||
] | ||
for task in tasks] | ||
all_component_refs = [ | ||
item for sublist in component_refs for item in sublist | ||
] | ||
counted_refs = collections.Counter(all_component_refs) | ||
self.assertEqual(1, max(counted_refs.values())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my local testing, this passes both before and after the changes. I also observe that the YAML is not different. Is it possible there is something missing from this test case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad - went to harsh on cutting components to a minimal version. |
||
|
||
|
||
class V2NamespaceAliasTest(unittest.TestCase): | ||
"""Test that imports of both modules and objects are aliased (e.g. all | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a minimal example? If not, could we reduce this to the minimal example required to reproduce the problematic behavior? This will help us ensure we don't regress and will reduce the likelihood that the test is removed as redundant or unclear in the future.
Also, consider renaming the test method to reflect the behavior under test and, if needed, adding a docstring to describe in more detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be much better now, thanks for the push