Skip to content

Commit

Permalink
Tag SageMaker docker image upload with current mlflow version (mlflow…
Browse files Browse the repository at this point in the history
…#124)

The SageMaker deployment docker image should be tagged with the mlflow version used so one can track the correct image to use in deploy(). This PR uses the current mlflow version to tag the ECR image instead of "latest" for SageMaker docker image upload.
  • Loading branch information
sueann committed Jul 6, 2018
1 parent 5570468 commit 5677086
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mlflow/sagemaker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from mlflow.utils.logging_utils import eprint
from mlflow.utils.file_utils import TempDir, _copy_project

DEFAULT_IMAGE_NAME = "mlflow_sage"
DEFAULT_IMAGE_NAME = "mlflow-pyfunc"

_DOCKERFILE_TEMPLATE = """
# Build an image that can serve pyfunc model in SageMaker
Expand Down Expand Up @@ -102,7 +102,7 @@ def build_image(name=DEFAULT_IMAGE_NAME, mlflow_home=None):
eprint(x, end='')


_full_template = "{account}.dkr.ecr.{region}.amazonaws.com/{image}:latest"
_full_template = "{account}.dkr.ecr.{region}.amazonaws.com/{image}:{version}"


def push_image_to_ecr(image=DEFAULT_IMAGE_NAME):
Expand All @@ -119,7 +119,8 @@ def push_image_to_ecr(image=DEFAULT_IMAGE_NAME):
account = caller_id['Account']
my_session = boto3.session.Session()
region = my_session.region_name or "us-west-2"
fullname = _full_template.format(account=account, region=region, image=image)
fullname = _full_template.format(account=account, region=region, image=image, version=mlflow.version.VERSION)
eprint("Pushing docker image {image} to {repo}".format(image=image, repo=fullname))
ecr_client = boto3.client('ecr')
if not ecr_client.describe_repositories(repositoryNames=[image])['repositories']:
ecr_client.create_repository(repositoryName=image)
Expand Down

0 comments on commit 5677086

Please sign in to comment.