Session: Sagemaker Session Class

SessionR Documentation

Sagemaker Session Class

Description

Manage interactions with the Amazon SageMaker APIs and any other AWS services needed. This class provides convenient methods for manipulating entities and resources that Amazon SageMaker uses, such as training jobs, endpoints, and input datasets in S3. AWS service calls are delegated to an underlying paws session, which by default is initialized using the AWS configuration chain. When you make an Amazon SageMaker API call that accesses an S3 bucket location and one is not specified, the “Session“ creates a default bucket based on a naming convention which includes the current AWS account ID.

Active bindings

paws_region_name

Returns aws region associated with Session

Methods

Public methods


Method new()

Creates a new instance of this [R6][R6::R6Class] class. Initialize a SageMaker Session.

Usage
Session$new(
  paws_session = NULL,
  sagemaker_client = NULL,
  sagemaker_runtime_client = NULL,
  default_bucket = NULL
)
Arguments
paws_session

(PawsSession): The underlying AWS credentails passed to paws SDK.

sagemaker_client

(sagemaker): Client which makes Amazon SageMaker service calls other than “InvokeEndpoint“ (default: None). Estimators created using this “Session“ use this client. If not provided, one will be created using this instance's “paws session“.

sagemaker_runtime_client

(sagemakerruntime): Client which makes “InvokeEndpoint“ calls to Amazon SageMaker (default: None). Predictors created using this “Session“ use this client. If not provided, one will be created using this instance's “paws session“.

default_bucket

(str): The default Amazon S3 bucket to be used by this session. This will be created the next time an Amazon S3 bucket is needed (by calling :func:default_bucket). If not provided, a default bucket will be created based on the following format: "sagemaker-region-aws-account-id". Example: "sagemaker-my-custom-bucket".


Method upload_data()

Upload local file or directory to S3.If a single file is specified for upload, the resulting S3 object key is “key_prefix/filename“ (filename does not include the local path, if any specified). If a directory is specified for upload, the API uploads all content, recursively, preserving relative structure of subdirectories. The resulting object key names are: “key_prefix/relative_subdirectory_path/filename“.

Usage
Session$upload_data(path, bucket = NULL, key_prefix = "data", ...)
Arguments
path

(str): Path (absolute or relative) of local file or directory to upload.

bucket

(str): Name of the S3 Bucket to upload to (default: None). If not specified, the default bucket of the “Session“ is used (if default bucket does not exist, the “Session“ creates it).

key_prefix

(str): Optional S3 object key name prefix (default: 'data'). S3 uses the prefix to create a directory structure for the bucket content that it display in the S3 console.

...

(any): Optional extra arguments that may be passed to the upload operation. Similar to ExtraArgs parameter in S3 upload_file function. Please refer to the ExtraArgs parameter documentation here: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html#the-extraargs-parameter

Returns

str: The S3 URI of the uploaded file(s). If a file is specified in the path argument, the URI format is: “s3://bucket name/key_prefix/original_file_name“. If a directory is specified in the path argument, the URI format is “s3://bucket name/key_prefix“.


Method upload_string_as_file_body()

Upload a string as a file body.

Usage
Session$upload_string_as_file_body(body, bucket, key, kms_key = NULL)
Arguments
body

(str): String representing the body of the file.

bucket

(str): Name of the S3 Bucket to upload to (default: None). If not specified, the default bucket of the “Session“ is used (if default bucket does not exist, the “Session“ creates it).

key

(str): S3 object key. This is the s3 path to the file.

kms_key

(str): The KMS key to use for encrypting the file.

Returns

str: The S3 URI of the uploaded file. The URI format is: “s3://bucket name/key“.


Method download_data()

Download file or directory from S3.

Usage
Session$download_data(path, bucket, key_prefix = "", ...)
Arguments
path

(str): Local path where the file or directory should be downloaded to.

bucket

(str): Name of the S3 Bucket to download from.

key_prefix

(str): Optional S3 object key name prefix.

...

(any): Optional extra arguments that may be passed to the download operation. Please refer to the ExtraArgs parameter in the boto3 documentation here: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-example-download-file.html

Returns

NULL invisibly


Method read_s3_file()

Read a single file from S3.

Usage
Session$read_s3_file(bucket, key_prefix)
Arguments
bucket

(str): Name of the S3 Bucket to download from.

key_prefix

(str): S3 object key name prefix.

Returns

str: The body of the s3 file as a string.


Method list_s3_files()

Lists the S3 files given an S3 bucket and key.

Usage
Session$list_s3_files(bucket, key_prefix = NULL)
Arguments
bucket

(str): Name of the S3 Bucket to download from.

key_prefix

(str): S3 object key name prefix.

Returns

(str): The list of files at the S3 path.


Method default_bucket()

Return the name of the default bucket to use in relevant Amazon SageMaker interactions.

Usage
Session$default_bucket()
Returns

(str): The name of the default bucket, which is of the form: “sagemaker-region-AWS account ID“.


Method train()

Create an Amazon SageMaker training job. Train the learner on a set of observations of the provided 'task'. Mutates the learner by reference, i.e. stores the model alongside other information in field '$state'.

Usage
Session$train(
  input_mode,
  input_config,
  role,
  job_name,
  output_config = NULL,
  resource_config = NULL,
  vpc_config = NULL,
  hyperparameters = NULL,
  stop_condition = NULL,
  tags = NULL,
  metric_definitions = NULL,
  enable_network_isolation = FALSE,
  image_uri = NULL,
  algorithm_arn = NULL,
  encrypt_inter_container_traffic = FALSE,
  use_spot_instances = FALSE,
  checkpoint_s3_uri = NULL,
  checkpoint_local_path = NULL,
  experiment_config = NULL,
  debugger_rule_configs = NULL,
  debugger_hook_config = NULL,
  tensorboard_output_config = NULL,
  enable_sagemaker_metrics = NULL,
  profiler_rule_configs = NULL,
  profiler_config = NULL,
  environment = NULL,
  retry_strategy = NULL
)
Arguments
input_mode

(str): The input mode that the algorithm supports. Valid modes:

  • 'File': Amazon SageMaker copies the training dataset from the S3 location to a directory in the Docker container.

  • 'Pipe': Amazon SageMaker streams data directly from S3 to the container via a Unix-named pipe.

input_config

(list): A list of Channel objects. Each channel is a named input source. Please refer to the format details described: https://botocore.readthedocs.io/en/latest/reference/services/sagemaker.html#SageMaker.Client.create_training_job

role

(str): An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. You must grant sufficient permissions to this role.

job_name

(str): Name of the training job being created.

output_config

(dict): The S3 URI where you want to store the training results and optional KMS key ID.

resource_config

(dict): Contains values for ResourceConfig:

  • instance_count (int): Number of EC2 instances to use for training. The key in resource_config is 'InstanceCount'.

  • instance_type (str): Type of EC2 instance to use for training, for example, 'ml.c4.xlarge'. The key in resource_config is 'InstanceType'.

vpc_config

(dict): Contains values for VpcConfig:

  • subnets (list[str]): List of subnet ids. The key in vpc_config is 'Subnets'.

  • security_group_ids (list[str]): List of security group ids. The key in vpc_config is 'SecurityGroupIds'.

