Skip to content

Commit 7ea8488

Browse files
committed
migrating to WfFormat v1.3
1 parent fe4172e commit 7ea8488

6 files changed

Lines changed: 47 additions & 49 deletions

File tree

wfcommons/common/task.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2020-2021 The WfCommons Team.
4+
# Copyright (c) 2020-2022 The WfCommons Team.
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -36,9 +36,9 @@ class Task:
3636
:type runtime: float
3737
:param cores: Number of cores required by the task.
3838
:type cores: float
39-
:param task_id: Job unique ID (e.g., ID0000001).
39+
:param task_id: Task unique ID (e.g., ID0000001).
4040
:type task_id: Optional[str]
41-
:param category: Job category (can be used, for example, to define jobs that use the same program).
41+
:param category: Task category (can be used, for example, to define tasks that use the same program).
4242
:type category: Optional[str]
4343
:param machine: Machine on which is the task has been executed.
4444
:type machine: Optional[Machine]

wfcommons/common/workflow.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2020-2021 The WfCommons Team.
4+
# Copyright (c) 2020-2022 The WfCommons Team.
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -54,9 +54,9 @@ def __init__(self,
5454
) -> None:
5555
"""Create an object of a workflow representation."""
5656
self.description: Optional[
57-
str] = description if description else 'Instance generated with WfCommons - https://wfcommons.org'
57+
str] = description if description else "Instance generated with WfCommons - https://wfcommons.org"
5858
self.created_at: str = str(datetime.utcnow().isoformat())
59-
self.schema_version: str = "1.2"
59+
self.schema_version: str = "1.3"
6060
self.wms_name: Optional[str] = "WfCommons" if not wms_name else wms_name
6161
self.wms_version: Optional[str] = str(__version__) if not wms_version else wms_version
6262
self.wms_url: Optional[str] = f"https://docs.wfcommons.org/en/v{__version__}/" if not wms_url else wms_url
@@ -76,23 +76,23 @@ def write_json(self, json_file_path: Optional[pathlib.Path] = None) -> None:
7676
workflow_tasks = []
7777

