From c0cd9dca777d6ba991d1868c60d8cae1043ad75a Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Thu, 21 Nov 2024 16:39:48 +0100 Subject: [PATCH] Upgrade documentation for migration to aiida-core 2.6 Remove usage of `load_documentation_profile` in docs. With aiida-core/pull/6226 the usage of load_documentation_profile is not anymore required as the Django backend is not anymore supported and can therefore be removed. graphql.utils has been moved to graphql.utilities and usage of `print_schema` has been adapted. --- aiida_restapi/graphql/orm_factories.py | 3 ++- aiida_restapi/graphql/sphinx_ext.py | 4 ++-- docs/source/conf.py | 8 -------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/aiida_restapi/graphql/orm_factories.py b/aiida_restapi/graphql/orm_factories.py index 3a7d2f9..fade6fa 100644 --- a/aiida_restapi/graphql/orm_factories.py +++ b/aiida_restapi/graphql/orm_factories.py @@ -31,9 +31,10 @@ def get_pydantic_type_name(annotation: Any) -> Any: """ - In pydantic v1, one could do field.type_, + In pydantic v1, one could do `field.type_`, but in v2, one has to go though field.annotation """ + args = typing.get_args(annotation) if args: return args[0] diff --git a/aiida_restapi/graphql/sphinx_ext.py b/aiida_restapi/graphql/sphinx_ext.py index 329b1ea..88bea4c 100644 --- a/aiida_restapi/graphql/sphinx_ext.py +++ b/aiida_restapi/graphql/sphinx_ext.py @@ -3,7 +3,7 @@ # pylint: disable=import-outside-toplevel from typing import TYPE_CHECKING, List -from graphql.utils.schema_printer import print_schema +from graphql.utilities import print_schema from .main import SCHEMA @@ -21,7 +21,7 @@ class SchemaDirective(SphinxDirective): def run(self) -> List[Element]: """Run the directive.""" - text = print_schema(SCHEMA) + text = print_schema(SCHEMA.graphql_schema) # TODO for lexing tried: https://gitlab.com/marcogiusti/pygments-graphql/-/blob/master/src/pygments_graphql.py # but it failed code_node = literal_block(text, text) # , language="graphql") diff --git a/docs/source/conf.py b/docs/source/conf.py index 38ab465..80ebe50 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,16 +14,8 @@ import sys import time -from aiida.manage.configuration import load_documentation_profile - import aiida_restapi -# -- AiiDA-related setup -------------------------------------------------- - -# Load the dummy profile even if we are running locally, this way the documentation will succeed even if the current -# default profile of the AiiDA installation does not use a Django backend. -load_documentation_profile() - extensions = [ 'myst_parser', 'sphinx_external_toc',