Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
22 changes: 19 additions & 3 deletions src/apify_client/clients/resource_clients/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def get_actor_representation(
'seoTitle': seo_title,
'seoDescription': seo_description,
'versions': versions,
'restartOnError': restart_on_error,
'isPublic': is_public,
'isDeprecated': is_deprecated,
'isAnonymouslyRunnable': is_anonymously_runnable,
Expand All @@ -79,6 +78,7 @@ def get_actor_representation(
'maxItems': default_run_max_items,
'memoryMbytes': default_run_memory_mbytes,
'timeoutSecs': default_run_timeout_secs,
'restartOnError': restart_on_error,
'forcePermissionLevel': default_run_force_permission_level,
},
'exampleRunInput': {
Expand Down Expand Up @@ -153,7 +153,7 @@ def update(
seo_title: The title of the Actor optimized for search engines.
seo_description: The description of the Actor optimized for search engines.
versions: The list of Actor versions.
restart_on_error: If true, the main Actor run process will be restarted whenever it exits with
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
a non-zero status code.
is_public: Whether the Actor is public.
is_deprecated: Whether the Actor is deprecated.
Expand Down Expand Up @@ -224,6 +224,7 @@ def start(
build: str | None = None,
max_items: int | None = None,
max_total_charge_usd: Decimal | None = None,
restart_on_error: bool | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
force_permission_level: ActorPermissionLevel | None = None,
Expand All @@ -242,6 +243,8 @@ def start(
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
per result, you will not be charged for more results than the given limit.
max_total_charge_usd: A limit on the total charged amount for pay-per-event actors.
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
a non-zero status code.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit
specified in the default run configuration for the Actor.
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
Expand All @@ -267,6 +270,7 @@ def start(
build=build,
maxItems=max_items,
maxTotalChargeUsd=max_total_charge_usd,
restartOnError=restart_on_error,
memory=memory_mbytes,
timeout=timeout_secs,
waitForFinish=wait_for_finish,
Expand All @@ -292,6 +296,7 @@ def call(
build: str | None = None,
max_items: int | None = None,
max_total_charge_usd: Decimal | None = None,
restart_on_error: bool | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
webhooks: list[dict] | None = None,
Expand All @@ -313,6 +318,8 @@ def call(
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
per result, you will not be charged for more results than the given limit.
max_total_charge_usd: A limit on the total charged amount for pay-per-event actors.
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
a non-zero status code.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit
specified in the default run configuration for the Actor.
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
Expand All @@ -338,6 +345,7 @@ def call(
build=build,
max_items=max_items,
max_total_charge_usd=max_total_charge_usd,
restart_on_error=restart_on_error,
memory_mbytes=memory_mbytes,
timeout_secs=timeout_secs,
webhooks=webhooks,
Expand Down Expand Up @@ -565,7 +573,7 @@ async def update(
seo_title: The title of the Actor optimized for search engines.
seo_description: The description of the Actor optimized for search engines.
versions: The list of Actor versions.
restart_on_error: If true, the main Actor run process will be restarted whenever it exits with
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
a non-zero status code.
is_public: Whether the Actor is public.
is_deprecated: Whether the Actor is deprecated.
Expand Down Expand Up @@ -636,6 +644,7 @@ async def start(
build: str | None = None,
max_items: int | None = None,
max_total_charge_usd: Decimal | None = None,
restart_on_error: bool | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
force_permission_level: ActorPermissionLevel | None = None,
Expand All @@ -654,6 +663,8 @@ async def start(
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
per result, you will not be charged for more results than the given limit.
max_total_charge_usd: A limit on the total charged amount for pay-per-event actors.
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
a non-zero status code.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit
specified in the default run configuration for the Actor.
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
Expand All @@ -679,6 +690,7 @@ async def start(
build=build,
maxItems=max_items,
maxTotalChargeUsd=max_total_charge_usd,
restartOnError=restart_on_error,
memory=memory_mbytes,
timeout=timeout_secs,
waitForFinish=wait_for_finish,
Expand All @@ -704,6 +716,7 @@ async def call(
build: str | None = None,
max_items: int | None = None,
max_total_charge_usd: Decimal | None = None,
restart_on_error: bool | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
webhooks: list[dict] | None = None,
Expand All @@ -725,6 +738,8 @@ async def call(
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
per result, you will not be charged for more results than the given limit.
max_total_charge_usd: A limit on the total charged amount for pay-per-event actors.
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
a non-zero status code.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit
specified in the default run configuration for the Actor.
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
Expand All @@ -750,6 +765,7 @@ async def call(
build=build,
max_items=max_items,
max_total_charge_usd=max_total_charge_usd,
restart_on_error=restart_on_error,
memory_mbytes=memory_mbytes,
timeout_secs=timeout_secs,
webhooks=webhooks,
Expand Down
4 changes: 2 additions & 2 deletions src/apify_client/clients/resource_clients/actor_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def create(
seo_title: The title of the Actor optimized for search engines.
seo_description: The description of the Actor optimized for search engines.
versions: The list of Actor versions.
restart_on_error: If true, the main Actor run process will be restarted whenever it exits with
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
a non-zero status code.
is_public: Whether the Actor is public.
is_deprecated: Whether the Actor is deprecated.
Expand Down Expand Up @@ -205,7 +205,7 @@ async def create(
seo_title: The title of the Actor optimized for search engines.
seo_description: The description of the Actor optimized for search engines.
versions: The list of Actor versions.
restart_on_error: If true, the main Actor run process will be restarted whenever it exits with
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
a non-zero status code.
is_public: Whether the Actor is public.
is_deprecated: Whether the Actor is deprecated.
Expand Down
8 changes: 8 additions & 0 deletions src/apify_client/clients/resource_clients/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def resurrect(
timeout_secs: int | None = None,
max_items: int | None = None,
max_total_charge_usd: Decimal | None = None,
restart_on_error: bool | None = None,
) -> dict:
"""Resurrect a finished Actor run.

Expand All @@ -181,6 +182,8 @@ def resurrect(
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.
restart_on_error: Determines whether the resurrected run will be restarted if it fails.
By default, the resurrected run uses the same setting as before.

Returns:
The Actor run data.
Expand All @@ -191,6 +194,7 @@ def resurrect(
timeout=timeout_secs,
maxItems=max_items,
maxTotalChargeUsd=max_total_charge_usd,
restartOnError=restart_on_error,
)

response = self.http_client.call(
Expand Down Expand Up @@ -483,6 +487,7 @@ async def resurrect(
timeout_secs: int | None = None,
max_items: int | None = None,
max_total_charge_usd: Decimal | None = None,
restart_on_error: bool | None = None,
) -> dict:
"""Resurrect a finished Actor run.

Expand All @@ -502,6 +507,8 @@ async def resurrect(
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.
restart_on_error: Determines whether the resurrected run will be restarted if it fails.
By default, the resurrected run uses the same setting as before.

Returns:
The Actor run data.
Expand All @@ -512,6 +519,7 @@ async def resurrect(
timeout=timeout_secs,
maxItems=max_items,
maxTotalChargeUsd=max_total_charge_usd,
restartOnError=restart_on_error,
)

response = await self.http_client.call(
Expand Down
26 changes: 26 additions & 0 deletions src/apify_client/clients/resource_clients/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def get_task_representation(
max_items: int | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
restart_on_error: bool | None = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: @janbuchar, is this a breaking change (changing the order of the parameters) ? I'm not sure about the exact intricacies of the Python argument ordering.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, technically it is. But:

  1. Nobody in their right mind would call this with positional (non-keyword) arguments. In fact, the entire signature of the function should probably be keyword-only, but that's breaking
  2. While it is not de facto private, it probably should be

That considered, is it a problem to just move the parameter down?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wasn't specific enough and didn't choose the best example. Similar changes are present throughout this and other files in public function. Please, see the last commit.

See for instance start. Same question there.

The positioning can be changed, but I would rather keep it near other similar options.
What do you think ? In other languages, it would definitely be a BC, but I'm not sure about the Python.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image If the signature has this, any parameters behind the asterisk can go in any order, no BC break. What the thing means is "everything after the asterisk must be passed with a keyword (`foo(..., bar=42)`)", so the order doesn't matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if there's no asterisk in the list of args, I'd just add a new argument at the end, just to be safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Only such occurrence was in get_task_representation in the task.py.
Moved to the end of args list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im getting FBT001 Boolean-typed positional argument in function definition linting error.
Would adding asterix in the list help?

def get_task_representation(
    actor_id: str | None = None,
    name: str | None = None,
    task_input: dict | None = None,
    build: str | None = None,
    max_items: int | None = None,
    memory_mbytes: int | None = None,
    timeout_secs: int | None = None,
    title: str | None = None,
    actor_standby_desired_requests_per_actor_run: int | None = None,
    actor_standby_max_requests_per_actor_run: int | None = None,
    actor_standby_idle_timeout_secs: int | None = None,
    actor_standby_build: str | None = None,
    actor_standby_memory_mbytes: int | None = None,
    *,
    restart_on_error: bool | None = None,
) -> dict:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Asterix should be able to help. The lint rule exists because free-floating boolean arguments are confusing (foo(True, True, False, True)).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

title: str | None = None,
actor_standby_desired_requests_per_actor_run: int | None = None,
actor_standby_max_requests_per_actor_run: int | None = None,
Expand All @@ -48,6 +49,7 @@ def get_task_representation(
'maxItems': max_items,
'memoryMbytes': memory_mbytes,
'timeoutSecs': timeout_secs,
'restartOnError': restart_on_error,
},
'input': task_input,
'title': title,
Expand Down Expand Up @@ -87,6 +89,7 @@ def update(
max_items: int | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
restart_on_error: bool | None = None,
title: str | None = None,
actor_standby_desired_requests_per_actor_run: int | None = None,
actor_standby_max_requests_per_actor_run: int | None = None,
Expand All @@ -109,6 +112,8 @@ def update(
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
in the task settings.
task_input: Task input dictionary.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
title: A human-friendly equivalent of the name.
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
a single Actor Standby run.
Expand All @@ -129,6 +134,7 @@ def update(
max_items=max_items,
memory_mbytes=memory_mbytes,
timeout_secs=timeout_secs,
restart_on_error=restart_on_error,
title=title,
actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
Expand All @@ -154,6 +160,7 @@ def start(
max_items: int | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
restart_on_error: bool | None = None,
wait_for_finish: int | None = None,
webhooks: list[dict] | None = None,
) -> dict:
Expand All @@ -171,6 +178,8 @@ def start(
in the task settings.
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
it is 0, the maximum value is 60.
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
Expand All @@ -189,6 +198,7 @@ def start(
maxItems=max_items,
memory=memory_mbytes,
timeout=timeout_secs,
restartOnError=restart_on_error,
waitForFinish=wait_for_finish,
webhooks=encode_webhook_list_to_base64(webhooks) if webhooks is not None else None,
)
Expand All @@ -211,6 +221,7 @@ def call(
max_items: int | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
restart_on_error: bool | None = None,
webhooks: list[dict] | None = None,
wait_secs: int | None = None,
) -> dict | None:
Expand All @@ -230,6 +241,8 @@ def call(
in the task settings.
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive
a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for
the Actor or task, you do not have to add it again here.
Expand All @@ -245,6 +258,7 @@ def call(
max_items=max_items,
memory_mbytes=memory_mbytes,
timeout_secs=timeout_secs,
restart_on_error=restart_on_error,
webhooks=webhooks,
)

Expand Down Expand Up @@ -343,6 +357,7 @@ async def update(
max_items: int | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
restart_on_error: bool | None = None,
title: str | None = None,
actor_standby_desired_requests_per_actor_run: int | None = None,
actor_standby_max_requests_per_actor_run: int | None = None,
Expand All @@ -364,6 +379,8 @@ async def update(
in the task settings.
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
task_input: Task input dictionary.
title: A human-friendly equivalent of the name.
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
Expand All @@ -385,6 +402,7 @@ async def update(
max_items=max_items,
memory_mbytes=memory_mbytes,
timeout_secs=timeout_secs,
restart_on_error=restart_on_error,
title=title,
actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
Expand All @@ -410,6 +428,7 @@ async def start(
max_items: int | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
restart_on_error: bool | None = None,
wait_for_finish: int | None = None,
webhooks: list[dict] | None = None,
) -> dict:
Expand All @@ -427,6 +446,8 @@ async def start(
in the task settings.
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
it is 0, the maximum value is 60.
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
Expand All @@ -445,6 +466,7 @@ async def start(
maxItems=max_items,
memory=memory_mbytes,
timeout=timeout_secs,
restartOnError=restart_on_error,
waitForFinish=wait_for_finish,
webhooks=encode_webhook_list_to_base64(webhooks) if webhooks is not None else None,
)
Expand All @@ -467,6 +489,7 @@ async def call(
max_items: int | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
restart_on_error: bool | None = None,
webhooks: list[dict] | None = None,
wait_secs: int | None = None,
) -> dict | None:
Expand All @@ -486,6 +509,8 @@ async def call(
in the task settings.
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive
a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for
the Actor or task, you do not have to add it again here.
Expand All @@ -501,6 +526,7 @@ async def call(
max_items=max_items,
memory_mbytes=memory_mbytes,
timeout_secs=timeout_secs,
restart_on_error=restart_on_error,
webhooks=webhooks,
)

Expand Down
Loading
Loading