apify 3.4.2b16__tar.gz → 3.4.2b18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. {apify-3.4.2b16 → apify-3.4.2b18}/CHANGELOG.md +6 -0
  2. {apify-3.4.2b16 → apify-3.4.2b18}/PKG-INFO +1 -1
  3. {apify-3.4.2b16 → apify-3.4.2b18}/pyproject.toml +1 -1
  4. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/_actor.py +6 -7
  5. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/_configuration.py +2 -2
  6. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/events/_types.py +2 -3
  7. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/middlewares/apify_proxy.py +4 -7
  8. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_models.py +6 -0
  9. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_request_queue_shared_client.py +3 -3
  10. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_request_queue_single_client.py +3 -3
  11. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_file_system/_storage_client.py +2 -0
  12. {apify-3.4.2b16 → apify-3.4.2b18}/.gitignore +0 -0
  13. {apify-3.4.2b16 → apify-3.4.2b18}/CONTRIBUTING.md +0 -0
  14. {apify-3.4.2b16 → apify-3.4.2b18}/LICENSE +0 -0
  15. {apify-3.4.2b16 → apify-3.4.2b18}/README.md +0 -0
  16. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/__init__.py +0 -0
  17. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/_charging.py +0 -0
  18. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/_consts.py +0 -0
  19. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/_crypto.py +0 -0
  20. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/_proxy_configuration.py +0 -0
  21. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/_utils.py +0 -0
  22. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/_webhook.py +0 -0
  23. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/events/__init__.py +0 -0
  24. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/events/_apify_event_manager.py +0 -0
  25. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/events/py.typed +0 -0
  26. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/log.py +0 -0
  27. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/py.typed +0 -0
  28. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/request_loaders/__init__.py +0 -0
  29. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/request_loaders/_apify_request_list.py +0 -0
  30. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/request_loaders/py.typed +0 -0
  31. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/__init__.py +0 -0
  32. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/_actor_runner.py +0 -0
  33. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/_async_thread.py +0 -0
  34. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/_logging_config.py +0 -0
  35. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/_serialization.py +0 -0
  36. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/extensions/__init__.py +0 -0
  37. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/extensions/_httpcache.py +0 -0
  38. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/middlewares/__init__.py +0 -0
  39. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/middlewares/py.typed +0 -0
  40. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/pipelines/__init__.py +0 -0
  41. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/pipelines/actor_dataset_push.py +0 -0
  42. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/pipelines/py.typed +0 -0
  43. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/py.typed +0 -0
  44. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/requests.py +0 -0
  45. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/scheduler.py +0 -0
  46. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/scrapy/utils.py +0 -0
  47. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/__init__.py +0 -0
  48. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/__init__.py +0 -0
  49. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_alias_resolving.py +0 -0
  50. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_api_client_creation.py +0 -0
  51. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_dataset_client.py +0 -0
  52. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_key_value_store_client.py +0 -0
  53. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_request_queue_client.py +0 -0
  54. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_storage_client.py +0 -0
  55. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/_utils.py +0 -0
  56. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_apify/py.typed +0 -0
  57. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_file_system/__init__.py +0 -0
  58. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_file_system/_dataset_client.py +0 -0
  59. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_file_system/_key_value_store_client.py +0 -0
  60. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_ppe_dataset_mixin.py +0 -0
  61. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_smart_apify/__init__.py +0 -0
  62. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/_smart_apify/_storage_client.py +0 -0
  63. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storage_clients/py.typed +0 -0
  64. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storages/__init__.py +0 -0
  65. {apify-3.4.2b16 → apify-3.4.2b18}/src/apify/storages/py.typed +0 -0
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  <!-- git-cliff-unreleased-start -->
6
6
  ## 3.4.2 - **not yet released**
7
7
 
