-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
2,401 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,4 +141,8 @@ tests/*.txt | |
*.txt | ||
tmp*.json | ||
|
||
!examples/*.ipynb | ||
!examples/*.ipynb | ||
|
||
workflow-examples/* | ||
/.python-version | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from abc import ABC, abstractmethod | ||
import yaml | ||
from cwlkernel.cwlrepository.CWLComponent import WorkflowComponent, CWLTool, CWLWorkflow | ||
from io import StringIO | ||
|
||
|
||
class CWLBuilder(ABC): | ||
@abstractmethod | ||
def build(self) -> WorkflowComponent: | ||
pass | ||
|
||
|
||
class CWLSnippetBuilder(CWLBuilder): | ||
_code: str | ||
|
||
def __init__(self): | ||
self._code = "" | ||
|
||
def append(self, code: str, indent: int = 0) -> None: | ||
code = '\n'. \ | ||
join([''.join([' ' for _ in range(indent)]) + line | ||
for line in code.splitlines()]) | ||
if self._code == "": | ||
self._code = str(code) | ||
else: | ||
self._code += '\n' + str(code) | ||
|
||
def get_current_code(self) -> str: | ||
return self._code | ||
|
||
def build(self) -> WorkflowComponent: | ||
code = yaml.load(StringIO(self._code), yaml.Loader) | ||
if 'id' not in code: | ||
raise ValueError("the workflow must contain an id") | ||
if code['class'] == 'CommandLineTool': | ||
return CWLTool(code.get('id'), code) | ||
elif code['class'] == 'Workflow': | ||
return CWLWorkflow(code.get('id'), code) | ||
|
||
def clear(self): | ||
self._code = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.