mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-05 04:15:08 -05:00
This is a follow-up of https://github.com/Significant-Gravitas/AutoGPT/pull/8752 There are several APIs and functions related to graph execution that are unused now. There is also confusion about the name of `GraphExecution` that exists in graph.py & execution.py. ### Changes 🏗️ * Renamed `GraphExecution` in `execution.py` to `GraphExecutionEntry`, this is only used as a queue entry for execution. * Removed unused `get_graph_execution` & `list_executions` in `execution.py`. * Removed `with_run` option on `get_graph` function in `graph.py`. * Removed `GraphMetaWithRuns` * Removed exposed functions only for testing. * Removed `executions` fields in Graph model. ### Checklist 📋 #### For code changes: - [ ] I have clearly listed my changes in the PR description - [ ] I have made a test plan - [ ] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [ ] ... <details> <summary>Example test plan</summary> - [ ] Create from scratch and execute an agent with at least 3 blocks - [ ] Import an agent from file upload, and confirm it executes correctly - [ ] Upload agent to marketplace - [ ] Import an agent from marketplace and confirm it executes correctly - [ ] Edit an agent from monitor, and confirm it executes correctly </details> #### For configuration changes: - [ ] `.env.example` is updated or already compatible with my changes - [ ] `docker-compose.yml` is updated or already compatible with my changes - [ ] I have included a list of my configuration changes in the PR description (under **Changes**) <details> <summary>Examples of configuration changes</summary> - Changing ports - Adding new services that need to communicate with each other - Secrets or environment variable changes - New or infrastructure changes such as databases </details> --------- Co-authored-by: Krzysztof Czerwinski <34861343+kcze@users.noreply.github.com>
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
import pytest
|
|
|
|
from backend.data import db
|
|
from backend.executor import ExecutionScheduler
|
|
from backend.server.model import CreateGraph
|
|
from backend.usecases.sample import create_test_graph, create_test_user
|
|
from backend.util.service import get_service_client
|
|
from backend.util.test import SpinTestServer
|
|
|
|
|
|
@pytest.mark.asyncio(scope="session")
|
|
async def test_agent_schedule(server: SpinTestServer):
|
|
await db.connect()
|
|
test_user = await create_test_user()
|
|
test_graph = await server.agent_server.test_create_graph(
|
|
create_graph=CreateGraph(graph=create_test_graph()),
|
|
user_id=test_user.id,
|
|
)
|
|
|
|
scheduler = get_service_client(ExecutionScheduler)
|
|
schedules = scheduler.get_execution_schedules(test_graph.id, test_user.id)
|
|
assert len(schedules) == 0
|
|
|
|
schedule = scheduler.add_execution_schedule(
|
|
graph_id=test_graph.id,
|
|
user_id=test_user.id,
|
|
graph_version=1,
|
|
cron="0 0 * * *",
|
|
input_data={"input": "data"},
|
|
)
|
|
assert schedule
|
|
|
|
schedules = scheduler.get_execution_schedules(test_graph.id, test_user.id)
|
|
assert len(schedules) == 1
|
|
assert schedules[0].cron == "0 0 * * *"
|
|
|
|
scheduler.delete_schedule(schedule.id, user_id=test_user.id)
|
|
schedules = scheduler.get_execution_schedules(test_graph.id, user_id=test_user.id)
|
|
assert len(schedules) == 0
|