Data Management#
Where is my data saved?#
You can find the current project data directory with the command projects.dir
. Everything is stored in this folder or a subdirectory. Similarly, you can find the logs directory with the command projects.logs_dir
. Brightway uses a Python library to select an appropriate, platform-specific path, namely:
C:\Documents and Settings\<User>\Application Data\Local Settings\pylca\Brightway3
/Users/<User>/Library/Application Support/Brightway3
/home/<User>/.local/share/Brightway3
How do I change my data directory?#
You can specify a custom data directory path by setting the environment variable BRIGHTWAY2_DIR
. Brightway will raise an OSError
if this is not a writable directory.
Warning
This is not recommended for use by beginners, but if you have multiple or non-standard installations of Brightway it might be useful.
To change the storage location of Brightway data to a directory of your choice, set an environment variable in the default shell of your Unix system.
Note
Replace <PATH>
with your desired absolute directory path and restart the shell.
echo 'export BRIGHTWAY2_DIR=<PATH>' >> ~/.zshenv
To change the storage location of Brightway data to a directory of your choice, set an environment variable using the Windows Power Shell.
Note
Replace <PATH>
with your desired absolute directory path and restart the shell.
[Environment]::SetEnvironmentVariable("BRIGHTWAY2_DIR", "<PATH>", "User")
How do I change my data directory in a conda environment?#
When you create a conda environment, it lives in a folder similar to <YOUR_ANACONDA_INSTALL_DIR>/envs/<YOUR_ENV_NAME>
. When conda activates or deactivates an environment, it looks for additional scripts in the two subfolders activate.d
and deactivate.d
within this folder. To set persistent environment variables (like BRIGHTWAY2_DIR
) in the virtual environment:
Navigate into your virtual environment folders just doing (both Mac/Linux and Windows):
cd <YOUR_ANACONDA_INSTALL_DIR>/envs/<YOUR_ENV_NAME>
Create the two folders
activate.d
anddeactivate.d
Create scripts in the folders that set and unset the environment variables (in this case
BRIGHTWAY2_DIR
). The names of the files don’t matter, but the file extensions do. Inside the folderactivate.d
create the file<WHATEVER_NAME_YOU_LIKE.sh
and inside it writeexport BRIGHTWAY2_DIR=<YOUR_NEW_DIR_PATH>
. Inside the folderdeactivate.d
create the file<WHATEVER_NAME_YOU_LIKE.sh
and inside it writeBRIGHTWAY2_DIR=
.
When you create a conda environment, it lives in a folder similar to <YOUR_ANACONDA_INSTALL_DIR>/envs/<YOUR_ENV_NAME>
. When conda activates or deactivates an environment, it looks for additional scripts in the two subfolders activate.d
and deactivate.d
within this folder. To set persistent environment variables (like BRIGHTWAY2_DIR
) in the virtual environment:
Navigate into your virtual environment folders just doing (both Mac/Linux and Windows):
cd <YOUR_ANACONDA_INSTALL_DIR>/envs/<YOUR_ENV_NAME>
Create the two folders
activate.d
anddeactivate.d
Create scripts in the folders that set and unset the environment variables (in this case
BRIGHTWAY2_DIR
). The names of the files don’t matter, but the file extensions do. Inside the folderactivate.d
create the file<WHATEVER_NAME_YOU_LIKE.bat
and inside it writeexport BRIGHTWAY2_DIR=<YOUR_NEW_DIR_PATH>
. Inside the folderdeactivate.d
create the file<WHATEVER_NAME_YOU_LIKE.bat
and inside it writeBRIGHTWAY2_DIR=
.
How do I backup my data?#
Each project is just a subdirectory, and this can be backed up using any normal tools, including cloud backups like Dropbox. You can save a snapshot of entire project directory with backup_data_directory
, or save a single project with backup_project_directory
. Both functions return the filepath of the created archive file.