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

Generate complete API docs using sphinx-apidoc #1330

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9d21d0d
add first script for sphinx-apidoc
ltalirz Mar 8, 2018
3bd16ce
add :noindex: attribute to source/*/dev.rst
ltalirz Mar 8, 2018
474fde3
adding a few more :noindex: directives
ltalirz Mar 8, 2018
7dde5fc
fix creative ascii art in docstrings
ltalirz Mar 8, 2018
206d709
fix various formatting errors
ltalirz Mar 8, 2018
ce4794f
Fix warnings coming from compiling of sphinx autodoc
sphuber Mar 8, 2018
a77497e
remove apidoc.sh testing script => Makefile
ltalirz Mar 8, 2018
e77533c
minor edit of travis script
ltalirz Mar 8, 2018
abf2562
document apidoc Makefile option
ltalirz Mar 8, 2018
61d88ff
change apidoc link name
ltalirz Mar 9, 2018
5167d84
revert tocdepth back to default
ltalirz Mar 9, 2018
c76e90f
Remove the caching module from aiida.restapi.common
sphuber Mar 9, 2018
64ed9f7
Remove vestigial tests loading file for django
sphuber Mar 9, 2018
7d99399
Isolating alembic checks (and sqla schema checks in general) when we …
szoupanos Mar 12, 2018
78dee22
Missing files for commit 82c799b
szoupanos Mar 13, 2018
3846089
remove QueryTool
ltalirz Mar 23, 2018
0cc179c
fix leftover conflict from rebase
ltalirz Mar 23, 2018
18f8f43
docs: work around built-in type bug
ltalirz Mar 23, 2018
8d2ac95
fix most nitpicky issues
ltalirz Mar 23, 2018
607f2b5
ibump sphinx version
ltalirz Mar 24, 2018
98ff32e
include private and special members in apidoc
ltalirz Mar 24, 2018
fe21305
fix all regular warnings except for 1
ltalirz Mar 25, 2018
b80445e
fix most nitpicky warnings
ltalirz Mar 25, 2018
5b33325
fix codeblocks
ltalirz Mar 25, 2018
5a9804b
fix remaining 3 issues
ltalirz Mar 25, 2018
e617da2
starting to remove old api docdbexporters
ltalirz Mar 26, 2018
8d232f7
remove/merge dbexporters docs
ltalirz Mar 26, 2018
91b99c5
move registrytools docs to python modules
ltalirz Mar 26, 2018
178223c
remove common/dev.rst
ltalirz Mar 26, 2018
25e0195
move transport doc to developer doc
ltalirz Mar 26, 2018
a986484
improve apidoc layout a bit
ltalirz Mar 26, 2018
24e3c04
move orm doc to developer_documentation
ltalirz Mar 26, 2018
bb3945f
move control.postgres doc to python module
ltalirz Mar 26, 2018
02a635e
Merge branch 'release_v0.11.3' into issue_1242_sphinx-apidoc_rebased
ltalirz Mar 27, 2018
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
6 changes: 4 additions & 2 deletions .travis-data/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ set -ev

case "$TEST_TYPE" in
docs)
# Compile the docs (HTML format); -W to convert warnings in errors,
# Compile the docs (HTML format);
# -C change to 'docs' directory before doing anything
# -n to warn about all missing references
SPHINXOPTS="-nW" make -C docs html
# -W to convert warnings in errors
SPHINXOPTS="-nW" make -C docs
;;
tests)
# Add the .travis-data folder to the python path such that defined workchains can be found by the daemon
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v0.11.3

- Remove QueryTool (was deprecated in favor of QueryBuilder since v0.8.0)


## v0.11.2:

### Critical bug fixes
Expand Down
1 change: 1 addition & 0 deletions aiida/backends/djsite/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def get_workflow_list(pk_list=tuple(), user=None, all_states=False,
n_days_ago=None):
"""
Get a list of workflow.

:param user: A ORM User class if you want to filter by user
:param pk_list: Limit the results to this list of PKs
:param all_states: if False, limit results to "active" (e.g., running) wfs
Expand Down
18 changes: 9 additions & 9 deletions aiida/backends/djsite/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
from django.db import models as m
from django_extensions.db.fields import UUIDField
from django.contrib.auth.models import (
AbstractBaseUser, BaseUserManager, PermissionsMixin)
AbstractBaseUser, BaseUserManager, PermissionsMixin )
from django.utils.encoding import python_2_unicode_compatible
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.query import QuerySet

from aiida.utils import timezone
from aiida.common.exceptions import (
ConfigurationError, DbContentError, MissingPluginError)
ConfigurationError, DbContentError, MissingPluginError )

from aiida.backends.settings import AIIDANODES_UUID_VERSION
from aiida.backends.djsite.settings.settings import AUTH_USER_MODEL
Expand Down Expand Up @@ -319,10 +319,10 @@ def _deserialize_attribute(mainitem, subitems, sep, original_class=None,
:param subitems: must be a dictionary of dictionaries. In the top-level dictionary,
the key must be the key of the attribute, stripped of all prefixes
(i.e., if the mainitem has key 'a.b' and we pass subitems
'a.b.0', 'a.b.1', 'a.b.1.c', their keys must be '0', '1', '1.c').
It must be None if the value is not iterable (int, str,
float, ...).
It is an empty dictionary if there are no subitems.
'a.b.0', 'a.b.1', 'a.b.1.c', their keys must be '0', '1', '1.c').
It must be None if the value is not iterable (int, str,
float, ...).
It is an empty dictionary if there are no subitems.
:param sep: a string, the separator between subfields (to separate the
name of a dictionary from the keys it contains, for instance)
:param original_class: if these elements come from a specific subclass
Expand All @@ -341,7 +341,7 @@ def _deserialize_attribute(mainitem, subitems, sep, original_class=None,
from the number declared in the ival field).

:return: the deserialized value
:raise DeserializationError: if an error occurs
:raise aiida.backends.djsite.db.models.DeserializationException: if an error occurs
"""
from aiida.utils.timezone import (
is_naive, make_aware, get_current_timezone)
Expand Down Expand Up @@ -1380,7 +1380,7 @@ def get_dbcomputer(cls, computer):
"""
Return a DbComputer from its name (or from another Computer or DbComputer instance)
"""
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.core.exceptions import MultipleObjectsReturned
from aiida.common.exceptions import NotExistent
from aiida.orm.computer import Computer

Expand Down Expand Up @@ -1604,7 +1604,7 @@ class DbWorkflow(m.Model):

def get_aiida_class(self):
"""
Return the corresponding aiida instance of class aiida.worflow
Return the corresponding aiida instance of class aiida.workflow
"""
from aiida.orm.workflow import Workflow

Expand Down
68 changes: 0 additions & 68 deletions aiida/backends/djsite/db/tests.py

This file was deleted.

17 changes: 10 additions & 7 deletions aiida/backends/djsite/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ def query_jobcalculations_by_computer_user_state(

Issue a warning if the state is not in the list of valid states.

:param string state: The state to be used to filter (should be a string among
:param state: The state to be used to filter (should be a string among
those defined in aiida.common.datastructures.calc_states)
:type state: str
:param computer: a Django DbComputer entry, or a Computer object, of a
computer in the DbComputer table.
A string for the hostname is also valid.
Expand Down Expand Up @@ -299,23 +300,25 @@ def get_all_parents(self, node_pks, return_values=['id']):
def get_closest_parents(pks,*args,**kwargs):
"""
Get the closest parents dbnodes of a set of nodes.

:param pks: one pk or an iterable of pks of nodes
:param chunk_size: we chunk the pks into groups of this size,
to optimize the speed (default=50)
:param print_progress: print the the progression if True (default=False).
:param args & kwargs: additional query parameters
:return: a dictionary of the form:
{pk1: pk of closest parent of node with pk1,
pk2: pk of closest parent of node with pk2,
etc.
}
:param args: additional query parameters
:param kwargs: additional query parameters
:returns: a dictionary of the form
pk1: pk of closest parent of node with pk1,
pk2: pk of closest parent of node with pk2

.. note:: It works also if pks is a list of nodes rather than their pks

.. todo:: find a way to always get a parent (when there is one) from each pk.
Now, when the same parent has several children in pks, only
one of them is kept. This is a BUG, related to the use of a dictionary
(children_dict, see below...).
For now a work around is to use chunk_size=1.

"""
from aiida.orm import Node
from aiida.backends.djsite.db import models
Expand Down
2 changes: 1 addition & 1 deletion aiida/backends/djsite/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
# Note: this variable might disappear in the future
REPOSITORY_PROTOCOL, REPOSITORY_PATH = parse_repository_uri(REPOSITORY_URI)

if settings.IN_DOC_MODE:
if settings.IN_RT_DOC_MODE:
pass
elif REPOSITORY_PROTOCOL == 'file':
if not os.path.isdir(REPOSITORY_PATH):
Expand Down
27 changes: 0 additions & 27 deletions aiida/backends/djsite/settings/urls.py

This file was deleted.

1 change: 1 addition & 0 deletions aiida/backends/djsite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def load_dbenv(process=None, profile=None):
def _load_dbenv_noschemacheck(process, profile):
"""
Load the database environment (Django) WITHOUT CHECKING THE SCHEMA VERSION.

:param process: the process that is calling this command ('verdi', or
'daemon')
:param profile: the string with the profile to use. If not specified,
Expand Down
9 changes: 6 additions & 3 deletions aiida/backends/general/abstractqueries.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,25 @@ def query_jobcalculations_by_computer_user_state(

Issue a warning if the state is not in the list of valid states.

:param string state: The state to be used to filter (should be a string among
:param state: The state to be used to filter (should be a string among
those defined in aiida.common.datastructures.calc_states)
:type state: str
:param computer: a Django DbComputer entry, or a Computer object, of a
computer in the DbComputer table.
A string for the hostname is also valid.
:param user: a Django entry (or its pk) of a user in the DbUser table;
if present, the results are restricted to calculations of that
specific user
:param bool only_computer_user_pairs: if False (default) return a queryset
:param only_computer_user_pairs: if False (default) return a queryset
where each element is a suitable instance of Node (it should
be an instance of Calculation, if everything goes right!)
If True, return only a list of tuples, where each tuple is
in the format
('dbcomputer__id', 'user__id')
[where the IDs are the IDs of the respective tables]
:param int limit: Limit the number of rows returned
:type only_computer_user_pairs: bool
:param limit: Limit the number of rows returned
:type limit: int

:return: a list of calculation objects matching the filters.
"""
Expand Down
4 changes: 4 additions & 0 deletions aiida/backends/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

# This is used (and should be set to true) for the correct compilation
# of the documentation on readthedocs
IN_RT_DOC_MODE = False

# This is same as the trigger above, but is switched on for RTD documentation
# compilation but also for local documentation compilation.
IN_DOC_MODE = False

# The following is a dummy config.json configuration that it is used for the
Expand Down
5 changes: 3 additions & 2 deletions aiida/backends/sqlalchemy/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ def get_group_list(user, type_string, n_days_ago=None,
def get_workflow_list(pk_list=tuple(), user=None, all_states=False,
n_days_ago=None):
"""
Get a list of workflow.
Get a list of workflow

:param user: A ORM User class if you want to filter by user
:param pk_list: Limit the results to this list of PKs
:param all_states: if False, limit results to "active" (e.g., running) wfs
:param n_days_ago: an integer number of days. If specifies, limit results to
workflows started up to this number of days ago
workflows started up to this number of days ago
"""
from aiida.orm.workflow import Workflow
from aiida.backends.sqlalchemy.models.workflow import DbWorkflow
Expand Down
20 changes: 12 additions & 8 deletions aiida/backends/sqlalchemy/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
###########################################################################
from __future__ import with_statement
from alembic import context

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
from aiida.backends.settings import IN_DOC_MODE

# The available SQLAlchemy tables
from aiida.backends.sqlalchemy.models.authinfo import DbAuthInfo
Expand Down Expand Up @@ -53,6 +50,12 @@ def run_migrations_online():
and associate a connection with the context.

"""
# This is the Alembic Config object, which provides
# access to the values within the .ini file in use.
# It is initialized by alembic and we enrich it here
# to point to the right database configuration.
config = context.config

connectable = config.attributes.get('connection', None)

if connectable is None:
Expand All @@ -69,7 +72,8 @@ def run_migrations_online():
with context.begin_transaction():
context.run_migrations()

if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
if not IN_DOC_MODE:
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
3 changes: 2 additions & 1 deletion aiida/backends/sqlalchemy/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def __get__(self, obj, _type):
class _AiidaQuery(orm.Query):

def __init__(self, *args, **kwargs):
super(_AiidaQuery, self).__init__(*args, **kwargs)
"""Constructor"""
super(_AiidaQuery, self).__init__(*args, **kwargs)

def __iter__(self):
iterator = super(_AiidaQuery, self).__iter__()
Expand Down
13 changes: 8 additions & 5 deletions aiida/backends/sqlalchemy/tests/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ def migrate_db_with_non_testing_migrations(self, destination):
def test_migrations_forward_backward(self):
"""
This is a very broad test that checks that the migration mechanism
works. More specifically, it checks that:
- Alembic database migrations to specific versions work (upgrade &
downgrade)
- The methods that are checking the database schema version and perform
the migration procedure to the last version work correctly.
works. More specifically, it checks that::

- Alembic database migrations to specific versions work (upgrade &
downgrade)

- The methods that are checking the database schema version and perform
the migration procedure to the last version work correctly.

"""
from aiida.backends.sqlalchemy.tests.migration_test import versions
from aiida.backends.sqlalchemy.utils import check_schema_version
Expand Down
10 changes: 10 additions & 0 deletions aiida/backends/sqlalchemy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,13 @@ def check_schema_version(force_migration=False, alembic_cfg=None):
import sys
from aiida.common.utils import query_yes_no
from aiida.backends import sqlalchemy as sa
from aiida.backends.settings import IN_DOC_MODE

# Early exit if we compile the documentation since the schema
# check is not needed and it creates problems with the sqlalchemy
# migrations
if IN_DOC_MODE:
return

# If an alembic configuration file is given then use that one.
if alembic_cfg is None:
Expand Down Expand Up @@ -467,6 +474,9 @@ def get_db_schema_version(config):
:param config: The alembic configuration.
:return: The version of the database.
"""
if config is None:
return None

script = ScriptDirectory.from_config(config)

def get_db_version(rev, _):
Expand Down
Loading