diff --git a/renku/core/migration/utils/conversion.py b/renku/core/migration/utils/conversion.py index f88708c5a0..f2499a17f0 100644 --- a/renku/core/migration/utils/conversion.py +++ b/renku/core/migration/utils/conversion.py @@ -209,7 +209,7 @@ def convert_license(license): project_id=project_context.project.id, initial_identifier=_convert_dataset_identifier(dataset.initial_identifier), same_as=_convert_same_as(dataset.same_as), - title=dataset.title, + name=dataset.title, version=dataset.version, ), tags, diff --git a/renku/domain_model/dataset.py b/renku/domain_model/dataset.py index 34d84c74d0..3b9bb10e36 100644 --- a/renku/domain_model/dataset.py +++ b/renku/domain_model/dataset.py @@ -438,7 +438,7 @@ def __init__( self.identifier = identifier or uuid4().hex self.id = id or Dataset.generate_id(identifier=self.identifier) - self.name: Optional[str] = name or slug + self.name: Optional[str] = name self.slug: str = slug self.title: Optional[str] = None diff --git a/renku/ui/cli/dataset.py b/renku/ui/cli/dataset.py index 107d23b341..ffb4e48d54 100644 --- a/renku/ui/cli/dataset.py +++ b/renku/ui/cli/dataset.py @@ -677,8 +677,8 @@ def edit(slug, title, name, description, creators, metadata, metadata_source, ke communicator = ClickCallback() - if title: - if name: + if title != NO_VALUE: + if name != NO_VALUE: raise errors.ParameterError("Cannot pass both 'title' and 'name'", show_prefix=False) communicator.warn("The '-t/--title' flags are deprecated. Use '-n/--name' instead.") name = title diff --git a/tests/cli/test_datasets.py b/tests/cli/test_datasets.py index 2ad816b569..146232ba93 100644 --- a/tests/cli/test_datasets.py +++ b/tests/cli/test_datasets.py @@ -168,7 +168,7 @@ def test_dataset_show(runner, project, subdirectory, datadir_option, datadir): assert "keyword-1" in result.output assert "keyword-2" in result.output assert "Created: " in result.output - assert "Name: my-dataset" in result.output + assert "Slug: my-dataset" in result.output assert "John Doe " in result.output assert "some_unique_value" in result.output assert "https://schema.org/specialProperty" in result.output @@ -289,7 +289,7 @@ def test_datasets_invalid_name(runner, project, name): result = runner.invoke(cli, ["dataset", "create", name]) assert 2 == result.exit_code - assert f"Dataset name '{name}' is not valid" in result.output + assert f"Dataset slug '{name}' is not valid" in result.output assert f"Hint: '{get_slug(name)}' is valid" in result.output diff --git a/tests/core/commands/test_graph.py b/tests/core/commands/test_graph.py index 65ca13a124..f8e701cc20 100644 --- a/tests/core/commands/test_graph.py +++ b/tests/core/commands/test_graph.py @@ -260,7 +260,7 @@ def test_graph_export_full(): MagicMock( spec=Dataset, id="/datasets/abcdefg12345", - name="my-dataset", + slug="my-dataset", dataset_files=[ DatasetFile( id="/dataset-files/abcdefg123456789", @@ -278,7 +278,7 @@ def test_graph_export_full(): ] dataset_gateway.get_by_id.return_value = Dataset( id="/datasets/0000000aaaaaaa", - name="my-dataset", + slug="my-dataset", date_created=datetime.fromisoformat("2022-07-12T16:29:14+02:00"), date_modified=datetime.fromisoformat("2022-07-12T16:29:14+02:00"), date_removed=None, @@ -444,6 +444,7 @@ def test_graph_export_full(): "https://swissdatasciencecenter.github.io/renku-ontology#originalIdentifier": [{"@value": "abcdefg"}], "http://schema.org/dateCreated": [{"@value": "2022-07-12T16:29:14+02:00"}], "http://schema.org/dateModified": [{"@value": "2022-07-12T16:29:14+02:00"}], + "https://swissdatasciencecenter.github.io/renku-ontology#slug": [{"@value": "my-dataset"}], }, { "@id": "/entities/1234567890/data/my-dataset", diff --git a/tests/core/fixtures/core_datasets.py b/tests/core/fixtures/core_datasets.py index 733dda1467..f527f028a0 100644 --- a/tests/core/fixtures/core_datasets.py +++ b/tests/core/fixtures/core_datasets.py @@ -54,7 +54,7 @@ def project_with_datasets(project, directory_tree, with_injection) -> Generator[ person_2 = Person.from_string("P2 ") with with_injection(): - create_dataset(name="dataset-1", keywords=["dataset", "1"], creators=[person_1]) + create_dataset(slug="dataset-1", keywords=["dataset", "1"], creators=[person_1]) dataset = add_to_dataset("dataset-2", urls=[str(p) for p in directory_tree.glob("*")], create=True, copy=True) dataset.keywords = ["dataset", "2"] diff --git a/tests/core/management/test_repository.py b/tests/core/management/test_repository.py index 5f14c99ffd..a270ee5946 100644 --- a/tests/core/management/test_repository.py +++ b/tests/core/management/test_repository.py @@ -28,7 +28,7 @@ def test_latest_version(project, with_injection): """Test returning the latest version of `SoftwareAgent`.""" from renku import __version__ - create_dataset_command().build().execute("ds1", title="", description="", creators=[]) + create_dataset_command().build().execute("ds1", name="", description="", creators=[]) with project_context.with_path(project.path), with_injection(): assert __version__ == project_context.latest_agent @@ -38,7 +38,7 @@ def test_latest_version_user_commits(project, with_injection): """Test retrieval of `SoftwareAgent` with latest non-renku command.""" from renku import __version__ - create_dataset_command().build().execute("ds1", title="", description="", creators=[]) + create_dataset_command().build().execute("ds1", name="", description="", creators=[]) file = Path("my-file") file.write_text("123") diff --git a/tests/domain_model/test_dataset.py b/tests/domain_model/test_dataset.py index a2f114495c..3838b1e173 100644 --- a/tests/domain_model/test_dataset.py +++ b/tests/domain_model/test_dataset.py @@ -90,12 +90,12 @@ def test_slug_is_created_from_name_when_missing(slug): @pytest.mark.parametrize("name", ["", None]) -def test_slug_is_copied_to_name_when_name_is_missing(name): - """Test that dataset uses slug as name when name isn't passed.""" +def test_slug_is_not_copied_to_name_when_name_is_missing(name): + """Test that dataset doesn't use slug as name when name isn't passed.""" dataset = Dataset(slug="machine-friendly-slug", name=name) assert "machine-friendly-slug" == dataset.slug - assert "machine-friendly-slug" == dataset.name + assert name == dataset.name assert dataset.title is None diff --git a/tests/fixtures/domain_models.py b/tests/fixtures/domain_models.py index eb8e8bbd26..9cc7f93369 100644 --- a/tests/fixtures/domain_models.py +++ b/tests/fixtures/domain_models.py @@ -27,12 +27,12 @@ def empty_dataset_model(): """Dataset without files.""" from renku.domain_model.dataset import Dataset - def _create_dataset(name="my-dataset", identifier="5e77e63037614ea89309e21befe91dbb"): + def _create_dataset(slug="my-dataset", identifier="5e77e63037614ea89309e21befe91dbb"): return Dataset( id=Dataset.generate_id(identifier), identifier=identifier, initial_identifier=identifier, - name=name, + slug=slug, date_created=datetime.fromisoformat("2022-07-12T16:29:14+02:00"), ) @@ -45,10 +45,10 @@ def dataset_model(): from renku.domain_model.dataset import Dataset, DatasetFile from renku.domain_model.entity import Entity - def _create_dataset(name="my-dataset", num_files=2, identifier="14249f1571fb4a2786ddeb7f706b9833"): + def _create_dataset(slug="my-dataset", num_files=2, identifier="14249f1571fb4a2786ddeb7f706b9833"): files = [] for i in range(num_files): - path = f"data/{name}/{i}" + path = f"data/{slug}/{i}" files.append( DatasetFile( id=DatasetFile.generate_id(), @@ -60,7 +60,7 @@ def _create_dataset(name="my-dataset", num_files=2, identifier="14249f1571fb4a27 id=Dataset.generate_id(identifier), identifier=identifier, initial_identifier=identifier, - name=name, + slug=slug, dataset_files=files, date_created=datetime.fromisoformat("2022-07-12T16:29:14+02:00"), date_modified=datetime.fromisoformat("2022-07-12T16:29:14+02:00"), @@ -73,9 +73,9 @@ def _create_dataset(name="my-dataset", num_files=2, identifier="14249f1571fb4a27 def derived_dataset_model(empty_dataset_model, dataset_model): """Dataset with modification.""" - def _create_dataset(name="my-dataset", identifier="5d8e5f72ef21441291cbf19db5a417ce"): - source_dataset = empty_dataset_model(name) - new_dataset = dataset_model(name) + def _create_dataset(slug="my-dataset", identifier="5d8e5f72ef21441291cbf19db5a417ce"): + source_dataset = empty_dataset_model(slug) + new_dataset = dataset_model(slug) new_dataset.derive_from(source_dataset, identifier=identifier) return new_dataset