Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handles infrastructure errors before the agent submit a flow #6903

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Avoiding the use of monkeypatch
  • Loading branch information
hallenmaia committed Sep 21, 2022
commit a1c394628e8df3f4fab8c96b3e336116103ae899
10 changes: 2 additions & 8 deletions tests/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,25 +443,19 @@ async def test_agent_submit_run_aborts_without_raising_if_server_raises_abort(
)

async def test_agent_fails_flow_if_get_infrastructure_fails(
self, orion_client, deployment, monkeypatch, mock_infrastructure_run
self, orion_client, deployment, mock_infrastructure_run
):
flow_run = await orion_client.create_flow_run_from_deployment(
deployment.id,
state=Scheduled(scheduled_time=pendulum.now("utc")),
)

async def bad_infrastructure(self, name):
raise ValueError("Bad!")

monkeypatch.setattr(
"prefect.agent.OrionAgent.get_infrastructure", bad_infrastructure
)

async with OrionAgent(
work_queues=[deployment.work_queue_name], prefetch_seconds=10
) as agent:
agent.submitting_flow_run_ids.add(flow_run.id)
agent.logger = MagicMock()
agent.get_infrastructure = AsyncMock(side_effect=ValueError("Bad!"))

await agent.submit_run(flow_run)

Expand Down