Skip to content

Commit

Permalink
remove redundant lines
Browse files Browse the repository at this point in the history
  • Loading branch information
muddymudskipper committed Jul 1, 2024
1 parent 6c3687e commit 0ea55c4
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions cmem_plugin_reason/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ def post_provenance(plugin: WorkflowPlugin, context: ExecutionContext) -> None:
project_graph = f"http://di.eccenca.com/project/{context.task.project_id()}"

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

result = json.loads(post_select(query=type_query))

try:
Expand All @@ -142,16 +143,6 @@ def post_provenance(plugin: WorkflowPlugin, context: ExecutionContext) -> None:
plugin.log.warning("Could not add provenance data to output file")
return

plugin.log.info(str(plugin_type))

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

param_split = (
plugin_type.replace(
"https://vocab.eccenca.com/di/functions/Plugin_",
Expand All @@ -160,6 +151,14 @@ def post_provenance(plugin: WorkflowPlugin, context: ExecutionContext) -> None:
+ "_"
)

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

result = json.loads(post_select(query=parameter_query))
param_sparql = f"<{plugin_iri}> a <{plugin_type}> . "
for binding in result["results"]["bindings"]:
Expand All @@ -173,8 +172,6 @@ def post_provenance(plugin: WorkflowPlugin, context: ExecutionContext) -> None:
<{plugin.output_graph_iri}> <http://www.w3.org/ns/prov#wasGeneratedBy> <{plugin_iri}> .
{param_sparql}
}}
}}
"""
}}"""

plugin.log.info(insert_query)
post_update(query=insert_query)

0 comments on commit 0ea55c4

Please sign in to comment.