Update app.py
Browse files
app.py
CHANGED
|
@@ -213,10 +213,9 @@ with gr.Blocks() as demo:
|
|
| 213 |
content_dict = get_topic_content(topic_code)
|
| 214 |
return gr.update(choices=list(content_dict.keys()), visible=True), content_dict, topic_code
|
| 215 |
|
| 216 |
-
def update_reports(topic_content_name: str, content_dict: dict = None, topic_name: str = '')-> Tuple[Dict[str, str], str, Any]:
|
| 217 |
-
"""Updates the UI dropdown menu with available report titles for a selected topic content,
|
| 218 |
-
|
| 219 |
-
|
| 220 |
Args:
|
| 221 |
topic_content_name (str): The name of the selected topic content (e.g., "Darba samaksa (algas)"). Topic content names you can get from `update_topic_content` (`content_dict` object).
|
| 222 |
content_dict (dict): A dictionary mapping topic content names to their corresponding content codes. Obtained from `update_topic_content` (2nd returned object: `content_dict`).
|
|
@@ -242,7 +241,7 @@ with gr.Blocks() as demo:
|
|
| 242 |
titles_dict = get_titles(topic_content_code)
|
| 243 |
return titles_dict, topic_content_code, gr.update(choices=list(titles_dict.keys()), visible=True)
|
| 244 |
|
| 245 |
-
def update_topic_params_and_link(report_title: str, titles_dict:
|
| 246 |
"""Prepares and returns metadata, a hyperlink, and query parameter preview for a selected report
|
| 247 |
from the Official Statistics Portal of Latvia (CSP).
|
| 248 |
|
|
@@ -306,9 +305,8 @@ with gr.Blocks() as demo:
|
|
| 306 |
lang (str): Language. Default value 'en'.
|
| 307 |
topic_params_str (str): string representation of a list that is needed for data extraction. Arguments in the list should be in the following order: topic code, topic content code, topic sub-content code, report ID.\
|
| 308 |
These codes you can get from the function get_titles.
|
| 309 |
-
query_kwargs_str (str): string representation of a dictionary - keyword arguments for query configuration
|
| 310 |
-
Possible query argument names ('code') and their possible values ('values')
|
| 311 |
-
can be obtained using the function get_query_values.
|
| 312 |
'valueTexts' from get_query_values could help if 'values' is unclear.
|
| 313 |
Returns:
|
| 314 |
list: The list of the dictionaries, where dictionary's key 'key' contains query parameters and key 'values' contains values.
|
|
|
|
| 213 |
content_dict = get_topic_content(topic_code)
|
| 214 |
return gr.update(choices=list(content_dict.keys()), visible=True), content_dict, topic_code
|
| 215 |
|
| 216 |
+
def update_reports(topic_content_name: str, content_dict: dict = None, topic_name: str = '') -> Tuple[Dict[str, str], str, Any]:
|
| 217 |
+
"""Updates the UI dropdown menu with available report titles for a selected topic content, and returns the titles dictionary and the corresponding content code.
|
| 218 |
+
|
|
|
|
| 219 |
Args:
|
| 220 |
topic_content_name (str): The name of the selected topic content (e.g., "Darba samaksa (algas)"). Topic content names you can get from `update_topic_content` (`content_dict` object).
|
| 221 |
content_dict (dict): A dictionary mapping topic content names to their corresponding content codes. Obtained from `update_topic_content` (2nd returned object: `content_dict`).
|
|
|
|
| 241 |
titles_dict = get_titles(topic_content_code)
|
| 242 |
return titles_dict, topic_content_code, gr.update(choices=list(titles_dict.keys()), visible=True)
|
| 243 |
|
| 244 |
+
def update_topic_params_and_link(report_title: str, titles_dict: dict) -> Tuple[str, Any, Any]:
|
| 245 |
"""Prepares and returns metadata, a hyperlink, and query parameter preview for a selected report
|
| 246 |
from the Official Statistics Portal of Latvia (CSP).
|
| 247 |
|
|
|
|
| 305 |
lang (str): Language. Default value 'en'.
|
| 306 |
topic_params_str (str): string representation of a list that is needed for data extraction. Arguments in the list should be in the following order: topic code, topic content code, topic sub-content code, report ID.\
|
| 307 |
These codes you can get from the function get_titles.
|
| 308 |
+
query_kwargs_str (str): string representation of a dictionary - keyword arguments for query configuration.\
|
| 309 |
+
Possible query argument names ('code') and their possible values ('values') can be obtained using the function get_query_values.\
|
|
|
|
| 310 |
'valueTexts' from get_query_values could help if 'values' is unclear.
|
| 311 |
Returns:
|
| 312 |
list: The list of the dictionaries, where dictionary's key 'key' contains query parameters and key 'values' contains values.
|