Skip to content

AiiDAlab migration to 2.x guide

Jusong Yu edited this page Nov 20, 2022 · 2 revisions

The AiiDAlab app migration guide

First of all, since the AiiDAlab app is usually based on a specific AiiDA plugin, you need to migrate the plugin first. You can find from how to migrate AiiDA plugin to 2.0.

Set AIIDA_WARN_v3=1 on notebook

AiiDA provides an environment variable AiiDA_WARN_v3 for popping up the deprecation warnings for where the old APIs are used in your package. To have this variable set in the notebook and display the warnings, please first put the following code at the very beginning of your notebook.

import os
os.environ["AIIDA_WARN_v3"] = "1"

Open the notebook using "Edit App" mode instead of the appmode which will hide the warnings during the running.

Deprecated API/widgets of aiidalab-widgets-base (AWB)

We create ComputationalResourcesWidget for computer and code setup from AWB version 1.3, to include and replace the widgets for the same purpose, they are:

  • CodeDropdown
  • AiiDACodeSetup
  • ComputerDatabaseWidget
  • SshComputerSetup
  • AiiDAComputerSetup
  • ComputerDropdown renamed as ComputerDropdownWidget

All these deprecated widgets are removed from AWB 2.0 and you should considered to use ComputatioanalResourcesWidget instead.

API changes: UUID as the traitlets in AWB

AiiDA is not thread-safe, for the node queried from DB, it will live at the end of DB session. In the AiiDAlab widget, we use threading for the widget since we don't want to block the whole notebook in some long-running operation. However, some traitlets in the widget implementation are AiiDA nodes, which leads to the issue that when the threading is closed the session is also finalized thereafter the node is expired and invalid to be used. For more details on the discussion about thread-local problem: check https://github.com/aiidateam/aiida-core/issues/5765

We break the API backward compatibility by changing all the traitlets that use AiiDA node to the static UUID, only loading the node and consuming it in the local scope. The PR involves all the widgets that explicitly use threading for the AiiDA node. There are possibilities that the other thread triggers the traitlets change and has AiiDA node in the extra threading, which also causes the exact same issue. One example is the ComputationalResourceWidget, which has AiiDA code node as traitlets but has no threading. The issue happened when it is called from QeApp by additional threading from the code setup widget. In the future, we will change all the traitlets to UUID.

The widgets changed are:

  • ComputationalResourcesWidget because of QeApp code setup trigger refresh it in a thread.
  • ComputerDropdownWidget
  • ProcessListWidget because the thread call in the update function for process.
  • ProcessMonitor thread call in join()
  • ProcessNodesTreeWidget