hyperparameters

(dict): Hyperparameters for model training. The hyperparameters are made accessible as a dict[str, str] to the training code on SageMaker. For convenience, this accepts other types for keys and values, but “str()“ will be called to convert them before training.

stop_condition

(dict): Defines when training shall finish. Contains entries that can be understood by the service like “MaxRuntimeInSeconds“.

tags

(list[dict]): List of tags for labeling a training job. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.

metric_definitions

(list[dict]): A list of dictionaries that defines the metric(s) used to evaluate the training jobs. Each dictionary contains two keys: 'Name' for the name of the metric, and 'Regex' for the regular expression used to extract the metric from the logs.

enable_network_isolation

(bool): Whether to request for the training job to run with network isolation or not.

image_uri

(str): Docker image_uri containing training code.

algorithm_arn

(str): Algorithm Arn from Marketplace.

encrypt_inter_container_traffic

(bool): Specifies whether traffic between training containers is encrypted for the training job (default: “False“).

use_spot_instances

(bool): whether to use spot instances for training.

checkpoint_s3_uri

(str): The S3 URI in which to persist checkpoints that the algorithm persists (if any) during training. (default: “None“).

checkpoint_local_path

(str): The local path that the algorithm writes its checkpoints to. SageMaker will persist all files under this path to 'checkpoint_s3_uri' continually during training. On job startup the reverse happens - data from the s3 location is downloaded to this path before the algorithm is started. If the path is unset then SageMaker assumes the checkpoints will be provided under '/opt/ml/checkpoints/'. (Default: NULL).

experiment_config

(dict): Experiment management configuration. Dictionary contains three optional keys, 'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'. (Default: NULL)

debugger_rule_configs

Configuration information for debugging rules

debugger_hook_config

Configuration information for debugging rules

tensorboard_output_config

Xonfiguration information for tensorboard output

enable_sagemaker_metrics

(bool): enable SageMaker Metrics Time Series. For more information see: https://docs.aws.amazon.com/sagemaker/latest/dg/API_AlgorithmSpecification.html#SageMaker-Type-AlgorithmSpecification-EnableSageMakerMetricsTimeSeries (Default: NULL).

profiler_rule_configs

(list[dict]): A list of profiler rule configurations.

profiler_config

(dict): Configuration for how profiling information is emitted with SageMaker Profiler. (default: “None“).

environment

(dict[str, str]) : Environment variables to be set for use during training job (default: “None“)

retry_strategy

(dict): Defines RetryStrategy for InternalServerFailures. * max_retry_attsmpts (int): Number of times a job should be retried. The key in RetryStrategy is 'MaxRetryAttempts'.

Returns

str: ARN of the training job, if it is created.


Method update_training_job()

Calls the UpdateTrainingJob API for the given job name and returns the response.

Usage
Session$update_training_job(
  job_name,
  profiler_rule_configs = NULL,
  profiler_config = NULL
)
Arguments
job_name

(str): Name of the training job being updated.

profiler_rule_configs

(list): List of profiler rule configurations. (default: “None“).

profiler_config

(dict): Configuration for how profiling information is emitted with SageMaker Profiler. (default: “None“).


Method process()

Create an Amazon SageMaker processing job.

Usage
Session$process(
  inputs = NULL,
  output_config = NULL,
  job_name = NULL,
  resources = NULL,
  stopping_condition = NULL,
  app_specification = NULL,
  environment = NULL,
  network_config = NULL,
  role_arn,
  tags = NULL,
  experiment_config = NULL
)
Arguments
inputs

([dict]): List of up to 10 ProcessingInput dictionaries.

output_config

(dict): A config dictionary, which contains a list of up to 10 ProcessingOutput dictionaries, as well as an optional KMS key ID.

job_name

(str): The name of the processing job. The name must be unique within an AWS Region in an AWS account. Names should have minimum length of 1 and maximum length of 63 characters.

resources

(dict): Encapsulates the resources, including ML instances and storage, to use for the processing job.

stopping_condition

(dict[str,int]): Specifies a limit to how long the processing job can run, in seconds.

app_specification

(dict[str,str]): Configures the processing job to run the given image. Details are in the processing container specification.

environment

(dict): Environment variables to start the processing container with.

network_config

(dict): Specifies networking options, such as network traffic encryption between processing containers, whether to allow inbound and outbound network calls to and from processing containers, and VPC subnets and security groups to use for VPC-enabled processing jobs.

role_arn

(str): The Amazon Resource Name (ARN) of an IAM role that Amazon SageMaker can assume to perform tasks on your behalf.

tags

([dict[str,str]]): A list of dictionaries containing key-value pairs.

experiment_config

(dict): Experiment management configuration. Dictionary contains three optional keys, 'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'. (Default: NULL)


Method create_monitoring_schedule()

Create an Amazon SageMaker monitoring schedule.

Usage
Session$create_monitoring_schedule(
  monitoring_schedule_name,
  schedule_expression = NULL,
  statistics_s3_uri = NULL,
  constraints_s3_uri = NULL,
  monitoring_inputs = NULL,
  monitoring_output_config = NULL,
  instance_count = 1,
  instance_type = NULL,
  volume_size_in_gb = NULL,
  volume_kms_key = NULL,
  image_uri = NULL,
  entrypoint = NULL,
  arguments = NULL,
  record_preprocessor_source_uri = NULL,
  post_analytics_processor_source_uri = NULL,
  max_runtime_in_seconds = NULL,
  environment = NULL,
  network_config = NULL,
  role_arn = NULL,
  tags = NULL
)
Arguments
monitoring_schedule_name

(str): The name of the monitoring schedule. The name must be unique within an AWS Region in an AWS account. Names should have a minimum length of 1 and a maximum length of 63 characters.

schedule_expression

(str): The cron expression that dictates the monitoring execution schedule.

statistics_s3_uri

(str): The S3 uri of the statistics file to use.

constraints_s3_uri

(str): The S3 uri of the constraints file to use.

monitoring_inputs

([dict]): List of MonitoringInput dictionaries.

monitoring_output_config

(dict): A config dictionary, which contains a list of MonitoringOutput dictionaries, as well as an optional KMS key ID.

instance_count

(int): The number of instances to run.

instance_type

(str): The type of instance to run.

volume_size_in_gb

(int): Size of the volume in GB.

volume_kms_key

(str): KMS key to use when encrypting the volume.

image_uri

(str): The image uri to use for monitoring executions.

entrypoint

(str): The entrypoint to the monitoring execution image.

arguments

(str): The arguments to pass to the monitoring execution image.

record_preprocessor_source_uri

(str or None): The S3 uri that points to the script that pre-processes the dataset (only applicable to first-party images).

post_analytics_processor_source_uri

(str or None): The S3 uri that points to the script that post-processes the dataset (only applicable to first-party images).

max_runtime_in_seconds

(int): Specifies a limit to how long the processing job can run, in seconds.

environment

(dict): Environment variables to start the monitoring execution container with.

network_config

(dict): Specifies networking options, such as network traffic encryption between processing containers, whether to allow inbound and outbound network calls to and from processing containers, and VPC subnets and security groups to use for VPC-enabled processing jobs.

