From c0a2f8dd90189fdb305d2a04c602eae0c17e4fe4 Mon Sep 17 00:00:00 2001 From: Josef Prochazka Date: Fri, 6 Jun 2025 10:34:37 +0200 Subject: [PATCH 1/3] Expose redirect `logger` argument in `Actor.call` TODO: Wait for apify api new release --- src/apify/_actor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/apify/_actor.py b/src/apify/_actor.py index b8fcdc05..11e54665 100644 --- a/src/apify/_actor.py +++ b/src/apify/_actor.py @@ -812,6 +812,7 @@ async def call( timeout: timedelta | None | Literal['RemainingTime'] = None, webhooks: list[Webhook] | None = None, wait: timedelta | None = None, + logger: logging.Logger | None | Literal['default'] = 'default', ) -> ActorRun | None: """Start an Actor on the Apify Platform and wait for it to finish before returning. @@ -834,6 +835,9 @@ async def call( a webhook set up for the Actor, you do not have to add it again here. wait: The maximum number of seconds the server waits for the run to finish. If not provided, waits indefinitely. + logger: Logger used to redirect logs from the Actor run. Using "default" literal means that a predefined + default logger will be used. Setting `None` will disable any log propagation. Passing custom logger + will redirect logs to the provided logger. Returns: Info about the started Actor run. @@ -866,6 +870,7 @@ async def call( timeout_secs=int(actor_call_timeout.total_seconds()) if actor_call_timeout is not None else None, webhooks=serialized_webhooks, wait_secs=int(wait.total_seconds()) if wait is not None else None, + logger=logger, ) return ActorRun.model_validate(api_result) From ccfbcc496aa94b3e08054192b6b736067748e504 Mon Sep 17 00:00:00 2001 From: Josef Prochazka Date: Wed, 18 Jun 2025 11:28:37 +0200 Subject: [PATCH 2/3] Bump the client version that contains the log redirection --- pyproject.toml | 2 +- uv.lock | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c8eede5e..a98a2eb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ keywords = [ "scraping", ] dependencies = [ - "apify-client>=1.9.2", + "apify-client>=1.11.0", "apify-shared>=1.3.0", "crawlee~=0.6.0", "cryptography>=42.0.0", diff --git a/uv.lock b/uv.lock index 51c33935..2e6265d1 100644 --- a/uv.lock +++ b/uv.lock @@ -70,7 +70,7 @@ dev = [ [package.metadata] requires-dist = [ - { name = "apify-client", specifier = ">=1.9.2" }, + { name = "apify-client", specifier = ">=1.11.0" }, { name = "apify-shared", specifier = ">=1.3.0" }, { name = "crawlee", specifier = "~=0.6.0" }, { name = "cryptography", specifier = ">=42.0.0" }, @@ -102,16 +102,17 @@ dev = [ [[package]] name = "apify-client" -version = "1.10.0" +version = "1.11.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "apify-shared" }, + { name = "colorama" }, { name = "httpx" }, { name = "more-itertools" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/c8/e5/88583af493739cc8624a41a3346b26c03851130d5c0c4e7c554cf591e5ca/apify_client-1.10.0.tar.gz", hash = "sha256:be846c466e898f838edffecff7ef07de99a184498bea0245b5709b4fa732415d", size = 340789, upload-time = "2025-04-29T06:49:00.9Z" } +sdist = { url = "https://files.pythonhosted.org/packages/49/44/b7cae857f2129d4093bc5a0a2267fcbba7905207a0b7cc424dc3c7c90291/apify_client-1.11.0.tar.gz", hash = "sha256:c2e151754c35be9bc7c1028bf7cb127aeb1ffa2fbd1ec1ad7e97b901deb32e08", size = 346095, upload-time = "2025-06-13T11:46:39.129Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/76/91/c92aba86e2cd57529b1916cdc452b3955adc3ddc5f29a5d380ef4f1feec8/apify_client-1.10.0-py3-none-any.whl", hash = "sha256:213c515f7dbcbf966351c31e47331e9895b0e9f3aee8ca62473c902431ec37af", size = 77659, upload-time = "2025-04-29T06:48:59.411Z" }, + { url = "https://files.pythonhosted.org/packages/8f/24/d3273bfe5b4a96fd60c8d554edbab99274fae8cb2347b96f2e3fa0bc4d5b/apify_client-1.11.0-py3-none-any.whl", hash = "sha256:9d691960bdbeee17624a2a82aafc4f0bfba9b48820a48f559b7eba76bf01cb3c", size = 82550, upload-time = "2025-06-13T11:46:37.483Z" }, ] [[package]] From e890ae9c72a79a60164cae0c0fc9e2ee3da5afbc Mon Sep 17 00:00:00 2001 From: Josef Prochazka Date: Wed, 18 Jun 2025 13:15:21 +0200 Subject: [PATCH 3/3] Workaround flaky test setup in Python versions > 3.13.3 --- tests/unit/conftest.py | 3 ++- uv.lock | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 6f336cd6..2e574da7 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -38,7 +38,8 @@ def prepare_test_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Callabl """ def _prepare_test_env() -> None: - delattr(apify._actor.Actor, '__wrapped__') + if hasattr(apify._actor.Actor, '__wrapped__'): + delattr(apify._actor.Actor, '__wrapped__') apify._actor._ActorType._is_any_instance_initialized = False # Set the environment variable for the local storage directory to the temporary path. diff --git a/uv.lock b/uv.lock index fe68b40e..ba18b20c 100644 --- a/uv.lock +++ b/uv.lock @@ -32,7 +32,7 @@ wheels = [ [[package]] name = "apify" -version = "2.6.0" +version = "2.6.1" source = { editable = "." } dependencies = [ { name = "apify-client" },