def test_prepare_channel_duplicate(): channels = [{ "ChannelName": MODEL_CHANNEL_NAME, "DataSource": { "S3DataSource": { "S3DataDistributionType": "FullyReplicated", "S3DataType": "S3Prefix", "S3Uri": "s3://blah/blah", } }, }] with pytest.raises(ValueError) as error: _Job._prepare_channel(channels, MODEL_URI, MODEL_CHANNEL_NAME) assert "Duplicate channel {} not allowed.".format( MODEL_CHANNEL_NAME) in str(error)
def test_prepare_channel(channel_uri, channel_name, content_type, input_mode): channel = _Job._prepare_channel( [], channel_uri, channel_name, content_type=content_type, input_mode=input_mode ) assert channel["DataSource"]["S3DataSource"]["S3Uri"] == channel_uri assert channel["DataSource"]["S3DataSource"]["S3DataDistributionType"] == "FullyReplicated" assert channel["DataSource"]["S3DataSource"]["S3DataType"] == "S3Prefix" assert channel["ChannelName"] == channel_name assert "CompressionType" not in channel assert "RecordWrapperType" not in channel # The model channel should use all the defaults except InputMode and ContentType if channel_name == MODEL_CHANNEL_NAME: assert channel["ContentType"] == "application/x-sagemaker-model" assert channel["InputMode"] == "File"
def test_prepare_channel_with_missing_uri(): assert _Job._prepare_channel([], channel_uri=None, channel_name=None) is None
def test_prepare_channel_with_missing_name(): with pytest.raises(ValueError) as ex: _Job._prepare_channel([], channel_uri=MODEL_URI, channel_name=None) assert "Expected a channel name if a channel URI {} is specified".format( MODEL_URI) in str(ex)