From 49ad8887d4840f36eb9a1865a842b3d9fde091c8 Mon Sep 17 00:00:00 2001 From: Maximilian Hoerstrup Date: Tue, 21 Nov 2023 11:45:30 +0100 Subject: [PATCH] Create UUIDs for counting loops and add hashing UUIDs are now created when a CountingLoop object is created. The __hash__ function is implemented, so that the uuid is used as the unique hash. --- pfdl_scheduler/model/counting_loop.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pfdl_scheduler/model/counting_loop.py b/pfdl_scheduler/model/counting_loop.py index 9b8cd1b..79c531a 100644 --- a/pfdl_scheduler/model/counting_loop.py +++ b/pfdl_scheduler/model/counting_loop.py @@ -9,6 +9,8 @@ # standard libraries from dataclasses import dataclass from typing import List, Union +import uuid +import hashlib # 3rd party libraries from antlr4.ParserRuleContext import ParserRuleContext @@ -58,3 +60,7 @@ def __init__( self.counting_variable: str = counting_variable self.limit: str = limit self.parallel: bool = parallel + self.uuid = str(uuid.uuid4()) + + def __hash__(self) -> int: + return int(uuid.UUID(self.uuid))