Skip to content

feat: add maxItems and maxTotalChargeUsd to resurrect #360

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

Merged
merged 3 commits into from
Mar 10, 2025
Merged
Changes from all commits
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
21 changes: 20 additions & 1 deletion src/apify_client/clients/resource_clients/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import random
import string
import time
from typing import Any
from typing import TYPE_CHECKING, Any

from apify_shared.utils import filter_out_none_values_recursively, ignore_docs, parse_date_fields

Expand All @@ -15,6 +15,9 @@
from apify_client.clients.resource_clients.log import LogClient, LogClientAsync
from apify_client.clients.resource_clients.request_queue import RequestQueueClient, RequestQueueClientAsync

if TYPE_CHECKING:
from decimal import Decimal


class RunClient(ActorJobBaseClient):
"""Sub-client for manipulating a single Actor run."""
Expand Down Expand Up @@ -132,6 +135,8 @@ def resurrect(
build: str | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
max_items: int | None = None,
max_total_charge_usd: Decimal | None = None,
) -> dict:
"""Resurrect a finished Actor run.

Expand All @@ -147,6 +152,10 @@ def resurrect(
uses the same memory limit as before.
timeout_secs: New timeout for the resurrected run, in seconds. By default, the resurrected run uses the
same timeout as before.
max_items: Maximum number of items that the resurrected pay-per-result run will return. By default, the
resurrected run uses the same limit as before. Limit can be only increased.
max_total_charge_usd: Maximum cost for the resurrected pay-per-event run in USD. By default, the
resurrected run uses the same limit as before. Limit can be only increased.

Returns:
The Actor run data.
Expand All @@ -155,6 +164,8 @@ def resurrect(
build=build,
memory=memory_mbytes,
timeout=timeout_secs,
maxItems=max_items,
maxTotalChargeUsd=max_total_charge_usd,
)

response = self.http_client.call(
Expand Down Expand Up @@ -385,6 +396,8 @@ async def resurrect(
build: str | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
max_items: int | None = None,
max_total_charge_usd: Decimal | None = None,
) -> dict:
"""Resurrect a finished Actor run.

Expand All @@ -400,6 +413,10 @@ async def resurrect(
uses the same memory limit as before.
timeout_secs: New timeout for the resurrected run, in seconds. By default, the resurrected run uses the
same timeout as before.
max_items: Maximum number of items that the resurrected pay-per-result run will return. By default, the
resurrected run uses the same limit as before. Limit can be only increased.
max_total_charge_usd: Maximum cost for the resurrected pay-per-event run in USD. By default, the
resurrected run uses the same limit as before. Limit can be only increased.

Returns:
The Actor run data.
Expand All @@ -408,6 +425,8 @@ async def resurrect(
build=build,
memory=memory_mbytes,
timeout=timeout_secs,
maxItems=max_items,
maxTotalChargeUsd=max_total_charge_usd,
)

response = await self.http_client.call(
Expand Down