Skip to content

Commit 68d2bfe

Browse files
committed
rm shapes and ontology path separation
1 parent fe7747c commit 68d2bfe

5 files changed

Lines changed: 9 additions & 64 deletions

File tree

kgforge/core/archetypes/model.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,7 @@ def _initialize_service(self, source: str, **source_config) -> Any:
177177

178178
if origin == "directory":
179179

180-
ontology_path = Path(source_config["ontology_path"]) \
181-
if "ontology_path" in source_config else None
182-
shapes_path = Path(source_config["shapes_path"]) \
183-
if "shapes_path" in source_config else None
184-
source_path = Path(source)
185-
186-
return self._service_from_directory(
187-
source_path=source_path, ontologies_path=ontology_path, shapes_path=shapes_path,
188-
context_iri=context_iri
189-
)
180+
return self._service_from_directory(dir_path=Path(source), context_iri=context_iri)
190181
elif origin == "url":
191182
return self._service_from_url(source, context_iri)
192183
elif origin == "store":
@@ -197,10 +188,7 @@ def _initialize_service(self, source: str, **source_config) -> Any:
197188

198189
@staticmethod
199190
@abstractmethod
200-
def _service_from_directory(
201-
source_path: Optional[Path], ontologies_path: Optional[Path],
202-
shapes_path: Optional[Path], context_iri: Optional[str]
203-
) -> Any:
191+
def _service_from_directory(dir_path: Path, context_iri: Optional[str]) -> Any:
204192
pass
205193

206194
@staticmethod

kgforge/specializations/models/demo_model.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,8 @@ def _validate_one(self, resource: Resource, type_: str) -> None:
9696
# Utils.
9797

9898
@staticmethod
99-
def _service_from_directory(
100-
source_path: Optional[Path], ontologies_path: Optional[Path],
101-
shapes_path: Optional[Path], context_iri: Optional[str]
102-
):
103-
return ModelLibrary(source_path)
99+
def _service_from_directory(dir_path: Path, context_iri: Optional[str]):
100+
return ModelLibrary(dir_path)
104101

105102

106103
class ModelLibrary:

kgforge/specializations/models/rdf/pyshacl_shape_wrapper.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
1-
import pyshacl
21
from pyshacl import Shape, ShapesGraph
32
from rdflib import Graph, URIRef
43
from pyshacl.constraints import ALL_CONSTRAINT_PARAMETERS
54

5+
from typing import List, Optional, Set, Tuple, Dict
66

77
from kgforge.specializations.models.rdf.collectors import ALL_COLLECTORS
88

9-
from time import perf_counter
10-
from typing import TYPE_CHECKING, List, Optional, Set, Tuple, Type, Union, Dict
11-
12-
from rdflib import BNode, Literal, URIRef
13-
14-
from pyshacl.consts import (
15-
SH_Info,
16-
SH_resultSeverity,
17-
SH_Warning,
18-
)
19-
from pyshacl.errors import ConstraintLoadError, ConstraintLoadWarning, ReportableRuntimeError, \
20-
ShapeLoadError
21-
22-
from pyshacl.pytypes import GraphLike
23-
24-
if TYPE_CHECKING:
25-
from pyshacl.constraints import ConstraintComponent
26-
from pyshacl.shapes_graph import ShapesGraph
27-
289

2910
ALL_COLLECTORS_MAP = {c.constraint(): c for c in ALL_COLLECTORS}
3011

kgforge/specializations/models/rdf/rdf_model_directory_service.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,8 @@
2727

2828
class DirectoryService(RdfService):
2929

30-
def __init__(self, source_path: Path, ontologies_path: Optional[Path],
31-
shapes_path: Optional[Path], context_iri: str) -> None:
32-
33-
g = Graph()
34-
if ontologies_path is None and shapes_path is None:
35-
if source_path is None:
36-
raise Exception("Must specify source path")
37-
else:
38-
g = load_rdf_files(source_path, g)
39-
else:
40-
g = load_rdf_files(ontologies_path, g)
41-
g = load_rdf_files(shapes_path, g)
42-
43-
self._graph = g
30+
def __init__(self, dir_path: Path, context_iri: str) -> None:
31+
self._graph = load_rdf_files(dir_path, Graph())
4432
self._shapes_graph = ShapesGraphWrapper(self._graph)
4533
super().__init__(self._graph, context_iri)
4634

kgforge/specializations/models/rdf_model.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,8 @@ def _validate_one(self, resource: Resource, type_: str) -> None:
132132
# Utils.
133133

134134
@staticmethod
135-
def _service_from_directory(
136-
source_path: Optional[Path],
137-
ontologies_path: Optional[Path],
138-
shapes_path: Optional[Path],
139-
context_iri: str,
140-
**dir_config
141-
) -> RdfService:
142-
return DirectoryService(
143-
source_path=source_path,
144-
ontologies_path=ontologies_path, shapes_path=shapes_path, context_iri=context_iri
145-
)
135+
def _service_from_directory(dir_path: Path, context_iri: str, **dir_config) -> RdfService:
136+
return DirectoryService(dir_path=dir_path, context_iri=context_iri)
146137

147138
@staticmethod
148139
def _service_from_store(store: Callable, context_config: Optional[Dict],

0 commit comments

Comments
 (0)