diff --git a/pfdl_scheduler/petri_net/drawer.py b/pfdl_scheduler/petri_net/drawer.py index 1cbc446..1bd9e90 100644 --- a/pfdl_scheduler/petri_net/drawer.py +++ b/pfdl_scheduler/petri_net/drawer.py @@ -90,10 +90,6 @@ def draw_clusters(clust, attr): attr["style"] = DEFAULT_CLUSTER_STYLE -def draw_clusters(clust, attr): - attr["style"] = "" - - def draw_petri_net(net, file_path, file_ending=".png"): """Calls the draw method form the Snakes module on the given PetriNet.""" with draw_lock: diff --git a/pfdl_scheduler/petri_net/generator.py b/pfdl_scheduler/petri_net/generator.py index d1695b6..995098a 100644 --- a/pfdl_scheduler/petri_net/generator.py +++ b/pfdl_scheduler/petri_net/generator.py @@ -8,7 +8,7 @@ # standard libraries import copy -from typing import Any, Callable, Dict, List, OrderedDict, Tuple +from typing import Any, Callable, Dict, List, OrderedDict import uuid import functools import json @@ -229,7 +229,6 @@ def generate_statements( if multiple_statements: if i < len(statements) - 1: current_connection_uuid = create_transition("connection", "", self.net, node) - # node.cluster.add_child(Cluster(current_connection_uuid)) else: current_connection_uuid = last_connection_uuid else: @@ -248,7 +247,7 @@ def generate_statements( if isinstance(statement, Service): connection_uuids = [self.generate_service(*args)] elif isinstance(statement, TaskCall): - connection_uuids, new_task_context = self.generate_task_call(*args) + connection_uuids = self.generate_task_call(*args) elif isinstance(statement, Parallel): connection_uuids = [self.generate_parallel(*args)] elif isinstance(statement, CountingLoop): @@ -347,7 +346,7 @@ def generate_task_call( for last_connection_uuid in last_connection_uuids: self.add_callback(last_connection_uuid, self.callbacks.task_finished, new_task_context) - return last_connection_uuids, new_task_context + return last_connection_uuids def generate_parallel( self, @@ -570,7 +569,7 @@ def generate_parallel_loop( parallel_loop_node, ) cluster = Cluster([parallel_loop_started]) - # node.cluster.add_child(cluster) + parallel_loop_node.cluster = cluster self.net.add_output(parallel_loop_started, first_transition_uuid, Value(1)) self.net.add_input(parallel_loop_started, second_transition_uuid, Value(1)) @@ -617,7 +616,6 @@ def remove_place_on_runtime(self, place_uuid: str) -> None: place_uuid: The uuid as string of the task which should be removed from the net. """ if self.net.has_place(place_uuid): - # self.net.clusters._nodes.add(place_uuid) self.net.remove_place(place_uuid) if self.draw_net: draw_petri_net(self.net, self.path_for_image) diff --git a/pfdl_scheduler/petri_net/logic.py b/pfdl_scheduler/petri_net/logic.py index 183b09f..cc247c0 100644 --- a/pfdl_scheduler/petri_net/logic.py +++ b/pfdl_scheduler/petri_net/logic.py @@ -53,7 +53,7 @@ def draw_petri_net(self) -> None: If the `draw_net` flag is set, this method will save the petri net in a "temp" folder inside the root folder of the project. The petri net is saved as an image and as a dot - file to allow further processing. The dot file contains also the "call_tree" a tree + file to allow further processing. The dot file also contains the "call_tree", a tree structure that describes the call hierarchy of PFDL tasks. Args: diff --git a/pfdl_scheduler/scheduler.py b/pfdl_scheduler/scheduler.py index ddd3d6c..d1f0fc5 100644 --- a/pfdl_scheduler/scheduler.py +++ b/pfdl_scheduler/scheduler.py @@ -104,10 +104,6 @@ def __init__( file_name=self.scheduler_uuid, ) self.setup_scheduling(draw_petri_net) - - # enable logging - # self.attach(LogEntryObserver(self.scheduler_uuid)) - if dashboard_host_address != "": self.attach( DashboardObserver(dashboard_host_address, self.scheduler_uuid, pfdl_string) diff --git a/pfdl_scheduler/utils/log_entry_observer.py b/pfdl_scheduler/utils/log_entry_observer.py index e06ae1b..3775e51 100644 --- a/pfdl_scheduler/utils/log_entry_observer.py +++ b/pfdl_scheduler/utils/log_entry_observer.py @@ -38,8 +38,8 @@ class LogEntryObserver(Observer): def __init__(self, scheduler_uuid: str): logging.basicConfig( - filename="temp/" + scheduler_uuid + ".log", - encoding="utf-8", + filename=LOG_FILE_LOCATION + scheduler_uuid + LOG_FILE_FORMAT, + encoding=LOG_FILE_ENCODING, level=logging.DEBUG, filemode=LOG_FILE_FILEMODE, ) diff --git a/pfdl_scheduler/utils/parsing_utils.py b/pfdl_scheduler/utils/parsing_utils.py index 397983a..56a1454 100644 --- a/pfdl_scheduler/utils/parsing_utils.py +++ b/pfdl_scheduler/utils/parsing_utils.py @@ -94,7 +94,7 @@ def write_tokens_to_file(token_stream: CommonTokenStream) -> None: file.write(token_text + "\n") -def extract_content_and_file_path(program): +def extract_content_and_file_path(program: str) -> Tuple[str, str]: """Extracts the file path and loads the PFDL string for a given program. Args: diff --git a/tests/test_files/scheduling/task_synchronisation.pfdl b/tests/test_files/scheduling/task_synchronisation.pfdl index f40d7cd..bcdc11b 100644 --- a/tests/test_files/scheduling/task_synchronisation.pfdl +++ b/tests/test_files/scheduling/task_synchronisation.pfdl @@ -20,7 +20,7 @@ Struct CuttingResult sheet_parts: SheetPart[] End -Struct TransportOrderStep_Struct +Struct TransportOrderStep location: string End @@ -50,13 +50,13 @@ Task cuttingTask End Task transport - Transport_Service + Transport In - TransportOrderStep_Struct + TransportOrderStep { "location": "start" } - TransportOrderStep_Struct + TransportOrderStep { "location": "goal" } diff --git a/tests/unit_test/test_pfdl_tree_visitor.py b/tests/unit_test/test_pfdl_tree_visitor.py index f3e2205..6ad61ba 100644 --- a/tests/unit_test/test_pfdl_tree_visitor.py +++ b/tests/unit_test/test_pfdl_tree_visitor.py @@ -12,7 +12,7 @@ # standard libraries import unittest -from unittest.mock import MagicMock, Mock +from unittest.mock import MagicMock from unittest.mock import patch from pfdl_scheduler.model.parallel import Parallel @@ -20,7 +20,6 @@ # local sources from pfdl_scheduler.validation.error_handler import ErrorHandler from pfdl_scheduler.parser.PFDLParser import PFDLParser -from pfdl_scheduler.parser.PFDLParserVisitor import PFDLParserVisitor from pfdl_scheduler.model.process import Process from pfdl_scheduler.model.struct import Struct from pfdl_scheduler.model.task import Task @@ -36,10 +35,8 @@ from pfdl_scheduler.parser.pfdl_tree_visitor import ( PFDLTreeVisitor, - PRIMITIVE_DATATYPES, IN_KEY, OUT_KEY, - START_TASK, ) from antlr4 import ParserRuleContext @@ -719,8 +716,6 @@ def test_initializeArray(self): # without length with patch.object(self.visitor, "visitArray", return_value=-1): - array = Array("string") - array.length = 10 self.assertEqual( self.visitor.initializeArray(array_context, variable_type), Array("string") )