Skip to content

Commit

Permalink
log posting result graph error
Browse files Browse the repository at this point in the history
  • Loading branch information
muddymudskipper committed Jul 13, 2024
1 parent 4cc4586 commit 64d1dec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmem_plugin_reason/plugin_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def _execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> Non
create_xml_catalog_file(self.temp, graphs)
self.reason(graphs)
setup_cmempy_user_access(context.user)
send_result(self.output_graph_iri, Path(self.temp) / "result.ttl")
send_result(self, self.output_graph_iri, Path(self.temp) / "result.ttl")
if self.validate_profile:
self.post_valid_profiles(inputs, graphs)
post_provenance(self, get_provenance(self, context))
Expand Down
2 changes: 1 addition & 1 deletion cmem_plugin_reason/plugin_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _execute(self, context: ExecutionContext) -> Entities:

if self.produce_graph:
setup_cmempy_user_access(context.user)
send_result(self.output_graph_iri, Path(self.temp) / "output.ttl")
send_result(self, self.output_graph_iri, Path(self.temp) / "output.ttl")
setup_cmempy_user_access(context.user)
post_provenance(self, get_provenance(self, context))

Expand Down
20 changes: 10 additions & 10 deletions cmem_plugin_reason/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ def get_graphs_tree(graph_iris: tuple) -> dict:
return graphs


def send_result(iri: str, filepath: Path) -> None:
def send_result(plugin: WorkflowPlugin, iri: str, filepath: Path) -> None:
"""Send result"""
post_streamed(
res = post_streamed(
iri,
str(filepath),
replace=True,
content_type="text/turtle",
)
if res.status_code != 204: # noqa: PLR2004
plugin.log.error("Error posting result graph.")


def post_provenance(plugin: WorkflowPlugin, prov: dict | None) -> None:
Expand All @@ -116,7 +118,6 @@ def post_provenance(plugin: WorkflowPlugin, prov: dict | None) -> None:
param_sparql = ""
for name, iri in prov["parameters"].items():
param_sparql += f'\n<{prov["plugin_iri"]}> <{iri}> "{plugin.__dict__[name]}" .'

insert_query = f"""
INSERT DATA {{
GRAPH <{plugin.output_graph_iri}> {{
Expand All @@ -130,7 +131,6 @@ def post_provenance(plugin: WorkflowPlugin, prov: dict | None) -> None:
}}
}}
"""

post_update(query=insert_query)


Expand Down Expand Up @@ -169,13 +169,13 @@ def get_provenance(plugin: WorkflowPlugin, context: ExecutionContext) -> dict |
)

parameter_query = f"""
SELECT ?parameter {{
GRAPH <{project_graph}> {{
<{plugin_iri}> ?parameter ?o .
FILTER(STRSTARTS(STR(?parameter), "https://vocab.eccenca.com/di/functions/param_"))
}}
SELECT ?parameter {{
GRAPH <{project_graph}> {{
<{plugin_iri}> ?parameter ?o .
FILTER(STRSTARTS(STR(?parameter), "https://vocab.eccenca.com/di/functions/param_"))
}}
"""
}}
"""

new_plugin_iri = f'{"_".join(plugin_iri.split("_")[:-1])}_{token_hex(8)}'
result = json.loads(post_select(query=parameter_query))
Expand Down

0 comments on commit 64d1dec

Please sign in to comment.