Skip to content
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
6 changes: 3 additions & 3 deletions renku/api/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DatasetsApiMixin(object):
@property
def renku_datasets_path(self):
"""Return a ``Path`` instance of Renku dataset metadata folder."""
return self.renku_path.joinpath(self.DATASETS)
return Path(self.renku_home).joinpath(self.DATASETS)

def datasets_from_commit(self, commit=None):
"""Return datasets defined in a commit."""
Expand Down Expand Up @@ -80,11 +80,11 @@ def datasets(self):
result[path] = self.get_dataset(path)
return result

def get_dataset(self, path):
def get_dataset(self, path, commit=None):
"""Return a dataset from a given path."""
if not path.is_absolute():
path = self.path / path
return Dataset.from_yaml(path, client=self)
return Dataset.from_yaml(path, client=self, commit=commit)

def dataset_path(self, name):
"""Get dataset path from name."""
Expand Down
12 changes: 8 additions & 4 deletions renku/models/_jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def from_jsonld(
cls,
data,
client=None,
commit=None,
__reference__=None,
__source__=None,
):
Expand All @@ -331,7 +332,9 @@ def from_jsonld(
) != type_:
new_cls = cls.__type_registry__[type_]
if cls != new_cls:
return new_cls.from_jsonld(data, client=client)
return new_cls.from_jsonld(
data, client=client, commit=commit
)

if cls._jsonld_translate:
data = ld.compact(data, {'@context': cls._jsonld_translate})
Expand All @@ -355,6 +358,7 @@ def from_jsonld(
data_ = {}
if client:
data_['client'] = client
data_['commit'] = commit

for k, v in compacted.items():
if k in fields:
Expand All @@ -372,7 +376,7 @@ def from_jsonld(
return self

@classmethod
def from_yaml(cls, path, client=None):
def from_yaml(cls, path, client=None, commit=None):
"""Return an instance from a YAML file."""
import yaml

Expand All @@ -381,10 +385,10 @@ def from_yaml(cls, path, client=None):
self = cls.from_jsonld(
source,
client=client,
commit=commit,
__reference__=path,
__source__=deepcopy(source),
__source__=deepcopy(source)
)

return self

def asjsonld(self):
Expand Down
10 changes: 9 additions & 1 deletion renku/models/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def unlink_file(self, file_path):
return self.files.pop(index)

def __attrs_post_init__(self):
"""Post-Init hook to set _id field."""
"""Post-Init hook."""
self._id = self.identifier

if not self._label:
Expand All @@ -487,3 +487,11 @@ def __attrs_post_init__(self):
)

datasetfile.client = client

try:
self.commit = self.client.find_previous_commit(
self.path, revision=self.commit or 'HEAD'
)
except KeyError:
# if with_dataset is used, the dataset is not committed yet
pass
8 changes: 8 additions & 0 deletions renku/models/provenance/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""Represent provenance entities."""

import weakref
from pathlib import Path

import attr

Expand Down Expand Up @@ -77,6 +78,13 @@ def default_project(self):
if self.client:
return self.client.project

def __attrs_post_init__(self):
"""Post-init hook."""
if self.path:
path = Path(self.path)
if path.is_absolute():
self.path = str(path.relative_to(self.client.path))


@jsonld.s(
type=[
Expand Down
1 change: 0 additions & 1 deletion tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def test_data_add(
assert not os.access(
'data/dataset/file', stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
)
# assert os.stat('data/dataset/file/metadata.yml')

# check the linking
if scheme in ('', 'file://'):
Expand Down