Skip to content

Environment Variables

⚙️Complete Environment Variables -> Github

Debug Configuration

Environment VariableDescriptionDefault Value
SWANLAB_DEBUGWhether to enable debug mode. When enabled, debug messages are printed in the terminal and mirrored to diagnostic log files.false

Global Configuration

Environment VariableDescriptionDefault Value
SWANLAB_ROOTPath where SwanLab global folder is saved.swanlab folder in the user's home directory
SWANLAB_PUBLICWhether to make experiments public. Accepts true, yes, 1; leave empty for privatePrivate
SWANLAB_LOGDIRPath where SwanLab parsed log files are savedswanlog folder in the current working directory
SWANLAB_MODESwanLab's parsing mode. Available modes: local, online (cloud is an alias), offline, disabled. Case-sensitiveonline
SWANLAB_API_HOSTAPI address for the SwanLab cloud environmenthttps://api.swanlab.cn
SWANLAB_WEB_HOSTWeb address for the SwanLab cloud environment. For private deployment, only this variable needs to be set, no need to set SWANLAB_API_HOSThttps://swanlab.cn

Experiment Configuration

Environment VariableDescription
SWANLAB_PROJ_NAMEProject name, equivalent to swanlab.init(project="...")
SWANLAB_WORKSPACEWorkspace name, equivalent to swanlab.init(workspace="...")
SWANLAB_EXP_NAMEExperiment name, equivalent to swanlab.init(experiment_name="...")
SWANLAB_RUN_IDExperiment run ID, equivalent to swanlab.init(id="...")
SWANLAB_RESUMEWhether to resume training, equivalent to swanlab.init(resume=...), possible values: must, allow, never
SWANLAB_DESCRIPTIONExperiment description, equivalent to swanlab.init(description="...")
SWANLAB_TAGSExperiment tags, equivalent to swanlab.init(tags=[...]). If you want to add multiple tags, write it as SWANLAB_TAGS="tag1,tag2,tag3"
SWANLAB_GROUPExperiment group, used to categorize experiments into different groups for better management and differentiation
SWANLAB_JOB_TYPEExperiment task type, used to identify the current experiment's task type (e.g., classification, regression, etc.)
SWANLAB_EXP_COLORExperiment color, equivalent to swanlab.init(color="..."). Supports preset color names, RGB strings, or hex color codes.
SWANLAB_RUN_PARALLELParallel mode, equivalent to swanlab.init(parallel="..."). Possible value: shared.
SWANLAB_RUN_DIRCustom run directory name. When set, directory conflict retries are skipped and the directory is created directly (default: auto-generated)
SWANLAB_RUN_DIR_MAX_LENGTHMaximum length for the auto-generated run directory name (default: 255)

Login Authentication

Environment VariableDescription
SWANLAB_API_KEYCloud API Key. During login, this environment variable is checked first. If it doesn't exist, the system checks if the user is already logged in. If not, the login process is initiated.
- If a string is passed to the login interface, this environment variable is ignored.
- If the user is already logged in, this environment variable takes precedence over locally stored login information.

Behavior Control

Environment VariableDescription
SWANLAB_DISABLE_GITWhether to disable Git, possible values: True, False. When set to True, Git information will not be recorded.

Others

Environment VariableDescription
SWANLAB_WEBHOOKWebhook address.
When SwanLab initialization is complete, if this environment variable exists, it will be called to send a message.
SWANLAB_WEBHOOK_VALUEThe value passed to the Webhook callback structure.
When SWANLAB_WEBHOOK exists, if this environment variable exists, it will be sent as the value of the Webhook callback structure.
SWANLAB_WEBHOOK_TIMEOUTWebhook request timeout in seconds (default: 5)

Probe Configuration

Control the types of environment information SwanLab collects at startup via the probe parameter (e.g., swanlab.init(probe={"hardware": False})) or the environment variables below. All probe options accept true/false, 1/0, yes/no.

Environment VariableDescriptionDefault Value
SWANLAB_PROBE_HARDWAREWhether to collect static hardware information (GPU model, CPU cores, total memory, etc.)true
SWANLAB_PROBE_RUNTIMEWhether to collect software runtime information (OS, Python version, launch command, etc.)true
SWANLAB_PROBE_REQUIREMENTSWhether to collect Python dependency list (similar to pip freeze)true
SWANLAB_PROBE_CONDAWhether to collect Conda environment configuration, disabled by default to avoid extra startup overheadfalse
SWANLAB_PROBE_GITWhether to collect Git repository information (current branch, latest commit, remote URL)true
SWANLAB_PROBE_SWANLABWhether to collect SwanLab metadata (version, run directory, etc.)true
SWANLAB_PROBE_MONITORWhether to enable periodic hardware monitoring (CPU usage, GPU utilization, memory, etc.)true
SWANLAB_PROBE_MONITOR_INTERVALPeriodic hardware monitoring collection interval (seconds)10
SWANLAB_PROBE_MONITOR_DISK_DIRDisk I/O monitoring reference directory, used to calculate disk usageSystem root directory

Local Dashboard Configuration

Environment VariableDescriptionDefault Value
SWANLAB_DASHBOARD_HOSTHost address for the local SwanLab dashboard server127.0.0.1
SWANLAB_DASHBOARD_PORTPort number for the local SwanLab dashboard server5092

Logging Configuration

Environment VariableDescriptionDefault Value
SWANLAB_LOG_LEVELSwanLab log output level, controls log verbosity. Possible values: debug (most verbose), info (default), warning, error, critical (least verbose)info

Core Behavior

Environment VariableDescriptionDefault Value
SWANLAB_SKIP_SWANBOARD_VERSION_CHECKWhether to skip the swanboard version compatibility check. Set to 1 to skipNot skipped
SWANLAB_FS_TIMEOUTFile system operation timeout (seconds), useful for NAS environments with high async latency5.0
SWANLAB_CORE_SECTION_RULEMetric key segmentation rule, specifies which / to use to split section and metric name: 0=first, 1=second, -1=last0
SWANLAB_CORE_RECORD_BATCHMaximum number of records per HTTP request10000
SWANLAB_TERMINAL_PROXY_TYPETerminal log proxy strategy: all (all), stdout, stderr, none (no collection)all
SWANLAB_TERMINAL_MAX_LENGTHMaximum character length per line for terminal log collection1024

Advanced Configuration

Environment VariableDescriptionDefault Value
SWANLAB_SECRETS_DIRK8s / Docker container Secret configuration file directory, used to inject sensitive information (such as API Key)None
SWANLAB_CONFIG_DIRGlobal configuration file directory path, SwanLab reads *.yaml / *.yml config files from this directory/etc/swanlab