Skip to content

fix: convert network_config in processing_config to dict #1733

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
merged 1 commit into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sagemaker/workflow/airflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ def processing_config(
config["Environment"] = processor.env

if processor.network_config is not None:
config["NetworkConfig"] = processor.network_config
config["NetworkConfig"] = processor.network_config._to_request_dict()

processing_resources = sagemaker.processing.ProcessingJob.prepare_processing_resources(
instance_count=processor.instance_count,
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_airflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from mock import Mock, MagicMock, patch

from sagemaker import chainer, estimator, model, mxnet, tensorflow, transformer, tuner, processing
from sagemaker.network import NetworkConfig
from sagemaker.processing import ProcessingInput, ProcessingOutput
from sagemaker.workflow import airflow
from sagemaker.amazon import amazon_estimator
Expand Down Expand Up @@ -1598,6 +1599,13 @@ def test_deploy_config_from_amazon_alg_estimator(sagemaker_session):
@patch("sagemaker.utils.sagemaker_timestamp", MagicMock(return_value=TIME_STAMP))
def test_processing_config(sagemaker_session):

network_config = NetworkConfig(
encrypt_inter_container_traffic=False,
enable_network_isolation=True,
security_group_ids=["sg1"],
subnets=["subnet1"],
)

processor = processing.Processor(
role="arn:aws:iam::0122345678910:role/SageMakerPowerUser",
image_uri="{{ image_uri }}",
Expand All @@ -1612,6 +1620,7 @@ def test_processing_config(sagemaker_session):
sagemaker_session=sagemaker_session,
tags=[{"{{ key }}": "{{ value }}"}],
env={"{{ key }}": "{{ value }}"},
network_config=network_config,
)

outputs = [
Expand Down Expand Up @@ -1699,5 +1708,10 @@ def test_processing_config(sagemaker_session):
"RoleArn": "arn:aws:iam::0122345678910:role/SageMakerPowerUser",
"StoppingCondition": {"MaxRuntimeInSeconds": 3600},
"Tags": [{"{{ key }}": "{{ value }}"}],
"NetworkConfig": {
"EnableInterContainerTrafficEncryption": False,
"EnableNetworkIsolation": True,
"VpcConfig": {"SecurityGroupIds": ["sg1"], "Subnets": ["subnet1"]},
},
}
assert config == expected_config