Skip to content

Commit c61384b

Browse files
authored
refactor: rename jsonld.py to yaml.py in utils (#2818)
1 parent b2e6ecd commit c61384b

File tree

13 files changed

+28
-28
lines changed

13 files changed

+28
-28
lines changed

renku/command/checks/validate_shacl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from renku.command.schema.project import ProjectSchema
2626
from renku.core.interface.dataset_gateway import IDatasetGateway
2727
from renku.core.util.shacl import validate_graph
28-
from renku.domain_model.jsonld import NoDatesSafeLoader
28+
from renku.core.util.yaml import NoDatesSafeLoader
2929

3030

3131
def _shacl_graph_to_string(graph):

renku/core/migration/m_0003__1_jsonld.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
get_pre_0_3_4_datasets_metadata,
3131
is_using_temporary_datasets_path,
3232
)
33-
from renku.domain_model.jsonld import read_yaml, write_yaml
33+
from renku.core.util.yaml import read_yaml, write_yaml
3434

3535

3636
def migrate(migration_context):

renku/core/migration/m_0009__new_metadata_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
)
4949
from renku.core.migration.utils.conversion import convert_dataset
5050
from renku.core.util import communication
51+
from renku.core.util.yaml import load_yaml
5152
from renku.domain_model.entity import Collection, Entity
52-
from renku.domain_model.jsonld import load_yaml
5353
from renku.domain_model.project import Project
5454
from renku.domain_model.provenance.activity import Activity, Association, Generation, Usage
5555
from renku.domain_model.provenance.agent import Person, SoftwareAgent

renku/core/migration/models/v3.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from renku.core.migration.models.v9 import Person as OldPerson
2626
from renku.core.migration.models.v9 import generate_project_id, wfprov
2727
from renku.core.migration.utils import OLD_METADATA_PATH, generate_dataset_tag_id, generate_url_id, get_datasets_path
28+
from renku.core.util import yaml
2829
from renku.core.util.urls import get_host
29-
from renku.domain_model import jsonld
3030

3131

3232
class Base:
@@ -86,7 +86,7 @@ class Project(Base):
8686
@classmethod
8787
def from_yaml(cls, path, client):
8888
"""Read content from YAML file."""
89-
data = jsonld.read_yaml(path)
89+
data = yaml.read_yaml(path)
9090
self = ProjectSchemaV3().load(data)
9191

9292
if not self.creator:
@@ -107,7 +107,7 @@ def to_yaml(self, path):
107107
self.agent_version = __version__
108108

109109
data = ProjectSchemaV3().dump(self)
110-
jsonld.write_yaml(path=path, data=data)
110+
yaml.write_yaml(path=path, data=data)
111111

112112

113113
class Collection(Base):
@@ -166,7 +166,7 @@ class Dataset(Base):
166166
@classmethod
167167
def from_yaml(cls, path, client=None, commit=None):
168168
"""Read content from YAML file."""
169-
data = jsonld.read_yaml(path)
169+
data = yaml.read_yaml(path)
170170
self = DatasetSchemaV3(client=client, commit=commit).load(data)
171171
self._metadata_path = path
172172
return self
@@ -175,7 +175,7 @@ def to_yaml(self, path=None):
175175
"""Write content to a YAML file."""
176176
data = DatasetSchemaV3().dump(self)
177177
path = path or self._metadata_path or os.path.join(self.path, OLD_METADATA_PATH)
178-
jsonld.write_yaml(path=path, data=data)
178+
yaml.write_yaml(path=path, data=data)
179179

180180

181181
class PersonSchemaV3(JsonLDSchema):

renku/core/migration/models/v7.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from renku.command.schema.calamus import fields, prov, renku, schema
2525
from renku.core.migration.utils import OLD_METADATA_PATH, get_datasets_path
26-
from renku.domain_model import jsonld
26+
from renku.core.util import yaml
2727

2828
from .v3 import Base, DatasetFileSchemaV3, DatasetSchemaV3, UrlSchemaV3
2929

@@ -34,7 +34,7 @@ class Dataset(Base):
3434
@classmethod
3535
def from_yaml(cls, path, client=None, commit=None):
3636
"""Read content from YAML file."""
37-
data = jsonld.read_yaml(path)
37+
data = yaml.read_yaml(path)
3838
self = DatasetSchemaV7(client=client, commit=commit).load(data)
3939
self._metadata_path = path
4040
return self
@@ -43,7 +43,7 @@ def to_yaml(self, path=None):
4343
"""Write content to a YAML file."""
4444
data = DatasetSchemaV7().dump(self)
4545
path = path or self._metadata_path or os.path.join(self.path, OLD_METADATA_PATH)
46-
jsonld.write_yaml(path=path, data=data)
46+
yaml.write_yaml(path=path, data=data)
4747

4848

4949
class DatasetFileSchemaV7(DatasetFileSchemaV3):

renku/core/migration/models/v8.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from renku.command.schema.calamus import Uri, fields, prov, schema
2626
from renku.core.migration.models.v9 import generate_file_id
2727
from renku.core.migration.utils import OLD_METADATA_PATH, get_datasets_path
28-
from renku.domain_model import jsonld
28+
from renku.core.util import yaml
2929

