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

UnboundLocalError when invalid SourceCode is provided #5041

Open
benieric opened this issue Feb 14, 2025 · 0 comments
Open

UnboundLocalError when invalid SourceCode is provided #5041

benieric opened this issue Feb 14, 2025 · 0 comments
Labels
component: pysdk-team Related to SageMaker Python SDK Core Issues component: training Relates to the SageMaker Training Platform type: bug

Comments

@benieric
Copy link
Contributor

benieric commented Feb 14, 2025

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.

@benieric benieric added component: training Relates to the SageMaker Training Platform component: pysdk-team Related to SageMaker Python SDK Core Issues labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pysdk-team Related to SageMaker Python SDK Core Issues component: training Relates to the SageMaker Training Platform type: bug
Projects
None yet
Development

No branches or pull requests

2 participants