Skip to content

entry_point modified when setting source_dir in Estimator if local mode executionΒ #4081

Open
@Milogav

Description

@Milogav

Describe the bug
Setting source_dir and entry_point arguments for Estimator in local mode results in wrong entry_point path if the script is not located at the source dir root but inside a sub folder

if self.sagemaker_session.local_mode and local_code:
# if there is no source dir, use the directory containing the entry point.
if self.source_dir is None:
self.source_dir = os.path.dirname(self.entry_point)
self.entry_point = os.path.basename(self.entry_point)
code_dir = "file://" + self.source_dir

To reproduce

Using for example

source_dir='/home/ubuntu/src
entry_point='pipeline/program/run.py

results in

self.source_dir='/home/ubuntu/src
self.entry_point='run.py

Which raises a ValueError due to the wrong path:

if not os.path.isfile(os.path.join(directory, script)):

Expected behavior
Keep entry point path unchanged if source_dir is provided

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: 2.179.0
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans):
  • Framework version:
  • Python version: 3.10
  • CPU or GPU:
  • Custom Docker image (Y/N):

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions