FrameworkModel | R Documentation |
This class hosts user-defined code in S3 and sets code location and configuration in model environment variables.
sagemaker.mlcore::ModelBase
-> sagemaker.mlcore::Model
-> FrameworkModel
new()
Initialize a “FrameworkModel“.
FrameworkModel$new( model_data, image_uri, role, entry_point, source_dir = NULL, predictor_cls = NULL, env = NULL, name = NULL, container_log_level = "INFO", code_location = NULL, sagemaker_session = NULL, dependencies = NULL, git_config = NULL, ... )
model_data
(str): The S3 location of a SageMaker model data “.tar.gz“ file.
image_uri
(str): A Docker image URI.
role
(str): An IAM role name or ARN for SageMaker to access AWS resources on your behalf.
entry_point
(str): Path (absolute or relative) to the Python source file which should be executed as the entry point to model hosting. This should be compatible with either Python 2.7 or Python 3.5. If 'git_config' is provided, 'entry_point' should be a relative location to the Python source file in the Git repo. Example With the following GitHub repo directory structure: >>> |—– README.md >>> |—– src >>> |—– inference.py >>> |—– test.py You can assign entry_point='src/inference.py'.
source_dir
(str): Path (absolute, relative or an S3 URI) to a directory with any other training source code dependencies aside from the entry point file (default: None). If “source_dir“ is an S3 URI, it must point to a tar.gz file. Structure within this directory are preserved when training on Amazon SageMaker. If 'git_config' is provided, 'source_dir' should be a relative location to a directory in the Git repo. If the directory points to S3, no code will be uploaded and the S3 location will be used instead. .. admonition:: Example With the following GitHub repo directory structure: >>> |—– README.md >>> |—– src >>> |—– inference.py >>> |—– test.py You can assign entry_point='inference.py', source_dir='src'.
predictor_cls
(callable[string, sagemaker.session.Session]): A function to call to create a predictor (default: None). If not None, “deploy“ will return the result of invoking this function on the created endpoint name.
env
(dict[str, str]): Environment variables to run with “image“ when hosted in SageMaker (default: None).
name
(str): The model name. If None, a default model name will be selected on each “deploy“.
container_log_level
(str): Log level to use within the container (default: "INFO").
code_location
(str): Name of the S3 bucket where custom code is uploaded (default: None). If not specified, default bucket created by “sagemaker.session.Session“ is used.
sagemaker_session
(sagemaker.session.Session): A SageMaker Session object, used for SageMaker interactions (default: None). If not specified, one is created using the default AWS configuration chain.
dependencies
(list[str]): A list of paths to directories (absolute or relative) with any additional libraries that will be exported to the container (default: []). The library folders will be copied to SageMaker in the same folder where the entrypoint is copied. If 'git_config' is provided, 'dependencies' should be a list of relative locations to directories with any additional libraries needed in the Git repo. If the “'source_dir“' points to S3, code will be uploaded and the S3 location will be used instead. .. admonition:: Example The following call >>> Estimator(entry_point='inference.py', dependencies=['my/libs/common', 'virtual-env']) results in the following inside the container: >>> $ ls >>> opt/ml/code >>> |—— inference.py >>> |—— common >>> |—— virtual-env
git_config
(dict[str, str]): Git configurations used for cloning files, including “repo“, “branch“, “commit“, “2FA_enabled“, “username“, “password“ and “token“. The “repo“ field is required. All other fields are optional. “repo“ specifies the Git repository where your training script is stored. If you don't provide “branch“, the default value 'master' is used. If you don't provide “commit“, the latest commit in the specified branch is used. .. admonition:: Example The following config: >>> git_config = 'repo': 'https://github.com/aws/sagemaker-python-sdk.git', >>> 'branch': 'test-branch-git-config', >>> 'commit': '329bfcf884482002c05ff7f44f62599ebc9f445a' results in cloning the repo specified in 'repo', then checkout the 'master' branch, and checkout the specified commit. “2FA_enabled“, “username“, “password“ and “token“ are used for authentication. For GitHub (or other Git) accounts, set “2FA_enabled“ to 'True' if two-factor authentication is enabled for the account, otherwise set it to 'False'. If you do not provide a value for “2FA_enabled“, a default value of 'False' is used. CodeCommit does not support two-factor authentication, so do not provide "2FA_enabled" with CodeCommit repositories. For GitHub and other Git repos, when SSH URLs are provided, it doesn't matter whether 2FA is enabled or disabled; you should either have no passphrase for the SSH key pairs, or have the ssh-agent configured so that you will not be prompted for SSH passphrase when you do 'git clone' command with SSH URLs. When HTTPS URLs are provided: if 2FA is disabled, then either token or username+password will be used for authentication if provided (token prioritized); if 2FA is enabled, only token will be used for authentication if provided. If required authentication info is not provided, python SDK will try to use local credentials storage to authenticate. If that fails either, an error message will be thrown. For CodeCommit repos, 2FA is not supported, so '2FA_enabled' should not be provided. There is no token in CodeCommit, so 'token' should not be provided too. When 'repo' is an SSH URL, the requirements are the same as GitHub-like repos. When 'repo' is an HTTPS URL, username+password will be used for authentication if they are provided; otherwise, python SDK will try to use either CodeCommit credential helper or local credential storage for authentication.
...
: Keyword arguments passed to the “Model“ initializer.
prepare_container_def()
Return a container definition with framework configuration set in model environment variables. This also uploads user-supplied code to S3.
FrameworkModel$prepare_container_def( instance_type = NULL, accelerator_type = NULL )
instance_type
(str): The EC2 instance type to deploy this Model to. For example, 'ml.p2.xlarge'.
accelerator_type
(str): The Elastic Inference accelerator type to deploy to the instance for loading and making inferences to the model. For example, 'ml.eia1.medium'.
dict[str, str]: A container definition object usable with the CreateModel API.
clone()
The objects of this class are cloneable with this method.
FrameworkModel$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.