Skip to content

Commit 0c91f06

Browse files
speg03jesterhazy
authored andcommitted
fix: local data source relative path includes the first directory (#702)
1 parent 9b5f13b commit 0c91f06

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/sagemaker/local/data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def get_data_source_instance(data_source, sagemaker_session):
4444
"""
4545
parsed_uri = urlparse(data_source)
4646
if parsed_uri.scheme == 'file':
47-
return LocalFileDataSource(parsed_uri.path)
47+
return LocalFileDataSource(parsed_uri.netloc + parsed_uri.path)
4848
elif parsed_uri.scheme == 's3':
4949
return S3DataSource(parsed_uri.netloc, parsed_uri.path, sagemaker_session)
5050

tests/unit/test_local_data.py

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def test_get_data_source_instance_with_file(LocalFileDataSource, sagemaker_local
2828
LocalFileDataSource.assert_called_with('/my/file')
2929
assert data_source is not None
3030

31+
data_source = sagemaker.local.data.get_data_source_instance('file://relative/path', sagemaker_local_session)
32+
LocalFileDataSource.assert_called_with('relative/path')
33+
assert data_source is not None
34+
3135

3236
@patch('sagemaker.local.data.S3DataSource')
3337
def test_get_data_source_instance_with_s3(S3DataSource, sagemaker_local_session):

0 commit comments

Comments
 (0)