Skip to content

Commit

Permalink
refac
Browse files Browse the repository at this point in the history
  • Loading branch information
ssssarah committed Jul 19, 2024
1 parent fb7088e commit 85b5ff0
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions kgforge/specializations/models/rdf_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

DEFAULT_TYPE_ORDER = [str, float, int, bool, datetime.date, datetime.time]

VALIDATION_PARALLELISM = 10
VALIDATION_PARALLELISM = 100


class RdfModel(Model):
Expand Down Expand Up @@ -176,17 +176,14 @@ def fc_call(t):
ont_graph=ont_graph, short_message=True, raise_=False, context=context
)

def validate_iterator(self, resources, type_: str, inference: str, context: Context):
for r in resources:
type_to_validate, shape, shacl_graph, ont_graph, r = self._get_shape_stuff(r, type_)
yield type_to_validate, shape, shacl_graph, ont_graph, r, inference, context

def _validate_many(self, resources: List[Resource], type_: str, inference: str) -> None:

resources_2 = Pool(processes=VALIDATION_PARALLELISM).map(
RdfModel.fc_call,
self.validate_iterator(resources, type_, inference, context=self.service.context)
)
def validate_iterator():
for r in resources:
type_to_validate, shape, shacl_graph, ont_graph, r = self._get_shape_stuff(r, type_)
yield type_to_validate, shape, shacl_graph, ont_graph, r, inference, self.service.context

resources_2 = Pool().map(RdfModel.fc_call, validate_iterator())

for r_1, r_2 in zip(resources, resources_2):
r_1._validated = r_2._validated
Expand Down

0 comments on commit 85b5ff0

Please sign in to comment.