@@ -431,7 +431,7 @@ def draw(self, filepath):
431431 'Cannot produce visualization of RDF, you need to install '
432432 'graphviz dependency https://graphviz.org/' )
433433
434- def publish_as_nanopub (self , use_test_server = False , ** kwargs ):
434+ def publish_as_nanopub (self , use_test_server = False , publish_steps = False , ** kwargs ):
435435 """Publish to nanopub server.
436436
437437 Publish the workflow as nanopublication to the nanopub server.
@@ -441,6 +441,9 @@ def publish_as_nanopub(self, use_test_server=False, **kwargs):
441441
442442 Args:
443443 use_test_server (bool): Toggle using the test nanopub server.
444+ publish_steps (bool): Toggle publishing publishing all unpublished steps first before
445+ publishing the workflow. (Otherwise an exception is raised and unpublished steps
446+ need to be published manually first)
444447 kwargs: Keyword arguments to be passed to [nanopub.Publication.from_assertion](
445448 https://nanopub.readthedocs.io/en/latest/reference/publication.html#
446449 nanopub.publication.Publication.from_assertion).
@@ -453,7 +456,11 @@ def publish_as_nanopub(self, use_test_server=False, **kwargs):
453456 for step in self :
454457 if step .is_modified or not step ._is_published :
455458 self ._is_modified = True # If one of the steps is modified the workflow is too.
456- raise RuntimeError (f'{ step } was not published yet, please publish steps first' )
459+ if publish_steps :
460+ step .publish_as_nanopub (use_test_server = use_test_server , ** kwargs )
461+ else :
462+ raise RuntimeError (f'{ step } was not published yet, please publish steps first, '
463+ f'or use force=True' )
457464
458465 return self ._publish_as_nanopub (use_test_server = use_test_server , ** kwargs )
459466
0 commit comments