Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
m-alisafaee committed Sep 18, 2023
1 parent 565ca28 commit 1d226db
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion renku/core/migration/utils/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion renku/domain_model/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions renku/ui/cli/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>" in result.output
assert "some_unique_value" in result.output
assert "https://schema.org/specialProperty" in result.output
Expand Down Expand Up @@ -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


Expand Down
5 changes: 3 additions & 2 deletions tests/core/commands/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/core/fixtures/core_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def project_with_datasets(project, directory_tree, with_injection) -> Generator[
person_2 = Person.from_string("P2 <[email protected]>")

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"]
Expand Down
4 changes: 2 additions & 2 deletions tests/core/management/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions tests/domain_model/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
16 changes: 8 additions & 8 deletions tests/fixtures/domain_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)

Expand All @@ -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(),
Expand All @@ -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"),
Expand All @@ -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

Expand Down

0 comments on commit 1d226db

Please sign in to comment.