8
+ ### 🚀 Features
9
+
10
+ - Expose missing platform env vars via Actor.get_env() ([#984](https://github.com/apify/apify-sdk-python/pull/984)) ([f6e9b3b](https://github.com/apify/apify-sdk-python/commit/f6e9b3b328768aefb51257a258c4b6f03980fc72)) by [@vdusek](https://github.com/vdusek)
11
+
8
12
  ### 🐛 Bug Fixes
9
13
 
10
14
  - **scrapy:** Correct proxy middleware exception log and import ([#953](https://github.com/apify/apify-sdk-python/pull/953)) ([5bd6eb9](https://github.com/apify/apify-sdk-python/commit/5bd6eb9843d90844cec083372e932413bceedec9)) by [@vdusek](https://github.com/vdusek)
@@ -18,6 +22,8 @@ All notable changes to this project will be documented in this file.
18
22
  - Accept arbitrary JSON userData in ApifyRequestList ([#966](https://github.com/apify/apify-sdk-python/pull/966)) ([2cfd8a5](https://github.com/apify/apify-sdk-python/commit/2cfd8a590ae52a38b7efe39bb8a3a1570437b2fc)) by [@vdusek](https://github.com/vdusek)
19
23
  - Coerce null stats in Apify request queue metadata ([#974](https://github.com/apify/apify-sdk-python/pull/974)) ([63eb771](https://github.com/apify/apify-sdk-python/commit/63eb771e0234575ae3842cba9441938c3e4116fc)) by [@vdusek](https://github.com/vdusek)
20
24
  - Allow Actor.reboot() to be retried after a failed or cancelled attempt ([#968](https://github.com/apify/apify-sdk-python/pull/968)) ([7d46ec5](https://github.com/apify/apify-sdk-python/commit/7d46ec551252e7137f605e86894511315335f488)) by [@vdusek](https://github.com/vdusek)
25
+ - Correct reclaim_request count adjustment for already-handled requests ([#973](https://github.com/apify/apify-sdk-python/pull/973)) ([86f4cd5](https://github.com/apify/apify-sdk-python/commit/86f4cd53d774e940954faa0b80b7ca5733d74fcf)) by [@vdusek](https://github.com/vdusek)
26
+ - **scrapy:** Drop deprecated spider arg from Scrapy proxy middleware methods ([#977](https://github.com/apify/apify-sdk-python/pull/977)) ([49dd836](https://github.com/apify/apify-sdk-python/commit/49dd836c986b0e3bda4bb6485be8ad95d286cd82)) by [@vdusek](https://github.com/vdusek)
21
27
 
22
28
  ### 🚜 Refactor
23
29
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apify
3
- Version: 3.4.2b16
3
+ Version: 3.4.2b18
4
4
  Summary: Apify SDK for Python
5
5
  Project-URL: Apify Homepage, https://apify.com
6
6
  Project-URL: Changelog, https://docs.apify.com/sdk/python/docs/changelog
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "apify"
7
- version = "3.4.2b16"
7
+ version = "3.4.2b18"
8
8
  description = "Apify SDK for Python"
9
9
  authors = [{ name = "Apify Technologies s.r.o.", email = "support@apify.com" }]
10
10
  license = { file = "LICENSE" }
@@ -118,7 +118,7 @@ class _ActorType:
118
118
  configuration: The Actor configuration to use. If not provided, a default configuration is created.
119
119
  configure_logging: Whether to set up the default logging configuration.
120
120
  exit_process: Whether the Actor should call `sys.exit` when the context manager exits.
121
- Defaults to True, except in IPython, Pytest, and Scrapy environments.
121
+ Defaults to True, except in IPython and Scrapy environments.
122
122
  exit_code: The exit code the Actor should use when exiting.
123
123
  status_message: Final status message to display upon Actor termination.
124
124
  event_listeners_timeout: Maximum time to wait for Actor event listeners to complete before exiting.
@@ -912,7 +912,7 @@ class _ActorType:
912
912
  a non-zero status code.
913
913
  memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
914
914
  in the default run configuration for the Actor.
915
- timeout: Optional timeout for the run, in seconds. By default, the run uses timeout specified in
915
+ timeout: Optional timeout for the run. By default, the run uses timeout specified in
916
916
  the default run configuration for the Actor. Using `inherit` will set timeout of the other Actor
917
917
  to the time remaining from this Actor timeout.
918
918
  force_permission_level: Override the Actor's permissions for this run. If not set, the Actor will run
@@ -1019,7 +1019,7 @@ class _ActorType:
1019
1019
  a non-zero status code.
1020
1020
  memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
1021
1021
  in the default run configuration for the Actor.
1022
- timeout: Optional timeout for the run, in seconds. By default, the run uses timeout specified in
1022
+ timeout: Optional timeout for the run. By default, the run uses timeout specified in
1023
1023
  the default run configuration for the Actor. Using `inherit` will set timeout of the other Actor
1024
1024
  to the time remaining from this Actor timeout.
1025
1025
  force_permission_level: Override the Actor's permissions for this run. If not set, the Actor will run
@@ -1088,17 +1088,16 @@ class _ActorType:
1088
1088
  directly rather than an Actor task, please use the `Actor.call`
1089
1089
 
1090
1090
  Args:
1091
- task_id: The ID of the Actor to be run.
1091
+ task_id: The ID of the Actor task to be run.
1092
1092
  task_input: Overrides the input to pass to the Actor run.
1093
1093
  token: The Apify API token to use for this request (defaults to the `APIFY_TOKEN` environment variable).
1094
- content_type: The content type of the input.
1095
1094
  build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
1096
1095
  the run uses the build specified in the default run configuration for the Actor (typically latest).
1097
1096
  restart_on_error: If true, the Task run process will be restarted whenever it exits with
1098
1097
  a non-zero status code.
1099
1098
  memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
1100
1099
  in the default run configuration for the Actor.
1101
- timeout: Optional timeout for the run, in seconds. By default, the run uses timeout specified in
1100
+ timeout: Optional timeout for the run. By default, the run uses timeout specified in
1102
1101
  the default run configuration for the Actor. Using `inherit` will set timeout of the other Actor to the
1103
1102
  time remaining from this Actor timeout.
1104
1103
  webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can
@@ -1217,7 +1216,7 @@ class _ActorType:
1217
1216
  # Call all the listeners for the PERSIST_STATE and MIGRATING events, and wait for them to finish.
1218
1217
  # PERSIST_STATE listeners are called to allow the Actor to persist its state before the reboot.
1219
1218
  # MIGRATING listeners are called to allow the Actor to gracefully stop in-progress tasks before
1220
- # the reboot. Typically, crawlers are listening for the MIIGRATING event to stop processing new requests.
1219
+ # the reboot. Typically, crawlers are listening for the MIGRATING event to stop processing new requests.
1221
1220
  # We can't just emit the events and wait for all listeners to finish,
1222
1221
  # because this method might be called from an event listener itself, and we would deadlock.
1223
1222
  persist_state_listeners = flatten(
@@ -426,7 +426,7 @@ class Configuration(CrawleeConfiguration):
426
426
  'actor_web_server_port',
427
427
  'apify_container_port',
428
428
  ),
429
- description='TCP port for the Actor to start an HTTP server on'
429
+ description='TCP port for the Actor to start an HTTP server on. '
430
430
  'This server can be used to receive external messages or expose monitoring and control interfaces',
431
431
  ),
432
432
  ] = 4321
@@ -458,7 +458,7 @@ class Configuration(CrawleeConfiguration):
458
458
  | None,
459
459
  Field(
460
460
  alias='apify_actor_pricing_info',
461
- description='JSON string with prising info of the actor',
461
+ description='JSON string with pricing info of the actor',
462
462
  discriminator='pricing_model',
463
463
  ),
464
464
  BeforeValidator(_parse_actor_pricing_info),
@@ -20,9 +20,8 @@ from apify._utils import docs_group
20
20
  ActorEventTypes = Literal['systemInfo', 'persistState', 'migrating', 'aborting']
21
21
  """Event types emitted by the Apify platform during an Actor run.
22
22
 
23
- This is the Apify-specific subset of [`Event`][crawlee.events.Event] for the full set
24
- (including framework-level events like `SESSION_RETIRED` or `BROWSER_LAUNCHED`) use
25
- [`Event`][crawlee.events.Event] from `apify`.
23
+ This is the Apify-specific subset of `Event`. For the full set (including framework-level events
24
+ like `SESSION_RETIRED` or `BROWSER_LAUNCHED`), use `Event` from `apify`.
26
25
  """
27
26
 
28
27
 
@@ -10,7 +10,7 @@ from apify import Actor, ProxyConfiguration
10
10
  from apify.scrapy.utils import get_basic_auth_header
11
11
 
12
12
  if TYPE_CHECKING:
13
- from scrapy import Request, Spider
13
+ from scrapy import Request
14
14
  from scrapy.crawler import Crawler
15
15
 
16
16
 
@@ -63,17 +63,16 @@ class ApifyHttpProxyMiddleware:
63
63
 
64
64
  return cls(proxy_settings)
65
65
 
66
- async def process_request(self, request: Request, spider: Spider) -> None:
66
+ async def process_request(self, request: Request) -> None:
67
67
  """Process a Scrapy request by assigning a new proxy.
68
68
 
69
69
  Args:
70
70
  request: Scrapy Request object.
71
- spider: Scrapy Spider object.
72
71
 
73
72
  Raises:
74
73
  ValueError: If username and password are not provided in the proxy URL.
75
74
  """
76
- Actor.log.debug(f'ApifyHttpProxyMiddleware.process_request: request={request}, spider={spider}')
75
+ Actor.log.debug(f'ApifyHttpProxyMiddleware.process_request: request={request}')
77
76
  url = await self._get_new_proxy_url()
78
77
 
79
78
  if not (url.username and url.password):
@@ -89,14 +88,12 @@ class ApifyHttpProxyMiddleware:
89
88
  self,
90
89
  request: Request,
91
90
  exception: Exception,
92
- spider: Spider,
93
91
  ) -> None:
94
92
  """Process an exception that occurs during request processing.
95
93
 
96
94
  Args:
97
95
  request: Scrapy Request object.
98
96
  exception: Exception object.
99
- spider: Scrapy Spider object.
100
97
 
101
98
  Returns:
102
99
  Returning None, meaning Scrapy will continue processing this exception, executing any other
@@ -104,7 +101,7 @@ class ApifyHttpProxyMiddleware:
104
101
  exception handling kicks in.
105
102
  """
106
103
  Actor.log.debug(
107
- f'ApifyHttpProxyMiddleware.process_exception: request={request}, exception={exception}, spider={spider}',
104
+ f'ApifyHttpProxyMiddleware.process_exception: request={request}, exception={exception}',
108
105
  )
109
106
 
110
107
  if isinstance(exception, TunnelError):
@@ -102,7 +102,13 @@ class CachedRequest(BaseModel):
102
102
  """The expiration time of the lock on the request."""
103
103
 
104
104
 
105
+ @docs_group('Storage data')
105
106
  class ApifyRequestQueueMetadata(RequestQueueMetadata):
107
+ """Extended request queue metadata model for Apify platform.
108
+
109
+ Includes additional Apify-specific fields.
110
+ """
111
+
106
112
  model_config = ConfigDict(alias_generator=to_camel)
107
113
 
108
114
  stats: Annotated[
@@ -262,9 +262,9 @@ class ApifyRequestQueueSharedClient:
262
262
  processed_request = await self._update_request(request, forefront=forefront)
263
263
  processed_request.unique_key = request.unique_key
264
264
 
265
- # If the request was previously handled, decrement our handled count since
266
- # we're putting it back for processing.
267
- if request.was_already_handled and not processed_request.was_already_handled:
265
+ # The platform reports the request's state before this update via `was_already_handled`. If it was
266
+ # handled, this update moved it from handled back to pending, so mirror that in the local metadata.
267
+ if processed_request.was_already_handled:
268
268
  self.metadata.handled_request_count -= 1
269
269
  self.metadata.pending_request_count += 1
270
270
 
@@ -263,9 +263,9 @@ class ApifyRequestQueueSingleClient:
263
263
  processed_request = await self._update_request(request, forefront=forefront)
264
264
  processed_request.id = request_id
265
265
  processed_request.unique_key = request.unique_key
266
- # If the request was previously handled, decrement our handled count since
267
- # we're putting it back for processing.
268
- if request.was_already_handled and not processed_request.was_already_handled:
266
+ # The platform reports the request's state before this update via `was_already_handled`. If it was
267
+ # handled, this update moved it from handled back to pending, so mirror that in the local metadata.
268
+ if processed_request.was_already_handled:
269
269
  self.metadata.handled_request_count -= 1
270
270
  self.metadata.pending_request_count += 1
271
271
 
@@ -9,6 +9,7 @@ from crawlee.storage_clients import FileSystemStorageClient
9
9
 
10
10
  from ._dataset_client import ApifyFileSystemDatasetClient
11
11
  from ._key_value_store_client import ApifyFileSystemKeyValueStoreClient
12
+ from apify._utils import docs_group
12
13
 
13
14
  if TYPE_CHECKING:
14
15
  from collections.abc import Hashable
@@ -16,6 +17,7 @@ if TYPE_CHECKING:
16
17
  from crawlee.storage_clients._file_system import FileSystemKeyValueStoreClient
17
18
 
18
19
 
20
+ @docs_group('Storage clients')
19
21
  class ApifyFileSystemStorageClient(FileSystemStorageClient):
20
22
  """Apify-specific implementation of the file system storage client.
21
23
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes