Skip to content

Commit

Permalink
validation parallelism global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ssssarah committed Jul 19, 2024
1 parent 4574808 commit ff9284b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 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 = 100
VALIDATION_PARALLELISM = None


class RdfModel(Model):
Expand Down Expand Up @@ -168,8 +168,7 @@ def _get_shape_stuff(self, r: Resource, type_: str) -> Tuple[str, ShapeWrapper,
return type_to_validate, shape, shacl_graph, ont_graph, r

@staticmethod
def fc_call(t):
type_to_validate, shape, shacl_graph, ont_graph, r, inference, context = t
def fc_call(type_to_validate, shape, shacl_graph, ont_graph, r, inference, context):

return RdfModel._validate(
resource=r, type_to_validate=type_to_validate, inference=inference, shape=shape, shacl_graph=shacl_graph,
Expand All @@ -183,7 +182,7 @@ def validate_iterator():
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())
resources_2 = Pool(processes=VALIDATION_PARALLELISM).starmap(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 ff9284b

Please sign in to comment.