File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -128,10 +128,6 @@ def __init__(
128
128
self ._configure_logging = configure_logging
129
129
self ._apify_client = self .new_client ()
130
130
131
- # Create an instance of the cloud storage client, the local storage client is obtained
132
- # from the service locator.
133
- self ._cloud_storage_client = ApifyStorageClient ()
134
-
135
131
# Set the event manager based on whether the Actor is running on the platform or locally.
136
132
self ._event_manager = (
137
133
ApifyEventManager (
@@ -282,6 +278,10 @@ async def init(self) -> None:
282
278
if _ActorType ._is_any_instance_initialized :
283
279
self .log .warning ('Repeated Actor initialization detected - this is non-standard usage, proceed with care' )
284
280
281
+ # Create an instance of the cloud storage client, the local storage client is obtained
282
+ # from the service locator
283
+ self ._cloud_storage_client = ApifyStorageClient (configuration = self .configuration )
284
+
285
285
# Make sure that the currently initialized instance is also available through the global `Actor` proxy
286
286
cast ('Proxy' , Actor ).__wrapped__ = self
287
287
Original file line number Diff line number Diff line change @@ -445,17 +445,17 @@ def get_configuration(self) -> Configuration:
445
445
return self ._configuration
446
446
447
447
stored_configuration = super ().get_configuration ()
448
+ apify_configuration = Configuration ()
448
449
449
450
# Ensure the returned configuration is of type Apify Configuration.
450
451
# Most likely crawlee configuration was already set. Create Apify configuration from it.
451
- # Env vars will have lower priority than the stored configuration.
452
- model_dump = stored_configuration .model_dump ()
453
- # The configuration will read env variables first and overridden with stored_configuration
454
- _config = Configuration ()
455
- for key in model_dump :
456
- if model_dump [key ]:
457
- setattr (_config , key , model_dump [key ])
458
- return _config
452
+ # Due to known Pydantic issue https://github.com/pydantic/pydantic/issues/9516, creating new instance of
453
+ # Configuration from existing one in situation where environment can have some fields set by alias is very
454
+ # unpredictable. Use the stable workaround.
455
+ for name in stored_configuration .model_fields :
456
+ setattr (apify_configuration , name , getattr (stored_configuration , name ))
457
+
458
+ return apify_configuration
459
459
460
460
461
461
# Ensure that ApifyServiceLocator is used to make sure Apify Configuration is used.
You can’t perform that action at this time.
0 commit comments