From de8f1e9578e2bee90ef4b5a25cf0a6c8880a32dd Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Thu, 8 Jun 2023 00:54:13 +0200 Subject: [PATCH 1/3] init: move record_once to finalize_app --- invenio_vocabularies/ext.py | 39 +++++++++++++++++++++++++++++++++++ invenio_vocabularies/views.py | 25 +--------------------- setup.cfg | 7 ++++++- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/invenio_vocabularies/ext.py b/invenio_vocabularies/ext.py index 4c34513c..4e7ab481 100644 --- a/invenio_vocabularies/ext.py +++ b/invenio_vocabularies/ext.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2020-2022 CERN. +# Copyright (C) 2023 Graz University of Technology. # # Invenio-Vocabularies is free software; you can redistribute it and/or # modify it under the terms of the MIT License; see LICENSE file for more @@ -123,3 +124,41 @@ def init_resource(self, app): service=self.service, config=app.config["VOCABULARIES_RESOURCE_CONFIG"], ) + + +def finalize_app(app): + """Finalize app. + + NOTE: replace former @record_once decorator + """ + init(app) + + +def api_finalize_app(app): + """Api Finalize app. + + NOTE: replace former @record_once decorator + """ + init(app) + + +def init(app): + """Init app.""" + # Register services - cannot be done in extension because + # Invenio-Records-Resources might not have been initialized. + sregistry = app.extensions["invenio-records-resources"].registry + ext = app.extensions["invenio-vocabularies"] + sregistry.register(ext.affiliations_service, service_id="affiliations") + sregistry.register(ext.awards_service, service_id="awards") + sregistry.register(ext.funders_service, service_id="funders") + sregistry.register(ext.names_service, service_id="names") + sregistry.register(ext.subjects_service, service_id="subjects") + sregistry.register(ext.service, service_id="vocabularies") + # Register indexers + iregistry = app.extensions["invenio-indexer"].registry + iregistry.register(ext.affiliations_service.indexer, indexer_id="affiliations") + iregistry.register(ext.awards_service.indexer, indexer_id="awards") + iregistry.register(ext.funders_service.indexer, indexer_id="funders") + iregistry.register(ext.names_service.indexer, indexer_id="names") + iregistry.register(ext.subjects_service.indexer, indexer_id="subjects") + iregistry.register(ext.service.indexer, indexer_id="vocabularies") diff --git a/invenio_vocabularies/views.py b/invenio_vocabularies/views.py index be150406..fcc20b78 100644 --- a/invenio_vocabularies/views.py +++ b/invenio_vocabularies/views.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2020-2022 CERN. +# Copyright (C) 2023 Graz University of Technology. # # Invenio-Vocabularies is free software; you can redistribute it and/or # modify it under the terms of the MIT License; see LICENSE file for more @@ -13,30 +14,6 @@ blueprint = Blueprint("invenio_vocabularies_ext", __name__) -@blueprint.record_once -def init(state): - """Init app.""" - app = state.app - # Register services - cannot be done in extension because - # Invenio-Records-Resources might not have been initialized. - sregistry = app.extensions["invenio-records-resources"].registry - ext = app.extensions["invenio-vocabularies"] - sregistry.register(ext.affiliations_service, service_id="affiliations") - sregistry.register(ext.awards_service, service_id="awards") - sregistry.register(ext.funders_service, service_id="funders") - sregistry.register(ext.names_service, service_id="names") - sregistry.register(ext.subjects_service, service_id="subjects") - sregistry.register(ext.service, service_id="vocabularies") - # Register indexers - iregistry = app.extensions["invenio-indexer"].registry - iregistry.register(ext.affiliations_service.indexer, indexer_id="affiliations") - iregistry.register(ext.awards_service.indexer, indexer_id="awards") - iregistry.register(ext.funders_service.indexer, indexer_id="funders") - iregistry.register(ext.names_service.indexer, indexer_id="names") - iregistry.register(ext.subjects_service.indexer, indexer_id="subjects") - iregistry.register(ext.service.indexer, indexer_id="vocabularies") - - def create_blueprint_from_app(app): """Create app blueprint.""" return app.extensions["invenio-vocabularies"].resource.as_blueprint() diff --git a/setup.cfg b/setup.cfg index 7eb90223..60c70db2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2020-2024 CERN. -# Copyright (C) 2022 Graz University of Technology. +# Copyright (C) 2022-2024 Graz University of Technology. # # Invenio-Vocabularies is free software; you can redistribute it and/or # modify it under the terms of the MIT License; see LICENSE file for more @@ -67,6 +67,10 @@ invenio_base.api_blueprints = invenio_vocabularies_names = invenio_vocabularies.views:create_names_blueprint_from_app invenio_vocabularies_subjects = invenio_vocabularies.views:create_subjects_blueprint_from_app invenio_vocabularies_ext = invenio_vocabularies.views:blueprint +invenio_base.api_finalize_app = + invenio_vocabularies = invenio_vocabularies.ext:api_finalize_app +invenio_base.finalize_app = + invenio_vocabularies = invenio_vocabularies.ext:finalize_app invenio_db.alembic = invenio_vocabularies = invenio_vocabularies:alembic invenio_db.models = @@ -95,6 +99,7 @@ invenio_assets.webpack = invenio_i18n.translations = invenio_vocabularies = invenio_vocabularies + [build_sphinx] source-dir = docs/ build-dir = docs/_build From d8ecd6a708f08918c353ff06b2033b854c48939b Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Mon, 24 Jul 2023 22:23:00 +0200 Subject: [PATCH 2/3] setup: use pytest-black-ng instead of pytest-black * pytest-black seems out of support. the last commit was from 2020-10-05. Further pytest-black uses a out of date method which mentions pytest>=7.0 with a DeprecationWarning. The simplest solution is to use pytest-black-ng which fixes this situation. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 60c70db2..afa6a7f4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,7 +34,7 @@ install_requires = [options.extras_require] tests = - pytest-black>=0.3.0 + pytest-black-ng>=0.4.0 invenio-app>=1.3.3,<2.0.0 invenio-db[postgresql,mysql]>=1.0.14,<2.0.0 pytest-invenio>=2.1.0,<3.0.0 From 1240516bf94101e39eb19bf91d5da632ef18c0fe Mon Sep 17 00:00:00 2001 From: Karolina Przerwa Date: Fri, 22 Mar 2024 09:55:40 +0100 Subject: [PATCH 3/3] installation: upgrade invenio-app --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index afa6a7f4..d9196202 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,7 +35,7 @@ install_requires = [options.extras_require] tests = pytest-black-ng>=0.4.0 - invenio-app>=1.3.3,<2.0.0 + invenio-app>=1.4.0,<2.0.0 invenio-db[postgresql,mysql]>=1.0.14,<2.0.0 pytest-invenio>=2.1.0,<3.0.0 Sphinx>=4.5