1414from abc import ABC , abstractmethod
1515from os import path
1616from logging import Logger
17- from typing import Any , Dict , List , Optional , Set
17+ from typing import Any , Dict , List , Optional
1818
1919from wfcommons .common .file import File , FileLink
2020from wfcommons .common .task import Task , TaskType
2323
2424
2525class WorkflowRecipe (ABC ):
26- """An abstract class of workflow recipes for creating synthetic workflow instances.
26+ """
27+ An abstract class of workflow recipes for creating synthetic workflow instances.
2728
2829 :param name: The workflow recipe name.
2930 :type name: str
3031 :param data_footprint: The upper bound for the workflow total data footprint (in bytes).
31- :type data_footprint: int
32+ :type data_footprint: Optional[ int]
3233 :param num_tasks: The upper bound for the total number of tasks in the workflow.
33- :type num_tasks: int
34+ :type num_tasks: Optional[ int]
3435 :param runtime_factor: The factor of which tasks runtime will be increased/decreased.
35- :type runtime_factor: float
36+ :type runtime_factor: Optional[ float]
3637 :param input_file_size_factor: The factor of which tasks input files size will be increased/decreased.
37- :type input_file_size_factor: float
38+ :type input_file_size_factor: Optional[ float]
3839 :param output_file_size_factor: The factor of which tasks output files size will be increased/decreased.
39- :type output_file_size_factor: float
40+ :type output_file_size_factor: Optional[ float]
4041 :param logger: The logger where to log information/warning or errors (optional).
41- :type logger: Logger
42+ :type logger: Optional[ Logger]
4243 """
4344
4445 def __init__ (self , name : str ,
@@ -57,23 +58,24 @@ def __init__(self, name: str,
5758 if output_file_size_factor <= 0.0 :
5859 raise ValueError ("The output file size factor should be a number higher than 0.0." )
5960
60- self .logger = logging .getLogger (__name__ ) if logger is None else logger
61+ self .logger : Optional [ Logger ] = logging .getLogger (__name__ ) if logger is None else logger
6162 self .name = name
62- self .data_footprint = data_footprint
63- self .num_tasks = num_tasks
64- self .runtime_factor = runtime_factor
65- self .input_file_size_factor = input_file_size_factor
66- self .output_file_size_factor = output_file_size_factor
63+ self .data_footprint : Optional [ int ] = data_footprint
64+ self .num_tasks : Optional [ int ] = num_tasks
65+ self .runtime_factor : Optional [ float ] = runtime_factor
66+ self .input_file_size_factor : Optional [ float ] = input_file_size_factor
67+ self .output_file_size_factor : Optional [ float ] = output_file_size_factor
6768 self .tasks_files : Dict [str , List [File ]] = {}
6869 self .tasks_files_names : Dict [str , List [str ]] = {}
69- self .task_id_counter = 1
70+ self .task_id_counter : int = 1
7071 self .tasks_map = {}
7172 self .tasks_children = {}
7273 self .tasks_parents = {}
7374
7475 @abstractmethod
7576 def _workflow_recipe (self ) -> Dict [str , Any ]:
76- """Recipe for generating synthetic instances for a workflow. Recipes can be
77+ """
78+ Recipe for generating synthetic instances for a workflow. Recipes can be
7779 generated by using the :class:`~wfcommons.wfinstances.instance_analyzer.InstanceAnalyzer`.
7880
7981 :return: A recipe in the form of a dictionary in which keys are task prefixes.
@@ -96,11 +98,11 @@ def from_num_tasks(cls,
9698 :param num_tasks: The upper bound for the total number of tasks in the workflow.
9799 :type num_tasks: int
98100 :param runtime_factor: The factor of which tasks runtime will be increased/decreased.
99- :type runtime_factor: float
101+ :type runtime_factor: Optional[ float]
100102 :param input_file_size_factor: The factor of which tasks input files size will be increased/decreased.
101- :type input_file_size_factor: float
103+ :type input_file_size_factor: Optional[ float]
102104 :param output_file_size_factor: The factor of which tasks output files size will be increased/decreased.
103- :type output_file_size_factor: float
105+ :type output_file_size_factor: Optional[ float]
104106
105107 :return: A workflow recipe object that will generate synthetic workflows up to
106108 the total number of tasks provided.
@@ -110,18 +112,20 @@ def from_num_tasks(cls,
110112
111113 @abstractmethod
112114 def build_workflow (self , workflow_name : Optional [str ] = None ) -> Workflow :
113- """Generate a synthetic workflow instance.
115+ """
116+ Generate a synthetic workflow instance.
114117
115118 :param workflow_name: The workflow name
116- :type workflow_name: int
119+ :type workflow_name: Optional[str]
117120
118121 :return: A synthetic workflow instance object.
119122 :rtype: Workflow
120123 """
121124 raise NotImplementedError
122125
123126 def _generate_task (self , task_name : str , task_id : str ) -> Task :
124- """Generate a synthetic task.
127+ """
128+ Generate a synthetic task.
125129
126130 :param task_name: task name.
127131 :type task_name: str
@@ -165,7 +169,8 @@ def _generate_task(self, task_name: str, task_id: str) -> Task:
165169 return task
166170
167171 def _generate_task_name (self , prefix : str ) -> str :
168- """Generate a task name from a prefix appended with an ID.
172+ """
173+ Generate a task name from a prefix appended with an ID.
169174
170175 :param prefix: task prefix.
171176 :type prefix: str
@@ -178,7 +183,8 @@ def _generate_task_name(self, prefix: str) -> str:
178183 return task_name
179184
180185 def _generate_task_files (self , task : Task ) -> List [File ]:
181- """Generate input and output files for a task.
186+ """
187+ Generate input and output files for a task.
182188
183189 :param task: task object.
184190 :type task: Task
@@ -211,7 +217,8 @@ def _generate_task_files(self, task: Task) -> List[File]:
211217 return output_files_list
212218
213219 def _generate_files (self , task_id : str , recipe : Dict [str , Any ], link : FileLink ) -> List [File ]:
214- """Generate files for a specific task ID.
220+ """
221+ Generate files for a specific task ID.
215222
216223 :param task_id: task ID.
217224 :type task_id: str
@@ -242,7 +249,8 @@ def _generate_files(self, task_id: str, recipe: Dict[str, Any], link: FileLink)
242249 return files_list
243250
244251 def _generate_file (self , extension : str , recipe : Dict [str , Any ], link : FileLink ) -> File :
245- """Generate a file according to a file recipe.
252+ """
253+ Generate a file according to a file recipe.
246254
247255 :param extension:
248256 :type extension: str
@@ -263,7 +271,8 @@ def _generate_file(self, extension: str, recipe: Dict[str, Any], link: FileLink)
263271 size = size )
264272
265273 def _get_files_by_task_and_link (self , task_id : str , link : FileLink ) -> List [File ]:
266- """Get the list of files for a task ID and link type.
274+ """
275+ Get the list of files for a task ID and link type.
267276
268277 :param task_id: task ID.
269278 :type task_id: str
0 commit comments