6666_ensure_context = ensure_context ('_active' )
6767
6868
69+ def _warn_max_items_deprecated () -> None :
70+ warnings .warn (
71+ '`max_items` is deprecated and will be removed in version 5.0.0. It works only with legacy pay-per-result '
72+ 'Actors. Use `max_total_charge_usd` instead.' ,
73+ FutureWarning ,
74+ # This helper, the SDK method, and its `ensure_context` wrapper sit between the warning and the caller.
75+ stacklevel = 4 ,
76+ )
77+
78+
6979@docs_name ('Actor' )
7080@docs_group ('Actor' )
7181class _ActorType :
@@ -956,8 +966,8 @@ async def start(
956966 content_type: The content type of the input.
957967 build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
958968 the run uses the build specified in the default run configuration for the Actor (typically latest).
959- max_items: Maximum number of dataset items you are charged for, for pay-per-result Actors. It caps the
960- charge, not the output, so the run can return fewer or more items than this .
969+ max_items: Deprecated, use `max_total_charge_usd` instead. Will be removed in version 5.0.0. Works only with
970+ legacy pay-per-result Actors .
961971 max_total_charge_usd: A limit on the total charged amount, in USD. Once the run exceeds it, the platform
962972 aborts the run, which takes a few seconds, so the final charge can slightly overshoot the limit.
963973 restart_on_error: If true, the Actor run process will be restarted whenever it exits with
@@ -976,6 +986,9 @@ async def start(
976986 Returns:
977987 Info about the started Actor run
978988 """
989+ if max_items is not None :
990+ _warn_max_items_deprecated ()
991+
979992 client = self .new_client (token = token ) if token else self .apify_client
980993
981994 actor_client = client .actor (actor_id )
@@ -1057,8 +1070,9 @@ async def resurrect(
10571070 timeout: New timeout for the resurrected run. By default, the resurrected run uses the same timeout as
10581071 before. Using `inherit` will set timeout of the resurrected run to the time remaining from this Actor
10591072 timeout.
1060- max_items: Maximum number of items that the resurrected pay-per-result run will return. By default, the
1061- resurrected run uses the same limit as before. The limit can only be increased.
1073+ max_items: Deprecated, use `max_total_charge_usd` instead. Will be removed in version 5.0.0. Works only with
1074+ legacy pay-per-result Actors. By default, the resurrected run uses the same limit as before. The limit
1075+ can only be increased.
10621076 max_total_charge_usd: A limit on the total charged amount of the resurrected run, in USD. Once the run
10631077 exceeds it, the platform aborts the run, which takes a few seconds, so the final charge can slightly
10641078 overshoot the limit. By default, the resurrected run uses the same limit as before. The limit can only
@@ -1069,6 +1083,9 @@ async def resurrect(
10691083 Returns:
10701084 Info about the resurrected Actor run.
10711085 """
1086+ if max_items is not None :
1087+ _warn_max_items_deprecated ()
1088+
10721089 client = self .new_client (token = token ) if token else self .apify_client
10731090
10741091 return await client .run (run_id ).resurrect (
@@ -1110,8 +1127,8 @@ async def call(
11101127 content_type: The content type of the input.
11111128 build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
11121129 the run uses the build specified in the default run configuration for the Actor (typically latest).
1113- max_items: Maximum number of dataset items you are charged for, for pay-per-result Actors. It caps the
1114- charge, not the output, so the run can return fewer or more items than this .
1130+ max_items: Deprecated, use `max_total_charge_usd` instead. Will be removed in version 5.0.0. Works only with
1131+ legacy pay-per-result Actors .
11151132 max_total_charge_usd: A limit on the total charged amount, in USD. Once the run exceeds it, the platform
11161133 aborts the run, which takes a few seconds, so the final charge can slightly overshoot the limit.
11171134 restart_on_error: If true, the Actor run process will be restarted whenever it exits with
@@ -1134,6 +1151,9 @@ async def call(
11341151 Returns:
11351152 Info about the started Actor run.
11361153 """
1154+ if max_items is not None :
1155+ _warn_max_items_deprecated ()
1156+
11371157 client = self .new_client (token = token ) if token else self .apify_client
11381158
11391159 actor_client = client .actor (actor_id )
@@ -1186,8 +1206,8 @@ async def start_task(
11861206 token: The Apify API token to use for this request (defaults to the `APIFY_TOKEN` environment variable).
11871207 build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
11881208 the run uses the build specified in the default run configuration for the Actor (typically latest).
1189- max_items: Maximum number of dataset items you are charged for, for pay-per-result Actors. It caps the
1190- charge, not the output, so the run can return fewer or more items than this .
1209+ max_items: Deprecated, use `max_total_charge_usd` instead. Will be removed in version 5.0.0. Works only with
1210+ legacy pay-per-result Actors .
11911211 max_total_charge_usd: A limit on the total charged amount, in USD. Once the run exceeds it, the platform
11921212 aborts the run, which takes a few seconds, so the final charge can slightly overshoot the limit.
11931213 restart_on_error: If true, the Task run process will be restarted whenever it exits with
@@ -1204,6 +1224,9 @@ async def start_task(
12041224 Returns:
12051225 Info about the started Actor run.
12061226 """
1227+ if max_items is not None :
1228+ _warn_max_items_deprecated ()
1229+
12071230 client = self .new_client (token = token ) if token else self .apify_client
12081231 task_client = client .task (task_id )
12091232 return await task_client .start (
@@ -1246,8 +1269,8 @@ async def call_task(
12461269 token: The Apify API token to use for this request (defaults to the `APIFY_TOKEN` environment variable).
12471270 build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
12481271 the run uses the build specified in the default run configuration for the Actor (typically latest).
1249- max_items: Maximum number of dataset items you are charged for, for pay-per-result Actors. It caps the
1250- charge, not the output, so the run can return fewer or more items than this .
1272+ max_items: Deprecated, use `max_total_charge_usd` instead. Will be removed in version 5.0.0. Works only with
1273+ legacy pay-per-result Actors .
12511274 max_total_charge_usd: A limit on the total charged amount, in USD. Once the run exceeds it, the platform
12521275 aborts the run, which takes a few seconds, so the final charge can slightly overshoot the limit.
12531276 restart_on_error: If true, the Task run process will be restarted whenever it exits with
@@ -1265,6 +1288,9 @@ async def call_task(
12651288 Returns:
12661289 Info about the started Actor run.
12671290 """
1291+ if max_items is not None :
1292+ _warn_max_items_deprecated ()
1293+
12681294 client = self .new_client (token = token ) if token else self .apify_client
12691295
12701296 task_client = client .task (task_id )
0 commit comments