The Ethopy Analysis package uses a unified configuration system for database connections and analysis settings. Configuration is optional - the package works with defaults.
If EthoPy is installed on your machine, ethopy-analysis automatically reads your existing
~/.ethopy/local_conf.json. No extra configuration is required — just run your analysis.
~/.ethopy/local_conf.json ← detected and used automatically
To verify it was picked up correctly:
ethopy-analysis config-summary# Copy template and add your credentials
cp dj_conf.template.json dj_conf.json
# Edit dj_conf.json with your database detailsexport DJ_HOST="database.example.org:3306"
export DJ_USER="your_username"
export DJ_PASSWORD="your_password"ethopy-analysis create-config --output-path config.jsonThe system searches for a configuration file in this priority order and uses the first one found:
| Priority | Location | File(s) |
|---|---|---|
| 1 | Current directory | ethopy_config.json, config.json, dj_conf.json |
| 2 | ./config/ subdirectory |
ethopy_config.json, config.json, dj_conf.json |
| 3 | ~/.ethopy/ |
ethopy_config.json, config.json, dj_conf.json |
| 4 | Package directory | ethopy_config.json, config.json, dj_conf.json |
| 5 (fallback) | ~/.ethopy/ |
local_conf.json (EthoPy format, auto-converted) |
Environment variables (DJ_HOST, DJ_USER, DJ_PASSWORD) are applied after the file is
loaded and always override file values.
Used by Methods 2–4 above.
{
"database": {
"host": "your-database-host:3306",
"user": "your_username",
"password": "your_password",
"schemas": {
"experiment": "lab_experiments",
"stimulus": "lab_stimuli",
"behavior": "lab_behavior"
}
},
"paths": {
"data_dir": "./data",
"output_dir": "./output"
}
}If ~/.ethopy/local_conf.json is the only config found, it is automatically converted.
The relevant fields that are read are:
{
"dj_local_conf": {
"database.host": "your-database-host",
"database.user": "your_username",
"database.password": "your_password",
"database.port": 3306
},
"SCHEMATA": {
"experiment": "lab_experiments",
"behavior": "lab_behavior",
"stimulus": "lab_stimuli"
}
}All other fields in local_conf.json (e.g. source_path, Channels, logging) are ignored.
If SCHEMATA is absent, default schema names are used.
host: Database host and port (e.g."database.example.org:3306")user: Database usernamepassword: Database passwordschemas: Schema name mappings
{
"schemas": {
"experiment": "lab_experiments",
"stimulus": "lab_stimuli",
"behavior": "lab_behavior"
}
}Environment variables are applied after the config file and override any file values:
export DJ_HOST="database.example.org:3306"
export DJ_USER="your_username"
export DJ_PASSWORD="your_password"
export ETHOPY_OUTPUT_DIR="/path/to/output"export DJ_HOST="database.example.org:3306"
export DJ_USER="your_username"
export DJ_PASSWORD="your_secure_password"The recommended file name is ethopy_config.json (highest priority in the search order).
All *.json files are in .gitignore, so credentials are never accidentally committed.
# create your local config — it will never be committed
cp dj_conf.template.json ethopy_config.json
# edit ethopy_config.json and add your credentialsdj_conf.json and config.json are also supported and equally git-safe.
- All
.jsonfiles are excluded by.gitignore - Use environment variables for CI/CD pipelines
- If you use EthoPy,
~/.ethopy/local_conf.jsonis already outside the repo
ethopy-analysis test-db-connectionethopy-analysis config-summaryfrom ethopy_analysis.config.settings import load_config
# Load specific file
config = load_config("my_config.json")- Run
ethopy-analysis config-summaryto see which file (if any) was loaded - Check that the file is named exactly
ethopy_config.json,config.json, ordj_conf.json - Use an absolute path to force a specific file:
load_config("/full/path/to/config.json")
- Confirm the file exists at
~/.ethopy/local_conf.json - Check it contains a
dj_local_confkey — that is how the format is detected - If a higher-priority config file exists (e.g.
dj_conf.jsonin the current directory), it takes precedence
- Verify
hostis inhost:portformat (e.g."db.lab.org:3306") - Check credentials with
ethopy-analysis test-db-connection - Confirm the schema names match your database
The package works without configuration:
- Database: Uses environment variables or prompts
- Paths: Uses current directory
- Analysis: Uses reasonable defaults
Configure only what you need to customize!