Skip to content

Commit 309eb2f

Browse files
fix(dataset): set isBasedOn for renku datasets (#1617)
(cherry picked from commit 3aee6b8)
1 parent 3185d6d commit 309eb2f

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

renku/core/commands/dataset.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ def add_file(
160160
sources=(),
161161
destination="",
162162
ref=None,
163-
with_metadata=None,
164163
urlscontext=contextlib.nullcontext,
165164
commit_message=None,
166165
progress=None,
@@ -178,7 +177,6 @@ def add_file(
178177
sources=sources,
179178
destination=destination,
180179
ref=ref,
181-
with_metadata=with_metadata,
182180
urlscontext=urlscontext,
183181
progress=progress,
184182
interactive=interactive,
@@ -257,8 +255,6 @@ def _add_to_dataset(
257255
click.echo(WARNING + msg)
258256

259257
if with_metadata:
260-
for file_ in dataset.files:
261-
file_.based_on = None
262258
# dataset has the correct list of files
263259
with_metadata.files = dataset.files
264260
with_metadata.url = dataset._id
@@ -306,7 +302,7 @@ def file_unlink(client, name, include, exclude, interactive=False, yes=False, co
306302
(
307303
"include or exclude filters not found.\n"
308304
"Check available filters with `renku dataset unlink --help`\n"
309-
"Hint: `renku dataset unlink mydataset -I myfile`"
305+
"Hint: `renku dataset unlink my-dataset -I path`"
310306
)
311307
)
312308

renku/core/models/datasets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,16 @@ class Dataset(Entity, CreatorMixin, ReferenceMixin):
346346

347347
EDITABLE_FIELDS = [
348348
"creators",
349+
"date_created",
349350
"date_published",
350351
"description",
352+
"files",
351353
"in_language",
352354
"keywords",
353355
"license",
354356
"title",
355357
"url",
356358
"version",
357-
"date_created",
358-
"files",
359359
]
360360

361361
_id = attr.ib(default=None, kw_only=True)
@@ -476,6 +476,8 @@ def update_metadata(self, other_dataset):
476476
if val:
477477
setattr(self, field_, val)
478478

479+
self.same_as = other_dataset.same_as
480+
479481
return self
480482

481483
def update_files(self, files):

tests/cli/test_integration_datasets.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,13 @@ def test_import_renku_dataset_preserves_directory_hierarchy(runner, project, cli
312312
assert 0 == runner.invoke(cli, ["dataset", "import", "--yes", "--name", "remote", url]).exit_code
313313

314314
dataset = client.load_dataset("remote")
315-
assert (client.path / dataset.data_dir / "README.md").exists()
316-
assert (client.path / dataset.data_dir / "python" / "data" / "README.md").exists()
317-
assert (client.path / dataset.data_dir / "r" / "data" / "README.md").exists()
315+
paths = ["README.md", os.path.join("python", "data", "README.md"), os.path.join("r", "data", "README.md")]
316+
317+
for path in paths:
318+
assert (client.path / dataset.data_dir / path).exists()
319+
file_ = dataset.find_file(dataset.data_dir / path)
320+
assert file_.based_on
321+
assert file_.based_on.path.endswith(path)
318322

319323

320324
@pytest.mark.integration

0 commit comments

Comments
 (0)