Skip to content

Commit 3e761e7

Browse files
Adds files to files entry
1 parent c576b8e commit 3e761e7

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

wfcommons/common/workflow.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,18 @@ def write_json(self, json_file_path: Optional[pathlib.Path] = None) -> None:
177177
machines_list.append(machine.name)
178178
workflow_machines.append(machine.as_dict())
179179

180+
# add files to the workflow json object (input and output)
181+
for file in task.input_files:
182+
files.append(file.as_dict())
183+
for file in task.output_files:
184+
files.append(file.as_dict())
185+
180186
if workflow_machines:
181187
workflow_json["workflow"]["execution"]["machines"] = workflow_machines
182188

189+
if files and len(files) > 0:
190+
workflow_json["workflow"]["specification"]["files"] = files
191+
183192
# write to file
184193
if not json_file_path:
185194
json_file_path = pathlib.Path(f"{self.name.lower()}.json")

wfcommons/wfgen/abstract_recipe.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ def _generate_task_files(self, task: Task) -> List[File]:
205205
output_files_list = self._generate_files(task.task_id, task_recipe['output'], FileLink.OUTPUT)
206206
task.output_files = self.tasks_files[task.task_id]
207207

208-
209-
210208
# obtain input files from parents
211209
input_files = []
212210

@@ -221,13 +219,14 @@ def _generate_task_files(self, task: Task) -> List[File]:
221219
if input_file not in self.tasks_files_names[task.task_id]:
222220
self.tasks_files[task.task_id].append(File(name=input_file,
223221
link=FileLink.INPUT,
224-
size=input_file.size))
222+
size=input_file.size))
225223
self.tasks_files_names[task.task_id].append(input_file)
226224

227225
# generate additional input files
228226
self._generate_files(task.task_id, task_recipe['input'], FileLink.INPUT)
229227
task.input_files = [ifile for ifile in self.tasks_files[task.task_id] if ifile.link == FileLink.INPUT]
230228

229+
231230
return output_files_list
232231

233232
def _generate_files(self, task_id: str, recipe: Dict[str, Any], link: FileLink) -> List[File]:
@@ -248,9 +247,9 @@ def _generate_files(self, task_id: str, recipe: Dict[str, Any], link: FileLink)
248247
extension_list: List[str] = []
249248
for f in self.tasks_files[task_id]:
250249
if f.link == link:
250+
extension_list.append(path.splitext(f.file_id)[1] if '.' in f.file_id else f.file_id)
251251
files_list.append(f)
252-
extension_list.append(path.splitext(f.name)[1] if '.' in f.name else f.name)
253-
252+
254253
for extension in recipe:
255254
if extension not in extension_list:
256255
file = self._generate_file(extension, recipe, link)
@@ -278,10 +277,12 @@ def _generate_file(self, extension: str, recipe: Dict[str, Any], link: FileLink)
278277
else self.output_file_size_factor) * generate_rvs(recipe[extension]['distribution'],
279278
recipe[extension]['min'],
280279
recipe[extension]['max']))
280+
281281
return File(file_id=str(uuid.uuid4()) + extension,
282282
link=link,
283283
size=size)
284284

285+
285286
def _get_files_by_task_and_link(self, task_id: str, link: FileLink) -> List[File]:
286287
"""
287288
Get the list of files for a task ID and link type.

wfcommons/wfinstances/instance_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def build_summary(self,
109109
# For each input_file and output_file, append the file size to the dictionary
110110
for infile in task.input_files:
111111
extension: str = path.splitext(infile.file_id)[1] if '.' in infile.file_id else infile.file_id
112-
# print(f"file {infile.file_id} extension: {extension}")
112+
113113
if extension[1:].isnumeric():
114114
extension = path.splitext(infile.file_id.replace(extension, ''))[1]
115115

0 commit comments

Comments
 (0)