Skip to content

Commit

Permalink
Remove batch commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomperez98 committed Jan 6, 2025
1 parent 90d3414 commit 86d3824
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/resonate/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from typing_extensions import Self

from resonate.dataclasses import BatchCommand, DurablePromise
from resonate.dataclasses import DurablePromise
from resonate.options import Options

if TYPE_CHECKING:
Expand Down Expand Up @@ -49,7 +49,7 @@ def to_rfi(self) -> RFI:
@final
@dataclass
class LFC:
unit: Invocation[Any] | BatchCommand
unit: Invocation[Any]
opts: Options = field(default=Options())

def options(
Expand Down Expand Up @@ -86,7 +86,7 @@ def options(self) -> Self:
@final
@dataclass
class LFI:
unit: Invocation[Any] | BatchCommand
unit: Invocation[Any]
opts: Options = field(default=Options())

def options(
Expand Down
22 changes: 5 additions & 17 deletions src/resonate/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RFC,
RFI,
)
from resonate.dataclasses import BatchCommand, DurablePromise, Invocation, RegisteredFn
from resonate.dataclasses import DurablePromise, Invocation, RegisteredFn
from resonate.time import now

if TYPE_CHECKING:
Expand Down Expand Up @@ -133,8 +133,6 @@ def rfi(
) -> RFI:
return self.rfc(func_or_cmd, *args, **kwargs).to_rfi()

@overload
def lfi(self, cmd: BatchCommand, /) -> LFI: ...
@overload
def lfi(
self,
Expand All @@ -161,10 +159,7 @@ def lfi(
) -> LFI: ...
def lfi(
self,
func_or_cmd: DurableCoro[P, T]
| DurableFn[P, T]
| BatchCommand
| RegisteredFn[P, T],
func_or_cmd: DurableCoro[P, T] | DurableFn[P, T] | RegisteredFn[P, T],
/,
*args: P.args,
**kwargs: P.kwargs,
Expand All @@ -180,8 +175,6 @@ def lfi(
"""
return self.lfc(func_or_cmd, *args, **kwargs).to_lfi()

@overload
def lfc(self, func: BatchCommand, /) -> LFC: ...
@overload
def lfc(
self,
Expand All @@ -208,10 +201,7 @@ def lfc(
) -> LFC: ...
def lfc(
self,
func_or_cmd: DurableCoro[P, T]
| DurableFn[P, T]
| BatchCommand
| RegisteredFn[P, T],
func_or_cmd: DurableCoro[P, T] | DurableFn[P, T] | RegisteredFn[P, T],
/,
*args: P.args,
**kwargs: P.kwargs,
Expand All @@ -222,10 +212,8 @@ def lfc(
LFC and await for the result of the execution. It's syntax
sugar for `yield (yield ctx.lfi(...))`
"""
unit: BatchCommand | Invocation[Any]
if isinstance(func_or_cmd, BatchCommand):
unit = func_or_cmd
elif isinstance(func_or_cmd, RegisteredFn):
unit: Invocation[Any]
if isinstance(func_or_cmd, RegisteredFn):
unit = Invocation(func_or_cmd.fn, *args, **kwargs)
else:
unit = Invocation(func_or_cmd, *args, **kwargs)
Expand Down
3 changes: 0 additions & 3 deletions src/resonate/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ def __init__(
self.kwargs = kwargs


class BatchCommand: ...


class DurablePromise:
def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions src/resonate/processor/traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any

from resonate.traits import SubSystem
from resonate.traits import Subsystem

if TYPE_CHECKING:
from resonate.dataclasses import SQE


class IProcessor(SubSystem, ABC):
class IProcessor(Subsystem, ABC):
@abstractmethod
def enqueue(self, sqe: SQE[Any]) -> None: ...
4 changes: 2 additions & 2 deletions src/resonate/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Optional, TypeVar, final

from resonate.cmd_queue import CommandQ, Invoke
from resonate.traits import SubSystem
from resonate.traits import Subsystem

T = TypeVar("T")

Expand All @@ -22,7 +22,7 @@ def _secs_to_ns(secs: float) -> float:


@final
class DelayQueue(SubSystem):
class DelayQueue(Subsystem):
def __init__(self) -> None:
self._inq = Queue[Optional[tuple[Invoke, float]]]()
self._delayed: list[tuple[float, Invoke]] = []
Expand Down
4 changes: 2 additions & 2 deletions src/resonate/task_sources/traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from abc import ABC, abstractmethod
from typing import Any

from resonate.traits import SubSystem
from resonate.traits import Subsystem


class ITaskSource(SubSystem, ABC):
class ITaskSource(Subsystem, ABC):
@abstractmethod
def set_pid(self, pid: str) -> None: ...
@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion src/resonate/traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from resonate.cmd_queue import CommandQ


class SubSystem(ABC):
class Subsystem(ABC):
@abstractmethod
def start(self, cmd_queue: CommandQ) -> None: ...

Expand Down

0 comments on commit 86d3824

Please sign in to comment.