ValidationException in Sagemaker pipeline creation

Viewed 608

I am new to Sagmaker. I am creating a pipeline in sagemaker where I initialize the number of epochs as a pipeline parameter. But when I upsert, it shows this error. Check the following code for reference, please.

epoch_count = ParameterInteger(name="EpochCount", default_value=1)
pipeline = Pipeline(
name=f"a_name",
parameters=[
    training_instance_type,
    training_instance_count,
    epoch_count,
    hugging_face_model_name,
    endpoint_instance_type,
    endpoint_instance_type_alternate,
],
steps=[step_train, step_register, step_deploy_lambda],
sagemaker_session=sagemaker_session,

)

Error - ---

---------------------------------------------------------------------------
ClientError                               Traceback (most recent call last)
<ipython-input-54-138a517611f0> in <module>
----> 1 pipeline.upsert(role_arn=role)

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/pipeline.py in upsert(self, role_arn, description, tags, parallelism_config)
    217         """
    218         try:
--> 219             response = self.create(role_arn, description, tags, parallelism_config)
    220         except ClientError as e:
    221             error = e.response["Error"]

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/pipeline.py in create(self, role_arn, description, tags, parallelism_config)
    119             Tags=tags,
    120         )
--> 121         return self.sagemaker_session.sagemaker_client.create_pipeline(**kwargs)
    122 
    123     def _create_args(

/opt/conda/lib/python3.7/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
    389                     "%s() only accepts keyword arguments." % py_operation_name)
    390             # The "self" in this scope is referring to the BaseClient.
--> 391             return self._make_api_call(operation_name, kwargs)
    392 
    393         _api_call.__name__ = str(py_operation_name)

/opt/conda/lib/python3.7/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
    717             error_code = parsed_response.get("Error", {}).get("Code")
    718             error_class = self.exceptions.from_code(error_code)
--> 719             raise error_class(parsed_response, operation_name)
    720         else:
    721             return parsed_response

ClientError: An error occurred (ValidationException) when calling the CreatePipeline operation: Cannot assign property reference [Parameters.EpochCount] to argument of type [String]
1 Answers

I replace

epoch_count = ParameterInteger(name="EpochCount", default_value=1)

with

epoch_count = ParameterString(name="EpochCount", default_value="1")

And it works. Maybe we can only use an integer in pipeline parameters from the sagemaker notebook. But epoch_count is being used in the docker container, which is not directly something of Sagemaker, and that's my understanding.

Related