Skip to content

Pipeline AttributeError: 'ParameterString' object has no attribute 'startswith #3974

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

Closed
urirosenberg opened this issue Jul 4, 2023 · 3 comments
Labels
component: pipelines Relates to the SageMaker Pipeline Platform type: bug

Comments

@urirosenberg
Copy link

urirosenberg commented Jul 4, 2023

Describe the bug
Hi, I am using SDK version 2.169.0 on SM studio notebook.
Error
AttributeError: 'ParameterString' object has no attribute 'startswith' when using pipelines ParameterString
training_instance_type = ParameterString(name="TrainingInstanceType", default_value="ml.m5.xlarge")

To reproduce
Run the following notebook: https://github.com/aws/amazon-sagemaker-examples/blob/main/sagemaker-pipelines/tabular/model-monitor-clarify-pipelines/sagemaker-pipeline-model-monitor-clarify-steps.ipynb

Expected behavior
No error

Screenshots or logs

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/sagemaker/utils.py in volume_size_supported(instance_type)
   1405         # local mode does not support volume size
-> 1406         if instance_type.startswith("local"):
   1407             return False

AttributeError: 'ParameterString' object has no attribute 'startswith'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-57-5181e304d56b> in <module>
----> 1 pipeline.definition()

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/pipeline.py in definition(self)
    364     def definition(self) -> str:
    365         """Converts a request structure to string representation for workflow service calls."""
--> 366         request_dict = self.to_request()
    367         self._interpolate_step_collection_name_in_depends_on(request_dict["Steps"])
    368         request_dict["PipelineExperimentConfig"] = interpolate(

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/pipeline.py in to_request(self)
    106             if self.pipeline_experiment_config is not None
    107             else None,
--> 108             "Steps": build_steps(self.steps, self.name),
    109         }
    110 

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/utilities.py in build_steps(steps, pipeline_name)
     98                 pipeline_name, step.name, get_code_hash(step), get_config_hash(step)
     99             ):
--> 100                 request_dicts.append(step.to_request())
    101     return request_dicts
    102 

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/steps.py in to_request(self)
    506     def to_request(self) -> RequestType:
    507         """Updates the request dictionary with cache configuration."""
--> 508         request_dict = super().to_request()
    509         if self.cache_config:
    510             request_dict.update(self.cache_config.config)

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/steps.py in to_request(self)
    350     def to_request(self) -> RequestType:
    351         """Gets the request structure for `ConfigurableRetryStep`."""
--> 352         step_dict = super().to_request()
    353         if self.retry_policies:
    354             step_dict["RetryPolicies"] = self._resolve_retry_policy(self.retry_policies)

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/steps.py in to_request(self)
    119             "Name": self.name,
    120             "Type": self.step_type.value,
--> 121             "Arguments": self.arguments,
    122         }
    123         if self.depends_on:

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/steps.py in arguments(self)
    479             # execute fit function with saved parameters,
    480             # and store args in PipelineSession's _context
--> 481             execute_job_functions(self.step_args)
    482 
    483             # populate request dict with args

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/utilities.py in execute_job_functions(step_args)
    406     """
    407 
--> 408     chained_args = step_args.func(*step_args.func_args, **step_args.func_kwargs)
    409     if isinstance(chained_args, _StepArguments):
    410         execute_job_functions(chained_args)

/opt/conda/lib/python3.7/site-packages/sagemaker/estimator.py in fit(self, inputs, wait, logs, job_name, experiment_config)
   1267                 a default job name based on the training image name and current timestamp.
   1268             experiment_config (dict[str, str]): Experiment management configuration.
-> 1269                 Optionally, the dict can contain four keys:
   1270                 'ExperimentName', 'TrialName', 'TrialComponentDisplayName' and 'RunName'..
   1271                 The behavior of setting these keys is as follows:

/opt/conda/lib/python3.7/site-packages/sagemaker/estimator.py in start_new(cls, estimator, inputs, experiment_config)
   2213             estimator (sagemaker.estimator.EstimatorBase): Estimator object
   2214                 created by the user.
-> 2215             inputs (str): Parameters used when called
   2216                 :meth:`~sagemaker.estimator.EstimatorBase.fit`.
   2217             experiment_config (dict[str, str]): Experiment management configuration.

/opt/conda/lib/python3.7/site-packages/sagemaker/session.py in train(self, input_mode, input_config, role, job_name, output_config, resource_config, vpc_config, hyperparameters, stop_condition, tags, metric_definitions, enable_network_isolation, image_uri, training_image_config, container_entry_point, container_arguments, algorithm_arn, encrypt_inter_container_traffic, use_spot_instances, checkpoint_s3_uri, checkpoint_local_path, experiment_config, debugger_rule_configs, debugger_hook_config, tensorboard_output_config, enable_sagemaker_metrics, profiler_rule_configs, profiler_config, environment, retry_strategy)
    841             not customer_supplied_kms_key
    842             and "InstanceType" in inferred_resource_config
--> 843             and not instance_supports_kms(inferred_resource_config["InstanceType"])
    844             and "VolumeKmsKeyId" in inferred_resource_config
    845         ):

/opt/conda/lib/python3.7/site-packages/sagemaker/utils.py in instance_supports_kms(instance_type)
   1429         ValueError: If the instance type is improperly formatted.
   1430     """
-> 1431     return volume_size_supported(instance_type)

/opt/conda/lib/python3.7/site-packages/sagemaker/utils.py in volume_size_supported(instance_type)
   1420         return "d" not in family and not family.startswith("g5")
   1421     except Exception as e:
-> 1422         raise ValueError(f"Failed to parse instance type '{instance_type}': {str(e)}")
   1423 
   1424 

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/entities.py in __str__(self)
     85         """Override built-in String function for PipelineVariable"""
     86         raise TypeError(
---> 87             "Pipeline variables do not support __str__ operation. "
     88             "Please use `.to_string()` to convert it to string type in execution time"
     89             "or use `.expr` to translate it to Json for display purpose in Python SDK."

TypeError: Pipeline variables do not support __str__ operation. Please use `.to_string()` to convert it to string type in execution timeor use `.expr` to translate it to Json for display purpose in Python SDK.

System information
A description of your system. Please provide:

  • SageMaker Python SDK version: 2.169.0
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): Pipelines
  • Framework version:
  • Python version: 3
  • CPU or GPU: CPU
  • Custom Docker image (Y/N):N

Additional context
Add any other context about the problem here.

@joseproura
Copy link

Hi, it starts to happen to us without changing source code.
And finally we realize that rolling back sagemaker sdk to 2.160.0 it works again.

@brockwade633 brockwade633 added the component: pipelines Relates to the SageMaker Pipeline Platform label Jul 10, 2023
@brockwade633
Copy link
Contributor

Hi @joseproura and @urirosenberg, a bug fix regarding this issue was recently merged: #3972. I've executed the provided notebook with no issues. Are you able to verify expected behavior as well, when using the latest version of sagemaker?

!{sys.executable} -m pip install 'sagemaker' --upgrade

@joseproura
Copy link

Hi @joseproura and @urirosenberg, a bug fix regarding this issue was recently merged: #3972. I've executed the provided notebook with no issues. Are you able to verify expected behavior as well, when using the latest version of sagemaker?

!{sys.executable} -m pip install 'sagemaker' --upgrade

@brockwade633 yes, with the last version everything goes perfect.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pipelines Relates to the SageMaker Pipeline Platform type: bug
Projects
None yet
Development

No branches or pull requests

3 participants