Developer Reference
pfdl_scheduler
api
service_api
Contains the ServiceAPI class.
ServiceAPI(service, task_context, uuid='', in_loop=False)
dataclass
Represents a called Service.
Represents a Service or Service Call in the langauge which can be mapped to a real service that can be executed.
Attributes:
Name | Type | Description |
---|---|---|
service |
Service
|
A description of the called Service. |
task_context |
TaskAPI
|
A TaskAPI representaiton of the Task from which the service was called. |
uuid |
str
|
A UUID4 which is generated at object creation and is used in the scheduling. |
in_loop |
bool
|
A boolean indicating whether the Service was called within a loop. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service |
Service
|
A description of the called Service. |
required |
task_context |
TaskAPI
|
A TaskAPI representaiton of the Task from which the service was called. |
required |
uuid |
str
|
A UUID4 which is generated at object creation and is used in the scheduling. |
''
|
in_loop |
bool
|
A boolean indicating whether the Service was called within a loop. |
False
|
Source code in pfdl_scheduler/api/service_api.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
task_api
Contains the TaskAPI class.
TaskAPI(task, task_context, uuid='', task_call=None, in_loop=False)
dataclass
Represents a called Task.
Represents a specific entity of a called Task. It combines the information of the Task itself and the parameters of the call. A TaskAPI object is used in the task started and finished callback which are called by the scheduler.
Attributes:
Name | Type | Description |
---|---|---|
task |
Task
|
A description of the called Task. |
task_context |
TaskAPI
|
A TaskAPI representaiton of the Task from which the called task was invoked. |
uuid |
str
|
A UUID4 which is generated at object creation and is used in the scheduling. |
task_call |
TaskCall
|
Information about the input and output parameters of the called Task. |
in_loop |
bool
|
A boolean indicating whether the Task was called within a loop. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
Task
|
A description of the called Task. |
required |
task_context |
TaskAPI
|
A TaskAPI representaiton of the Task from which the called task was invoked. |
required |
uuid |
str
|
A UUID4 which is generated at object creation and is used in the scheduling. |
''
|
task_call |
TaskCall
|
Information about the input and output parameters of the called Task. |
None
|
in_loop |
bool
|
A boolean indicating whether the Task was called within a loop. |
False
|
Source code in pfdl_scheduler/api/task_api.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
extension
Contains the start up script used in the VSCode extension.
A program executed in the VS Code extension which has a string containing a PFDL program as input.
model
array
Contains the Array class.
Array(type_of_elements='', values=None, context=None)
Represents an Array in the PFDL.
Used as as an array definition or a returned array with elements in it.
Attributes:
Name | Type | Description |
---|---|---|
type_of_elements |
str
|
A string representing the type of the elements inside the array. |
values |
List[Any]
|
A list of elements of the Array (empty if it is a array definition). |
length |
int
|
An integer for the length of the Array. If it is not defined it gets the value -1. |
context |
ParserRuleContext
|
ANTLR context object of this class. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type_of_elements |
str
|
A string representing the type of the elements inside the array. |
''
|
values |
List[Any]
|
A list of elements of the Array (empty if it is a array definition). |
None
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/array.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
append_value(value)
Adds an element to the array and increase the length.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
Any
|
The value that should be added to the array. |
required |
Source code in pfdl_scheduler/model/array.py
65 66 67 68 69 70 71 72 73 74 |
|
length_defined()
Returns whether the lenght of the array is defined.
Returns:
Type | Description |
---|---|
bool
|
True if the length of the array is defined. |
Source code in pfdl_scheduler/model/array.py
76 77 78 79 80 81 82 |
|
condition
Contains the Condition class.
Condition(expression=None, passed_stmts=None, failed_stmts=None, context=None)
dataclass
Represents a conditional statement in the PFDL.
A Condition consists of a boolean expression which has to be satisfied in order to execute the statements in the Passed block. Otherwise the statements in the Failed block will be executed.
Attributes:
Name | Type | Description |
---|---|---|
expression |
Dict
|
Boolean expression in form of a dict (see Visitor for the dict structure). |
passed_stmts |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements which are executed when the expression is satisfied. |
failed_stmts |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements which are executed when the expression is not satisfied. |
context |
ParserRuleContext
|
ANTLR context object of this class. |
context_dict |
Dict
|
Maps other attributes with ANTLR context objects. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
expression |
Dict
|
Boolean expression in form of a dict (see Visitor for the dict structure). |
None
|
passed_stmts |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements which are executed when the expression is satisfied. |
None
|
failed_stmts |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements which are executed when the expression is not satisfied. |
None
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/condition.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
counting_loop
Contains the CountingLoop class.
CountingLoop(statements=None, counting_variable='', limit='', parallel=False, context=None)
dataclass
Bases: Loop
Represents a Counting Loop in the PFDL.
Counting loops count a variable from an initial value to a given upper limit. If the parallel keyword was used, this loop executes the statements in the loop body in parallel as many times as the loop would iterate.
Attributes:
Name | Type | Description |
---|---|---|
statements |
List of statements inside the loop body. |
|
context |
ANTLR context object of this class. |
|
context_dict |
Maps other attributes with ANTLR context objects. |
|
counting_variable |
str
|
Name of the variable which is counted in the loop. |
limit |
str
|
Integer for the upper limit. |
parallel |
bool
|
A boolean indicating if the loop is a parallel loop or not. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
statements |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements inside the loop body. |
None
|
counting_variable |
str
|
Name of the variable which is counted in the loop. |
''
|
limit |
str
|
Integer for the upper limit. |
''
|
parallel |
bool
|
A boolean indicating if the loop is a parallel loop or not. |
False
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/counting_loop.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
loop
Contains the Loop class.
Loop(statements=None, context=None)
dataclass
The base class for the PFDL loops.
Attributes:
Name | Type | Description |
---|---|---|
statements |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements inside the loop body. |
context |
ParserRuleContext
|
ANTLR context object of this class. |
context_dict |
Dict
|
Maps other attributes with ANTLR context objects. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
statements |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements inside the loop body. |
None
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/loop.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
parallel
Contains the Parallel class.
Parallel(task_calls=None, context=None)
dataclass
Represents a Parallel statement in the PFDL.
Each task within this instruction is executed in parallel with the calling task. When all parallel tasks are finished, the calling task continues its execution.
Attributes:
Name | Type | Description |
---|---|---|
task_calls |
List[TaskCall]
|
List of Task Calls in the Parallel statement. |
context |
ParserRuleContext
|
ANTLR context object of this class. |
context_dict |
Dict
|
Maps other attributes with ANTLR context objects. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_calls |
List[TaskCall]
|
List of Task Calls in the Parallel statement. |
None
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/parallel.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
process
Contains the Process class.
Process(structs=None, tasks=None)
dataclass
Represents a production process described in a PFDL file.
A Process consists of multiple Structs and Tasks. A Process object gets created after the visitor traverses the syntax tree.
Attributes:
Name | Type | Description |
---|---|---|
structs |
Dict[str, Struct]
|
A dict for mapping the Struct names to the Struct objects. |
task |
Dict[str, Struct]
|
A dict for mapping the Task names to the Task objects. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
structs |
Dict[str, Struct]
|
A dict for mapping the Struct names to the Struct objects. |
None
|
tasks |
Dict[str, Task]
|
A dict for mapping the Task names to the Task objects. |
None
|
Source code in pfdl_scheduler/model/process.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
service
Contains the Service class.
Service(name='', input_parameters=None, output_parameters=None, context=None)
dataclass
Represents a Service or Service Call in the PFDL.
Represents a Service or Service Call in the langauge which can be mapped to a real service that can be executed.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
A string representing the name of the Service. |
input_parameters |
List[Union[str, List[str], Struct]]
|
List of input parameters of the Service. |
output_parameters |
OrderedDict[str, Union[str, Array]]
|
List of output parameters of the Service. |
context |
ParserRuleContext
|
ANTLR context object of this class. |
context_dict |
Dict
|
Maps other attributes with ANTLR context objects. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
A string representing the name of the Service. |
''
|
input_parameters |
List[Union[str, List[str], Struct]]
|
List of input parameters of the Service. |
None
|
output_parameters |
Dict[str, Union[str, Array]]
|
List of output parameters of the Service. |
None
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/service.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
struct
Contains the Struct class.
Struct(name='', attributes=None, context=None)
dataclass
Represents a Struct in the PFDL.
Data container for Services and Taskcalls. Used both for Struct definitons and instantiated Structs.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
A string representing the name of the Struct. |
attributes |
Dict[str, Union[str, Array, Struct]]
|
A dict which maps the attribute names to the defined type or a value (if its a instantiated struct). |
context |
ParserRuleContext
|
ANTLR context object of this class. |
context_dict |
Dict
|
Maps other attributes with ANTLR context objects. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
A string representing the name of the Struct. |
''
|
attributes |
Dict[str, Union[str, Array, Struct]]
|
A dict which maps the attribute names to the defined type or a value (if its a instantiated struct). |
None
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/struct.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
from_json(json_string, error_handler, struct_context)
classmethod
Creates a Struct instance out of the given JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string |
str
|
A JSON string desribing the Struct. |
required |
error_handler |
ErrorHandler
|
An ErrorHandler instance used for printing errors. |
required |
Returns:
Type | Description |
---|---|
Struct
|
The Struct which was created from the JSON string. |
Source code in pfdl_scheduler/model/struct.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
parse_json(json_object, error_handler, struct_context)
Parses the JSON Struct initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_object |
Dict
|
A JSON object describing the Struct. |
required |
error_handler |
ErrorHandler
|
An ErrorHandler instance used for printing errors. |
required |
struct_context |
ParserRuleContext
|
The ANTLR struct context the struct corresponds to. |
required |
Returns:
Type | Description |
---|---|
Struct
|
A Struct object representing the initialized Struct. |
Source code in pfdl_scheduler/model/struct.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
task
Contains the Task class.
Task(name='', statements=None, variables=None, input_parameters=None, output_parameters=None, context=None)
dataclass
Represents a Task in the PFDL.
A Task contains statements which are executed sequentially. It is possible to define input and output parameters of a Task.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
A string representing the name of the Task. |
statements |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements which are executed sequentially. |
variables |
Dict[str, Union[str, Array]]
|
Dict for mapping variable names with their values. |
input_parameters |
OrderedDict[str, Union[str, Array]]
|
OrderedDict for mapping input parameter names with their values. |
output_parameters |
List[str]
|
List of variable names as output parameters. |
context |
ParserRuleContext
|
ANTLR context object of this class. |
context_dict |
Dict
|
Maps other attributes with ANTLR context objects. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
A string representing the name of the Task. |
''
|
statements |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements which are executed sequentially. |
None
|
variables |
Dict[str, Union[str, Array]]
|
Dict for mapping variable names with their values. |
None
|
input_parameters |
OrderedDict[str, Union[str, Array]]
|
OrderedDict for mapping input parameter names with their values. |
None
|
output_parameters |
List[str]
|
List of variable names as output parameters. |
None
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/task.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
task_call
Contains the TaskCall class.
TaskCall(name='', input_parameters=None, output_parameters=None, context=None)
dataclass
Represents a TaskCall in the PFDL.
Provides information about the name and call parameters of a Task which is called within another Task.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
A string representing the name of the TaskCall. |
input_parameters |
List[Union[str, List[str], Struct]]
|
List of input parameters of the TaskCall. |
output_parameters |
Dict[str, Union[str, Array]]
|
List of output parameters of the TaskCall. |
context |
ParserRuleContext
|
ANTLR context object of this class. |
context_dict |
Dict
|
Maps other attributes with ANTLR context objects. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
A string representing the name of the TaskCall. |
''
|
input_parameters |
List[Union[str, List[str], Struct]]
|
List of input parameters of the TaskCall. |
None
|
output_parameters |
Dict[str, Union[str, Array]]
|
List of output parameters of the TaskCall. |
None
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/task_call.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
while_loop
Contains the WhileLoop class.
WhileLoop(statements=None, expression=None, context=None)
dataclass
Bases: Loop
Represents a While Loop in the PFDL.
Loops until conditional statement (expression) is satisfied.
Attributes:
Name | Type | Description |
---|---|---|
statements |
List of statements inside the loop body. |
|
expression |
Dict
|
Boolean expression in form of a dict. |
context |
Dict
|
ANTLR context object of this class. |
context_dict |
Dict
|
Maps other attributes with ANTLR context objects. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
statements |
List[Union[Service, TaskCall, Loop, Condition]]
|
List of statements inside the loop body. |
None
|
expression |
Dict
|
Boolean expression in form of a dict. |
None
|
context |
ParserRuleContext
|
ANTLR context object of this class. |
None
|
Source code in pfdl_scheduler/model/while_loop.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
parser
pfdl_tree_visitor
Contains PFDLTreeVisitor class.
PFDLTreeVisitor(error_handler)
Bases: PFDLParserVisitor
Traverses the given parse tree and store program information in a Process object.
This class overrides the generated visitor methods from the ANTLR generated PFDLParserVisitor. A Process object is created and gets filled while traversing the syntax tree.
Attributes:
Name | Type | Description |
---|---|---|
error_handler |
ErrorHandler
|
ErrorHandler instance for printing errors while visiting. |
current_task |
Task
|
Reference to the currently visited Task. Every visitor method can access it. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
error_handler |
ErrorHandler
|
ErrorHandler instance for printing errors while visiting. |
required |
Source code in pfdl_scheduler/parser/pfdl_tree_visitor.py
49 50 51 52 53 54 55 56 |
|
visitProgram(ctx)
Starts the visiting of the syntax tree of the given PFDL program.
Source code in pfdl_scheduler/parser/pfdl_tree_visitor.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
petri_net
callbacks
Contains the PetriNetCallbacks class.
PetriNetCallbacks
dataclass
Internal callback functions that can be registered in the petri net.
Attributes:
Name | Type | Description |
---|---|---|
task_started |
Callable[[TaskAPI], Any]
|
Callback function which gets called when a task is started. |
service_started |
Callable[[ServiceAPI], Any]
|
Callback function which gets called when a service is started. |
service_finished |
Callable[[ServiceAPI], Any]
|
Callback function which gets called when a task is started. |
condition_started |
Callable[[Condition, str, str, TaskAPI], Any]
|
Callback function which gets called when a task is started. |
while_loop_started |
Callable[[WhileLoop, str, str, TaskAPI], Any]
|
Callback function which gets called when a while loop is started. |
counting_loop_started |
Callable[[CountingLoop, str, str, TaskAPI], Any]
|
Callback function which gets called when a counting loop is started. |
parallel_loop_started |
Callable[[CountingLoop, TaskAPI, List, str, str], Any]
|
Callback function which gets called when a parallel loop is started. |
task_finished |
Callable[[TaskAPI], Any]
|
Callback function which gets called when a task is finished. |
drawer
Functions defined here set attributes for drawing the petri net.
draw_lock = threading.Lock()
module-attribute
Constants that are used in the drawer functions
draw_arcs(arc, attr)
Set attributes for drawing arcs.
Source code in pfdl_scheduler/petri_net/drawer.py
67 68 69 70 71 |
|
draw_graph(graph, attr)
Set attributes for drawing the net.
Source code in pfdl_scheduler/petri_net/drawer.py
38 39 40 |
|
draw_petri_net(net, file_path)
Calls the draw method form the Snakes module on the given PetriNet.
Source code in pfdl_scheduler/petri_net/drawer.py
74 75 76 77 78 79 80 81 82 83 84 85 |
|
draw_place(place, attr)
Set attributes for drawing places.
Source code in pfdl_scheduler/petri_net/drawer.py
43 44 45 46 47 48 49 50 51 52 53 54 |
|
draw_transition(trans, attr)
Set attributes for drawing transitions.
Source code in pfdl_scheduler/petri_net/drawer.py
57 58 59 60 61 62 63 64 |
|
generator
Contains the PetriNetGenerator class.
PetriNetGenerator(path_for_image='', used_in_extension=False, generate_test_ids=False, draw_net=True)
Generates a Petri Net from a given Process object which corresponds to a PFDL file.
Attributes:
Name | Type | Description |
---|---|---|
path_for_image |
str
|
The path where the image of the generated Petri Net is saved. |
net |
PetriNet
|
The snakes Petri Net instance. |
tasks |
Dict[str, Task]
|
A dict representing the Tasks of the given Process object. |
transition_dict |
OrderedDict
|
A dict for mapping the UUIDs of the Transitions to their behavior. |
place_dict |
Dict
|
A dict for mapping the service id to the place name. |
task_started_id |
str
|
The id of the 'Task started' place. |
callbacks |
PetriNetCallbacks
|
A PetriNetCallbacks instance representing functions called while execution. |
generate_test_ids |
bool
|
A boolean indicating if test ids (counting from 0) should be generated. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_for_image |
str
|
The path where the image of the generated Petri Net is saved. |
''
|
used_in_extension |
bool
|
A boolean indicating if the Generator is used within the extension. |
False
|
generate_test_ids |
bool
|
A boolean indicating if test ids (counting from 0) should be generated. |
False
|
draw_net |
bool
|
A boolean indicating if the petri net should be drawn. |
True
|
Source code in pfdl_scheduler/petri_net/generator.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
add_callback(transition_id, callback_function, *args)
Registers the given callback function in the transition_dict.
If the transition the transition_id refers to is fired, the callback function will be called with the given arguments inside the PetriNetLogic class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transition_id |
str
|
The UUID of the transition where the callback is called if fired. |
required |
callback_function |
Callable
|
The callback function which should be called. |
required |
*args |
Any
|
Arguments with which the callback function is called. |
()
|
Source code in pfdl_scheduler/petri_net/generator.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
generate_condition(condition, task_context, first_transition_id, second_transition_id, in_loop=False)
Generate Petri Net components for the Condition statement.
Returns:
Type | Description |
---|---|
List[str]
|
The ids of the last transitions of the Condition petri net component. |
Source code in pfdl_scheduler/petri_net/generator.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
generate_counting_loop(loop, task_context, first_transition_id, second_transition_id, in_loop=False)
Generates the Petri Net components for a Couting Loop.
Returns:
Type | Description |
---|---|
str
|
The id of the last transition of the CountingLoop petri net component. |
Source code in pfdl_scheduler/petri_net/generator.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
generate_parallel(parallel, task_context, first_transition_id, second_transition_id, in_loop=False)
Generate the Petri Net components for a Parallel statement.
Returns:
Type | Description |
---|---|
str
|
The id of the last transition of the Parallel petri net component. |
Source code in pfdl_scheduler/petri_net/generator.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
generate_parallel_loop(loop, task_context, first_transition_id, second_transition_id)
Generates the static petri net components for a ParallelLoop.
This method will generate a placeholder for the ParallelLoop. The real amount of parallel startet Tasks is only known at runtime.
Returns:
Type | Description |
---|---|
str
|
The id of the last transition of the ParallelLoop petri net component. |
Source code in pfdl_scheduler/petri_net/generator.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
generate_parallel_loop_on_runtime(task_call, task_context, task_count, parallel_loop_started, first_transition_id, second_transition_id, in_loop=False)
Generates the dynamic petri net components for a ParallelLoop at runtime.
The amount of parallel started Tasks inside the ParallelLoop is only known at runtime. This method will generate as many parallel TaskCalls as specified in the task_count parameter.
Source code in pfdl_scheduler/petri_net/generator.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
|
generate_petri_net(process)
Generates a Petri Net from the given Process object.
Starts from the 'productionTask' and iterates over his statements. For each statement type like Condition or TaskCall a Petri Net component is generated. All components get connected at the end.
Returns:
Type | Description |
---|---|
PetriNet
|
A PetriNet instance representing the generated net. |
Source code in pfdl_scheduler/petri_net/generator.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
generate_service(service, task_context, first_transition_id, second_transition_id, in_loop=False)
Generate the Petri Net components for a Service Call.
Returns:
Type | Description |
---|---|
str
|
The id of the last transition of the Service petri net component. |
Source code in pfdl_scheduler/petri_net/generator.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
generate_statements(task_context, statements, first_connection_id, last_connection_id, in_loop=False)
Generate Petri Net components for each statement in the given Task
Iterate over the statements of the given Tasks and generate the corresponding Petri Net components. Connect the individual components with each other via a transition.
Returns:
Type | Description |
---|---|
List[str]
|
The ids of the last connections (transitions). |
Source code in pfdl_scheduler/petri_net/generator.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
generate_task_call(task_call, task_context, first_transition_id, second_transition_id, in_loop=False)
Generate the Petri Net components for a Task Call.
Returns:
Type | Description |
---|---|
List[str]
|
The ids of the last transitions of the TaskCall petri net component. |
Source code in pfdl_scheduler/petri_net/generator.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
generate_while_loop(loop, task_context, first_transition_id, second_transition_id, in_loop=False)
Generate the Petri Net components for a While Loop.
Returns:
Type | Description |
---|---|
str
|
The id of the last transition of the WhileLoop petri net component. |
Source code in pfdl_scheduler/petri_net/generator.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
|
parse_expression(expression)
Parses the given expression to a printable format.
Returns:
Type | Description |
---|---|
str
|
The content of the expression as a formatted string. |
Source code in pfdl_scheduler/petri_net/generator.py
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
|
create_place(name, net)
Utility function for creating a place with the snakes module.
This function is used to add a place with the given name and to add labels for scheduling (for example if the place represents an event or if its initialized).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
A string representing the displayed name of the place. |
required |
net |
PetriNet
|
The petri net instance this place should be added to. |
required |
Returns:
Type | Description |
---|---|
str
|
A UUID as string for the added place. |
Source code in pfdl_scheduler/petri_net/generator.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
|
create_transition(transition_name, transition_type, net)
Utility function for creating a transition with the snakes module.
This function is used to add a transition with the given name and to add labels for scheduling (currently only the type of the transition).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transition_name |
str
|
A string representing the displayed name of the transition. |
required |
net |
PetriNet
|
The petri net instance this transition should be added to. |
required |
Returns:
Type | Description |
---|---|
str
|
A UUID as string for the added transition. |
Source code in pfdl_scheduler/petri_net/generator.py
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
|
logic
Contains the PetriNetLogic class.
PetriNetLogic(petri_net_generator, draw_net=True)
Provides methods for interacting with the generated petri nets for scheduling.
Scheduling of the production process with the help of the generated petri nets is done in this class.
Attributes:
Name | Type | Description |
---|---|---|
petri_net_generator |
PetriNetGenerator
|
A reference to the PetriNetGenerator. |
petri_net |
PetriNet
|
A reference to the generated petri net. |
draw_net |
bool
|
Indiciating whether the net should be drawn. |
transition_dict |
Dict
|
A reference to the dict in the generator which maps the ids to callbacks. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
petri_net_generator |
PetriNetGenerator
|
A reference to the PetriNetGenerator. |
required |
draw_net |
bool
|
Indiciating whether the net should be drawn. |
True
|
Source code in pfdl_scheduler/petri_net/logic.py
36 37 38 39 40 41 42 43 44 45 46 |
|
draw_petri_net(name, petri_net)
Saves the given petri net as an image in the current working directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the image. |
required |
petri_net |
PetriNet
|
The petri net instance that should be drawn. |
required |
Source code in pfdl_scheduler/petri_net/logic.py
48 49 50 51 52 53 54 55 56 57 58 |
|
evaluate_petri_net()
Tries to fire every transition as long as all transitions were tried and nothing can be done anymore.
Source code in pfdl_scheduler/petri_net/logic.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
fire_event(event)
Adds a token to the corresponding place of the event in the petri net.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
Event
|
The Event object that is fired. |
required |
Source code in pfdl_scheduler/petri_net/logic.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
scheduler
Contains the Scheduler class.
Scheduler(pfdl_file_path, generate_test_ids=False, draw_petri_net=True)
Schedules Tasks of a given PFDL file.
The scheduler comprises almost the complete execution of a production order including the parsing of the PFDL description, model creation and validation and execution of the petri net. It interacts with the execution engines and informs them about services or tasks which started or finished.
Attributes:
Name | Type | Description |
---|---|---|
running |
bool
|
A boolean that indicates whether the scheduler is running. |
pfdl_file_valid |
bool
|
A boolean indicating wheter the given PFDL file was valid. |
process |
Process
|
The corresponding Process instance from the PFDL file. |
petri_net_generator |
PetriNetGenerator
|
A PetriNetGenerator instance for generating the petri net. |
petri_net_logic |
PetriNetLogic
|
A PetriNetLogic instance for execution of the petri net. |
task_callbacks |
TaskCallbacks
|
TaskCallbacks instance which holds the registered callbacks. |
variable_access_function |
Callable[[str], str]
|
The function which will be called when the scheduler needs a variable. |
loop_counters |
Dict[str, int]
|
A dict for mapping task ids to the current loop counter (counting loops). |
awaited_events |
List[Event]
|
A list of awaited |
generate_test_ids |
bool
|
Indicates whether test ids should be generated. |
test_id_counters |
List[int]
|
A List consisting of counters for the test ids of tasks and services. |
Initialize the object.
If the given path leads to a valid PFDL file the parsing will be started. If no errors
occour the model of the PFDL File will be transformed into a petri net and be drawn if
the draw_petri_net
flag is set. If generate_test_ids
is set the ids of the called
tasks and services will be an enumeration starting at 0.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pfdl_file_path |
str
|
The path to the PFDL file. |
required |
generate_test_ids |
bool
|
A boolean indicating whether test ids should be generated. |
False
|
draw_petri_net |
bool
|
A boolean indicating wheter the petri net should be drawn. |
True
|
Source code in pfdl_scheduler/scheduler.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
check_expression(expression, task_context)
Check the boolean value of the given PFDL expression as a Python expression.
This method only gets executed if the semantic error check is passed. This means that no additional semantic checks has to be performed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
expression |
Dict
|
A dict representing the expression. |
required |
task_context |
TaskAPI
|
The context in which the expression should be evaluated. |
required |
Returns:
Type | Description |
---|---|
bool
|
The value of the successfully executed expression in Python as a bool. |
Source code in pfdl_scheduler/scheduler.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
|
execute_expression(expression, task_context)
Executes the given PFDL expression as a Python expression.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
expression |
Dict
|
A dict representing the expression. |
required |
task_context |
TaskAPI
|
The context in which the expression should be evaluated. |
required |
Returns:
Type | Description |
---|---|
Any
|
The value of the expression executed in Python (type depends on specific expression). |
Source code in pfdl_scheduler/scheduler.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
fire_event(event)
Forwards the given Event to the PetriNetLogic instance.
The given Event
object will be passed to the petri net if it is an awaited
event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
Event
|
An |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the event could be fired to the petri net (is an awaited event). |
Source code in pfdl_scheduler/scheduler.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
on_condition_started(condition, then_uuid, else_uuid, task_context)
Executes Scheduling logic when a Condition statement is started.
Source code in pfdl_scheduler/scheduler.py
235 236 237 238 239 240 241 242 243 244 245 246 |
|
on_counting_loop_started(loop, then_uuid, else_uuid, task_context)
Executes Scheduling logic when a Counting Loop is started.
Source code in pfdl_scheduler/scheduler.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
on_parallel_loop_started(loop, task_context, parallelTask, parallel_loop_started, first_transition_id, second_transition_id)
Executes Scheduling logic when a Parallel Loop is started.
Source code in pfdl_scheduler/scheduler.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
|
on_service_finished(service_api)
Executes Scheduling logic when a Service is finished.
Source code in pfdl_scheduler/scheduler.py
230 231 232 233 |
|
on_service_started(service_api)
Executes Scheduling logic when a Service is started.
Source code in pfdl_scheduler/scheduler.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
on_task_finished(task_api)
Executes Scheduling logic when a Task is finished.
Source code in pfdl_scheduler/scheduler.py
320 321 322 323 324 325 |
|
on_task_started(task_api)
Executes Scheduling logic when a Task is started.
Source code in pfdl_scheduler/scheduler.py
203 204 205 206 207 208 209 210 211 212 |
|
on_while_loop_started(loop, then_uuid, else_uuid, task_context)
Executes Scheduling logic when a While Loop is started.
Source code in pfdl_scheduler/scheduler.py
248 249 250 251 252 253 254 255 256 257 258 259 |
|
register_callback_service_finished(callback)
Registers the given callback in the service_finished list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback |
Callable[[ServiceAPI], Any]
|
Function which will be invoked when a Service is finished. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the callback was successfully registered. |
Source code in pfdl_scheduler/scheduler.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
register_callback_service_started(callback)
Registers the given callback in the service_started list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback |
Callable[[ServiceAPI], Any]
|
Function which will be invoked when a Service is started. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the callback was successfully registered. |
Source code in pfdl_scheduler/scheduler.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
register_callback_task_finished(callback)
Registers the given callback in the task_finished list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback |
Callable[[TaskAPI], Any]
|
Function which will be invoked when a Task is finished. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the callback was successfully registered. |
Source code in pfdl_scheduler/scheduler.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
register_callback_task_started(callback)
Registers the given callback in the task_started list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback |
Callable[[TaskAPI], Any]
|
Function which will be invoked when a Task is started. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the callback was successfully registered. |
Source code in pfdl_scheduler/scheduler.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
register_for_petrinet_callbacks()
Register scheduler callback functions in the petri net.
Source code in pfdl_scheduler/scheduler.py
327 328 329 330 331 332 333 334 335 336 337 |
|
register_variable_access_function(var_access_func)
Registers the given callback as the variable acces function of the Scheduler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var_access_func |
Callable[[str], str]
|
The function which will be called when the scheduler needs a variable. |
required |
Source code in pfdl_scheduler/scheduler.py
195 196 197 198 199 200 201 |
|
start()
Starts the scheduling process for the given PFDL file from the path.
Returns:
Type | Description |
---|---|
bool
|
True if the corresponding PFDL file was valid and the Scheduler could be started. |
Source code in pfdl_scheduler/scheduler.py
100 101 102 103 104 105 106 107 108 109 110 |
|
scheduling
event
Contains the Event class.
Event(event_type='', data=None)
Data class for controlling the PetriNet instance.
Currently avaiable Events
- Event(event_type="service_finished", data={"service_id":
})
Attributes:
Name | Type | Description |
---|---|---|
event_type |
str
|
A string representing the type of the event. |
data |
Dict
|
A dict containing the corresponding data of the event type. |
Source code in pfdl_scheduler/scheduling/event.py
32 33 34 |
|
from_json(json_string)
classmethod
Creates an Event instance out of the given JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string |
str
|
A JSON string desribing the Event. |
required |
Returns:
Type | Description |
---|---|
Union[None, Event]
|
The Event which was created from the JSON string. None if the conversion failed. |
Source code in pfdl_scheduler/scheduling/event.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
task_callbacks
Contains the TaskCallbacks class.
TaskCallbacks()
dataclass
Contains lists of callback functions that where registered in the scheduler.
Attributes:
Name | Type | Description |
---|---|---|
task_started |
List[Callable[[TaskAPI], Any]]
|
A list of callback functions which get called when a task is started. |
service_started |
List[Callable[[ServiceAPI], Any]]
|
A list of callback functions which get called when a service is started. |
service_finished |
List[Callable[[ServiceAPI], Any]]
|
A list of callback functions which get called when a service is finished. |
task_finished |
List[Callable[[TaskAPI], Any]]
|
A list of callback functions which get called when a task is finished. |
Initialize the object.
Source code in pfdl_scheduler/scheduling/task_callbacks.py
29 30 31 32 33 34 |
|
utils
helpers
Helper functions used in the project (especially in the SemanticErrorChecker).
check_type_of_value(value, value_type)
Checks if the given value is the given type in the DSL.
Returns:
Type | Description |
---|---|
bool
|
True if the value is from the given value type. |
Source code in pfdl_scheduler/utils/helpers.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
get_type_of_variable_list(var_list, task, struct_definitions)
Iterates over the given variable list and gets the type of the last element.
Returns:
Type | Description |
---|---|
str
|
Type of the last element in the variable list as string. |
Source code in pfdl_scheduler/utils/helpers.py
39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
is_boolean(string)
Checks if the given string can be casted to a boolean.
Returns:
Type | Description |
---|---|
bool
|
True if the given string can be casted to a boolean. |
Source code in pfdl_scheduler/utils/helpers.py
76 77 78 79 80 81 82 83 84 |
|
is_con(string)
Checks if the given string is a condition element in the PFDL.
A condition element can be a PFDL string, boolean or number
Returns:
Type | Description |
---|---|
bool
|
True if the given string is a condition element in the PFDL. |
Source code in pfdl_scheduler/utils/helpers.py
54 55 56 57 58 59 60 61 62 |
|
is_float(string)
Checks if the given string can be casted to a float.
Returns:
Type | Description |
---|---|
bool
|
True if the given string can be casted to a float. |
Source code in pfdl_scheduler/utils/helpers.py
98 99 100 101 102 103 104 105 106 107 108 109 |
|
is_int(string)
Checks if the given string can be casted to an integer.
Returns:
Type | Description |
---|---|
bool
|
True if the given string can be casted to an integer. |
Source code in pfdl_scheduler/utils/helpers.py
112 113 114 115 116 117 118 119 120 121 122 123 |
|
is_number(string)
Checks if the given string can be casted to a number (int or float).
Returns:
Type | Description |
---|---|
bool
|
True if the given string can be casted to a number. |
Source code in pfdl_scheduler/utils/helpers.py
87 88 89 90 91 92 93 94 95 |
|
is_string(string)
Check if the given parameter is a string in the DSL: It should start and end with '"'.
Returns:
Type | Description |
---|---|
bool
|
True if the given string is a string in the DSL. |
Source code in pfdl_scheduler/utils/helpers.py
65 66 67 68 69 70 71 72 73 |
|
parse_operator(op)
Parses a PFDL operator in form of a string into a Python executable operator func.
Source code in pfdl_scheduler/utils/helpers.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
parsing_utils
Contains functions which are used to load and parse PFDL files.
load_file(file_path)
Loads the content of the file from the given path.
Returns:
Type | Description |
---|---|
str
|
The content of the file as a string. |
Source code in pfdl_scheduler/utils/parsing_utils.py
97 98 99 100 101 102 103 104 105 106 |
|
parse_file(file_path)
Loads the content of the file from the given path and calls the parse_string function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
The path to the PFDL file. |
required |
Returns:
Type | Description |
---|---|
Tuple[bool, Union[None, Process]]
|
A boolan indicating validity of the PFDL file and the process object if so, otherwise None. |
Source code in pfdl_scheduler/utils/parsing_utils.py
72 73 74 75 76 77 78 79 80 81 82 |
|
parse_string(pfdl_string, file_path='', used_in_extension=False)
Instantiate the ANTLR lexer and parser and parses the given PFDL string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pfdl_string |
str
|
A string containing the content of a PFDL file. |
required |
file_path |
str
|
The path of the PFDL file (used for error messages). |
''
|
used_in_extension |
bool
|
A boolean indicating if the function is called from the extension. |
False
|
Returns:
Type | Description |
---|---|
Tuple[bool, Union[None, Process]]
|
A boolan indicating validity of the PFDL file and the process object if so, otherwise None. |
Source code in pfdl_scheduler/utils/parsing_utils.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
write_tokens_to_file(token_stream)
Writes the given ANTLR CommonTokenStream into a file named 'token.txt'.
Source code in pfdl_scheduler/utils/parsing_utils.py
85 86 87 88 89 90 91 92 93 94 |
|
validation
error_handler
Contains the ErrorHandler class.
ErrorHandler(file_path, used_in_extension)
Keeps track of the total error amount in an PFDL file.
Provides a method for printing an erro which counts the errors.
Attributes:
Name | Type | Description |
---|---|---|
total_error_count |
int
|
Total number of errors. |
syntax_error_count |
int
|
Number of syntax errors. |
semantic_error_count |
int
|
Number of static semantic errors. |
file_path |
str
|
The file path to the PFDL file. |
used_in_extension |
bool
|
A boolean indicating if the Generator is used within the extension. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
The file path to the PFDL file. |
required |
used_in_extension |
bool
|
A boolean indicating if the Generator is used within the extension. |
required |
Source code in pfdl_scheduler/validation/error_handler.py
26 27 28 29 30 31 32 33 34 35 36 37 |
|
has_error()
Returns true if the total error_count is greater than zero.
Source code in pfdl_scheduler/validation/error_handler.py
78 79 80 |
|
print_error(error_msg, line=0, column=0, off_symbol_length=0, context=None, syntax_error=False)
Prints an error into the standard output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
error_msg |
str
|
A string containing the error message |
required |
line |
int
|
The line in which the error occured |
0
|
column |
int
|
The column in which the error occured |
0
|
off_symbol_length |
int
|
Length of the offending symbol |
0
|
context |
ParserRuleContext
|
ANTLR Context object (lines and column will be used from this if not None) |
None
|
syntax_error |
bool
|
A boolean indicating whether the error is a syntax error or not. |
False
|
Source code in pfdl_scheduler/validation/error_handler.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
semantic_error_checker
Contains the SemanticErrorChecker class.
SemanticErrorChecker(error_handler, process)
Checks for static semantic errors in a given Process object.
Each of the methods in this class checks for a specific semantic error. After calling the validate_process method the entire given process object and all the model objects it contains are tested for errors.
Attributes:
Name | Type | Description |
---|---|---|
error_handler |
ErrorHandler
|
ErrorHandler instance for printing errors. |
process |
Process
|
The Process object which has to be validated. |
tasks |
Dict[str, Task]
|
A Dict that contains all Task objects of the given process object. |
structs |
Dict[str, Struct]
|
A Dict that contains all Struct objects of the given process object. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
error_handler |
ErrorHandler
|
ErrorHandler instance for printing errors. |
required |
process |
Process
|
The Process object which has to be validated. |
required |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
49 50 51 52 53 54 55 56 57 58 59 |
|
check_array(instantiated_array, array_definition)
Calls check methods to validate the instantiated array.
Returns:
Type | Description |
---|---|
bool
|
True if the given array is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
|
check_attribute_access(variable_list, context, task)
Checks if the attribute access via a variable list (for example x.y.z) is valid.
Returns:
Type | Description |
---|---|
bool
|
True if the attribute access is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
|
check_binary_operation(expression, context, task)
Checks if a binary expression is a valid expression.
Returns:
Type | Description |
---|---|
bool
|
True if the given binary expression is a valid expression. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 |
|
check_call_input_parameters(called_entity, task)
Checks if the input parameters of a Service or Task Call are valid.
Returns:
Type | Description |
---|---|
bool
|
True if the input parameters of a Service or Task Call are valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
|
check_call_output_parameters(called_entity)
Checks if the output parameters of a Service or Task Call are valid.
Returns:
Type | Description |
---|---|
bool
|
True if the output parameters of a Service or Task Call are valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
492 493 494 495 496 497 498 499 500 501 502 503 504 |
|
check_call_parameters(called_entity, task)
Checks if the parameters of a Service or Task call are valid (input and output).
Returns:
Type | Description |
---|---|
bool
|
True if the parameters of a Service or Task call are valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
406 407 408 409 410 411 412 413 414 415 416 417 418 |
|
check_conditional_statement(condition, task)
Calls check methods for the conditional statement.
Calls check_statement for the Passed and Failed statements and checks if the boolean expression is valid.
Returns:
Type | Description |
---|---|
bool
|
True if the conditional statement is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 |
|
check_counting_loop(counting_loop, task)
Calls check methods for the Counting Loop statement.
Returns:
Type | Description |
---|---|
bool
|
True if the Counting Loop statement is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
679 680 681 682 683 684 685 686 687 688 689 690 |
|
check_expression(expression, context, task)
Executes checks to test given expression.
Returns:
Type | Description |
---|---|
bool
|
True if the given expression is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
check_for_missing_attribute_in_struct(struct, struct_definition)
Checks if an instantiated Struct is missing an attribute from the Struct definition.
Returns:
Type | Description |
---|---|
bool
|
True if no attributes are missing. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
|
check_for_unknown_attribute_in_struct(struct, identifier, struct_definition)
Checks if the given identifier in the instantiated struct exists in the struct definition.
Returns:
Type | Description |
---|---|
bool
|
True if the given identifier exists in the struct definition. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 |
|
check_for_unknown_datatypes_in_struct_definition(struct)
Checks for each attribute definition in the struct if the defined type exists.
Returns:
Type | Description |
---|---|
bool
|
True if all datatypes in the given struct are known. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
check_for_wrong_attribute_type_in_struct(struct, identifier, struct_definition)
Calls check methods for the attribute assignments in an instantiated Struct.
Returns:
Type | Description |
---|---|
bool
|
True if all attribute assignments are valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
|
check_if_input_parameter_matches(input_parameter, identifier, defined_type, task_call, called_task, task)
Checks if the input parameters of a Taskcall matches with the called Task.
Returns:
Type | Description |
---|---|
bool
|
True if the input parameters of a Taskcall matches with the called Task. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
|
check_if_struct_exists(struct)
Checks if the given Struct instance refers to a existing Struct definition.
Returns:
Type | Description |
---|---|
bool
|
True if the given Struct instance refers to a existing Struct definition. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
534 535 536 537 538 539 540 541 542 543 544 |
|
check_if_task_call_matches_with_called_task(task_call, task)
Checks if the parameters of the Taskcall matches with the parameters of the Task.
Multiple Checks are done
- Checks if length of parameters of Taskcall and Task matches.
- Checks if types of input and output parameters matches.
Returns:
Type | Description |
---|---|
bool
|
True if the parameters matches. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
check_if_task_call_parameter_length_match(task_call)
Checks if the length of the Task call parameters match with the called Task.
Returns:
Type | Description |
---|---|
bool
|
True if the parameter lengths matches. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
|
check_if_task_in_taskcall_exists(task_name, context)
Checks if the Task name in the Taskcall belongs to a Task.
Returns:
Type | Description |
---|---|
bool
|
True if the given name belongs to a Task. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
858 859 860 861 862 863 864 865 866 867 868 |
|
check_if_variable_definition_is_valid(identifier, variable_type, context)
Checks if the variable has the correct type.
Returns:
Type | Description |
---|---|
bool
|
True if variable definition is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 |
|
check_instantiated_struct_attributes(struct)
Calls multiple check methods to validate an instantiated Struct.
Returns:
Type | Description |
---|---|
bool
|
True if the instantiated Struct is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
|
check_parallel(parallel, task)
Calls check methods for the Parallel statement.
Returns:
Type | Description |
---|---|
bool
|
True if the given Parallel statement is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
159 160 161 162 163 164 165 166 |
|
check_service(service, task)
Calls check methods for the Service or Service Call statement.
Returns:
Type | Description |
---|---|
bool
|
True if the given Service statement is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
207 208 209 210 211 212 213 214 215 |
|
check_single_expression(expression, context, task)
Checks if a single expression is a valid expression.
Returns:
Type | Description |
---|---|
bool
|
True if the given single expression is a valid expression. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 |
|
check_statement(statement, task)
Calls check methods depending on the type of the statement.
Returns:
Type | Description |
---|---|
bool
|
True if the given statement is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
check_statements(task)
Executes semantic checks for all statements in a Task.
Returns:
Type | Description |
---|---|
bool
|
True if all Statements are valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
125 126 127 128 129 130 131 132 133 134 135 |
|
check_structs()
Executes semantic checks for each Struct.
Returns:
Type | Description |
---|---|
bool
|
True if all Struct definitions are valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
71 72 73 74 75 76 77 78 79 80 |
|
check_task_call(task_call, task)
Calls check methods for the TaskCall statement.
Returns:
Type | Description |
---|---|
bool
|
True if the given TaskCall statement is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
check_task_input_parameters(task)
Checks if the input parameters are valid.
Returns:
Type | Description |
---|---|
bool
|
True if the input parameters of the given Task are valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
check_task_output_parameters(task)
Checks if the output parameters are valid.
Checks if the variable names used as parameters are variables defined in the Task.
Returns:
Type | Description |
---|---|
bool
|
True if the output parameters of the given Task are valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
check_tasks()
Executes semantic checks for each Task.
Returns:
Type | Description |
---|---|
bool
|
True if all Task definitions are valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
check_unary_operation(expression, context, task)
Checks if a unary expression is a valid expression.
Returns:
Type | Description |
---|---|
bool
|
True if the given unary expression is a valid expression. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
757 758 759 760 761 762 763 |
|
check_while_loop(while_loop, task)
Calls check methods for the While Loop statement.
Returns:
Type | Description |
---|---|
bool
|
True if the While Loop statement is valid. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
|
expression_is_number(expression, task)
Checks if the given expression is a number (int or float).
Returns:
Type | Description |
---|---|
bool
|
True if the given expression is a number. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
|
expression_is_string(expression, task)
Checks if the given expression is a PFDL string.
Returns:
Type | Description |
---|---|
bool
|
True if the given expression is a PFDL string. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
819 820 821 822 823 824 825 826 827 828 829 830 |
|
instantiated_array_length_correct(instantiated_array, array_definition)
Checks if the length of the instantiated array matches with the array definition.
Returns:
Type | Description |
---|---|
bool
|
True if both lengths are equal. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
886 887 888 889 890 891 892 893 894 895 896 897 |
|
validate_process()
Starts static semantic checks.
Returns:
Type | Description |
---|---|
bool
|
True, if the process has no errors, otherwise False. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
61 62 63 64 65 66 67 68 |
|
variable_type_exists(variable_type)
Checks if the given variable type exists in the PFDL file.
A variable type can be a primitive (number, string or boolean) or an identifier of a defined Struct.
Returns:
Type | Description |
---|---|
bool
|
True if the variable type exists within the PFDL file. |
Source code in pfdl_scheduler/validation/semantic_error_checker.py
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
|
syntax_error_listener
Contains SyntaxErrorListener class.
SyntaxErrorListener(token_stream, error_handler)
Bases: ErrorListener
Custom ErrorListener for the PFDL.
Overrides Antlr ErrorListener class so we can use our ErrorHandler class for syntax errors.
Attributes:
Name | Type | Description |
---|---|---|
token_stream |
CommonTokenStream
|
ANTLR token stream. |
error_handler |
ErrorHandler
|
ErrorHandler instance for printing errors. |
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token_stream |
CommonTokenStream
|
ANTLR token stream. |
required |
error_handler |
ErrorHandler
|
ErrorHandler instance for printing errors. |
required |
Source code in pfdl_scheduler/validation/syntax_error_listener.py
31 32 33 34 35 36 37 38 39 40 |
|
syntaxError(recognizer, offendingSymbol, line, column, msg, e)
Overwrites the ANTLR ErrorListener method to use the error handler.
Source code in pfdl_scheduler/validation/syntax_error_listener.py
42 43 44 45 46 47 48 49 50 51 52 |
|