Skip to content

Commit

Permalink
Docs: Fix the intro/tutorial.md notebook
Browse files Browse the repository at this point in the history
The notebook creates and loads a temporary profile using the
`SqliteTempBackend` backend. This works fine as long as the profile is
only used in the current interpreter and no code is hit that checks the
profile is present in the `Config`. The reason is that although the
profile is loaded, it is created on the fly and not actually added to
the `Config` that is loaded in memory, nor is it written to the
`config.json` file on disk.

As soon as any code is called that will check the existence of the
temporary profile, through the config, it will fail. A good example is
when `%verdi process list` is called. At the end of the command, the
status of the daemon is checked, for which a `DaemonClient` instance is
constructed, which calls `config.get_option('daemon.timeout', profile)`.
This call will validate the provided profile to check that it actually
exists, i.e., is known within the config, which is not the case, and so
a `ProfileConfigurationError` is raised.

The solution is to update the notebook to actually add the created
temporary profile to the config loaded in memory. Note that this could
have the undesirable consequence that if the config state is written to
disk, the temporary profile can be added to `config.json`. This will not
be automatically cleaned up. Since here it concerns a demo notebook that
will just be run on temporary resources anyway, it not being cleaned up
is not a problem.

Ideally there would be a utility for notebooks that creates a temporary
profile and actually adds it to the config, and cleans it up at the end
of the notebook. But it will be difficult to guarantee the cleanup in
all cases.
  • Loading branch information
sphuber committed Apr 13, 2023
1 parent cec6c95 commit b26c2d4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/source/intro/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This tutorial can be downloaded and run as a Jupyter Notebook: {nb-download}`tut
:tags: ["hide-cell"]
from aiida import load_profile, engine, orm, plugins
from aiida.manage.configuration import get_config
from aiida.storage.sqlite_temp import SqliteTempBackend
%load_ext aiida
Expand All @@ -58,6 +59,9 @@ profile = load_profile(
),
allow_switch=True
)
config = get_config()
config.add_profile(profile)
config.set_default_profile(profile.name)
profile
```

Expand Down

0 comments on commit b26c2d4

Please sign in to comment.