Skip to content

Commit

Permalink
Experimental orchestrator (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r authored Jun 14, 2024
1 parent e4b0d00 commit 2f7ac6a
Show file tree
Hide file tree
Showing 57 changed files with 721 additions and 331 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"mypy-type-checker.importStrategy": "fromEnvironment",
"mypy-type-checker.preferDaemon": true,
"python.analysis.typeCheckingMode": "basic",
"python.languageServer": "Pylance"
"python.languageServer": "Pylance",
"ruff.fixAll": true
}
2 changes: 2 additions & 0 deletions inngest/_internal/client_lib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def create_function(
]
],
],
_experimental_execution: bool = False,
) -> typing.Callable[
[
typing.Union[
Expand Down Expand Up @@ -263,6 +264,7 @@ def decorator(
cancel=cancel,
concurrency=concurrency,
debounce=debounce,
experimental_execution=_experimental_execution,
fully_qualified_id=fully_qualified_fn_id,
local_id=fn_id,
name=name or fn_id,
Expand Down
138 changes: 0 additions & 138 deletions inngest/_internal/execution.py

This file was deleted.

2 changes: 1 addition & 1 deletion inngest/_internal/execution/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CallContext(types.BaseModel):


class CallStack(types.BaseModel):
stack: list[str]
stack: typing.Optional[list[str]] = None


@dataclasses.dataclass
Expand Down
21 changes: 16 additions & 5 deletions inngest/_internal/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class FunctionOpts(types.BaseModel):
cancel: typing.Optional[list[function_config.Cancel]] = None
concurrency: typing.Optional[list[function_config.Concurrency]] = None
debounce: typing.Optional[function_config.Debounce] = None
experimental_execution: bool = False

# Unique within an environment
fully_qualified_id: str
Expand Down Expand Up @@ -119,6 +120,7 @@ def __init__(
list[middleware_lib.UninitializedMiddleware]
] = None,
) -> None:
self._experimental_execution = opts.experimental_execution
self._handler = handler
self._middleware = middleware or []
self._opts = opts
Expand Down Expand Up @@ -157,11 +159,20 @@ async def call(
errors.FunctionNotFoundError("function ID mismatch")
)

orc = orchestrator.OrchestratorV0(
steps,
middleware,
target_hashed_id,
)
orc: orchestrator.BaseOrchestrator
if self._experimental_execution:
orc = orchestrator.OrchestratorExperimental(
steps,
middleware,
call_context.stack.stack or [],
target_hashed_id,
)
else:
orc = orchestrator.OrchestratorV0(
steps,
middleware,
target_hashed_id,
)

call_res = await orc.run(
client,
Expand Down
2 changes: 2 additions & 0 deletions inngest/_internal/orchestrator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from .base import BaseOrchestrator, BaseOrchestratorSync
from .experimental import OrchestratorExperimental
from .v0 import OrchestratorV0, OrchestratorV0Sync

__all__ = [
"BaseOrchestrator",
"BaseOrchestratorSync",
"OrchestratorExperimental",
"OrchestratorV0",
"OrchestratorV0Sync",
]
Loading

0 comments on commit 2f7ac6a

Please sign in to comment.