7878
workflow_json = {
79-
'name': self.name,
80-
'description': self.description,
81-
'createdAt': self.created_at,
82-
'schemaVersion': self.schema_version,
83-
'author': {
84-
'name': str(getpass.getuser()),
85-
'email': 'support@wfcommons.org'
79+
"name": self.name,
80+
"description": self.description,
81+
"createdAt": self.created_at,
82+
"schemaVersion": self.schema_version,
83+
"author": {
84+
"name": str(getpass.getuser()),
85+
"email": "support@wfcommons.org"
8686
},
87-
'wms': {
88-
'name': self.wms_name,
89-
'version': self.wms_version,
90-
'url': self.wms_url
87+
"wms": {
88+
"name": self.wms_name,
89+
"version": self.wms_version,
90+
"url": self.wms_url
9191
},
92-
'workflow': {
93-
'executedAt': self.executed_at,
94-
'makespan': self.makespan,
95-
'jobs': workflow_tasks
92+
"workflow": {
93+
"executedAt": self.executed_at,
94+
"makespan": self.makespan,
95+
"tasks": workflow_tasks
9696
}
9797
}
9898

@@ -101,18 +101,18 @@ def write_json(self, json_file_path: Optional[pathlib.Path] = None) -> None:
101101
for edge in self.edges:
102102
for task_name in edge:
103103
if task_name not in tasks_dependencies:
104-
tasks_dependencies[task_name] = {'parents': [], 'children': []}
105-
tasks_dependencies[edge[0]]['children'].append(edge[1])
106-
tasks_dependencies[edge[1]]['parents'].append(edge[0])
104+
tasks_dependencies[task_name] = {"parents": [], "children": []}
105+
tasks_dependencies[edge[0]]["children"].append(edge[1])
106+
tasks_dependencies[edge[1]]["parents"].append(edge[0])
107107

108108
# add tasks to the workflow json object
109109
for node in self.nodes:
110-
task: Task = self.nodes[node]['task']
110+
task: Task = self.nodes[node]["task"]
111111
task_obj = task.as_dict()
112112

113113
# manage task dependencies
114-
task_obj['parents'] = tasks_dependencies[task.name]['parents']
115-
task_obj['children'] = tasks_dependencies[task.name]['children']
114+
task_obj["parents"] = tasks_dependencies[task.name]["parents"]
115+
task_obj["children"] = tasks_dependencies[task.name]["children"]
116116

117117
workflow_tasks.append(task_obj)
118118

@@ -122,12 +122,12 @@ def write_json(self, json_file_path: Optional[pathlib.Path] = None) -> None:
122122
workflow_machines.append(task.machine.as_dict())
123123

124124
if workflow_machines:
125-
workflow_json['workflow']['machines'] = workflow_machines
125+
workflow_json["workflow"]["machines"] = workflow_machines
126126

127127
# write to file
128128
if not json_file_path:
129-
json_file_path = pathlib.Path(f'{self.name.lower()}.json')
130-
with open(json_file_path, 'w') as outfile:
129+
json_file_path = pathlib.Path(f"{self.name.lower()}.json")
130+
with open(json_file_path, "w") as outfile:
131131
outfile.write(json.dumps(workflow_json, indent=4))
132132

133133
def write_dot(self, dot_file_path: Optional[pathlib.Path] = None) -> None:

wfcommons/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2020-2021 The WfCommons Team.
4+
# Copyright (c) 2020-2022 The WfCommons Team.
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by

wfcommons/wfchef/utils.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2021 The WfCommons Team.
4+
# Copyright (c) 2021-2022 The WfCommons Team.
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -56,23 +56,22 @@ def create_graph(path: pathlib.Path) -> nx.DiGraph:
5656

5757
id_count = 0
5858

59-
for job in content['workflow']['jobs']:
59+
for task in content["workflow"]["tasks"]:
6060

6161
# specific for epigenomics -- have to think about how to do it in general
62-
if "genome-dax" in content['name']:
63-
_type, *_ = job['name'].split('_')
64-
graph.add_node(job['name'], label=_type, type=_type, id=str(id_count))
62+
if "genome-dax" in content["name"]:
63+
_type, *_ = task["name"].split("_")
64+
graph.add_node(task["name"], label=_type, type=_type, id=str(id_count))
6565
id_count += 1
6666
else:
6767
try:
68-
_type, _id = job['name'].split('_ID')
68+
_type, _id = task["name"].split("_ID")
6969
except ValueError:
70-
_type, _id = job['name'].split('_0')
71-
graph.add_node(job['name'], label=_type, type=_type, id=_id)
70+
_type, _id = task["name"].split("_0")
71+
graph.add_node(task["name"], label=_type, type=_type, id=_id)
7272

73-
# for job in content['workflow']['jobs']:
74-
for parent in job['parents']:
75-
graph.add_edge(parent, job['name'])
73+
for parent in task["parents"]:
74+
graph.add_edge(parent, task["name"])
7675

7776
for node in graph.nodes:
7877

wfcommons/wfinstances/instance.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2020-2021 The WfCommons Team.
4+
# Copyright (c) 2020-2022 The WfCommons Team.
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -103,7 +103,7 @@ def __init__(self, input_instance: pathlib.Path,
103103

104104
# Tasks
105105
self.workflow: Workflow = Workflow(name=self.name, makespan=self.makespan)
106-
for task in self.instance['workflow']['jobs']:
106+
for task in self.instance["workflow"]["tasks"]:
107107
# Required arguments are defined in the JSON scheme
108108
# Here name, type and runtime are required
109109
# By default the value is set to None if we do not find the value
@@ -147,9 +147,8 @@ def __init__(self, input_instance: pathlib.Path,
147147
logger=self.logger
148148
)
149149
)
150-
151150
# TODO: handle the case of the output files of the leaves tasks (not taken into account yet)
152-
for task in self.instance['workflow']['jobs']:
151+
for task in self.instance["workflow"]["tasks"]:
153152
for parent in task['parents']:
154153
self.workflow.add_edge(parent, task['name'], weight=0)
155154

wfcommons/wfinstances/schema.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2020-2021 The WfCommons Team.
4+
# Copyright (c) 2020-2022 The WfCommons Team.
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -113,14 +113,14 @@ def _semantic_validation(self, data: Dict[str, Any]):
113113
self.logger.debug('Skipping machines processing.')
114114

115115
tasks_ids = []
116-
for j in data['workflow']['jobs']:
116+
for j in data["workflow"]["tasks"]:
117117
tasks_ids.append(j['name'])
118118
if 'machine' in j and j['machine'] not in machine_ids:
119119
self.logger.error(f"Machine \"{j['machine']}\" is not declared in the list of machines.")
120120
has_error = True
121121

122122
# since tasks may be declared out of order, their dependencies are only verified here
123-
for j in data['workflow']['jobs']:
123+
for j in data["workflow"]["tasks"]:
124124
for p in j['parents']:
125125
if p not in tasks_ids:
126126
self.logger.error(f"Parent task \"{p['parentId']}\" is not declared in the list of workflow tasks.")

0 commit comments

Comments
 (0)