role_arn

(str): The Amazon Resource Name (ARN) of an IAM role that Amazon SageMaker can assume to perform tasks on your behalf.

tags

([dict[str,str]]): A list of dictionaries containing key-value pairs.


Method update_monitoring_schedule()

Update an Amazon SageMaker monitoring schedule.

Usage
Session$update_monitoring_schedule(
  monitoring_schedule_name,
  schedule_expression = NULL,
  statistics_s3_uri = NULL,
  constraints_s3_uri = NULL,
  monitoring_inputs = NULL,
  monitoring_output_config = NULL,
  instance_count = NULL,
  instance_type = NULL,
  volume_size_in_gb = NULL,
  volume_kms_key = NULL,
  image_uri = NULL,
  entrypoint = NULL,
  arguments = NULL,
  record_preprocessor_source_uri = NULL,
  post_analytics_processor_source_uri = NULL,
  max_runtime_in_seconds = NULL,
  environment = NULL,
  network_config = NULL,
  role_arn = NULL
)
Arguments
monitoring_schedule_name

(str): The name of the monitoring schedule. The name must be unique within an AWS Region in an AWS account. Names should have a minimum length of 1 and a maximum length of 63 characters.

schedule_expression

(str): The cron expression that dictates the monitoring execution schedule.

statistics_s3_uri

(str): The S3 uri of the statistics file to use.

constraints_s3_uri

(str): The S3 uri of the constraints file to use.

monitoring_inputs

([dict]): List of MonitoringInput dictionaries.

monitoring_output_config

(dict): A config dictionary, which contains a list of MonitoringOutput dictionaries, as well as an optional KMS key ID.

instance_count

(int): The number of instances to run.

instance_type

(str): The type of instance to run.

volume_size_in_gb

(int): Size of the volume in GB.

volume_kms_key

(str): KMS key to use when encrypting the volume.

image_uri

(str): The image uri to use for monitoring executions.

entrypoint

(str): The entrypoint to the monitoring execution image.

arguments

(str): The arguments to pass to the monitoring execution image.

record_preprocessor_source_uri

(str or None): The S3 uri that points to the script that

post_analytics_processor_source_uri

(str or None): The S3 uri that points to the script that post-processes the dataset (only applicable to first-party images).

max_runtime_in_seconds

(int): Specifies a limit to how long the processing job can run, in seconds.

environment

(dict): Environment variables to start the monitoring execution container with.

network_config

(dict): Specifies networking options, such as network traffic encryption between processing containers, whether to allow inbound and outbound network calls to and from processing containers, and VPC subnets and security groups to use for VPC-enabled processing jobs.

role_arn

(str): The Amazon Resource Name (ARN) of an IAM role that Amazon SageMaker can assume to perform tasks on your behalf.

pre-processes

the dataset (only applicable to first-party images).


Method start_monitoring_schedule()

Starts a monitoring schedule.

Usage
Session$start_monitoring_schedule(monitoring_schedule_name)
Arguments
monitoring_schedule_name

(str): The name of the Amazon SageMaker Monitoring Schedule to start.


Method stop_monitoring_schedule()

Stops a monitoring schedule.

Usage
Session$stop_monitoring_schedule(monitoring_schedule_name)
Arguments
monitoring_schedule_name

(str): The name of the Amazon SageMaker Monitoring Schedule to stop.


Method delete_monitoring_schedule()

Deletes a monitoring schedule.

Usage
Session$delete_monitoring_schedule(monitoring_schedule_name)
Arguments
monitoring_schedule_name

(str): The name of the Amazon SageMaker Monitoring Schedule to delete.


Method describe_monitoring_schedule()

Calls the DescribeMonitoringSchedule API for the given monitoring schedule name and returns the response.

Usage
Session$describe_monitoring_schedule(monitoring_schedule_name)
Arguments
monitoring_schedule_name

(str): The name of the processing job to describe.

Returns

dict: A dictionary response with the processing job description.


Method list_monitoring_executions()

Lists the monitoring executions associated with the given monitoring_schedule_name.

Usage
Session$list_monitoring_executions(
  monitoring_schedule_name,
  sort_by = "ScheduledTime",
  sort_order = "Descending",
  max_results = 100
)
Arguments
monitoring_schedule_name

(str): The monitoring_schedule_name for which to retrieve the monitoring executions.

sort_by

(str): The field to sort by. Can be one of: "CreationTime", "ScheduledTime", "Status". Default: "ScheduledTime".

sort_order

(str): The sort order. Can be one of: "Ascending", "Descending". Default: "Descending".

max_results

(int): The maximum number of results to return. Must be between 1 and 100.

Returns

dict: Dictionary of monitoring schedule executions.


Method list_monitoring_schedules()

Lists the monitoring executions associated with the given monitoring_schedule_name.

Usage
Session$list_monitoring_schedules(
  endpoint_name = NULL,
  sort_by = "CreationTime",
  sort_order = "Descending",
  max_results = 100
)
Arguments
endpoint_name

(str): The name of the endpoint to filter on. If not provided, does not filter on it. Default: None.

sort_by

(str): The field to sort by. Can be one of: "Name", "CreationTime", "Status". Default: "CreationTime".

sort_order

(str): The sort order. Can be one of: "Ascending", "Descending". Default: "Descending".

max_results

(int): The maximum number of results to return. Must be between 1 and 100.

Returns

dict: Dictionary of monitoring schedule executions.


Method was_processing_job_successful()

Calls the DescribeProcessingJob API for the given job name and returns the True if the job was successful. False otherwise.

Usage
Session$was_processing_job_successful(job_name)
Arguments
job_name

(str): The name of the processing job to describe.

Returns

bool: Whether the processing job was successful.


Method describe_processing_job()

Calls the DescribeProcessingJob API for the given job name and returns the response.

Usage
Session$describe_processing_job(job_name)
Arguments
job_name

(str): The name of the processing job to describe.

Returns

dict: A dictionary response with the processing job description.


Method stop_processing_job()

Calls the StopProcessingJob API for the given job name.

Usage
Session$stop_processing_job(job_name)
Arguments
job_name

(str): The name of the processing job to stop.


Method stop_training_job()

Calls the StopTrainingJob API for the given job name.

Usage
Session$stop_training_job(job_name)
Arguments
job_name

(str): The name of the training job to stop.


Method describe_training_job()

Calls the DescribeTrainingJob API for the given job name and returns the response.

Usage
Session$describe_training_job(job_name)
Arguments
job_name

(str): The name of the training job to describe.

Returns

dict: A dictionary response with the training job description.


Method auto_ml()

Create an Amazon SageMaker AutoML job.

Usage
Session$auto_ml(
  input_config,
  output_config,
  auto_ml_job_config,
  role,
  job_name,
  problem_type = NULL,
  job_objective = NULL,
  generate_candidate_definitions_only = FALSE,
  tags = NULL
)
Arguments
input_config

(list[dict]): A list of Channel objects. Each channel contains "DataSource" and "TargetAttributeName", "CompressionType" is an optional field.

output_config

(dict): The S3 URI where you want to store the training results and optional KMS key ID.

auto_ml_job_config

