Class: AWSCDK::Sagemaker::CfnModelPackage::S3ModelDataSourceProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
sagemaker/cfn_model_package.rb

Overview

Specifies the S3 location of ML model data to deploy.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compression_type:, s3_data_type:, s3_uri:, model_access_config: nil) ⇒ S3ModelDataSourceProperty

Returns a new instance of S3ModelDataSourceProperty.

Parameters:

  • compression_type (String)

    Specifies how the ML model data is prepared.

  • s3_data_type (String)

    Specifies the type of ML model data to deploy.

  • s3_uri (String)

    Specifies the S3 path of ML model data to deploy.

  • model_access_config (AWSCDK::IResolvable, AWSCDK::Sagemaker::CfnModelPackage::ModelAccessConfigProperty, nil) (defaults to: nil)

    Specifies the access configuration file for the ML model.



2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
# File 'sagemaker/cfn_model_package.rb', line 2229

def initialize(compression_type:, s3_data_type:, s3_uri:, model_access_config: nil)
  @compression_type = compression_type
  Jsii::Type.check_type(@compression_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "compressionType")
  @s3_data_type = s3_data_type
  Jsii::Type.check_type(@s3_data_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "s3DataType")
  @s3_uri = s3_uri
  Jsii::Type.check_type(@s3_uri, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "s3Uri")
  @model_access_config = model_access_config.is_a?(Hash) ? ::AWSCDK::Sagemaker::CfnModelPackage::ModelAccessConfigProperty.new(**model_access_config.transform_keys(&:to_sym)) : model_access_config
  Jsii::Type.check_type(@model_access_config, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19zYWdlbWFrZXIuQ2ZuTW9kZWxQYWNrYWdlLk1vZGVsQWNjZXNzQ29uZmlnUHJvcGVydHkifV19fQ==")), "modelAccessConfig") unless @model_access_config.nil?
end

Instance Attribute Details

#compression_typeString (readonly)

Specifies how the ML model data is prepared.

If you choose Gzip and choose S3Object as the value of S3DataType , S3Uri identifies an object that is a gzip-compressed TAR archive. SageMaker will attempt to decompress and untar the object during model deployment.

If you choose None and chooose S3Object as the value of S3DataType , S3Uri identifies an object that represents an uncompressed ML model to deploy.

If you choose None and choose S3Prefix as the value of S3DataType , S3Uri identifies a key name prefix, under which all objects represents the uncompressed ML model to deploy.

If you choose None, then SageMaker will follow rules below when creating model data files under /opt/ml/model directory for use by your inference code:

  • If you choose S3Object as the value of S3DataType , then SageMaker will split the key of the S3 object referenced by S3Uri by slash (/), and use the last part as the filename of the file holding the content of the S3 object.
  • If you choose S3Prefix as the value of S3DataType , then for each S3 object under the key name pefix referenced by S3Uri , SageMaker will trim its key by the prefix, and use the remainder as the path (relative to /opt/ml/model ) of the file holding the content of the S3 object. SageMaker will split the remainder by slash (/), using intermediate parts as directory names and the last part as filename of the file holding the content of the S3 object.
  • Do not use any of the following as file names or directory names:
  • An empty or blank string
  • A string which contains null bytes
  • A string longer than 255 bytes
  • A single dot ( . )
  • A double dot ( .. )
  • Ambiguous file names will result in model deployment failure. For example, if your uncompressed ML model consists of two S3 objects s3://mybucket/model/weights and s3://mybucket/model/weights/part1 and you specify s3://mybucket/model/ as the value of S3Uri and S3Prefix as the value of S3DataType , then it will result in name clash between /opt/ml/model/weights (a regular file) and /opt/ml/model/weights/ (a directory).
  • Do not organize the model artifacts in S3 console using folders . When you create a folder in S3 console, S3 creates a 0-byte object with a key set to the folder name you provide. They key of the 0-byte object ends with a slash (/) which violates SageMaker restrictions on model artifact file names, leading to model deployment failure.


2263
2264
2265
# File 'sagemaker/cfn_model_package.rb', line 2263

def compression_type
  @compression_type
end

#model_access_configAWSCDK::IResolvable, ... (readonly)

Specifies the access configuration file for the ML model.

You can explicitly accept the model end-user license agreement (EULA) within the ModelAccessConfig . You are responsible for reviewing and complying with any applicable license terms and making sure they are acceptable for your use case before downloading or using a model.



2284
2285
2286
# File 'sagemaker/cfn_model_package.rb', line 2284

def model_access_config
  @model_access_config
end

#s3_data_typeString (readonly)

Specifies the type of ML model data to deploy.

If you choose S3Prefix , S3Uri identifies a key name prefix. SageMaker uses all objects that match the specified key name prefix as part of the ML model data to deploy. A valid key name prefix identified by S3Uri always ends with a forward slash (/).

If you choose S3Object , S3Uri identifies an object that is the ML model data to deploy.



2272
2273
2274
# File 'sagemaker/cfn_model_package.rb', line 2272

def s3_data_type
  @s3_data_type
end

#s3_uriString (readonly)

Specifies the S3 path of ML model data to deploy.



2277
2278
2279
# File 'sagemaker/cfn_model_package.rb', line 2277

def s3_uri
  @s3_uri
end

Class Method Details

.jsii_propertiesObject



2286
2287
2288
2289
2290
2291
2292
2293
# File 'sagemaker/cfn_model_package.rb', line 2286

def self.jsii_properties
  {
    :compression_type => "compressionType",
    :s3_data_type => "s3DataType",
    :s3_uri => "s3Uri",
    :model_access_config => "modelAccessConfig",
  }
end

Instance Method Details

#to_jsiiObject



2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
# File 'sagemaker/cfn_model_package.rb', line 2295

def to_jsii
  result = {}
  result.merge!({
    "compressionType" => @compression_type,
    "s3DataType" => @s3_data_type,
    "s3Uri" => @s3_uri,
    "modelAccessConfig" => @model_access_config,
  })
  result.compact
end