-
Notifications
You must be signed in to change notification settings - Fork 5
Description
I like the idea of seeing annotated and typed function signatures are way to go for interoperability, together with a graph-like data structure.
However, going beyond linear workflow (loops, conditionals) may represent a challenge, see also #126
With AWL (https://github.com/OO-LD/awl-schema) we develop a more general way in using the Abstract Syntax Tree (AST) represenation of such a function-oriented code (on python or another programming languages) including also control structures.
By applying JSON-LD on the AST this lead directly to and RDF representation of the code, which can be queried or transformed with SPARQL (and re-transpiled to python)
The benefits of an integration in my view would be:
a) Workflows written in AWL ~ native python representation can be transfered to any workflow environment supported by PWD
b) PWD would get a semantic (RDF) representation out of the box by applying AWL to the native python representations (could be further enriched with https://github.com/pyiron/semantikon)
c) This RDF representation may also be utilized within PWD to parse more complex workflows
For c) @samwaseda and I also explored a transformation from AWL to the node and edge oriented representation of PWD:
Example code
def function_one(x):
return x
def function_two(x, y):
return x + y
SPARQL
PREFIX awl: <https://oo-ld.github.io/awl-schema/>
PREFIX ex: <https://example.org/>
CONSTRUCT {
ex:Workflow awl:HasNode ?function .
ex:Workflow a awl:Workflow .
?function awl:HasName ?functionName .
?function awl:HasInput ?input .
?input awl:HasName ?key
}
WHERE {
?module awl:HasPart ?functionDef .
?functionDef a awl:FunctionDef .
?functionDef awl:HasArgument/awl:HasArgument ?arg .
?functionDef awl:HasName ?functionName .
BIND (URI(concat(str(ex:),STR(?functionName))) as ?function)
?arg awl:HasKey ?key .
BIND (URI(concat(str(ex:),STR(?functionName),"/",STR(?key))) as ?input)
}
Result:
{
"id": "ex:Workflow",
"type": "awl:Workflow",
"nodes": [
{
"id": "ex:function_one",
"inputs": {
"id": "ex:function_one/x",
"name": "x"
},
"name": "function_one"
},
{
"id": "ex:my_workflow",
"inputs": [
{
"id": "ex:my_workflow/a",
"name": "a"
},
{
"id": "ex:my_workflow/b",
"name": "b"
}
],
"name": "my_workflow"
},
{
"id": "ex:function_two",
"inputs": [
{
"id": "ex:function_two/x",
"name": "x"
},
{
"id": "ex:function_two/y",
"name": "y"
}
],
"name": "function_two"
}
]
}