(dict): A dict of AutoMLJob config, containing "StoppingCondition", "SecurityConfig", optionally contains "VolumeKmsKeyId".

role

(str): The Amazon Resource Name (ARN) of an IAM role that Amazon SageMaker can assume to perform tasks on your behalf.

job_name

(str): A string that can be used to identify an AutoMLJob. Each AutoMLJob should have a unique job name.

problem_type

(str): The type of problem of this AutoMLJob. Valid values are "Regression", "BinaryClassification", "MultiClassClassification". If None, SageMaker AutoMLJob will infer the problem type automatically.

job_objective

(dict): AutoMLJob objective, contains "AutoMLJobObjectiveType" (optional), "MetricName" and "Value".

generate_candidate_definitions_only

(bool): Indicates whether to only generate candidate definitions. If True, AutoML.list_candidates() cannot be called. Default: False.

tags

([dict[str,str]]): A list of dictionaries containing key-value pairs.

Returns

NULL invisible


Method describe_auto_ml_job()

Calls the DescribeAutoMLJob API for the given job name and returns the response.

Usage
Session$describe_auto_ml_job(job_name)
Arguments
job_name

(str): The name of the AutoML job to describe.

Returns

dict: A dictionary response with the AutoML Job description.


Method list_candidates()

Returns the list of candidates of an AutoML job for a given name.

Usage
Session$list_candidates(
  job_name,
  status_equals = NULL,
  candidate_name = NULL,
  candidate_arn = NULL,
  sort_order = NULL,
  sort_by = NULL,
  max_results = NULL
)
Arguments
job_name

(str): The name of the AutoML job. If None, will use object's latest_auto_ml_job name.

status_equals

(str): Filter the result with candidate status, values could be "Completed", "InProgress", "Failed", "Stopped", "Stopping"

candidate_name

(str): The name of a specified candidate to list. Default to NULL

candidate_arn

(str): The Arn of a specified candidate to list. Default to NULL.

sort_order

(str): The order that the candidates will be listed in result. Default to NULL.

sort_by

(str): The value that the candidates will be sorted by. Default to NULL.

max_results

(int): The number of candidates will be listed in results, between 1 to 100. Default to None. If None, will return all the candidates.

Returns

list: A list of dictionaries with candidates information


Method wait_for_auto_ml_job()

Wait for an Amazon SageMaker AutoML job to complete.

Usage
Session$wait_for_auto_ml_job(job, poll = 5)
Arguments
job

(str): Name of the auto ml job to wait for.

poll

(int): Polling interval in seconds (default: 5).

Returns

(dict): Return value from the “DescribeAutoMLJob“ API.


Method logs_for_auto_ml_job()

Display the logs for a given AutoML job, optionally tailing them until the job is complete. If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from.

Usage
Session$logs_for_auto_ml_job(job_name, wait = FALSE, poll = 10)
Arguments
job_name

(str): Name of the Auto ML job to display the logs for.

wait

(bool): Whether to keep looking for new log entries until the job completes (Default: FALSE).

poll

(int): The interval in seconds between polling for new log entries and job completion (Default: 10).


Method compile_model()

Create an Amazon SageMaker Neo compilation job.

Usage
Session$compile_model(
  input_model_config,
  output_model_config,
  role,
  job_name,
  stop_condition,
  tags
)
Arguments
input_model_config

(dict): the trained model and the Amazon S3 location where it is stored.

output_model_config

(dict): Identifies the Amazon S3 location where you want Amazon SageMaker Neo to save the results of compilation job

role

(str): An AWS IAM role (either name or full ARN). The Amazon SageMaker Neo compilation jobs use this role to access model artifacts. You must grant sufficient permissions to this role.

job_name

(str): Name of the compilation job being created.

stop_condition

(dict): Defines when compilation job shall finish. Contains entries that can be understood by the service like “MaxRuntimeInSeconds“.

tags

(list[dict]): List of tags for labeling a compile model job. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.

Returns

str: ARN of the compile model job, if it is created.


Method tune()

Create an Amazon SageMaker hyperparameter tuning job

Usage
Session$tune(
  job_name,
  strategy = c("Bayesian", "Random"),
  objective_type,
  objective_metric_name,
  max_jobs,
  max_parallel_jobs,
  parameter_ranges,
  static_hyperparameters,
  input_mode,
  metric_definitions,
  role,
  input_config,
  output_config,
  resource_config,
  stop_condition,
  tags,
  warm_start_config,
  enable_network_isolation = FALSE,
  image_uri = NULL,
  algorithm_arn = NULL,
  early_stopping_type = "Off",
  encrypt_inter_container_traffic = FALSE,
  vpc_config = NULL,
  use_spot_instances = FALSE,
  checkpoint_s3_uri = NULL,
  checkpoint_local_path = NULL
)
Arguments
job_name

(str): Name of the tuning job being created.

strategy

(str): Strategy to be used for hyperparameter estimations.

objective_type

(str): The type of the objective metric for evaluating training jobs. This value can be either 'Minimize' or 'Maximize'.

objective_metric_name

(str): Name of the metric for evaluating training jobs.

max_jobs

(int): Maximum total number of training jobs to start for the hyperparameter tuning job.

max_parallel_jobs

(int): Maximum number of parallel training jobs to start.

parameter_ranges

(dict): Dictionary of parameter ranges. These parameter ranges can be one of three types: Continuous, Integer, or Categorical.

static_hyperparameters

(dict): Hyperparameters for model training. These hyperparameters remain unchanged across all of the training jobs for the hyperparameter tuning job. The hyperparameters are made accessible as a dictionary for the training code on SageMaker.

input_mode

(str): The input mode that the algorithm supports. Valid modes:

  • 'File' - Amazon SageMaker copies the training dataset from the S3 location to a directory in the Docker container.

  • 'Pipe' - Amazon SageMaker streams data directly from S3 to the container via a Unix-named pipe.

metric_definitions

(list[dict]): A list of dictionaries that defines the metric(s) used to evaluate the training jobs. Each dictionary contains two keys: 'Name' for the name of the metric, and 'Regex' for the regular expression used to extract the metric from the logs. This should be defined only for jobs that don't use an Amazon algorithm.

role

(str): An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. You must grant sufficient permissions to this role.

input_config

(list): A list of Channel objects. Each channel is a named input source. Please refer to the format details described: https://botocore.readthedocs.io/en/latest/reference/services/sagemaker.html#SageMaker.Client.create_training_job

output_config

(dict): The S3 URI where you want to store the training results and optional KMS key ID.

resource_config

(dict): Contains values for ResourceConfig:

  • instance_count (int): Number of EC2 instances to use for training. The key in resource_config is 'InstanceCount'.

  • instance_type (str): Type of EC2 instance to use for training, for example, 'ml.c4.xlarge'. The key in resource_config is 'InstanceType'.

stop_condition

(dict): When training should finish, e.g. “MaxRuntimeInSeconds“.

tags

(list[dict]): List of tags for labeling the tuning job. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.

warm_start_config

(dict): Configuration defining the type of warm start and other required configurations.

enable_network_isolation

(bool): Specifies whether to isolate the training container (Default: FALSE).

image_uri

(str): Docker image containing training code.

algorithm_arn

