Skip to content

[Fixes #13512] Create a task that loads required thesauri automatically#14187

Open
Copilot wants to merge 6 commits into
masterfrom
copilot/implement-issue-13512
Open

[Fixes #13512] Create a task that loads required thesauri automatically#14187
Copilot wants to merge 6 commits into
masterfrom
copilot/implement-issue-13512

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

  • Create thesaurus_subcommands/autoload.py with the autoload_thesauri() function
  • Update thesaurus.py to import autoload_thesauri from the new module and remove the inline definition

…s.py, and entrypoint call

Agent-Logs-Url: https://github.com/GeoNode/geonode/sessions/9a26ad60-2d0f-4255-861e-2bd45a3dee10

Co-authored-by: etj <717359+etj@users.noreply.github.com>
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

@etj etj linked an issue Apr 30, 2026 that may be closed by this pull request
Copilot finished work on behalf of etj April 30, 2026 13:57
Copilot AI requested a review from etj April 30, 2026 13:57
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

Copilot finished work on behalf of etj April 30, 2026 14:07
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

@etj etj marked this pull request as ready for review April 30, 2026 16:12
Copilot AI review requested due to automatic review settings April 30, 2026 16:12
@etj etj changed the title Add autoload subcommand to thesaurus management command for boot-time thesauri loading [Fixes #13512] Create a task that loads required thesauri automatically Apr 30, 2026
@etj etj requested a review from mattiagiupponi April 30, 2026 16:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new thesaurus autoload subcommand and wires it into Docker boot so thesauri shipped by installed apps (via thesauri/*.rdf) are automatically loaded/updated at startup.

Changes:

  • Introduces thesaurus autoload to discover thesauri/*.rdf under installed Django apps and load them with an idempotent update action.
  • Extends thesaurus loading to support language filtering (--langs) and reduces log verbosity for autoload runs.
  • Runs thesauri autoload during container startup via a new invoke loadthesauri task and documents the boot sequence.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tasks.py Adds invoke loadthesauri task to run python manage.py thesaurus autoload.
entrypoint.sh Calls invoke loadthesauri during non-celery container startup.
geonode/base/management/commands/thesaurus.py Registers autoload subcommand and adds --langs option for load.
geonode/base/management/commands/thesaurus_subcommands/autoload.py Implements app-discovery + RDF loading loop for autoload.
geonode/base/management/commands/thesaurus_subcommands/load.py Adds language filtering + logging control to thesaurus loader.
geonode/tests/test_autoload_thesaurus.py Adds tests validating autoload discovery, idempotency, skipping, and error continuation.
docs/src/setup/docker/vanilla-docker-installation.md Documents thesauri autoload as part of container initialization.
docs/src/admin/thesauri/thesauri.md Documents thesaurus autoload, app convention, and boot-time initialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread geonode/base/management/commands/thesaurus_subcommands/load.py Outdated
Comment on lines +69 to +70
with patch("geonode.base.management.commands.thesaurus.apps.get_app_configs", return_value=app_configs):
autoload_thesauri()
Comment thread geonode/base/management/commands/thesaurus_subcommands/autoload.py Outdated
Comment thread geonode/base/management/commands/thesaurus.py Outdated
Comment on lines 48 to 49
def load_thesaurus(input_file, identifier: str, action: str = ACTION_CREATE, default_lang: str = None, langs: List[str] = [], log_details=True):
g = Graph()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in cfad81d — changed langs: List[str] = [] to langs: List[str] = None and updated the normalization line to use (langs or []) so the behaviour is identical but the mutable default is eliminated.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 1.80180% with 109 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.79%. Comparing base (26f6548) to head (cfad81d).
⚠️ Report is 36 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14187      +/-   ##
==========================================
+ Coverage   74.58%   74.79%   +0.20%     
==========================================
  Files         959      977      +18     
  Lines       58172    59975    +1803     
  Branches     7948     8170     +222     
==========================================
+ Hits        43390    44858    +1468     
- Misses      13016    13293     +277     
- Partials     1766     1824      +58     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 12, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

@etj etj requested review from giohappy and removed request for mattiagiupponi May 12, 2026 17:10
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 14, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

Copilot finished work on behalf of etj May 14, 2026 14:02
Copilot AI requested a review from etj May 14, 2026 14:02
@etj etj requested a review from Copilot May 14, 2026 14:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (4)

geonode/tests/test_autoload_thesaurus.py:82

  • Same issue as above: this patch target points at a non-existent apps attribute in geonode.base.management.commands.thesaurus. Patch the apps.get_app_configs reference in the autoload subcommand module instead.
        app_configs = [self._make_app_config("fake_app", self.tmp_dir)]
        with patch("geonode.base.management.commands.thesaurus.apps.get_app_configs", return_value=app_configs):
            autoload_thesauri()
            autoload_thesauri()

geonode/tests/test_autoload_thesaurus.py:93

  • Same issue as above: this patch target points at a non-existent apps attribute in geonode.base.management.commands.thesaurus. Patch the apps.get_app_configs reference in the autoload subcommand module instead.
        app_without_thesauri = self._make_app_config("no_thesauri_app", self.tmp_dir.rstrip("/") + "_no_dir")
        app_configs = [app_without_thesauri]
        with patch("geonode.base.management.commands.thesaurus.apps.get_app_configs", return_value=app_configs):
            # Should not raise
            autoload_thesauri()

geonode/tests/test_autoload_thesaurus.py:106

  • Same issue as above: this patch target points at a non-existent apps attribute in geonode.base.management.commands.thesaurus. Patch the apps.get_app_configs reference in the autoload subcommand module instead.
        app_configs = [self._make_app_config("fake_app", self.tmp_dir)]
        with patch("geonode.base.management.commands.thesaurus.apps.get_app_configs", return_value=app_configs):
            # Should not raise despite the bad file
            autoload_thesauri()

geonode/base/management/commands/thesaurus_subcommands/load.py:77

  • default_lang now falls back to settings.LANGUAGE_CODE, which is commonly a regional tag like en-us. value_for_language() compares item.language.split('-')[0] to default_lang (full string), so this fallback can prevent matching en labels and lead to inconsistent title/label selection. Consider normalizing LANGUAGE_CODE to its base language (e.g., split('-')[0]) before using it here (or adjust value_for_language to compare base-to-base).
    default_lang = default_lang or getattr(settings, "THESAURUS_DEFAULT_LANG", None) or getattr(settings, "LANGUAGE_CODE", 'en')

    available_titles = [t
                        for t in itertools.chain(g.objects(scheme, DC.title), g.objects(scheme, DCTERMS.title))
                        if isinstance(t, Literal)]
    thesaurus_title = value_for_language(available_titles, default_lang) or f'Thesaurus: {identifier}'
    description = g.value(scheme, DC.description, None) or g.value(scheme, DCTERMS.description, None, default=thesaurus_title)

Comment on lines +68 to +70
app_configs = [self._make_app_config("fake_app", self.tmp_dir)]
with patch("geonode.base.management.commands.thesaurus.apps.get_app_configs", return_value=app_configs):
autoload_thesauri()
Comment on lines 91 to +102
tl_cnt = tl_add = 0
tk_cnt = tk_add = 0
tkl_cnt = tkl_add = 0
tkl_skp = 0

for lang in available_titles:
if lang.language is not None:
tl_cnt += 1
if langs and lang.language not in langs:
logger.debug(f"Skipping label for language '{lang.language}' not in requested langs {langs}")
tkl_skp += 1
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a task that loads required thesauri automatically

3 participants