Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inference update #30

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix model registry step
- `ModelStep` doesn't support `estimator.register()`, added intermediate `Model`
- fixed variable name for the lowercase lambda
acere committed Jan 24, 2023
commit a382adb66df7bf880726dacc8f93e0e21afc9338
21 changes: 13 additions & 8 deletions build_pipeline/pipelines/pipeline.py
Original file line number Diff line number Diff line change
@@ -16,13 +16,10 @@
from sagemaker.drift_check_baselines import DriftCheckBaselines
from sagemaker.estimator import Estimator
from sagemaker.inputs import TrainingInput
from sagemaker.model import Model
from sagemaker.model_metrics import MetricsSource, ModelMetrics
from sagemaker.model_monitor.dataset_format import DatasetFormat
from sagemaker.processing import (
ProcessingInput,
ProcessingOutput,
ScriptProcessor,
)
from sagemaker.processing import ProcessingInput, ProcessingOutput, ScriptProcessor
from sagemaker.s3 import S3Uploader
from sagemaker.sklearn.processing import SKLearnProcessor
from sagemaker.utils import name_from_base
@@ -152,7 +149,7 @@ def get_pipeline(
framework_version="0.23-1",
role=role,
instance_type=processing_instance_type,
instance_count=processing_instance_type,
instance_count=processing_instance_count,
sagemaker_session=sagemaker_session,
base_job_name=f"{base_job_prefix}/sklearn-preprocess",
)
@@ -334,9 +331,16 @@ def get_pipeline(
),
)

model = Model(
image_uri=image_uri,
model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts,
sagemaker_session=sagemaker_session,
role=role,
)

step_register = ModelStep(
name="RegisterModel",
step_args=xgb_train.register(
step_args=model.register(
content_types=["text/csv"],
response_types=["text/csv"],
inference_instances=["ml.t2.medium", "ml.t2.large", "ml.m5.large"],
@@ -394,7 +398,8 @@ def upload_pipeline(pipeline: Pipeline, default_bucket, base_job_prefix):
S3Uploader.upload_string_as_file_body(
pipeline_definition_body, f"s3://{default_bucket}/{pipeline_name}.json"
)
# Return JSON with parameters used in Cfn Stack creation as template-configuration.json
# Return JSON with parameters used in Cfn Stack creation as
# template-configuration.json
return {
"PipelineDefinitionBucket": default_bucket,
"PipelineDefinitionKey": f"{pipeline_name}.json",
4 changes: 2 additions & 2 deletions infra/service_catalog_stack.py
Original file line number Diff line number Diff line change
@@ -95,14 +95,14 @@ def __init__(
# Lambda powering the custom resource to convert names to lower case at
# deploy time
with open("lambda/lowercase_name.py", encoding="utf8") as fp:
lambda_start_pipeline_code = fp.read()
lambda_lowercase_code = fp.read()

lowercase_lambda = lambda_.Function(
self,
"LowerCaseLambda",
function_name="sagemaker-lowercase-names",
description="Returns the lowercase version of a string",
code=lambda_.Code.from_inline(lambda_start_pipeline_code),
code=lambda_.Code.from_inline(lambda_lowercase_code),
handler="index.lambda_handler",
runtime=lambda_.Runtime.PYTHON_3_8,
timeout=cdk.Duration.seconds(3),