(str): Resource ARN for training algorithm created on or subscribed from AWS Marketplace (Default: NULL).

early_stopping_type

(str): Specifies whether early stopping is enabled for the job. Can be either 'Auto' or 'Off'. If set to 'Off', early stopping will not be attempted. If set to 'Auto', early stopping of some training jobs may happen, but is not guaranteed to.

encrypt_inter_container_traffic

(bool): Specifies whether traffic between training containers is encrypted for the training jobs started for this hyperparameter tuning job (Default: FALSE).

vpc_config

(dict): Contains values for VpcConfig (default: None):

  • subnets (list[str]): List of subnet ids. The key in vpc_config is 'Subnets'.

  • security_group_ids (list[str]): List of security group ids. The key in vpc_config is 'SecurityGroupIds'.

use_spot_instances

(bool): whether to use spot instances for training.

checkpoint_s3_uri

(str): The S3 URI in which to persist checkpoints that the algorithm persists (if any) during training. (Default: FALSE).

checkpoint_local_path

(str): The local path that the algorithm writes its checkpoints to. SageMaker will persist all files under this path to 'checkpoint_s3_uri' continually during training. On job startup the reverse happens - data from the s3 location is downloaded to this path before the algorithm is started. If the path is unset then SageMaker assumes the checkpoints will be provided under '/opt/ml/checkpoints/'. (Default: NULL).


Method create_tuning_job()

Create an Amazon SageMaker hyperparameter tuning job. This method supports creating tuning jobs with single or multiple training algorithms (estimators), while the “tune()“ method above only supports creating tuning jobs with single training algorithm.

Usage
Session$create_tuning_job(
  job_name,
  tuning_config,
  training_config = NULL,
  training_config_list = NULL,
  warm_start_config = NULL,
  tags = NULL
)
Arguments
job_name

(str): Name of the tuning job being created.

tuning_config

(dict): Configuration to launch the tuning job.

training_config

(dict): Configuration to launch training jobs under the tuning job using a single algorithm.

training_config_list

(list[dict]): A list of configurations to launch training jobs under the tuning job using one or multiple algorithms. Either training_config or training_config_list should be provided, but not both.

warm_start_config

(dict): Configuration defining the type of warm start and other required configurations.

tags

(list[dict]): List of tags for labeling the tuning job. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.


Method describe_tuning_job()

Calls the DescribeHyperParameterTuningJob API for the given job name and returns the response.

Usage
Session$describe_tuning_job(job_name)
Arguments
job_name

(str): The name of the hyperparameter tuning job to describe.

Returns

dict: A dictionary response with the hyperparameter tuning job description.


Method stop_tuning_job()

Stop the Amazon SageMaker hyperparameter tuning job with the specified name.

Usage
Session$stop_tuning_job(name)
Arguments
name

(str): Name of the Amazon SageMaker hyperparameter tuning job.


Method transform()

Create an Amazon SageMaker transform job.

Usage
Session$transform(
  job_name = NULL,
  model_name = NULL,
  strategy = NULL,
  max_concurrent_transforms = NULL,
  max_payload = NULL,
  env = NULL,
  input_config = NULL,
  output_config = NULL,
  resource_config = NULL,
  experiment_config = NULL,
  tags = NULL,
  data_processing = NULL,
  model_client_config = NULL
)
Arguments
job_name

(str): Name of the transform job being created.

model_name

(str): Name of the SageMaker model being used for the transform job.

strategy

(str): The strategy used to decide how to batch records in a single request. Possible values are 'MultiRecord' and 'SingleRecord'.

max_concurrent_transforms

(int): The maximum number of HTTP requests to be made to each individual transform container at one time.

max_payload

(int): Maximum size of the payload in a single HTTP request to the container in MB.

env

(dict): Environment variables to be set for use during the transform job.

input_config

(dict): A dictionary describing the input data (and its location) for the job.

output_config

(dict): A dictionary describing the output location for the job.

resource_config

(dict): A dictionary describing the resources to complete the job.

experiment_config

(dict): A dictionary describing the experiment configuration for the job. Dictionary contains three optional keys, 'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'.

tags

(list[dict]): List of tags for labeling a transform job.

data_processing

(dict): A dictionary describing config for combining the input data and transformed data. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.

model_client_config

(dict): A dictionary describing the model configuration for the job. Dictionary contains two optional keys, 'InvocationsTimeoutInSeconds', and 'InvocationsMaxRetries'.


Method create_model()

Create an Amazon SageMaker “Model“. Specify the S3 location of the model artifacts and Docker image containing the inference code. Amazon SageMaker uses this information to deploy the model in Amazon SageMaker. This method can also be used to create a Model for an Inference Pipeline if you pass the list of container definitions through the containers parameter.

Usage
Session$create_model(
  name,
  role,
  container_defs = NULL,
  vpc_config = NULL,
  enable_network_isolation = FALSE,
  primary_container = NULL,
  tags = NULL
)
Arguments
name

(str): Name of the Amazon SageMaker “Model“ to create.

role

(str): An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. You must grant sufficient permissions to this role.

container_defs

(list[dict[str, str]] or [dict[str, str]]): A single container definition or a list of container definitions which will be invoked sequentially while performing the prediction. If the list contains only one container, then it'll be passed to SageMaker Hosting as the “PrimaryContainer“ and otherwise, it'll be passed as “Containers“.You can also specify the return value of “sagemaker.get_container_def()“ or “sagemaker.pipeline_container_def()“, which will used to create more advanced container configurations, including model containers which need artifacts from S3.

vpc_config

(dict[str, list[str]]): The VpcConfig set on the model (default: None)

  • 'Subnets' (list[str]): List of subnet ids.

  • 'SecurityGroupIds' (list[str]): List of security group ids.

enable_network_isolation

(bool): Wether the model requires network isolation or not.

primary_container

(str or dict[str, str]): Docker image which defines the inference code. You can also specify the return value of “sagemaker.container_def()“, which is used to create more advanced container configurations, including model containers which need artifacts from S3. This field is deprecated, please use container_defs instead.

tags

(list[list[str, str]]): Optional. The list of tags to add to the model. Example: tags = list(list('Key'= 'tagname', 'Value'= 'tagvalue')) For more information about tags, see https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags

Returns

str: Name of the Amazon SageMaker “Model“ created.


Method create_model_from_job()

Create an Amazon SageMaker “Model“ from a SageMaker Training Job.

Usage
Session$create_model_from_job(
  training_job_name,
  name = NULL,
  role = NULL,
  image_uri = NULL,
  model_data_url = NULL,
  env = NULL,
  enable_network_isolation = FALSE,
  vpc_config_override = "VPC_CONFIG_DEFAULT",
  tags = NULL
)
Arguments
training_job_name

(str): The Amazon SageMaker Training Job name.

name

(str): The name of the SageMaker “Model“ to create (default: None). If not specified, the training job name is used.

role

(str): The “ExecutionRoleArn“ IAM Role ARN for the “Model“, specified either by an IAM role name or role ARN. If None, the “RoleArn“ from the SageMaker Training Job will be used.

image_uri

(str): The Docker image reference (default: None). If None, it defaults to the Training Image in “training_job_name“.

model_data_url

