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

(AutoMLV2) UnboundLocalError: local variable 'input_config' referenced before assignment #4786

Open
athewsey opened this issue Jul 16, 2024 · 0 comments
Labels

Comments

@athewsey
Copy link
Collaborator

Describe the bug

The implementation of AutoMLJobV2._load_config, and the corresponding AutoMLV2.fit() documentation appear to be confused about exactly what types of input should be supported, leading to incomplete handling and the below error in some cases:

UnboundLocalError: local variable 'input_config' referenced before assignment 

Specifically, I would really like if AutoMLJobV2 could support fit() on plain S3 URI inputs like v1 AutoML.fit() did. It seems like the code might've been set up to not fully implement this possibility but not exclude it either?

To reproduce

Try to fit() an AutoMLV2 estimator using a plain S3 URI dataset instead of creating LocalAutoMLDataChannel objects:

automl = AutoMLV2(
    problem_config=AutoMLTabularConfig(target_attribute_name="y"),
    role=sgmk_role,
)

automl.fit("s3://DOC-EXAMPLE-BUCKET/my-bank-marketing.csv", wait=False)

Expected behavior
Like AutoMLV1, AutoMLV2 should recognise the S3 URI specification and map it to an input dataset with sensible defaults for the other LocalAutoMLDataChannel settings.

Screenshots or logs

UnboundLocalError                         Traceback (most recent call last)
Cell In[12], line 26
     12 print(f"Uploaded feature specification JSON to:\n{fspec_s3uri}")
     14 automl = AutoMLV2Estimator(
     15     problem_config=AutoMLTabularConfig(
     16         target_attribute_name="y",
   (...)
     23     output_path=f"s3://{bucket_name}/{bucket_prefix}/automl",
     24 )
---> 26 automl.fit(raw_data_s3uri, wait=False)

File /opt/conda/lib/python3.10/site-packages/sagemaker/automl/automlv2.py:819, in AutoMLV2.fit(self, inputs, wait, logs, job_name)
    817 self._prepare_for_auto_ml_job(job_name=job_name)
    818 self.inputs = inputs
--> 819 self.latest_auto_ml_job = AutoMLJobV2.start_new(self, inputs)  # pylint: disable=W0201
    820 if wait:
    821     self.latest_auto_ml_job.wait(logs=logs)

File /opt/conda/lib/python3.10/site-packages/sagemaker/automl/automlv2.py:1380, in AutoMLJobV2.start_new(cls, auto_ml, inputs)
   1365 @classmethod
   1366 def start_new(cls, auto_ml, inputs):
   1367     """Create a new Amazon SageMaker AutoMLV2 job from auto_ml_v2 object.
   1368 
   1369     Args:
   (...)
   1378         all information about the started AutoMLV2 job.
   1379     """
-> 1380     auto_ml_args = cls._get_auto_ml_v2_args(auto_ml, inputs)
   1382     auto_ml.sagemaker_session.create_auto_ml_v2(**auto_ml_args)
   1383     return cls(auto_ml.sagemaker_session, auto_ml.current_job_name, inputs)

File /opt/conda/lib/python3.10/site-packages/sagemaker/automl/automlv2.py:1357, in AutoMLJobV2._get_auto_ml_v2_args(cls, auto_ml, inputs)
   1343 @classmethod
   1344 def _get_auto_ml_v2_args(cls, auto_ml, inputs):
   1345     """Constructs a dict of arguments for an Amazon SageMaker AutoMLV2 job.
   1346 
   1347     Args:
   (...)
   1355         Dict: dict for `sagemaker.session.Session.auto_ml` method
   1356     """
-> 1357     config = cls._load_config(inputs, auto_ml)
   1358     auto_ml_args = config.copy()
   1359     auto_ml_args["job_name"] = auto_ml.current_job_name

File /opt/conda/lib/python3.10/site-packages/sagemaker/automl/automlv2.py:1423, in AutoMLJobV2._load_config(cls, inputs, auto_ml, expand_role)
   1418 role = auto_ml.sagemaker_session.expand_role(auto_ml.role) if expand_role else auto_ml.role
   1420 problem_config = auto_ml.problem_config.to_request_dict()
   1422 config = {
-> 1423     "input_config": input_config,
   1424     "output_config": output_config,
   1425     "problem_config": problem_config,
   1426     "role": role,
   1427     "job_objective": auto_ml.job_objective,
   1428 }
   1430 if (
   1431     auto_ml.volume_kms_key
   1432     or auto_ml.vpc_config
   1433     or auto_ml.encrypt_inter_container_traffic is not None
   1434 ):
   1435     config["security_config"] = {}

UnboundLocalError: local variable 'input_config' referenced before assignment

System information
A description of your system. Please provide:

  • SageMaker Python SDK version: 2.224.1
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): AutoMLV2
  • Framework version: -
  • Python version: 3.10.14
  • CPU or GPU: CPU
  • Custom Docker image (Y/N): N

Additional context

N/A

@athewsey athewsey added the bug label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant