Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update appStore/region_utils.py
Browse files- appStore/region_utils.py +13 -2
appStore/region_utils.py
CHANGED
@@ -34,11 +34,22 @@ def get_regions(region_df):
|
|
34 |
return region_df, unique_sub_regions
|
35 |
|
36 |
@st.cache_data
|
37 |
-
def get_country_name_and_region_mapping(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
"""
|
39 |
Build a mapping from country name -> code and code -> sub-region, by scanning the entire collection.
|
40 |
"""
|
41 |
-
|
|
|
|
|
|
|
|
|
42 |
country_set = set()
|
43 |
for res in results[0] + results[1]:
|
44 |
country = res.payload.get('metadata', {}).get('country', "[]")
|
|
|
34 |
return region_df, unique_sub_regions
|
35 |
|
36 |
@st.cache_data
|
37 |
+
def get_country_name_and_region_mapping(
|
38 |
+
_client,
|
39 |
+
collection_name,
|
40 |
+
region_df,
|
41 |
+
_hybrid_search_fn,
|
42 |
+
_clean_country_code_fn,
|
43 |
+
_get_country_name_fn
|
44 |
+
):
|
45 |
"""
|
46 |
Build a mapping from country name -> code and code -> sub-region, by scanning the entire collection.
|
47 |
"""
|
48 |
+
# Note the underscores in the function parameters above.
|
49 |
+
|
50 |
+
# Inside the function, just call them as usual:
|
51 |
+
results = _hybrid_search_fn(_client, "", collection_name)
|
52 |
+
|
53 |
country_set = set()
|
54 |
for res in results[0] + results[1]:
|
55 |
country = res.payload.get('metadata', {}).get('country', "[]")
|