Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow profile selection ipython magic %aiida #4071

Merged
merged 5 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions aiida/tools/ipython/ipython_magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,13 @@ def aiida(self, line='', local_ns=None):
from aiida.cmdline.utils.shell import get_start_namespace

self.is_warning = False
load_profile()
self.current_state = 'Loaded AiiDA DB environment.'
lcontent = line.strip()
if lcontent:
CasperWA marked this conversation as resolved.
Show resolved Hide resolved
profile = load_profile(lcontent)
else:
profile = load_profile()

self.current_state = 'Loaded AiiDA DB environment - profile name: {}.'.format(profile.name)

user_ns = get_start_namespace()
for key, value in user_ns.items():
Expand Down
5 changes: 3 additions & 2 deletions docs/source/install/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ The current ipython profile folder can be located using::

After this, if you open a Jupyter notebook as explained above and type in a cell::

%aiida
%aiida <profile_name>

followed by ``Shift-Enter``. You should receive the message "Loaded AiiDA DB environment."
followed by ``Shift-Enter``. The ``<profile_name>`` argument is optional, and the line magic selects the default profile if it is omitted.
zhubonan marked this conversation as resolved.
Show resolved Hide resolved
You should receive the message "Loaded AiiDA DB environment - profile name: <profile_name>."
zhubonan marked this conversation as resolved.
Show resolved Hide resolved
This line magic should also be enabled in standard ipython shells.