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__(
128128 self ._configure_logging = configure_logging
129129 self ._apify_client = self .new_client ()
130130
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-
135131 # Set the event manager based on whether the Actor is running on the platform or locally.
136132 self ._event_manager = (
137133 ApifyEventManager (
@@ -282,6 +278,10 @@ async def init(self) -> None:
282278 if _ActorType ._is_any_instance_initialized :
283279 self .log .warning ('Repeated Actor initialization detected - this is non-standard usage, proceed with care' )
284280
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+
285285 # Make sure that the currently initialized instance is also available through the global `Actor` proxy
286286 cast ('Proxy' , Actor ).__wrapped__ = self
287287
Original file line number Diff line number Diff line change @@ -445,17 +445,17 @@ def get_configuration(self) -> Configuration:
445445 return self ._configuration
446446
447447 stored_configuration = super ().get_configuration ()
448+ apify_configuration = Configuration ()
448449
449450 # Ensure the returned configuration is of type Apify Configuration.
450451 # 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
459459
460460
461461# Ensure that ApifyServiceLocator is used to make sure Apify Configuration is used.
You can’t perform that action at this time.
0 commit comments