[Fixes #13512] Create a task that loads required thesauri automatically#14187
Conversation
…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>
|
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. |
…ri loading Agent-Logs-Url: https://github.com/GeoNode/geonode/sessions/50827a39-23e0-47b0-9269-7c87c0ed4434 Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
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. |
Agent-Logs-Url: https://github.com/GeoNode/geonode/sessions/ca967273-78e4-4330-b1ee-7b10f8f774d9 Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
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. |
|
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. |
There was a problem hiding this comment.
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 autoloadto discoverthesauri/*.rdfunder 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 loadthesauritask 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.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #14187 +/- ##
==========================================
+ Coverage 74.58% 74.81% +0.22%
==========================================
Files 959 977 +18
Lines 58172 59999 +1827
Branches 7948 8175 +227
==========================================
+ Hits 43390 44886 +1496
- Misses 13016 13288 +272
- Partials 1766 1825 +59 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
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. |
Agent-Logs-Url: https://github.com/GeoNode/geonode/sessions/5771cb43-8066-4e9c-aa9d-1f71a79fadc5 Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
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. |
There was a problem hiding this comment.
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
appsattribute ingeonode.base.management.commands.thesaurus. Patch theapps.get_app_configsreference 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
appsattribute ingeonode.base.management.commands.thesaurus. Patch theapps.get_app_configsreference 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
appsattribute ingeonode.base.management.commands.thesaurus. Patch theapps.get_app_configsreference 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_langnow falls back tosettings.LANGUAGE_CODE, which is commonly a regional tag likeen-us.value_for_language()comparesitem.language.split('-')[0]todefault_lang(full string), so this fallback can prevent matchingenlabels and lead to inconsistent title/label selection. Consider normalizingLANGUAGE_CODEto its base language (e.g.,split('-')[0]) before using it here (or adjustvalue_for_languageto 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)
| 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 |
|
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. |
|
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. |
| def loadthesauri(ctx): | ||
| print("**************************thesauri*******************************") | ||
| ctx.run( | ||
| f"python manage.py thesaurus autoload --settings={_localsettings()}", |
There was a problem hiding this comment.
MINOR: This is a change i want to propose for the whole file, so i think is better to use django-admin rather than python manage.py to call the command
|
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 review |
Replace flake8 and black with ruff Update geonode/base/views.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Clear-text logging of sensitive information' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> 'CodeQL / Information exposure through an exception' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Potential fix for pull request finding 'CodeQL / URL redirection from remote source' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> PR review suggestions PR review suggestions Potential fix for pull request finding 'CodeQL / Information exposure through an exception' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> fix PR review suggestion Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> fix PR review suggestion Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Potential fix for pull request finding 'CodeQL / Information exposure through an exception' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> fix PR review suggestion Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> [Fixes #14244] Do not return WWW-Authenticate inside API exception response (#14265) * Do not return WWW-Authenticate inside API exception response * Test WWW-Authenticate stripped * Fix test docstring [Fixes #14262] Avoid returning all permissions in dataset owner payload (#14263) [Fixes #14248] Fix proxy registry initialization (#14249) [Fixes #13512] Create a task that loads required thesauri automatically (#14187) * Add autoload subcommand to thesaurus management command, task in tasks.py, and entrypoint call * Add documentation for thesaurus autoload command and boot-time thesauri loading * Move autoload_thesauri into its own thesaurus_subcommands/autoload.py * Log improvements, lang selection * Apply suggestions from code review * Fix mutable default argument for langs parameter in load_thesaurus * Fix patch apps.get_app_configs in correct autoload module * Fix code formatting * Improve load final log Co-authored-by: etj <717359+etj@users.noreply.github.com> Co-authored-by: Emanuele Tajariol <etj@geo-solutions.it> merge with master
thesaurus_subcommands/autoload.pywith theautoload_thesauri()functionthesaurus.pyto importautoload_thesaurifrom the new module and remove the inline definition