Skip to content

Commit 70890e7

Browse files
committed
Review call changes
1 parent 4b5946f commit 70890e7

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

src/apify/_actor.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def apify_client(self) -> ApifyClientAsync:
197197

198198
@property
199199
def configuration(self) -> Configuration:
200-
"""The Configuration instance the Actor instance uses."""
200+
"""The Configuration instance the Actor instance uses. Deprecated."""
201201
return self.config
202202

203203
@property
@@ -225,7 +225,7 @@ def _finalize_implicit_configuration(self) -> Configuration:
225225
)
226226
# Use the configuration from the service locator
227227
self._configuration = Configuration.get_global_configuration()
228-
return self.configuration
228+
return self.config
229229

230230
def _finalize_implicit_local_storage_client(self) -> StorageClient:
231231
"""Set implicit local storage client in the actor and return it.
@@ -304,7 +304,7 @@ async def init(self) -> None:
304304
"""
305305
if self._configuration:
306306
# Set explicitly the configuration in the service locator
307-
service_locator.set_configuration(self.configuration)
307+
service_locator.set_configuration(self.config)
308308
else:
309309
self._finalize_implicit_configuration()
310310

@@ -496,6 +496,7 @@ async def open_dataset(
496496
id=id,
497497
alias=alias,
498498
name=name,
499+
configuration=self.config,
499500
storage_client=storage_client,
500501
)
501502

@@ -533,6 +534,7 @@ async def open_key_value_store(
533534
id=id,
534535
alias=alias,
535536
name=name,
537+
configuration=self.config,
536538
storage_client=storage_client,
537539
)
538540

@@ -573,6 +575,7 @@ async def open_request_queue(
573575
id=id,
574576
alias=alias,
575577
name=name,
578+
configuration=self.config,
576579
storage_client=storage_client,
577580
)
578581

@@ -867,13 +870,13 @@ async def start(
867870

868871
def _get_remaining_time(self) -> timedelta | None:
869872
"""Get time remaining from the actor timeout. Returns `None` if not on an Apify platform."""
870-
if self.is_at_home() and self.configuration.timeout_at:
871-
return self.configuration.timeout_at - datetime.now(tz=timezone.utc)
873+
if self.is_at_home() and self.config.timeout_at:
874+
return self.config.timeout_at - datetime.now(tz=timezone.utc)
872875

873876
self.log.warning(
874877
'Returning `None` instead of remaining time. Using `RemainingTime` argument is only possible when the Actor'
875878
' is running on the Apify platform and when the timeout for the Actor run is set. '
876-
f'{self.is_at_home()=}, {self.configuration.timeout_at=}'
879+
f'{self.is_at_home()=}, {self.config.timeout_at=}'
877880
)
878881
return None
879882

tests/integration/test_actor_call_timeouts.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def main() -> None:
3030

3131
# Start another run of this actor with timeout set to the time remaining in this actor run
3232
other_run_data = await Actor.call(
33-
actor_id=Actor.configuration.actor_id or '',
33+
actor_id=Actor.config.actor_id or '',
3434
run_input={'called_from_another_actor': True},
3535
timeout='RemainingTime',
3636
)
@@ -39,13 +39,13 @@ async def main() -> None:
3939
# To make sure that the actor is started
4040
await asyncio.sleep(5)
4141
assert other_run_data.options is not None
42-
assert Actor.configuration.timeout_at is not None
43-
assert Actor.configuration.started_at is not None
42+
assert Actor.config.timeout_at is not None
43+
assert Actor.config.started_at is not None
4444

45-
remaining_time_after_actor_start = Actor.configuration.timeout_at - datetime.now(tz=timezone.utc)
45+
remaining_time_after_actor_start = Actor.config.timeout_at - datetime.now(tz=timezone.utc)
4646

4747
assert other_run_data.options.timeout > remaining_time_after_actor_start
48-
assert other_run_data.options.timeout < Actor.configuration.timeout_at - Actor.configuration.started_at
48+
assert other_run_data.options.timeout < Actor.config.timeout_at - Actor.config.started_at
4949
finally:
5050
# Make sure the other actor run is aborted
5151
await Actor.apify_client.run(other_run_data.id).abort()
@@ -77,7 +77,7 @@ async def main() -> None:
7777

7878
# Start another run of this actor with timeout set to the time remaining in this actor run
7979
other_run_data = await Actor.call(
80-
actor_id=Actor.configuration.actor_id or '',
80+
actor_id=Actor.config.actor_id or '',
8181
run_input={'called_from_another_actor': True},
8282
timeout='RemainingTime',
8383
)
@@ -88,13 +88,13 @@ async def main() -> None:
8888
await asyncio.sleep(5)
8989

9090
assert other_run_data.options is not None
91-
assert Actor.configuration.timeout_at is not None
92-
assert Actor.configuration.started_at is not None
91+
assert Actor.config.timeout_at is not None
92+
assert Actor.config.started_at is not None
9393

94-
remaining_time_after_actor_start = Actor.configuration.timeout_at - datetime.now(tz=timezone.utc)
94+
remaining_time_after_actor_start = Actor.config.timeout_at - datetime.now(tz=timezone.utc)
9595

9696
assert other_run_data.options.timeout > remaining_time_after_actor_start
97-
assert other_run_data.options.timeout < Actor.configuration.timeout_at - Actor.configuration.started_at
97+
assert other_run_data.options.timeout < Actor.config.timeout_at - Actor.config.started_at
9898
finally:
9999
# Make sure the other actor run is aborted
100100
await Actor.apify_client.run(other_run_data.id).abort()

tests/integration/test_actor_request_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ async def main() -> None:
334334
await rq_1.fetch_next_request()
335335

336336
# Accessed with client created explicitly with `client_key=None` should appear as distinct client
337-
api_client = ApifyClientAsync(token=Actor.configuration.token).request_queue(
337+
api_client = ApifyClientAsync(token=Actor.config.token).request_queue(
338338
request_queue_id=rq_1.id, client_key=None
339339
)
340340
await api_client.list_head()

tests/integration/test_request_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ async def test_rq_isolation(
10381038
async def main() -> None:
10391039
async with Actor:
10401040
# Get the unique actor name for creating unique queue names
1041-
actor_name = Actor.configuration.actor_id
1041+
actor_name = Actor.config.actor_id
10421042

10431043
# Open multiple queues with unique names
10441044
rq1 = await Actor.open_request_queue(name=f'{actor_name}-rq-1')

tests/unit/actor/test_actor_non_default_instance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ async def test_actor_global_works() -> None:
1616
non_default_configuration = Configuration(actor_full_name='Actor McActorson, esq.')
1717

1818
async with Actor(configuration=non_default_configuration):
19-
assert Actor.configuration is non_default_configuration
19+
assert Actor.config is non_default_configuration

0 commit comments

Comments
 (0)