SmartApifyStorageClient
Index
Methods
__init__
Initialize a new instance.
Parameters
optionalkeyword-onlycloud_storage_client: ApifyStorageClient | None = None
Storage client used when an Actor is running on the Apify platform, or when explicitly enabled via the
force_cloud
argument. Defaults toApifyStorageClient
.optionalkeyword-onlylocal_storage_client: StorageClient | None = None
Storage client used when an Actor is not running on the Apify platform and when
force_cloud
flag is not set. Defaults toFileSystemStorageClient
.
Returns None
__str__
Returns str
create_dataset_client
Parameters
optionalkeyword-onlyid: str | None = None
optionalkeyword-onlyname: str | None = None
optionalkeyword-onlyalias: str | None = None
optionalkeyword-onlyconfiguration: CrawleeConfiguration | None = None
Returns DatasetClient
create_kvs_client
Parameters
optionalkeyword-onlyid: str | None = None
optionalkeyword-onlyname: str | None = None
optionalkeyword-onlyalias: str | None = None
optionalkeyword-onlyconfiguration: CrawleeConfiguration | None = None
Returns KeyValueStoreClient
create_rq_client
Parameters
optionalkeyword-onlyid: str | None = None
optionalkeyword-onlyname: str | None = None
optionalkeyword-onlyalias: str | None = None
optionalkeyword-onlyconfiguration: CrawleeConfiguration | None = None
Returns RequestQueueClient
get_storage_client_cache_key
Parameters
configuration: CrawleeConfiguration
Returns Hashable
get_suitable_storage_client
Get a suitable storage client based on the global configuration and the value of the force_cloud flag.
Parameters
optionalkeyword-onlyforce_cloud: bool = False
If True, return
cloud_storage_client
.
Returns StorageClient
Storage client that automatically selects cloud or local storage client based on the environment.
This storage client provides access to datasets, key-value stores, and request queues by intelligently delegating to either the cloud or local storage client based on the execution environment and configuration.
When running on the Apify platform (which is detected via environment variables), this client automatically uses the
cloud_storage_client
to store storage data there. When running locally, it uses thelocal_storage_client
to store storage data there. You can also force cloud storage usage from your local machine by using theforce_cloud
argument.This storage client is designed to work specifically in
Actor
context and provides a seamless development experience where the same code works both locally and on the Apify platform without any changes.