Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Chris Proof of Principle #3

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.tox
.vscode
_build
build
8 changes: 8 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2

conda:
environment: environment.yml

sphinx:
builder: html
fail_on_warning: false
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# aiida-singledocs
# aiida-blog

Single page or other short miscelaneous documentation


### To Do:

* Autoinstall sphinx...
Binary file added docs/archives/visualising_graphs.aiida
Binary file not shown.
116 changes: 116 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Configuration file for the Sphinx documentation builder.
#

# -- Project information -----------------------------------------------------

project = "aiida-singledocs"
copyright = "2020, Francisco Ramirez"
author = "Francisco Ramirez, Chris Sewell"


version = "0.0.1"
release = version

# -- General configuration ---------------------------------------------------

needs_sphinx = "2.0"
extensions = ["myst_nb", "sphinx_panels", "ablog", "sphinx.ext.intersphinx"]

myst_admonition_enable = True
myst_html_img_enable = True
jupyter_execute_notebooks = "auto"

blog_path = "stories/index"
blog_title = "Stories"
blog_post_pattern = ["stories/*.md", "stories/*.ipynb"]
post_redirect_refresh = 1
post_auto_excerpt = 2
post_auto_image = 1
fontawesome_included = True
html_sidebars = {
"stories/index": ["tagcloud.html", "archives.html", "sbt-sidebar-nav.html"],
"stories/*": [
"sidebar-search-bs.html",
"postcard.html",
"recentposts.html",
"tagcloud.html",
"categories.html",
"archives.html",
"sbt-sidebar-nav.html",
"sbt-sidebar-footer.html",
],
}

intersphinx_mapping = {
"aiida": ("http://aiida-core.readthedocs.io/en/latest/", None),
}

# The master toctree document.
master_doc = "index"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"

# -- Options for HTML output -------------------------------------------------

html_theme = "sphinx_book_theme"
# html_title = f"version: {version}"
# html_favicon = "_static/quantum-mobile-v4-text-square.png"
# html_logo = "_static/quantum_mobile_text_wide.png"
html_theme_options = {
"home_page_in_toc": True,
"repository_url": "https://github.com/aiidateam/aiida-blog",
"repository_branch": "chris-branch",
"use_repository_button": True,
"use_issues_button": True,
"path_to_docs": "docs",
"use_edit_page_button": True,
"launch_buttons": {
"binderhub_url": "https://https://mybinder.org"
},
}
panels_add_bootstrap_css = False


def start_aiida(*args):
from unittest import mock
import os
import subprocess

subprocess.check_call(["reentry", "scan"])
from aiida.manage.external import postgres
from aiida.manage.tests import _GLOBAL_TEST_MANAGER, BACKEND_DJANGO
from aiida.common.utils import Capturing
# this is required on READTHEDOCS, since the docker container only contains C.UTF-8
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sphuber, quick question, is there a specific reason that _CREATE_DB_COMMAND is hard-coded to en_US.UTF-8. As commented, It's the only sticking point I had on getting this to work on RTD.

I'm planning to turn this into a small sphinx-extension,
so would probably want to make a PR to aiida-core, to change this in some way, to avoid this patch

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we applied this to have some consistency for the databases that are created by AiiDA, but I was not very close involved in that decision. This was mostly done between @giovannipizzi and @szoupanos if I remember correctly. If I understand correctly, you would apply the same change in aiida-core? Instead of hard coding utf-8 as encoding, use whatever is set by os.enivron['LANG']. I am not sure what the consequences of this would be.

What is the exact reason why having utf-8 fails for your use case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, you would apply the same change in aiida-core?

No probably just something like os.environ.get("AIIDA_DB_ENCODING", "en_US.UTF-8"), so nothing would change unless specified.

What is the exact reason why having utf-8 fails for your use case?

The RTD docker container does not set up en_US.UTF-8 or install locale. So I don't think there is any way to add it at run time.

https://github.com/readthedocs/readthedocs-docker-images/blob/master/Dockerfile

patch = mock.patch.object(
postgres,
"_CREATE_DB_COMMAND",
(
'CREATE DATABASE "{}" OWNER "{}" ENCODING \'UTF8\' '
f"LC_COLLATE='{os.environ['LANG']}' LC_CTYPE='{os.environ['LANG']}' "
"TEMPLATE=template0"
),
)

with Capturing(): # capture output of AiiDA DB setup
with patch:
_GLOBAL_TEST_MANAGER.use_temporary_profile(backend=BACKEND_DJANGO, pgtest=None)
from aiida.manage.configuration import settings

os.environ["AIIDA_PATH"] = settings.AIIDA_CONFIG_FOLDER


def end_aiida(*args):
from aiida.manage.tests import _GLOBAL_TEST_MANAGER

_GLOBAL_TEST_MANAGER.destroy_all()


def setup(app):
app.connect("builder-inited", start_aiida)
app.connect("build-finished", end_aiida)
Binary file added docs/images/aiida-crystal17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/provenance-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Welcome to AiiDA Stories

This site contains a collection of stories inspired in real life situations and use-cases of AiiDA.
You can use these stories to get a general feeling of what can be done with the code and what is like to work with it, as well as taking the procedures in them as templates for when you need to perform similar tasks.

Each story will specify at the beginning which version of the [Quantum Mobile](https://www.materialscloud.org/work/quantum-mobile) was used in its design/tests.

Using the correct virtual machine and creating a new profile that starts from a clean database (see the ``quicksetup`` command in the[`AiiDA documentation](https://aiida.readthedocs.io/projects/aiida-core/en/latest/intro/get_started.html#initialise-data-storage)) ensures the reproducibility of the commands if you want to test them out yourself.

Any other further set-ups required (such as importing databases) will be described in the introduction of the story.

```{toctree}
:maxdepth: 1

Stories <./stories/index>
```
Loading