fair-workflows / fairworkflows

A python library for constructing, modifying and publishing scientific workflows described using semantic technologies.
Apache License 2.0
12 stars 3 forks source link

Issue143 decorator semantic types #158

Closed raar1 closed 3 years ago

raar1 commented 3 years ago

Addresses #143 and #134

See end of noodles_fw.ipynb notebook for examples/explanation of new functionality.

Essentially, one or more semantic types may be (optionally) assigned to input/output parameters of is_fairstep decorated functions, by using that variable name as parameter to the decorator.

For example, here we assign semantic types to input parameter a and the output of the function, out1:

@is_fairstep(label='Addition', a='http://www.example.org/number', out1='http://www.example.org/float')
def add(a:float, b:float) -> float:
    """Adding up numbers!"""
    return a + b

Note that you can pass lists to each of these, so any number of semantic types may be provided for each parameter (including none).

In this PR I have also changed the original 'type' member var of FairVariable to computational_type, and in triples it appears after the rdfs:comment predicate rather than rdf:type. This is still a placeholder for a better solution, but as mentioned in #134 the rdf:type was incorrect for a string literal, so we had to change it.

svenvanderburg commented 3 years ago

Actually, we should also implement this for inputs and outputs of fairworkflows! I think it should be easy to implement that in this PR, if you think otherwise you can also create a new issue!

raar1 commented 3 years ago

Actually, we should also implement this for inputs and outputs of fairworkflows! I think it should be easy to implement that in this PR, if you think otherwise you can also create a new issue!

Agreed - added issue #161