Skip to content

Commit

Permalink
#44: adding tests for github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfsilva committed Sep 16, 2024
1 parent 3ea679d commit 50bdbfe
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
11 changes: 0 additions & 11 deletions tests/unit/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,3 @@ def test_workflow_add_dependencies_leaves(self, workflow: Workflow, tasks: list[
workflow.add_dependency(previous_task.task_id, task.task_id)
previous_task = task
assert(workflow.leaves() == [previous_task.task_id])

@pytest.mark.unit
def test_dot(self, workflow: Workflow) -> None:
dot_file_path = pathlib.Path("/tmp/workflow_test.dot")
workflow.add_task(Task(name="task_1", task_id="task_1", runtime=15.0))
workflow.add_task(Task(name="task_2", task_id="task_2", runtime=30.0))
workflow.add_dependency("task_1", "task_2")
workflow.write_dot(dot_file_path)
dot_workflow = Workflow("workflow")
dot_workflow.read_dot(dot_file_path)
# assert(workflow == dot_workflow)
7 changes: 3 additions & 4 deletions wfcommons/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# (at your option) any later version.

from .workflow import Workflow
from .file import File
from .file import FileLink
from .task import Task
from .task import TaskType
from .file import File, FileLink
from .task import Task, TaskType
from .machine import Machine, MachineSystem
3 changes: 3 additions & 0 deletions wfcommons/common/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ def as_dict(self) -> Dict[str, Union[str, int, FileLink]]:
'id': self.file_id,
'sizeInBytes': self.size
}

def __str__(self) -> str:
return self.file_id
3 changes: 1 addition & 2 deletions wfcommons/common/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,14 @@ def specification_as_dict(self) -> Dict:
:return: A JSON object representation of the task.
:rtype: Dict
"""
task_obj = {
return {
'name': self.name,
'id': self.task_id,
'parents': [],
'children': [],
'inputFiles': [f.file_id for f in self.input_files],
'outputFiles': [f.file_id for f in self.output_files]
}
return task_obj

def execution_as_dict(self) -> Dict:
"""A JSON representation of the task execution.
Expand Down
3 changes: 1 addition & 2 deletions wfcommons/common/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ def read_dot(self, dot_file_path: Optional[pathlib.Path] = None) -> None:
tasks_map = {}
for node in graph.nodes(data=True):
task_id = f"{node[1]['label']}_ID{node[0]}"
task = Task(name=node[1]['label'], task_id=task_id, runtime=0)
self.add_task(task)
self.add_task(Task(name=node[1]['label'], task_id=task_id, runtime=0))
tasks_map[node[0]] = task_id

for edge in graph.edges:
Expand Down

0 comments on commit 50bdbfe

Please sign in to comment.