(str): S3 location of the model data (default: None). If None, defaults to the “ModelS3Artifacts“ of “training_job_name“.

env

(dict[string,string]): Model environment variables (default: ).

enable_network_isolation

(bool): Whether the model requires network isolation or not.

vpc_config_override

(dict[str, list[str]]): Optional override for VpcConfig set on the model. Default: use VpcConfig from training job.

  • 'Subnets' (list[str]) List of subnet ids.

  • 'SecurityGroupIds' (list[str]) List of security group ids.

tags

(list[list[str, str]]): Optional. The list of tags to add to the model. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.

Returns

str: The name of the created “Model“.


Method create_model_package_from_algorithm()

Create a SageMaker Model Package from the results of training with an Algorithm Package

Usage
Session$create_model_package_from_algorithm(
  name,
  description = NULL,
  algorithm_arn = NULL,
  model_data = NULL
)
Arguments
name

(str): ModelPackage name

description

(str): Model Package description

algorithm_arn

(str): arn or name of the algorithm used for training.

model_data

(str): s3 URI to the model artifacts produced by training


Method create_model_package_from_containers()

Get request dictionary for CreateModelPackage API.

Usage
Session$create_model_package_from_containers(
  containers = NULL,
  content_types = NULL,
  response_types = NULL,
  inference_instances = NULL,
  transform_instances = NULL,
  model_package_name = NULL,
  model_package_group_name = NULL,
  model_metrics = NULL,
  metadata_properties = NULL,
  marketplace_cert = FALSE,
  approval_status = "PendingManualApproval",
  description = NULL,
  drift_check_baselines = NULL
)
Arguments
containers

(list): A list of inference containers that can be used for inference specifications of Model Package (default: None).

content_types

(list): The supported MIME types for the input data (default: None).

response_types

(list): The supported MIME types for the output data (default: None).

inference_instances

(list): A list of the instance types that are used to generate inferences in real-time (default: None).

transform_instances

(list): A list of the instance types on which a transformation job can be run or on which an endpoint can be deployed (default: None).

model_package_name

(str): Model Package name, exclusive to 'model_package_group_name', using 'model_package_name' makes the Model Package un-versioned (default: None).

model_package_group_name

(str): Model Package Group name, exclusive to 'model_package_name', using 'model_package_group_name' makes the Model Package versioned (default: None).

model_metrics

(ModelMetrics): ModelMetrics object (default: None).

metadata_properties

(MetadataProperties): MetadataProperties object (default: None)

marketplace_cert

(bool): A boolean value indicating if the Model Package is certified for AWS Marketplace (default: False).

approval_status

(str): Model Approval Status, values can be "Approved", "Rejected", or "PendingManualApproval" (default: "PendingManualApproval").

description

(str): Model Package description (default: None).

drift_check_baselines

(DriftCheckBaselines): DriftCheckBaselines object (default: None).


Method wait_for_model_package()

Wait for an Amazon SageMaker endpoint deployment to complete.

Usage
Session$wait_for_model_package(model_package_name, poll = 5)
Arguments
model_package_name

(str): Name of the “Endpoint“ to wait for.

poll

(int): Polling interval in seconds (default: 5).

Returns

dict: Return value from the “DescribeEndpoint“ API.


Method describe_model()

Calls the DescribeModel API for the given model name.

Usage
Session$describe_model(name)
Arguments
name

(str): The name of the SageMaker model.

Returns

dict: A dictionary response with the model description.


Method create_endpoint_config()

Create an Amazon SageMaker endpoint configuration. The endpoint configuration identifies the Amazon SageMaker model (created using the “CreateModel“ API) and the hardware configuration on which to deploy the model. Provide this endpoint configuration to the “CreateEndpoint“ API, which then launches the hardware and deploys the model.

Usage
Session$create_endpoint_config(
  name,
  model_name,
  initial_instance_count,
  instance_type,
  accelerator_type = NULL,
  tags = NULL,
  kms_key = NULL,
  data_capture_config_dict = NULL
)
Arguments
name

(str): Name of the Amazon SageMaker endpoint configuration to create.

model_name

(str): Name of the Amazon SageMaker “Model“.

initial_instance_count

(int): Minimum number of EC2 instances to launch. The actual number of active instances for an endpoint at any given time varies due to autoscaling.

instance_type

(str): Type of EC2 instance to launch, for example, 'ml.c4.xlarge'.

accelerator_type

(str): Type of Elastic Inference accelerator to attach to the instance. For example, 'ml.eia1.medium'. For more information: https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html

tags

(list[list[str, str]]): Optional. The list of tags to add to the endpoint config.

kms_key

(str): The KMS key that is used to encrypt the data on the storage volume attached to the instance hosting the endpoint.

data_capture_config_dict

(dict): Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. Default: None. Example: tags = list(list('Key'= 'tagname', 'Value'= 'tagvalue')) For more information about tags, see https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags

Returns

str: Name of the endpoint point configuration created.


Method create_endpoint_config_from_existing()

Create an Amazon SageMaker endpoint configuration from an existing one. Updating any values that were passed in. The endpoint configuration identifies the Amazon SageMaker model (created using the “CreateModel“ API) and the hardware configuration on which to deploy the model. Provide this endpoint configuration to the “CreateEndpoint“ API, which then launches the hardware and deploys the model.

Usage
Session$create_endpoint_config_from_existing(
  existing_config_name,
  new_config_name,
  new_tags = NULL,
  new_kms_key = NULL,
  new_data_capture_config_list = NULL,
  new_production_variants = NULL
)
Arguments
existing_config_name

(str): Name of the existing Amazon SageMaker endpoint configuration.

new_config_name

(str): Name of the Amazon SageMaker endpoint configuration to create.

new_tags

(List[list[str, str]]): Optional. The list of tags to add to the endpoint config. If not specified, the tags of the existing endpoint configuration are used. If any of the existing tags are reserved AWS ones (i.e. begin with "aws"), they are not carried over to the new endpoint configuration.

new_kms_key

(str): The KMS key that is used to encrypt the data on the storage volume attached to the instance hosting the endpoint (default: None). If not specified, the KMS key of the existing endpoint configuration is used.

new_data_capture_config_list

(dict): Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring (default: None). If not specified, the data capture configuration of the existing endpoint configuration is used.

new_production_variants

(list[dict]): The configuration for which model(s) to host and the resources to deploy for hosting the model(s). If not specified, the “ProductionVariants“ of the existing endpoint configuration is used.

Returns

str: Name of the endpoint point configuration created.


Method create_endpoint()

Create an Amazon SageMaker “Endpoint“ according to the endpoint configuration specified in the request. Once the “Endpoint“ is created, client applications can send requests to obtain inferences. The endpoint configuration is created using the “CreateEndpointConfig“ API.

Usage
Session$create_endpoint(endpoint_name, config_name, tags = NULL, wait = TRUE)
Arguments
endpoint_name

(str): Name of the Amazon SageMaker “Endpoint“ being created.

config_name

(str): Name of the Amazon SageMaker endpoint configuration to deploy.

tags

(list[list[str, str]]): Optional. The list of tags to add to the endpoint config.

wait

(bool): Whether to wait for the endpoint deployment to complete before returning (Default: TRUE).

