Skip to content

Commit

Permalink
temp_profile and html layout fix attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Dec 20, 2023
1 parent d03dfa9 commit 6dd2d6a
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 27 deletions.
22 changes: 22 additions & 0 deletions aiidalab_widgets_base/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,25 @@ def ase2spglib(ase_structure: Atoms) -> Tuple[Any, Any, Any]:
numbers = ase_structure.get_atomic_numbers()

return (lattice, positions, numbers)


# Load the temp profile for notebooks on readthedocs
def load_temp_profile():
"""Load the temp profile to make sure the docs build succeed even if the current
default profile of the AiiDA installation is not configured.
"""
from aiida import load_profile
from aiida.manage.configuration import get_config
from aiida.storage.sqlite_temp import SqliteTempBackend

profile = load_profile(
SqliteTempBackend.create_profile(
"readthedocs",
options={"warnings.development_version": False, "runner.poll.interval": 1},
debug=False,
),
allow_switch=True,
)
config = get_config()
config.add_profile(profile)
config.set_default_profile(profile.name)
8 changes: 4 additions & 4 deletions aiidalab_widgets_base/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ def __init__(self, parameter, downloadable=True, **kwargs):
</style>
"""

pd.set_option("max_colwidth", 40)
pd.set_option("max_colwidth", 100)
dataf = pd.DataFrame(
[(key, value) for key, value in sorted(parameter.get_dict().items())],
columns=["Key", "Value"],
)
self.value += dataf.to_html(
classes="df", index=False
) # specify that exported table belongs to 'df' class
# specify that exported table belongs to 'df' class
# this is used to setup table's appearance using CSS
# `colwidths-auto` and `table` are also required for proper table rendering in MyST: https://myst-parser.readthedocs.io/en/latest/syntax/tables.html
self.value += dataf.to_html(classes="df colwidths-auto table", index=False)
if downloadable:
payload = base64.b64encode(dataf.to_csv(index=False).encode()).decode()
fname = f"{parameter.pk}.csv"
Expand Down
28 changes: 24 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,31 @@
import time
from pathlib import Path

# Load the dummy profile to make sure the docs build succeed even if the current
# default profile of the AiiDA installation is not configured.
from aiida.manage.configuration import load_documentation_profile

load_documentation_profile()
# Load the temp profile to make sure the docs build succeed even if the current
# default profile of the AiiDA installation is not configured.
def load_temp_profile():
"""Load the temp profile to make sure the docs build succeed even if the current
default profile of the AiiDA installation is not configured.
"""
from aiida import load_profile
from aiida.manage.configuration import get_config
from aiida.storage.sqlite_temp import SqliteTempBackend

profile = load_profile(
SqliteTempBackend.create_profile(
"readthedocs",
options={"warnings.development_version": False, "runner.poll.interval": 1},
debug=False,
),
allow_switch=True,
)
config = get_config()
config.add_profile(profile)
config.set_default_profile(profile.name)


load_temp_profile()

from aiidalab_widgets_base import __version__ # pylint: disable=wrong-import-position

Expand Down
4 changes: 2 additions & 2 deletions notebooks/computational_resources.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"from aiidalab_widgets_base.utils import load_temp_profile\n",
"\n",
"load_profile();"
"load_temp_profile()"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions notebooks/eln_configure.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"from aiidalab_widgets_base.utils import load_temp_profile\n",
"\n",
"load_profile();"
"load_temp_profile()"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions notebooks/eln_import.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"from aiidalab_widgets_base.utils import load_temp_profile\n",
"\n",
"load_profile();"
"load_temp_profile()"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions notebooks/process.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"from aiidalab_widgets_base.utils import load_temp_profile\n",
"\n",
"load_profile();"
"load_temp_profile()"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions notebooks/process_list.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"from aiidalab_widgets_base.utils import load_temp_profile\n",
"\n",
"load_profile();"
"load_temp_profile()"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions notebooks/structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"from aiidalab_widgets_base.utils import load_temp_profile\n",
"\n",
"load_profile();"
"load_temp_profile()"
]
},
{
Expand Down Expand Up @@ -90,7 +90,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down
5 changes: 3 additions & 2 deletions notebooks/viewers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"source": [
"# default profile of the AiiDA installation is not configured.\n",
"from aiida import orm\n",
"from aiida.manage.configuration import load_documentation_profile\n",
"\n",
"load_documentation_profile()"
"from aiidalab_widgets_base.utils import load_temp_profile\n",
"\n",
"load_temp_profile()"
]
},
{
Expand Down
6 changes: 2 additions & 4 deletions notebooks/wizard_apps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
"metadata": {},
"outputs": [],
"source": [
"# Load the dummy profile to make sure the docs build succeed even if the current\n",
"# default profile of the AiiDA installation is not configured.\n",
"from aiida.manage.configuration import load_documentation_profile\n",
"from aiidalab_widgets_base.utils import load_temp_profile\n",
"\n",
"load_documentation_profile()"
"load_temp_profile()"
]
},
{
Expand Down

0 comments on commit 6dd2d6a

Please sign in to comment.