Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

dx(backend): deployable entry point for the BatchExecutor (#13340)

Nicholas Tindle62f17155e899
diff --git a/autogpt_platform/backend/backend/batch_executor.py b/autogpt_platform/backend/backend/batch_executor.py
new file mode 100644
index 0000000000..49e2820c13
--- /dev/null
+++ b/autogpt_platform/backend/backend/batch_executor.py
@@ -0,0 +1,19 @@
+from backend.app import run_processes
+from backend.executor.batch_executor import BatchExecutor
+
+
+def main():
+ """
+ Run the BatchExecutor poll loop as a standalone service.
+
+ This is the entry point the infra repo deploys (the loop otherwise
+ only runs inside the all-in-one ``poetry run app`` process, which
+ k8s never uses — services are deployed individually).
+ """
+ run_processes(
+ BatchExecutor(),
+ )
+
+
+if __name__ == "__main__":
+ main()
diff --git a/autogpt_platform/backend/backend/executor/batch_executor_test.py b/autogpt_platform/backend/backend/executor/batch_executor_test.py
index 3512a58c72..4cb76dcb4c 100644
--- a/autogpt_platform/backend/backend/executor/batch_executor_test.py
+++ b/autogpt_platform/backend/backend/executor/batch_executor_test.py
@@ -579,3 +579,21 @@ class TestBackoffMath:
result = _next_poll_at(60)
after = datetime.now(timezone.utc) + timedelta(seconds=60)
assert before + timedelta(seconds=59) <= result <= after + timedelta(seconds=1)
+
+
+def test_standalone_entry_point_runs_only_the_batch_executor():
+ """k8s deploys services individually; the infra repo needs a
+ console script that runs the BatchExecutor on its own (mirrors
+ backend/scheduler.py's shape)."""
+ import backend.batch_executor as entry
+ from backend.executor.batch_executor import BatchExecutor
+
+ assert callable(entry.main)
+ assert entry.BatchExecutor is BatchExecutor
+
+ with patch.object(entry, "run_processes") as run_processes:
+ entry.main()
+
+ run_processes.assert_called_once()
+ (batch_executor,) = run_processes.call_args.args
+ assert isinstance(batch_executor, BatchExecutor)
diff --git a/autogpt_platform/backend/pyproject.toml b/autogpt_platform/backend/pyproject.toml
index acef4cdc6a..d67109b47a 100644
--- a/autogpt_platform/backend/pyproject.toml
+++ b/autogpt_platform/backend/pyproject.toml
@@ -137,6 +137,7 @@ executor = "backend.exec:main"
analytics-setup = "scripts.generate_views:main_setup"
analytics-views = "scripts.generate_views:main_views"
copilot-executor = "backend.copilot.executor.__main__:main"
+batch-executor = "backend.batch_executor:main"
copilot-bot = "backend.copilot.bot.__main__:main"
cli = "backend.cli:main"
format = "scripts.linter:format"