Returns

str: Name of the Amazon SageMaker “Endpoint“ created.


Method update_endpoint()

Update an Amazon SageMaker “Endpoint“ according to the endpoint configuration specified in the request

Usage
Session$update_endpoint(endpoint_name, endpoint_config_name, wait = TRUE)
Arguments
endpoint_name

(str): Name of the Amazon SageMaker “Endpoint“ being created.

endpoint_config_name

(str): Name of the Amazon SageMaker endpoint configuration to deploy.

wait

(bool): Whether to wait for the endpoint deployment to complete before returning (Default: TRUE).

Returns

str: Name of the Amazon SageMaker “Endpoint“ being updated.


Method delete_endpoint()

Delete an Amazon SageMaker “Endpoint“.

Usage
Session$delete_endpoint(endpoint_name)
Arguments
endpoint_name

(str): Name of the Amazon SageMaker “Endpoint“ to delete.


Method delete_endpoint_config()

Delete an Amazon SageMaker endpoint configuration.

Usage
Session$delete_endpoint_config(endpoint_config_name)
Arguments
endpoint_config_name

(str): Name of the Amazon SageMaker endpoint configuration to delete.


Method delete_model()

Delete an Amazon SageMaker Model.

Usage
Session$delete_model(model_name)
Arguments
model_name

(str): Name of the Amazon SageMaker model to delete.


Method list_tags()

List the tags given an Amazon Resource Name

Usage
Session$list_tags(resource_arn, max_results = 50)
Arguments
resource_arn

(str): The Amazon Resource Name (ARN) for which to get the tags list.

max_results

(int): The maximum number of results to include in a single page. This method takes care of that abstraction and returns a full list.


Method wait_for_job()

Wait for an Amazon SageMaker training job to complete.

Usage
Session$wait_for_job(job, poll = 5)
Arguments
job

(str): Name of the training job to wait for.

poll

(int): Polling interval in seconds (default: 5).

Returns

(dict): Return value from the “DescribeTrainingJob“ API.


Method wait_for_processing_job()

Wait for an Amazon SageMaker Processing job to complete.

Usage
Session$wait_for_processing_job(job, poll = 5)
Arguments
job

(str): Name of the processing job to wait for.

poll

(int): Polling interval in seconds (Default: 5).

Returns

(dict): Return value from the “DescribeProcessingJob“ API.


Method wait_for_compilation_job()

Wait for an Amazon SageMaker Neo compilation job to complete.

Usage
Session$wait_for_compilation_job(job, poll = 5)
Arguments
job

(str): Name of the compilation job to wait for.

poll

(int): Polling interval in seconds (Default: 5).

Returns

(dict): Return value from the “DescribeCompilationJob“ API.


Method wait_for_edge_packaging_job()

Wait for an Amazon SageMaker Edge packaging job to complete.

Usage
Session$wait_for_edge_packaging_job(job, poll = 5)
Arguments
job

(str): Name of the edge packaging job to wait for.

poll

(int): Polling interval in seconds (default: 5).

Returns

(dict): Return value from the “DescribeEdgePackagingJob“ API.


Method wait_for_tuning_job()

Wait for an Amazon SageMaker hyperparameter tuning job to complete.

Usage
Session$wait_for_tuning_job(job, poll = 5)
Arguments
job

(str): Name of the tuning job to wait for.

poll

(int): Polling interval in seconds (default: 5).

Returns

(dict): Return value from the “DescribeHyperParameterTuningJob“ API.


Method describe_transform_job()

Calls the DescribeTransformJob API for the given job name and returns the response.

Usage
Session$describe_transform_job(job_name)
Arguments
job_name

(str): The name of the transform job to describe.

Returns

dict: A dictionary response with the transform job description.


Method wait_for_transform_job()

Wait for an Amazon SageMaker transform job to complete.

Usage
Session$wait_for_transform_job(job, poll = 5)
Arguments
job

(str): Name of the transform job to wait for.

poll

(int): Polling interval in seconds (default: 5).

Returns

(dict): Return value from the “DescribeTransformJob“ API.


Method stop_transform_job()

Stop the Amazon SageMaker hyperparameter tuning job with the specified name.

Usage
Session$stop_transform_job(name)
Arguments
name

(str): Name of the Amazon SageMaker batch transform job.


Method wait_for_endpoint()

Wait for an Amazon SageMaker endpoint deployment to complete.

Usage
Session$wait_for_endpoint(endpoint, poll = 30)
Arguments
endpoint

(str): Name of the “Endpoint“ to wait for.

poll

(int): Polling interval in seconds (Default: 30).

Returns

dict: Return value from the “DescribeEndpoint“ API.


Method endpoint_from_job()

Create an “Endpoint“ using the results of a successful training job. Specify the job name, Docker image containing the inference code, and hardware configuration to deploy the model. Internally the API, creates an Amazon SageMaker model (that describes the model artifacts and the Docker image containing inference code), endpoint configuration (describing the hardware to deploy for hosting the model), and creates an “Endpoint“ (launches the EC2 instances and deploys the model on them). In response, the API returns the endpoint name to which you can send requests for inferences.

Usage
Session$endpoint_from_job(
  job_name,
  initial_instance_count,
  instance_type,
  deployment_image = NULL,
  name = NULL,
  role = NULL,
  wait = TRUE,
  model_environment_vars = NULL,
  vpc_config_override = "VPC_CONFIG_DEFAULT",
  accelerator_type = NULL,
  data_capture_config = NULL
)
Arguments
job_name

(str): Name of the training job to deploy the results of.

initial_instance_count

(int): Minimum number of EC2 instances to launch. The actual number of active instances for an endpoint at any given time varies due to autoscaling.

instance_type

(str): Type of EC2 instance to deploy to an endpoint for prediction, for example, 'ml.c4.xlarge'.

deployment_image

(str): The Docker image which defines the inference code to be used as the entry point for accepting prediction requests. If not specified, uses the image used for the training job.

name

(str): Name of the “Endpoint“ to create. If not specified, uses the training job name.

role

(str): An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. You must grant sufficient permissions to this role.

wait

(bool): Whether to wait for the endpoint deployment to complete before returning (Default: True).

model_environment_vars

(dict[str, str]): Environment variables to set on the model container (Default: NULL).

vpc_config_override

(dict[str, list[str]]): Overrides VpcConfig set on the model. Default: use VpcConfig from training job.

  • 'Subnets' (list[str]): List of subnet ids.

  • 'SecurityGroupIds' (list[str]): List of security group ids.

accelerator_type

(str): Type of Elastic Inference accelerator to attach to the instance. For example, 'ml.eia1.medium'. For more information: https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html

data_capture_config

(DataCaptureConfig): Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. Default: None.

Returns

str: Name of the “Endpoint“ that is created.


Method endpoint_from_model_data()

Create and deploy to an “Endpoint“ using existing model data stored in S3.

Usage
Session$endpoint_from_model_data(
  model_s3_location,
  deployment_image,
  initial_instance_count,
  instance_type,
  name = NULL,
  role = NULL,
  wait = TRUE,
  model_environment_vars = NULL,
  model_vpc_config = NULL,
  accelerator_type = NULL,
  data_capture_config = NULL
)
Arguments
model_s3_location

