Skip to content

Commit

Permalink
fix service tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Jul 20, 2022
1 parent cbd03fe commit 233c747
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion renku/core/dataset/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __enter__(self):
if not self.create:
raise errors.DatasetNotFound(name=self.name)

# NOTE: Don't update provenance when creating here because it will be updated later
# NOTE: Don't update provenance when creating here because it will be updated later)
self.dataset = create_dataset(name=self.name, update_provenance=False, datadir=self.datadir)
elif self.create:
raise errors.DatasetExistsError('Dataset exists: "{}".'.format(self.name))
Expand Down
5 changes: 3 additions & 2 deletions renku/core/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def export_dataset(name, provider_name, tag, client_dispatcher: IClientDispatche
# TODO: all these callbacks are ugly, improve in #737
config_key_secret = "access_token"

dataset = cast(Dataset, datasets_provenance.get_by_name(name, strict=True, immutable=True))
dataset = datasets_provenance.get_by_name(name, strict=True, immutable=True)

provider = ProviderFactory.from_name(provider_name)

Expand All @@ -386,8 +386,9 @@ def export_dataset(name, provider_name, tag, client_dispatcher: IClientDispatche
if not dataset:
raise errors.DatasetNotFound(message=f"Cannot find dataset with id: '{selected_tag.dataset_id.value}'")

data_dir = dataset.get_datadir()
dataset = cast(Dataset, DynamicProxy(dataset))

data_dir = dataset.get_datadir()
dataset.data_dir = data_dir

exporter = provider.get_exporter(dataset=dataset, tag=selected_tag, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion renku/core/dataset/providers/renku.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def download_files(self, client: "LocalClient", destination: Path, extract: bool

url = remove_credentials(self.project_url)

dataset_datadir = self._remote_client.path / self.provider_dataset.get_datadir()
dataset_datadir = self.provider_dataset.get_datadir()
remote_repository = self.repository

if self.provider_dataset.version: # NOTE: A tag was specified for import
Expand Down
11 changes: 10 additions & 1 deletion renku/domain_model/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,16 @@ class DatasetDetailsJson(marshmallow.Schema):

annotations = marshmallow.fields.List(marshmallow.fields.Nested(AnnotationJson))

datadir = marshmallow.fields.Function(lambda d: getattr(d, "datadir_path", None) or str(d.get_datadir()))
datadir = marshmallow.fields.Method("get_datadir")

def get_datadir(self, obj):
"""Get data directory."""
if isinstance(obj, dict):
return str(obj.get("datadir_path", obj.get("datadir", "")))
if hasattr(obj, "datadir_path"):
return obj.datadir_path

return str(obj.get_datadir())


class DatasetFileDetailsJson(marshmallow.Schema):
Expand Down
3 changes: 3 additions & 0 deletions tests/service/views/test_dataset_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ def test_list_datasets_view(svc_client_with_repo):
"creators",
"keywords",
"annotations",
"datadir",
} == set(response.json["result"]["datasets"][0].keys())


Expand Down Expand Up @@ -666,6 +667,7 @@ def test_list_datasets_view_remote(svc_client_with_repo, it_remote_repo_url):
"creators",
"keywords",
"annotations",
"datadir",
} == set(response.json["result"]["datasets"][0].keys())


Expand Down Expand Up @@ -782,6 +784,7 @@ def test_create_and_list_datasets_view(svc_client_with_repo):
"created_at",
"keywords",
"annotations",
"datadir",
} == set(response.json["result"]["datasets"][0].keys())

assert payload["name"] in [ds["name"] for ds in response.json["result"]["datasets"]]
Expand Down

0 comments on commit 233c747

Please sign in to comment.