Fix: Unique readable data key errors (#1546)

* feat: export readable data key + dedupe better

* chore: ver
This commit is contained in:
Matt Kaye
2025-04-14 14:45:30 -04:00
committed by GitHub
parent 7190078b8d
commit eee938e326
2 changed files with 28 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
from abc import ABC, abstractmethod
from datetime import datetime
from enum import Enum
from typing import TYPE_CHECKING
from uuid import uuid4
@@ -58,10 +59,13 @@ class Condition(ABC):
class SleepCondition(Condition):
def __init__(self, duration: Duration) -> None:
def __init__(
self, duration: Duration, readable_data_key: str | None = None
) -> None:
super().__init__(
BaseCondition(
readable_data_key=f"sleep:{timedelta_to_expr(duration)}",
readable_data_key=readable_data_key
or f"sleep:{timedelta_to_expr(duration)}",
)
)
@@ -75,10 +79,15 @@ class SleepCondition(Condition):
class UserEventCondition(Condition):
def __init__(self, event_key: str, expression: str | None = None) -> None:
def __init__(
self,
event_key: str,
expression: str | None = None,
readable_data_key: str | None = None,
) -> None:
super().__init__(
BaseCondition(
readable_data_key=event_key,
readable_data_key=readable_data_key or event_key,
expression=expression,
)
)
@@ -95,10 +104,22 @@ class UserEventCondition(Condition):
class ParentCondition(Condition):
def __init__(
self, parent: "Task[TWorkflowInput, R]", expression: str | None = None
self,
parent: "Task[TWorkflowInput, R]",
expression: str | None = None,
readable_data_key: str | None = None,
) -> None:
super().__init__(
BaseCondition(readable_data_key=parent.name, expression=expression)
BaseCondition(
readable_data_key=readable_data_key
or (
parent.name
+ (f":{expression}" if expression else "")
+ ":"
+ datetime.now().isoformat()
),
expression=expression,
)
)
self.parent = parent

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "hatchet-sdk"
version = "1.4.0"
version = "1.4.1"
description = ""
authors = ["Alexander Belanger <alexander@hatchet.run>"]
readme = "README.md"