(str): S3 URI of the model artifacts to use for the endpoint.

deployment_image

(str): The Docker image which defines the runtime code to be used as the entry point for accepting prediction requests.

initial_instance_count

(int): Minimum number of EC2 instances to launch. The actual number of active instances for an endpoint at any given time varies due to autoscaling.

instance_type

(str): Type of EC2 instance to deploy to an endpoint for prediction, e.g. 'ml.c4.xlarge'.

name

(str): Name of the “Endpoint“ to create. If not specified, uses a name generated by combining the image name with a timestamp.

role

(str): An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. You must grant sufficient permissions to this role.

wait

(bool): Whether to wait for the endpoint deployment to complete before returning (Default: True).

model_environment_vars

(dict[str, str]): Environment variables to set on the model container (Default: NULL).

model_vpc_config

(dict[str, list[str]]): The VpcConfig set on the model (default: None)

  • 'Subnets' (list[str]): List of subnet ids.

  • 'SecurityGroupIds' (list[str]): List of security group ids.

accelerator_type

(str): Type of Elastic Inference accelerator to attach to the instance. For example, 'ml.eia1.medium'. For more information: https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html

data_capture_config

(DataCaptureConfig): Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. Default: None.

Returns

str: Name of the “Endpoint“ that is created.


Method endpoint_from_production_variants()

Create an SageMaker “Endpoint“ from a list of production variants.

Usage
Session$endpoint_from_production_variants(
  name,
  production_variants,
  tags = NULL,
  kms_key = NULL,
  wait = TRUE,
  data_capture_config_list = NULL
)
Arguments
name

(str): The name of the “Endpoint“ to create.

production_variants

(list[dict[str, str]]): The list of production variants to deploy.

tags

(list[dict[str, str]]): A list of key-value pairs for tagging the endpoint (Default: None).

kms_key

(str): The KMS key that is used to encrypt the data on the storage volume attached to the instance hosting the endpoint.

wait

(bool): Whether to wait for the endpoint deployment to complete before returning (Default: True).

data_capture_config_list

(list): Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. Default: None.

Returns

str: The name of the created “Endpoint“.


Method expand_role()

Expand an IAM role name into an ARN. If the role is already in the form of an ARN, then the role is simply returned. Otherwise we retrieve the full ARN and return it.

Usage
Session$expand_role(role)
Arguments
role

(str): An AWS IAM role (either name or full ARN).

Returns

str: The corresponding AWS IAM role ARN.


Method get_caller_identity_arn()

Returns the ARN user or role whose credentials are used to call the API.

Usage
Session$get_caller_identity_arn()
Returns

str: The ARN user or role


Method logs_for_job()

Display the logs for a given training job, optionally tailing them until the job is complete. If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from.

Usage
Session$logs_for_job(job_name, wait = FALSE, poll = 10, log_type = "All")
Arguments
job_name

(str): Name of the training job to display the logs for.

wait

(bool): Whether to keep looking for new log entries until the job completes (Default: False).

poll

(int): The interval in seconds between polling for new log entries and job completion (Default: 10).

log_type

(str): Type of logs to return from building sagemaker process


Method logs_for_processing_job()

Display the logs for a given processing job, optionally tailing them until the job is complete.

Usage
Session$logs_for_processing_job(job_name, wait = FALSE, poll = 10)
Arguments
job_name

(str): Name of the training job to display the logs for.

wait

(bool): Whether to keep looking for new log entries until the job completes (Default: False).

poll

(int): The interval in seconds between polling for new log entries and job completion (Default: 10).


Method logs_for_transform_job()

Display the logs for a given transform job, optionally tailing them until the job is complete. If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from.

Usage
Session$logs_for_transform_job(job_name, wait = FALSE, poll = 10)
Arguments
job_name

(str): Name of the transform job to display the logs for.

wait

(bool): Whether to keep looking for new log entries until the job completes (Default: FALSE).

poll

(int): The interval in seconds between polling for new log entries and job completion (Default: 10).


Method delete_feature_group()

Deletes a FeatureGroup in the FeatureStore service.

Usage
Session$delete_feature_group(feature_group_name)
Arguments
feature_group_name

(str): name of the feature group to be deleted.


Method create_feature_group()

Creates a FeatureGroup in the FeatureStore service.

Usage
Session$create_feature_group(
  feature_group_name,
  record_identifier_name,
  event_time_feature_name,
  feature_definitions,
  role_arn,
  online_store_config = NULL,
  offline_store_config = NULL,
  description = NULL,
  tags = NULL
)
Arguments
feature_group_name

(str): name of the FeatureGroup.

record_identifier_name

(str): name of the record identifier feature.

event_time_feature_name

(str): name of the event time feature.

feature_definitions

(Sequence[Dict[str, str]]): list of feature definitions.

role_arn

(str): ARN of the role will be used to execute the api.

online_store_config

(Dict[str, str]): dict contains configuration of the

offline_store_config

(Dict[str, str]): dict contains configuration of the feature offline store.

description

(str): description of the FeatureGroup.

tags

(List[Dict[str, str]]): list of tags for labeling a FeatureGroup.

feature

online store.

Returns

Response dict from service.


Method describe_feature_group()

Describe a FeatureGroup by name in FeatureStore service.

Usage
Session$describe_feature_group(feature_group_name, next_token = NULL)
Arguments
feature_group_name

(str): name of the FeatureGroup to descibe.

next_token

(str): next_token to get next page of features.

Returns

Response dict from service.


Method start_query_execution()

Start Athena query execution.

Usage
Session$start_query_execution(
  catalog,
  database,
  query_string,
  output_location,
  kms_key = NULL
)
Arguments
catalog

(str): name of the data catalog.

database

(str): name of the data catalog database.

query_string

(str): SQL expression.

output_location

(str): S3 location of the output file.

kms_key

(str): KMS key id will be used to encrypt the result if given.

Response

dict from the service.


Method get_query_execution()

Get execution status of the Athena query.

Usage
Session$get_query_execution(query_execution_id)
Arguments
query_execution_id

(str): execution ID of the Athena query.


Method wait_for_athena_query()

Wait for Athena query to finish.

Usage
Session$wait_for_athena_query(query_execution_id, poll = 5)
Arguments
query_execution_id

(str): execution ID of the Athena query.

poll

(int): time interval to poll get_query_execution API.


Method download_athena_query_result()

Download query result file from S3.

Usage
Session$download_athena_query_result(
  bucket,
  prefix,
  query_execution_id,
  filename
)
Arguments
bucket

(str): name of the S3 bucket where the result file is stored.

prefix

(str): S3 prefix of the result file.

query_execution_id

(str): execution ID of the Athena query.

filename

(str): name of the downloaded file.


Method account_id()

Get the AWS account id of the caller.

Usage
Session$account_id()
Returns

AWS account ID.


Method help()

Return class documentation

Usage
Session$help()

Method format()

foramt class

Usage
Session$format()

Method clone()

The objects of this class are cloneable with this method.

Usage
Session$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Other Session: LocalSession, PawsSession


DyfanJones/sagemaker-r-local documentation built on June 14, 2022, 10:32 p.m.