Skip to content

Commit

Permalink
config: add GND to concepts and places
Browse files Browse the repository at this point in the history
* Adds GND to concepts and places.
* Dependencies updates.
* Adds safety ignore for sentry-sdk version 1.45.1.

Co-Authored-by: Peter Weber <[email protected]>
  • Loading branch information
rerowep committed Sep 5, 2024
1 parent 04968b3 commit 9141f83
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 163 deletions.
295 changes: 157 additions & 138 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3569,20 +3569,20 @@ def _(x):
"base_url": os.environ.get(
"RERO_ILS_MEF_CONCEPTS_URL", "https://mef.rero.ch/api/concepts"
),
"sources": ["idref"],
"sources": ["idref", "gnd"],
},
"concepts-genreForm": {
"concepts_genreForm": {
"base_url": os.environ.get(
"RERO_ILS_MEF_CONCEPTS_URL", "https://mef.rero.ch/api/concepts"
),
"sources": ["idref"],
"sources": ["idref", "gnd"],
"filters": [{"idref.bnf_type": "genre/forme Rameau"}],
},
"places": {
"base_url": os.environ.get(
"RERO_ILS_MEF_PLACES_URL", "https://mef.rero.ch/api/places"
),
"sources": ["idref"],
"sources": ["idref", "gnd"],
},
}
RERO_ILS_ENTITY_TYPES = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"options": [
{
"label": "Genre, form",
"value": "concepts-genreForm"
"value": "concepts_genreForm"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion rero_ils/modules/entities/local_entities/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"person": Q("term", type=EntityType.PERSON),
"organisation": Q("term", type=EntityType.ORGANISATION),
"concepts": Q("term", type=EntityType.TOPIC),
"concepts-genreForm": Q("term", type=EntityType.TOPIC) & Q("term", genreForm=True),
"concepts_genreForm": Q("term", type=EntityType.TOPIC) & Q("term", genreForm=True),
}


Expand Down
15 changes: 7 additions & 8 deletions rero_ils/modules/entities/remote_entities/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def create_proxy(category):
"class": MefConceptsProxy,
"entities": (EntityType.TEMPORAL,),
},
"concepts-genreForm": {
"concepts_genreForm": {
"class": MefConceptsGenreFormProxy,
"entities": (EntityType.TOPIC,),
},
Expand Down Expand Up @@ -110,10 +110,10 @@ class MEFProxyMixin:

# Headers that should be excluded from remote MEF system response.
excluded_headers = [
"Content-Encoding",
"Content-Length",
"Transfer-Encoding",
"Connection",
"CONTENT-Encoding".upper(),
"Content-Length".upper(),
"Transfer-Encoding".upper(),
"Connection".upper(),
]
mef_entrypoint = None # Must be overridden by subclasses

Expand Down Expand Up @@ -163,13 +163,12 @@ def search(self, term):
content = json.loads(response.content)
for hit in content.get("hits", {}).get("hits", []):
self._post_process_result_hit(hit)

# Finally, return a flask `Response` from a `request.Response`. All
# remote server response headers were cloned in the new response except
# some inconsistent headers.
flask_response = jsonify(content)
for header_name, header_value in response.headers.items():
if header_name not in self.excluded_headers:
if header_name.upper() not in self.excluded_headers:
flask_response.headers[header_name] = header_value
return flask_response

Expand Down Expand Up @@ -317,7 +316,7 @@ def _post_process_result_hit(self, hit):
class MefConceptsGenreFormProxy(MefConceptsProxy):
"""Proxy on RERO-MEF authority system for specific `genreForm` concepts."""

mef_entrypoint = "concepts-genreForm"
mef_entrypoint = "concepts_genreForm"


class MefPlacesProxy(MEFProxyMixin):
Expand Down
2 changes: 2 additions & 0 deletions scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ eval ${PREFIX} invenio reroils index run --raise-on-error
#: don't forget to recreat the documents json schema files:
# SIZE=big # SIZE=small
# export RERO_ILS_MEF_AGENTS_URL=https://mef.rero.ch/api/agents
# export RERO_ILS_MEF_CONCEPTS_URL=https://mef.rero.ch/api/concepts
# export RERO_ILS_MEF_PLACES_URL=https://mef.rero.ch/api/places
# invenio reroils utils marc21tojson -t rero ${DATA_PATH}/documents_${SIZE}.xml ${DATA_PATH}/documents_${SIZE}.json ${DATA_PATH}/documents_${SIZE}_errors.xml -v -r
# Save the entities after setup for later use.
# invenio reroils utils export -t rement -o ${DATA_PATH}/remote_entities_${SIZE}.json -v
Expand Down
12 changes: 9 additions & 3 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ function pretests () {
# -> Vulnerability found in werkzeug version 2.2.3
# Vulnerability ID: 62019
# -> Vulnerability found in werkzeug version 2.2.3
# Vulnerability ID: 71595
# Vulnerability ID: 71595
# -> Vulnerability found in werkzeug version 2.2.3
# Vulnerability ID: 71594
# -> Vulnerability found in jinja2 version 3.1.4
# Vulnerability ID: 70612
# -> Vulnerability found in py version 1.11.0
# Vulnerability ID: 51457
# -> Vulnerability found in sentry-sdk version 1.45.1
# Vulnerability ID: 72260
# Vulnerability ID: 72260
info_msg "Check vulnerabilities:"
safety_exceptions="-i 40459 -i 70624 -i 51668 -i 42194 -i 42852 -i 71594 -i 62019 -i 71595 -i 70612 -i 51457 -i 72260"
safety_exceptions="-i 40459 -i 70624 -i 51668 -i 42194 -i 42852 -i 62019 -i 71595 -i 71594 -i 70612 -i 51457 -i 72260"
msg=$(safety check -o text ${safety_exceptions}) || {
echo "Safety vulnerabilites found for packages:" $(safety check -o bare ${safety_exceptions})
echo "Run: \"safety check -o screen ${safety_exceptions} | grep -i vulnerability\" for more details"
Expand Down
6 changes: 3 additions & 3 deletions tests/api/entities/local_entities/test_local_entities_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_local_search_by_proxy(client, local_entity_genre_form, local_entity_org
response = client.get(
url_for(
"api_local_entities.local_search_proxy",
entity_type="concepts-genreForm",
entity_type="concepts_genreForm",
term="personal",
size="dummy_qs_arg",
)
Expand All @@ -159,7 +159,7 @@ def test_local_search_by_proxy(client, local_entity_genre_form, local_entity_org
response = client.get(
url_for(
"api_local_entities.local_search_proxy",
entity_type="concepts-genreForm",
entity_type="concepts_genreForm",
term="personal",
size="0",
)
Expand All @@ -170,7 +170,7 @@ def test_local_search_by_proxy(client, local_entity_genre_form, local_entity_org
response = client.get(
url_for(
"api_local_entities.local_search_proxy",
entity_type="concepts-genreForm",
entity_type="concepts_genreForm",
term="dummy_key",
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_remote_search_proxy(
response = client.get(
url_for(
"api_remote_entities.remote_search_proxy",
entity_type="concepts-genreForm",
entity_type="concepts_genreForm",
term="side-car",
)
)
Expand Down
11 changes: 7 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,17 @@ def app_config(app_config):
},
"concepts": {
"base_url": "https://mef.rero.ch/api/concepts",
"sources": ["idref"],
"sources": ["idref", "gnd"],
},
"concepts-genreForm": {
"concepts_genreForm": {
"base_url": "https://mef.rero.ch/api/concepts",
"sources": ["idref"],
"sources": ["idref", "gnd"],
"filters": [{"idref.bnf_type": "sujet Rameau"}],
},
"places": {"base_url": "https://mef.rero.ch/api/places", "sources": ["idref"]},
"places": {
"base_url": "https://mef.rero.ch/api/places",
"sources": ["idref", "gnd"],
},
}
return app_config

Expand Down

0 comments on commit 9141f83

Please sign in to comment.