3030
from .v3 import CreatorMixinSchemaV3, DatasetTagSchemaV3, EntitySchemaV3, LanguageSchemaV3, PersonSchemaV3, UrlSchemaV3
3131
from .v7 import Base, DatasetFileSchemaV7
@@ -54,7 +54,7 @@ class Dataset(Base):
5454
@classmethod
5555
def from_yaml(cls, path, client=None, commit=None):
5656
"""Read content from YAML file."""
57-
data = jsonld.read_yaml(path)
57+
data = yaml.read_yaml(path)
5858
self = DatasetSchemaV8(client=client, commit=commit, flattened=True).load(data)
5959
self._metadata_path = path
6060
return self
@@ -66,7 +66,7 @@ def to_yaml(self, path=None):
6666

6767
data = DatasetSchemaV8(flattened=True).dump(self)
6868
path = path or self._metadata_path or os.path.join(self.path, OLD_METADATA_PATH)
69-
jsonld.write_yaml(path=path, data=data)
69+
yaml.write_yaml(path=path, data=data)
7070

7171

7272
class DatasetFileSchemaV8(DatasetFileSchemaV7):

renku/core/migration/models/v9.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
generate_url_id,
6060
get_datasets_path,
6161
)
62+
from renku.core.util import yaml as yaml
6263
from renku.core.util.datetime8601 import fix_datetime, parse_date
6364
from renku.core.util.doi import extract_doi, is_doi
6465
from renku.core.util.urls import get_host, get_slug
65-
from renku.domain_model import jsonld as jsonld
6666
from renku.domain_model.dataset import generate_default_name
6767
from renku.domain_model.refs import LinkReference
6868
from renku.infrastructure.repository import Commit
@@ -192,7 +192,7 @@ def project_id(self):
192192
@classmethod
193193
def from_yaml(cls, path, client=None):
194194
"""Return an instance from a YAML file."""
195-
data = jsonld.read_yaml(path)
195+
data = yaml.read_yaml(path)
196196
self = cls.from_jsonld(data=data, client=client)
197197
self._metadata_path = path
198198

@@ -216,7 +216,7 @@ def to_yaml(self, path=None):
216216

217217
self._metadata_path = path or self._metadata_path
218218
data = ProjectSchema().dump(self)
219-
jsonld.write_yaml(path=self._metadata_path, data=data)
219+
yaml.write_yaml(path=self._metadata_path, data=data)
220220

221221

222222
@attr.s(eq=False, order=False)
@@ -805,7 +805,7 @@ class Activity(CommitMixin):
805805
@classmethod
806806
def from_yaml(cls, path, client=None, commit=None):
807807
"""Return an instance from a YAML file."""
808-
data = jsonld.read_yaml(path)
808+
data = yaml.read_yaml(path)
809809

810810
self = cls.from_jsonld(data=data, client=client, commit=commit)
811811
self._metadata_path = path
@@ -1000,7 +1000,7 @@ def to_yaml(self, path=None):
10001000
"""Write an instance to the referenced YAML file."""
10011001
self._metadata_path = path or self._metadata_path
10021002
data = ProcessRunSchema(flattened=True).dump(self)
1003-
jsonld.write_yaml(path=self._metadata_path, data=data)
1003+
yaml.write_yaml(path=self._metadata_path, data=data)
10041004

10051005

10061006
@attr.s(eq=False, order=False)
@@ -1740,7 +1740,7 @@ def _update_files_metadata(self, files=None):
17401740
@classmethod
17411741
def from_yaml(cls, path, client=None, commit=None):
17421742
"""Return an instance from a YAML file."""
1743-
data = jsonld.read_yaml(path)
1743+
data = yaml.read_yaml(path)
17441744

17451745
self = cls.from_jsonld(data=data, client=client, commit=commit)
17461746
self._metadata_path = path
@@ -1765,7 +1765,7 @@ def to_yaml(self, path=None, immutable=False):
17651765

17661766
self._metadata_path = path or self._metadata_path
17671767
data = OldDatasetSchema(flattened=True).dump(self)
1768-
jsonld.write_yaml(path=self._metadata_path, data=data)
1768+
yaml.write_yaml(path=self._metadata_path, data=data)
17691769

17701770
def as_jsonld(self):
17711771
"""Create JSON-LD."""

renku/core/migration/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import pyld
2929

3030
from renku.core.management.client import LocalClient
31-
from renku.domain_model.jsonld import read_yaml
31+
from renku.core.util.yaml import read_yaml
3232

3333
OLD_METADATA_PATH = "metadata.yml"
3434
OLD_DATASETS_PATH = "datasets"

renku/core/util/os.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ def safe_read_yaml(file: str) -> Dict[str, Any]:
200200
otherwise raises a ParameterError exception.
201201
"""
202202
try:
203-
from renku.domain_model import jsonld as jsonld
203+
from renku.core.util import yaml as yaml
204204

205-
return jsonld.read_yaml(file)
205+
return yaml.read_yaml(file)
206206
except Exception as e:
207207
raise errors.ParameterError(e)
File renamed without changes.

0 commit comments

Comments
 (0)