aws/sagemaker-python-sdk

UnboundLocalError when invalid SourceCode is provided

benieric opened this issue · 1 comments

Describe the bug
A clear and concise description of what the bug is.

This error happens in the _prepare_train_script() method if code execution reaches this line without setting the execute_driver variable.

From some testing looks like this happens when an invalid SourceCode is provided to model trainer it results in an error like

UnboundLocalError: cannot access local variable 'execute_driver' where it is not associated with a value

For example:

source_code = SourceCode(entry_point="train.py")

model_trainer = ModelTrainer(source_code=source_code,...)
model_trainer.train() # would fail here

2 issues:

  1. This method should have a final else to raise error with more informative message instead of falling through and failing later
  2. The SourceCode class should fail sooner if user incorrectly tries to set entry_point instead of entry_script

To reproduce
A clear, step-by-step set of instructions to reproduce the bug.
The provided code need to be complete and runnable, if additional data is needed, please include them in the issue.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots or logs
If applicable, add screenshots or logs to help explain your problem.

System information
A description of your system. Please provide:

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

Additional context
Add any other context about the problem here.

Closing since has been closed and released