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

fix(dataset): fix user local fs data can't be fetched by server instance #1793

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/starwhale/api/_impl/dataset/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ def write_row(self, row: TabularDatasetRow) -> None:
artifacts_with_bin = False
for v in artifacts:
if not v.link and isinstance(v.fp, (str, Path)):
# convert user local file path to Starwhale link
v.link = Link(v.fp, with_local_fs_data=True)
# BaseArtifact reads from BaseArtifact.fp prior to any other sources like link
# When BaseArtifact.fp is user local file path , it is unreliable and should be removed.
v.fp = ""
if v.link and v.link.with_local_fs_data:
v.link.uri = self._copy_file(v.link.uri, False)
if (
Expand Down
5 changes: 5 additions & 0 deletions client/tests/sdk/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@ def test_user_raw_function_handler(self) -> None:
volume_bytes_size=100,
) as e:
summary = e.make_swds()
scan = e.tabular_dataset.scan()
for row in scan:
assert isinstance(row.data.get("original_data"), Binary)
assert not row.data.get("original_data").fp
assert row.data.get("original_data").link.uri

assert summary.rows == 10

Expand Down