Skip to main content

Configuration

A class for specifying the configuration of an actor.

Can be used either globally via Configuration.get_global_configuration(), or it can be specific to each Actor instance on the actor.config property.

Index

Constructors

__init__

  • __init__(api_base_url, api_public_base_url, container_port, container_url, default_dataset_id, default_key_value_store_id, default_request_queue_id, input_key, max_used_cpu_ratio, metamorph_after_sleep_millis, persist_state_interval_millis, persist_storage, proxy_hostname, proxy_password, proxy_port, proxy_status_url, purge_on_start, token, system_info_interval_millis): None
  • Create a Configuration instance.

    All the parameters are loaded by default from environment variables when running on the Apify platform. You can override them here in the Configuration constructor, which might be useful for local testing of your actors.


    Parameters

    • optionalapi_base_url: str

      The URL of the Apify API. This is the URL actually used for connecting to the API, so it can contain an IP address when running in a container on the platform.

    • optionalapi_public_base_url: str

      The public URL of the Apify API. This will always contain the public URL of the API, even when running in a container on the platform. Useful for generating shareable URLs to key-value store records or datasets.

    • optionalcontainer_port: int

      The port on which the container can listen for HTTP requests.

    • optionalcontainer_url: str

      The URL on which the container can listen for HTTP requests.

    • optionaldefault_dataset_id: str

      The ID of the default dataset for the actor.

    • optionaldefault_key_value_store_id: str

      The ID of the default key-value store for the actor.

    • optionaldefault_request_queue_id: str

      The ID of the default request queue for the actor.

    • optionalinput_key: str

      The key of the input record in the actor’s default key-value store

    • optionalmax_used_cpu_ratio: float

      The CPU usage above which the SYSTEM_INFO event will report the CPU is overloaded.

    • optionalmetamorph_after_sleep_millis: int

      How long should the actor sleep after calling metamorph.

    • optionalpersist_state_interval_millis: int

      How often should the actor emit the PERSIST_STATE event.

    • optionalpersist_storage: bool

      Whether the actor should persist its used storages to the filesystem when running locally.

    • optionalproxy_hostname: str

      The hostname of Apify Proxy.

    • optionalproxy_password: str

      The password for Apify Proxy.

    • optionalproxy_port: int

      The port of Apify Proxy.

    • optionalproxy_status_url: str

      The URL on which the Apify Proxy status page is available.

    • optionalpurge_on_start: bool

      Whether the actor should purge its default storages on startup, when running locally.

    • optionaltoken: str

      The API token for the Apify API this actor should use.

    • optionalsystem_info_interval_millis: int

      How often should the actor emit the SYSTEM_INFO event when running locally.

    Returns None

Methods

get_global_configuration

  • get_global_configuration(): 'Configuration'
  • Retrive the global configuration.

    The global configuration applies when you call actor methods via their static versions, e.g. Actor.init(). Also accessible via Actor.config.


    Returns 'Configuration'