Skip to content

Commit 65d7f27

Browse files
Merge pull request #154 from fair-workflows/bug-steps-without-uri2
Fix bug: #130 Steps without URI are reffered to as <None> in workflow RDF
2 parents 71d839b + 6d09184 commit 65d7f27

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

fairworkflows/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
# Generated workflow directory names
99
PYTHON_DIR = 'scripts'
1010
PLEX_DIR = 'plex'
11+
12+
DUMMY_FAIRWORKFLOWS_URI = 'http://fairworkflows.org'

fairworkflows/fairstep.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from rdflib import RDF, RDFS, DCTERMS
1010

1111
from fairworkflows import namespaces
12+
from fairworkflows.config import DUMMY_FAIRWORKFLOWS_URI
1213
from fairworkflows.rdf_wrapper import RdfWrapper, replace_in_rdf
1314

1415

@@ -93,6 +94,11 @@ def __init__(self, label: str = None, description: str = None, uri=None,
9394
self.inputs = inputs
9495
if outputs is not None:
9596
self.outputs = outputs
97+
# Set temporary URI to refer to this step in workflows
98+
# (i.e. 'http://fairworkflows.org#8769029329049')
99+
if uri is None:
100+
self._uri = DUMMY_FAIRWORKFLOWS_URI + '#step' + str(hash(self))
101+
96102
self._is_modified = False
97103
self._workflows = set()
98104

tests/test_fairworkflow.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ def test_build(self, test_step1, test_step2, test_step3):
6868
assert len(workflow.__str__()) > 0
6969
assert workflow.rdf is not None
7070

71+
def test_build_including_step_without_uri(self):
72+
step1 = FairStep()
73+
workflow = FairWorkflow()
74+
workflow.add(step1)
75+
assert (rdflib.URIRef('None'), None, None) not in workflow.rdf
76+
assert (None, None, rdflib.URIRef('None')) not in workflow.rdf
77+
7178
def test_construct_from_rdf_uri_not_in_subjects(self):
7279
rdf = read_rdf_test_resource('test_workflow.trig')
7380
# This URI is not in the subject of this RDF:

0 commit comments

Comments
 (0)