Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor PFDL code #60

Merged
merged 56 commits into from
Aug 23, 2024
Merged

Refactor PFDL code #60

merged 56 commits into from
Aug 23, 2024

Conversation

maxhoerstr
Copy link
Collaborator

  • Make code more modular to enable the reuse of the code (e.g.. make more functions and methods single purpose)
  • Fix various bugs in the petri net generation
  • Renaming
  • Format code and add docstrings
  • Allow a PFDL program to be passed over to the scheduler as a string (currently, only a file path was allowed)
  • Add various quality of live features/fixes
  • Allow the free configuration of the "start task" (former productionTask)
  • Allow integers as loop limits and negative numbers

- Create a tree where each node contains a group id, to map the
call hierarchy of the different tasks
There were still parent group ids used.
They are unnecessary now, since the structure of the calls is realised
with a tree structure (Node)
- Petri Net images and dot files are no always named "petri_net"
- Append Call Tree from PetriNetGenerator to dot file for extension
- Cluster individual components of the PFDL (Service, Tasks, ..)
- Save this information in the dot file
- Fix bug in drawing of petri net for extension
- Move creation of folders on better suiting location
- Remove unnecessary `used_in_extension` attributes and params
- Fix typos and remove comments
- Temporarily disable removal of nodes from the petri net
- Publish PFDL string to dashboard
- Rewrite methods so PFDL string can be extracted from the file and used
- Send Petri Net update before Order is finished
- Remove counting loop subgraph in dot file
This allows for more modularity so future plugin users can choose what
to reuse if the overwrite the init function of the scheduler.
OliverStolzBO and others added 19 commits January 9, 2024 15:24
- Use the term "uuid" wherever a uuid is assigned
- Avoid inconsistent variable naming
- Enable plugins to overload this method
- the changed file might have caused troubles when running it while the
MFDL plugin is active
- Enable reusing parts of the method when multiple types per variable
 are allowed
The way that the nodes (places and transitions) in the petri net
were clustered with the help of SNAKES was wrong. Now, the cluster is not overwritten anymore, but correctly added in the intended way.
This resolves a bug where the deletion of specific nodes resulted in an KeyError in the snakes library.
- Adjust docstrings
- Remove unused attribute 'cluster'
- Add definition for variable type
- Apply changes to tree visitor
- Adjust tests
- Instead of limiting the starting task name to 'productionTask',
it can now be modified by passing the desired name to the Process
Copy link
Collaborator

@OliverStolzBO OliverStolzBO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, I only figured out some minor improvements that could be applied to increase the code quality.

@@ -89,6 +90,10 @@ def draw_clusters(clust, attr):
attr["style"] = DEFAULT_CLUSTER_STYLE


def draw_clusters(clust, attr):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the intention of duplicating the method above, including the same number of attributes? One version should be removed (they are actually doing the same, since DEFAULT_CLUSTER_STYLE is never reassigned). Also, consider renaming clust into _ since it is unused.

@@ -7,6 +7,7 @@
"""Contains the PetriNetGenerator class."""

# standard libraries
import copy
from typing import Any, Callable, Dict, List, OrderedDict, Tuple
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy is used in Line 54 :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I marked the wrong line, this comment refers to the Tuple import in the line below

)
node.cluster.add_node(current_connection_id)
current_connection_uuid = create_transition("connection", "", self.net, node)
# node.cluster.add_child(Cluster(current_connection_uuid))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

)
cluster = Cluster([parallel_loop_started])
node.cluster.add_child(cluster)
# node.cluster.add_child(cluster)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

# self.net.remove_place(self.task_started_id)

if self.net.has_place(place_uuid):
# self.net.clusters._nodes.add(place_uuid)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

@@ -93,6 +94,29 @@ def write_tokens_to_file(token_stream: CommonTokenStream) -> None:
file.write(token_text + "\n")


def extract_content_and_file_path(program):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

program: str
return type: Tuple[str, str]

self.setup_scheduling(draw_petri_net)

# enable logging
# self.attach(LogEntryObserver(self.scheduler_uuid))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still useful?

@@ -20,7 +20,7 @@ Struct CuttingResult
sheet_parts: SheetPart[]
End

Struct TransportOrderStep
Struct TransportOrderStep_Struct
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove the _ in the Struct and Service names here to be consistent with the other test files

@@ -50,14 +50,14 @@ Task cuttingTask
End

Task transport
Transport
Transport_Service
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above

Comment on lines 722 to 723
array = Array("string")
array.length = 10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lines are meaningless and can be removed

Incorporate feedback regarding the quality of the code (fix typos, remove comments/ unused packages, fix naming)
@@ -20,7 +20,7 @@ Struct CuttingResult
sheet_parts: SheetPart[]
End

Struct TransportOrderStep_Struct
Struct TransportOrderStep
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using keywords of other plugins will cause problems there, so the Struct needs to have a different name than TransportOrderStep (same for Transport)

@maxhoerstr maxhoerstr merged commit 74ac2f6 into main Aug 23, 2024
6 checks passed
@maxhoerstr maxhoerstr deleted the refactoring branch August 26, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants