Skip to content

Download Script Fix + PVmap Changes in Mongolia Imports (Mongolia_Education, Mongolia_Health, Mongolia_Employment, Mongolia_Demographics - #2128

Open
kartik-s21 wants to merge 41 commits into
datacommonsorg:masterfrom
kartik-s21:mongolia-import-fix
Open

Download Script Fix + PVmap Changes in Mongolia Imports (Mongolia_Education, Mongolia_Health, Mongolia_Employment, Mongolia_Demographics#2128
kartik-s21 wants to merge 41 commits into
datacommonsorg:masterfrom
kartik-s21:mongolia-import-fix

Conversation

@kartik-s21

@kartik-s21kartik-s21 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This PR addresses data validation failures, point deletions, and execution timeouts across all four Mongolia imports (mongolia_education, mongolia_demographics, mongolia_health, and mongolia_employment).

With these fixes, all four datasets generate cleanly with 0.00% point deletions and execute without API network timeouts or connection dropouts.

Key Changes:

  1. Common Infrastructure (common_download_script.py)
    Updated table extraction, parsing logic, and retry formatting for Education, Demographics, and Health datasets to prevent data truncation and column shifts during downloading.

  2. Mongolia Education (mongolia_education)
    Added explicit date mappings for survey years 2024 and 2025 across all 6 education PVMAP tables.
    Updated run.sh and place mappings to cleanly handle regional groupings, resolving all historical point deletions (+350 newly recovered observation points).
    Document for deletions - link
    CL for missing references - link
    Validation Output - input0input1input2input3input4input5

  3. Mongolia Demographics (mongolia_demographics)
    Fixed 19.35% record deletion in marital status statistics (resident_population_by_agegroup_15_and_over_and_maritalstatus_pvmap.csv) by re-enabling the missing Age Group:Total mapping.
    Added explicit column key prefixes (Marital Status:, Age Group:, Gender:) to prevent ambiguous "Total" matches from creating duplicate observation conflicts.
    Validation Output - input0input1input2input3input4input5input6

  4. Mongolia Health (mongolia_health)
    Corrected column extraction and monthly time-series parsing logic for births, deaths, infant mortality, and child delivery tables, eliminating all dropped historical observation dates through 2025.
    Document for deletions - link
    Validation Output - input0input1input2input3input4input5

  5. Mongolia Employment (mongolia_employment)
    Fixed Cloud Batch container timeout (InvalidDCInstanceError) caused by over 100,000 fallback API calls during place resolution.
    Regenerated places_resolved.csv with 134 exhaustive mappings that account for leading whitespace hierarchy indentation.
    Validation Output - link

PR Checklist - link

@gemini-code-assistgemini-code-assistBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Mongolian demographics and education import scripts. It refactors common_download_script.py to dynamically resolve table paths and fetch metadata (English and Mongolian) from the API, mapping the POST response data to the expected format. It also extends observation dates up to 2030 in several mapping files and updates place resolution configurations. Feedback focuses on optimizing performance by caching API catalog requests and pre-building lookup dictionaries to avoid inefficient .index() lookups in loops. Additionally, it is recommended to increase the retry count for robust downloads and strip whitespaces from keys to normalize place names in places_resolved.csv.

Comment threadstatvar_imports/mongolia_imports/common_download_script.py
Comment threadstatvar_imports/mongolia_imports/common_download_script.py Outdated
Comment threadstatvar_imports/mongolia_imports/common_download_script.py Outdated
Comment threadstatvar_imports/mongolia_imports/common_download_script.py
@kartik-s21kartik-s21 changed the title Mongolia import fixDownload Script Fix + PVmap Changes in Mongolia Imports (Mongolia_Education, Mongolia_Health, Mongolia_Employment, Mongolia_DemographicsAug 4, 2026

@saanikaaasaanikaaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add differ results with the latest changes

@saanikaaasaanikaaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add output_counter

@kartik-s21

Copy link
Copy Markdown
ContributorAuthor

pls add output_counter

done

@kartik-s21

Copy link
Copy Markdown
ContributorAuthor

Pls add differ results with the latest changes

done

Age Group:Population aged 15 and over-Total,age,[15 - Years],,,,,,,,
Age Group:15-19,#ignore,skip,,,,,,,,
Age Group:70+,#ignore,skip,,,,,,,,
Age Group:Total,age,[15 - Years],,,,,,,,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the key in source only says Total, and we have mapped it to age 15 and above. Is it correct? Pls attach source reference to validated

"template_mcf": "output_files/employment_by_classification_of_economic_activities_region_gender_and_agegroup_output.tmcf",
"cleaned_csv": "output_files/employment_by_classification_of_economic_activities_region_gender_and_agegroup_output.csv"
"cleaned_csv": "output_files/employment_by_classification_of_economic_activities_region_gender_and_agegroup_output.csv",
"statvar_mcf": "output_files/employment_by_classification_of_economic_activities_region_gender_and_agegroup_output.mcf"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should avoid adding this file, as missing reference wont show up in cloud lint and we will fail to add a new schema if any introduced.
Also, if we are adding this now because we were getting any missing reference pls create schema CL with new schema.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment across entire file

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@kartik-s21@saanikaaa