Activity Browser and Brightway

Activity Browser and Brightway

About

This page documents how to

  • install Activity Browser based on Brightway

  • Make it available for use with the Jupyter Notebook app in OOD

References

GitHub - LCA-ActivityBrowser/activity-browser: GUI for brightway2 · GitHub

Installation

Even though Activity Browser is a GUI-based application, you do not need a full Desktop to install it. You can also just use a terminal-based ssh connection.

Installing Activity Browser will also install the necessary Brightway packages. Do not try to install Brightway first and then Activity Browser because this can lead to dependency conflicts

Here are the steps:

  1. If you have not used conda or mambe on ALICE before, you need to load the Miniforge module once and then initiate conda. After that, you do not need to load the Miniforge module anymore, because mamba/conda will be available in your environment (see also Installing Python packages)

  2. Create the environment and install it

    conda create -n ab -c conda-forge activity-browser
    1. Note that you the name “ab” for the environment is arbitary, feel free to use an alternative

Using Activity Browser

Do not use Activity Browser on the login nodes!

Because Acitivity Browser is a GUI-based installation which can be used to perform serious calculations, you should only use it through the Desktop App in Open Ondemand and not on the login nodes.

This way, Acitivity Browser runs in a Slurm job environment on a compute node and you specify the number of cores and amount of memory that you need.

As usual, we recommend starting small to run some tests and then scale up.

Here are the steps:

  1. Log in to OOD, go to the Desktop App, set the resources as needed and click on “Launch”

  2. Once the OOD shows that the app has started, Open a terminal in the desktop

  3. Activate the environment and start the application

    conda activate ab export XDG_RUNTIME_DIR=/tmp/runtime-$USER activity-browser

Starting the application may take a bit, please be patient.

Using Brightway with Juptyer app from OOD

Installing Acitivity Browser also installs Brightway. If you just need Brightway, you can install it on its own (see Installation — Brightway documentation). In this case, we recommend a simple Python virtual environment instead of conda for which you can load the JupyterLab module.

Using Brightway through the Jupyter app is very useful for testing and development. However, in production, it is best to turn the notebook into a Python script that you can submit with a Slurm batch job. This way, you can scale up your productivity by submitting multiple Slurm jobs, it improves the reproducibility and you automatically have logging.

Note that some functions in Brightway run in parallel?

For the following steps, we assume that you want to use Brightway from the conda environment with Activity Browser that you setup above.

  1. Activate the conda environment

    conda activate ab
  2. Install ipykernel and pyzmq

    conda install ipykernel pyzmq
  3. Make the conda environment avaible for use with Jupyter by installing the kernel. It is best to use the full python path

    # get the full python path $(which python) -m ipykernel install --user --name=ab --display-name="Conda (ActivityBrowser)"

    “name” should match the name of the environment, but “display-name” is arbitrary. The latter is shown when you select the kernel.

  4. If you are not yet in OOD, log in and go to the Jupyter app, set the resource settings as needed and click on “Launch”

  5. When OOD shows that Jupyter is running, click on “Connect to Jupyter”.

  6. In Jupyter, go to the “Kernel” menu on the top, select “Change Kernel” and select the kernel "Conda (ActivityBrowser)". If you found it, click on “Select”.

  7. Jupyter will now try to connect to the Kernel, which you can see on the bottom left and top right. When it says on the bottom Conda (ActivityBrowser) | Idle, Jupyter has successfully connected to the kernel and you can start using it.
    If it does not work, you will have to have a log at the output.log file from the job. You can access it in OOD, by clicking on the session ID in the “My Interactive Sessions” overview. If you cannot solve the issue there, feel free to contact the ALICE Helpdesk.

  8. If the kernel has connected successfully, try opening a Jupyter notebook and load the packages.

If you installed Brightway in a stand-alone Python environment, the steps are somewhat similar:

  1. Activate the Python environment

  2. Install ipykernel with pip install ipykernel

  3. Install the kernel for Jupyter, e.g,

    # assuming the Brightway is installed in a Python environment called "brightway" $(which python) -m ipykernel install --user --name=brightway --display-name="Pyenv (ActivityBrowser)"
  4. Continue with step 4 above for the conda setup.