Skip to content

Commit

Permalink
Fix redirect link download issue and update nl debug log formats (#4259)
Browse files Browse the repository at this point in the history
  • Loading branch information
shifucun authored May 22, 2024
1 parent 1c50089 commit 6d23dfb
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 81 deletions.
1 change: 0 additions & 1 deletion server/config/nl_page/topic_cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -15422,7 +15422,6 @@
],
"relevantVariableList": [
"UnemploymentRate_Person",
"Count_Person_NonWorker",
"UnemploymentRate_Person_Female",
"UnemploymentRate_Person_Male"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"Parts": [
{
"CosineScore": [
0.9257855415344238
0.9257859587669373
],
"QueryPart": "male population",
"SV": [
Expand All @@ -64,7 +64,7 @@
{
"CosineScore": [
0.9296979904174805,
0.884743332862854
0.8847434520721436
],
"QueryPart": "female population",
"SV": [
Expand Down Expand Up @@ -123,7 +123,7 @@
},
{
"CosineScore": [
0.917032778263092
0.9170326590538025
],
"QueryPart": "population female population",
"SV": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@
"Parts": [
{
"CosineScore": [
0.8084911108016968,
0.8080331087112427,
0.8044111728668213,
0.7984197735786438,
0.7966943979263306,
0.7915846705436707,
0.790185809135437,
0.8084912300109863,
0.8080331683158875,
0.8044112920761108,
0.7984198331832886,
0.7966946959495544,
0.791584849357605,
0.7901858687400818,
0.7865886688232422,
0.777317464351654,
0.776214063167572,
0.7629760503768921
0.7773175239562988,
0.7762140035629272,
0.7629759907722473
],
"QueryPart": "number poor hispanic",
"SV": [
Expand Down Expand Up @@ -104,7 +104,7 @@
{
"CosineScore": [
0.8433718681335449,
0.8265039324760437
0.8265039920806885
],
"QueryPart": "number poor hispanic women",
"SV": [
Expand All @@ -114,11 +114,11 @@
},
{
"CosineScore": [
0.7646968960762024,
0.7646970152854919,
0.7476688027381897,
0.7377066612243652,
0.7362767457962036,
0.7305883169174194
0.73770672082901,
0.7362766265869141,
0.7305881977081299
],
"QueryPart": "phd",
"SV": [
Expand All @@ -137,7 +137,7 @@
"Parts": [
{
"CosineScore": [
0.7890844941139221
0.7890845537185669
],
"QueryPart": "number poor",
"SV": [
Expand All @@ -146,10 +146,10 @@
},
{
"CosineScore": [
0.8151503801345825,
0.7885993719100952,
0.7775554060935974,
0.7752052545547485
0.8151504993438721,
0.7885995507240295,
0.7775554656982422,
0.7752053737640381
],
"QueryPart": "hispanic women phd",
"SV": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"Parts": [
{
"CosineScore": [
0.8787486553192139
0.8787485361099243
],
"QueryPart": "show climate change",
"SV": [
Expand All @@ -50,7 +50,7 @@
},
{
"CosineScore": [
1.0
0.9999998211860657
],
"QueryPart": "drought",
"SV": [
Expand All @@ -65,10 +65,10 @@
"Parts": [
{
"CosineScore": [
0.794236958026886,
0.7929013967514038,
0.7586168050765991,
0.758395791053772
0.7942368984222412,
0.7929012775421143,
0.7586166858673096,
0.7583957314491272
],
"QueryPart": "show climate",
"SV": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"comparisonVariables": [],
"context": {},
"debug": {},
"entities": ["Earth"],
"entities": [
"Earth"
],
"nonPlaceEntities": [],
"properties": [],
"sessionId": "007_999999999",
Expand All @@ -37,4 +39,4 @@
"dc/topic/sdg_8.8.2",
"dc/topic/ILOEMP2WAPRT"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,34 @@
],
"title": "Unemployment Rate"
},
{
"columns": [
{
"tiles": [
{
"statVarKey": [
"UnemploymentRate_Person_Female"
],
"title": "Unemployment Rate of Females in United Kingdom",
"type": "LINE"
}
]
},
{
"tiles": [
{
"description": "Unemployment Rate of Females in United Kingdom",
"statVarKey": [
"UnemploymentRate_Person_Female"
],
"title": "Unemployment Rate of Females in United Kingdom",
"type": "HIGHLIGHT"
}
]
}
],
"title": "Unemployment Rate of Females"
},
{
"columns": [
{
Expand Down Expand Up @@ -225,6 +253,10 @@
"name": "Unemployment Rate",
"statVar": "UnemploymentRate_Person"
},
"UnemploymentRate_Person_Female": {
"name": "Unemployment Rate of Females",
"statVar": "UnemploymentRate_Person_Female"
},
"sdg/EN_MAT_DOMCMPG": {
"name": "Domestic material consumption per unit of GDP",
"statVar": "sdg/EN_MAT_DOMCMPG"
Expand Down Expand Up @@ -620,25 +652,10 @@
},
"childTopics": [],
"exploreMore": {
"sdg/EN_MAT_DOMCMPG": {
"sdg_product": [
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF1",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF11",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF121",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF122",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF13",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF14",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF2",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF21",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF22",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF3",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF4",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF41",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF413",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF421",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF422",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF_AGG3A",
"sdg/EN_MAT_DOMCMPG.PRODUCT--MF_AGG3B"
"UnemploymentRate_Person_Female": {
"age": [
"UnemploymentRate_Person_25To74Years_Female",
"UnemploymentRate_Person_Upto25Years_Female"
]
}
},
Expand Down
11 changes: 10 additions & 1 deletion server/lib/nl/common/debug_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import cast, Dict
import logging
from typing import Dict

from server.lib.nl.detection.types import ClassificationType
from server.lib.nl.detection.types import Detection
Expand Down Expand Up @@ -134,6 +135,9 @@ def result_with_debug_info(data_dict: Dict, status: str,
for entity in query_detection.places_detected.entities_found:
entities_found_formatted += f"(name: {entity.name}, dcid: {entity.dcid}); "

query_transformations = query_detection_debug_logs.get(
'query_transformations', {})

debug_info.update({
'places_detected':
query_detection.places_detected.query_places_mentioned,
Expand All @@ -143,8 +147,13 @@ def result_with_debug_info(data_dict: Dict, status: str,
query_detection.places_detected.query_entities_mentioned,
'entities_resolved':
entities_found_formatted,
'query_index_type':
query_transformations.get('sv_detection_query_index_type', ''),
'query_with_places_removed':
query_detection.places_detected.query_without_place_substr,
'query_with_stop_words_removal':
query_transformations.get('sv_detection_query_stop_words_removal',
''),
'query_detection_debug_logs':
query_detection_debug_logs,
})
Expand Down
4 changes: 2 additions & 2 deletions server/routes/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def demo():


def load_redirects(name):
local_file = gcs.download_file(bucket=GLOBAL_CONFIG_BUCKET,
filename='redirects.json')
local_file = gcs.maybe_download(
gcs.make_path(GLOBAL_CONFIG_BUCKET, 'redirects.json'))
with open(local_file) as fp:
mapping = json.load(fp)
return mapping.get(name, '/')
Expand Down
5 changes: 5 additions & 0 deletions static/css/explore.scss
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@
width: 100%;
}

.nl-query-result-debug-info .highlight {
color: blue;
font-weight: bold;
}

#ranking-table-container {
margin-left: 24px;
}
Loading

0 comments on commit 6d23dfb

Please sign in to comment.