-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Feature/large pipeline #2706
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
Closed
Closed
Feature/large pipeline #2706
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
103b7e9
feature: Updated create/update pipeline to support large pipeline def…
c30bb0f
feature: Added parallelism config to create/update/start pipeline met…
e777674
Updated docstring, added describe call to check config
bc7573d
Merge branch 'master' into feature/large_pipeline
ameenkhan07 7370871
Fixed formatting issues
53061e8
feature: allow conditional parellel builds (#2727)
mufaddal-rohawala 1ff8ae3
fix endpoint bug (#2772)
BasilBeirouti a8d42ca
Merge branch 'master' into feature/large_pipeline
ahsan-z-khan 458d4f8
Merge branch 'dev' into feature/large_pipeline
ahsan-z-khan 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
"""Pipeline Parallelism Configuration""" | ||
from __future__ import absolute_import | ||
from sagemaker.workflow.entities import RequestType | ||
|
||
|
||
class ParallelismConfiguration: | ||
"""Parallelism config for SageMaker pipeline.""" | ||
|
||
def __init__(self, max_parallel_execution_steps: int): | ||
"""Create a ParallelismConfiguration | ||
|
||
Args: | ||
max_parallel_execution_steps, int: | ||
max number of steps which could be parallelized | ||
""" | ||
self.max_parallel_execution_steps = max_parallel_execution_steps | ||
|
||
def to_request(self) -> RequestType: | ||
"""Returns: the request structure.""" | ||
return { | ||
"MaxParallelExecutionSteps": self.max_parallel_execution_steps, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ | |
) | ||
from sagemaker.workflow.step_collections import RegisterModel | ||
from sagemaker.workflow.pipeline import Pipeline | ||
from sagemaker.workflow.parallelism_config import ParallelismConfiguration | ||
from sagemaker.lambda_helper import Lambda | ||
from sagemaker.feature_store.feature_group import FeatureGroup, FeatureDefinition, FeatureTypeEnum | ||
from tests.integ import DATA_DIR | ||
|
@@ -2277,3 +2278,96 @@ def cleanup_feature_group(feature_group: FeatureGroup): | |
except Exception as e: | ||
print(f"Delete FeatureGroup failed with error: {e}.") | ||
pass | ||
|
||
|
||
def test_large_pipeline(sagemaker_session, role, pipeline_name, region_name): | ||
instance_count = ParameterInteger(name="InstanceCount", default_value=2) | ||
|
||
outputParam = CallbackOutput(output_name="output", output_type=CallbackOutputTypeEnum.String) | ||
|
||
callback_steps = [ | ||
CallbackStep( | ||
name=f"callback-step{count}", | ||
sqs_queue_url="https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue", | ||
inputs={"arg1": "foo"}, | ||
outputs=[outputParam], | ||
) for count in range(2000) | ||
] | ||
pipeline = Pipeline( | ||
name=pipeline_name, | ||
parameters=[instance_count], | ||
steps=callback_steps, | ||
sagemaker_session=sagemaker_session, | ||
) | ||
|
||
try: | ||
response = pipeline.create(role) | ||
create_arn = response["PipelineArn"] | ||
assert re.match( | ||
fr"arn:aws:sagemaker:{region_name}:\d{{12}}:pipeline/{pipeline_name}", | ||
create_arn, | ||
) | ||
response = pipeline.describe() | ||
assert len(json.loads(pipeline.describe()["PipelineDefinition"])["Steps"]) == 2000 | ||
|
||
pipeline.parameters = [ParameterInteger(name="InstanceCount", default_value=1)] | ||
response = pipeline.update(role) | ||
update_arn = response["PipelineArn"] | ||
assert re.match( | ||
fr"arn:aws:sagemaker:{region_name}:\d{{12}}:pipeline/{pipeline_name}", | ||
update_arn, | ||
) | ||
finally: | ||
try: | ||
pipeline.delete() | ||
except Exception: | ||
pass | ||
|
||
def test_create_and_update_with_parallelism_config(sagemaker_session, role, pipeline_name, region_name): | ||
instance_count = ParameterInteger(name="InstanceCount", default_value=2) | ||
|
||
outputParam = CallbackOutput(output_name="output", output_type=CallbackOutputTypeEnum.String) | ||
|
||
callback_steps = [ | ||
CallbackStep( | ||
name=f"callback-step{count}", | ||
sqs_queue_url="https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue", | ||
inputs={"arg1": "foo"}, | ||
outputs=[outputParam], | ||
) | ||
for count in range(500) | ||
] | ||
pipeline = Pipeline( | ||
name=pipeline_name, | ||
parameters=[instance_count], | ||
steps=callback_steps, | ||
sagemaker_session=sagemaker_session, | ||
) | ||
|
||
|
||
try: | ||
response = pipeline.create(role, parallelism_config={"MaxParallelExecutionSteps": 50}) | ||
create_arn = response["PipelineArn"] | ||
assert re.match( | ||
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. Also do a describe call to verify the configuration |
||
fr"arn:aws:sagemaker:{region_name}:\d{{12}}:pipeline/{pipeline_name}", | ||
create_arn, | ||
) | ||
response = pipeline.describe() | ||
assert response["ParallelismConfiguration"]["MaxParallelExecutionSteps"] == 50 | ||
|
||
pipeline.parameters = [ParameterInteger(name="InstanceCount", default_value=1)] | ||
response = pipeline.update(role, parallelism_config={"MaxParallelExecutionSteps": 55}) | ||
update_arn = response["PipelineArn"] | ||
assert re.match( | ||
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. Also do a describe call to verify the configuration |
||
fr"arn:aws:sagemaker:{region_name}:\d{{12}}:pipeline/{pipeline_name}", | ||
update_arn, | ||
) | ||
|
||
response = pipeline.describe() | ||
assert response["ParallelismConfiguration"]["MaxParallelExecutionSteps"] == 55 | ||
|
||
finally: | ||
try: | ||
pipeline.delete() | ||
except Exception: | ||
pass |
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.
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.
Do a describe call to verify the configuration