Themes

Load and format SRF, GCM, and cross-cutting priority data for LLM consumption

load_thm


def load_thm(
    fname:str, # Filename to load
    path:str=None, # Directory containing theme files
    md:bool=False, # Return raw text instead of JSON?
)->dict | str: # Theme data as dict or raw text

Load theme file from path (JSON by default, or raw text if md=True)

Exported source
load_enbs = partial(load_thm, 'srf_enablers.json')
load_ccps = partial(load_thm, 'crosscutting_priorities.json')
load_srf_outs = partial(load_thm, 'srf_objectives.json')
load_gcms = partial(load_thm, 'gcms_long.md', md=True)
load_gcms_lut = partial(load_thm, 'gcm_to_srf_outputs.json')

For instance, to get:

e = load_enbs()[0]
{k: v for k, v in e.items() if k != 'indicators'}
{'id': '1',
 'title': 'Workforce',
 'description': 'IOM’s diverse and capable people are our most valued asset. Through investing in better workforce planning and people management, we will facilitate their professional development and improve their daily workplace experience. IOM will have flexible systems and procedures in place to ensure it can adapt to the future of work while ensuring the safety, security and well-being of its staff. IOM will strengthen its security posture and foster an inclusive and enabling work environment. Our leadership will have the ability to connect, motivate and inspire a sense of our shared vision and values.'}
e = load_ccps()[0]
{k: v for k, v in e.items() if k != 'indicators'}
{'id': '1',
 'title': 'Integrity, Transparency and Accountability',
 'description': 'Our leadership will oversee an organizational culture and internal systems that promote integrity, accountability and transparency. We will measure our progress against clearly defined goals and objectives, which will improve the visibility of our results for Member States and the people we serve. IOM will facilitate transparent discussions about our results and take corrective actions where necessary. We continue to strengthen our response to ethical challenges faced by our workforce and the individuals and communities with which we work.'}
  • SRF Outputs nested under SRF Objectives, Long- and Short-Term Outcomes
o = load_srf_outs()[0]
{k: v for k, v in o.items()}
{'id': '1',
 'title': 'Saving lives and protecting people on the move.',
 'long_term_outcomes': [{'id': '1a',
   'title': 'Human suffering is alleviated while the dignity and rights of people affected by crises are upheld.',
   'short_term_outcomes': [{'id': '1a1',
     'title': 'Crisis-affected populations have their basic needs met and have minimum living conditions with reduced barriers to access for marginalized and vulnerable individuals.',
     'outputs': [{'id': '1a11',
       'title': 'Crisis-affected populations in-need receive dignified shelter and settlement support.'},
      {'id': '1a12',
       'title': 'Government and local actors have resources, skills and tools to ensure assistance is delivered in an equitable manner, without barriers based on ethnicity, religion, gender, ability, migration status or other factors.'},
      {'id': '1a13',
       'title': 'Crisis-affected populations have access to cash and market-based interventions, whenever appropriate.'},
      {'id': '1a14',
       'title': 'Crisis-affected populations receive quality, comprehensive WASH programming at scale, ensuring the human right to water and sanitation and empowering them to meet their needs.'},
      {'id': '1a15',
       'title': 'Crisis-affected populations receive quality health and mental health and psychosocial support (MHPSS) services in a timely manner.'},
      {'id': '1a16',
       'title': 'Crisis-affected populations in-need receive movement assistance.'},
      {'id': '1a17',
       'title': 'Crisis-affected populations in camps and camp-like settings have equitable access to assistance, protection, and services in displacement sites, [to improve their quality of life and dignity during displacement while seeking and advocating for durable solutions.]'},
      {'id': '1a18',
       'title': 'Health service providers and systems have the knowledge, skills and resources to continue to provide essential health services in crisis-affected settings.'},
      {'id': '1a19',
       'title': 'Victims of human rights violations in the context of reparations and restitution mechanisms have improved living conditions and wellbeing.'}]},
    {'id': '1a2',
     'title': 'Humanitarian assistance is provided in a manner that actively contributes to immediate and longer-term needs of affected populations.',
     'outputs': [{'id': '1a21',
       'title': 'Humanitarian actors at all levels have knowledge and tools to formulate interventions that address both the immediate and longer-term needs of affected populations, including climate-sensitive considerations.'},
      {'id': '1a22',
       'title': 'Local stakeholders have capacity to actively contribute to the immediate and longer-term response.'}]},
    {'id': '1a3',
     'title': 'Decision makers and responders responsibly use data and its analysis to inform the delivery of assistance to crisis-affected populations.',
     'outputs': [{'id': '1a31',
       'title': 'Guidelines on data and information collection, sharing and management are in place that adhere to data protection standards, principles of confidentiality and a defined purpose, to protect the individuals and groups providing information from harm.'},
      {'id': '1a32',
       'title': 'Robust data on mobility and displacement is available, disaggregated by age, sex and disability using appropriate methodologies.'}]}]},
  {'id': '1b',
   'title': 'Threats and vulnerabilities are reduced or mitigated through humanitarian protection.',
   'short_term_outcomes': [{'id': '1b1',
     'title': 'Governments and humanitarian actors work with crisis-affected populations to identify and respond to their vulnerabilities and needs.',
     'outputs': [{'id': '1b11',
       'title': 'Governments and humanitarian actors have improved access to timely disaggregated data on the specific vulnerabilities and needs of all crisis-affected populations to inform evidence-based response.'},
      {'id': '1b12',
       'title': 'Crisis-affected populations participate in decision-making for the design, planning and implementation of humanitarian programming.'}]},
    {'id': '1b2',
     'title': 'Governments and humanitarian actors at all levels design and implement activities that reduce risks and threats associated with humanitarian crises.',
     'outputs': [{'id': '1b21',
       'title': 'Governments and humanitarian actors have knowledge, capacity and tools to effectively mainstream and implement protection in a way that upholds rights and dignity of crisis affected populations, including gender, age and disability related risks across all sectors of humanitarian response.'},
      {'id': '1b22',
       'title': 'Local actors are trained on how to address the protection needs of the most vulnerable.'},
      {'id': '1b23',
       'title': 'Appropriate and safe to access feedback and complaint mechanisms are established.'},
      {'id': '1b24',
       'title': 'Immigration and border authorities are trained on gender- and protection-sensitive humanitarian border management to address vulnerabilities and protection needs in crisis affected situations.'}]},
    {'id': '1b3',
     'title': 'Governments and humanitarian actors ensure that vulnerable groups who face exacerbated protection risks and threats have meaningful access to humanitarian protection.',
     'outputs': [{'id': '1b31',
       'title': 'Vulnerable groups and persons at risk in a humanitarian context receive quality health care services that respond to their needs.'},
      {'id': '1b32',
       'title': 'Governments and humanitarian actors have strengthened protection referral pathways to promote and facilitate access to humanitarian services and assistance.'},
      {'id': '1b33',
       'title': 'Vulnerable and at-risk persons are protected through their sustained and meaningful participation within humanitarian protection.'}]}]},
  {'id': '1c',
   'title': 'The quality of humanitarian assistance and response is enhanced',
   'short_term_outcomes': [{'id': '1c1',
     'title': 'Humanitarian actors have robust systems in place to effectively support operations and cope with operational needs.',
     'outputs': [{'id': '1c11',
       'title': 'Mechanisms for the procurement and movement of quality and cost-effective supplies are established and maintained.'}]},
    {'id': '1c2',
     'title': 'The quality of interagency coordination is enhanced, including IOM Cluster leadership, partnership and participation.',
     'outputs': [{'id': '1c21',
       'title': 'Humanitarian coordination mechanisms are established and strengthened to ensure the efficiency and effectiveness of humanitarian response.'},
      {'id': '1c22',
       'title': 'Humanitarian actors have knowledge, capacity, and resources to engage in the IASC system and multi-agency joint initiatives to ensure a holistic response to multifaceted impact of crisis.'},
      {'id': '1c23',
       'title': 'Humanitarian actors are supported to ensure that affected populations and local actors, especially marginalized groups, are fully consulted and can actively participate in humanitarian response.'}]}]}]}
print(load_gcms()[:1000])
# Objective 1
## Title: Collect and utilize accurate and disaggregated data as a basis for evidence-based policies
## Associated actions
- a. Elaborate and implement a comprehensive strategy for improving migration data at local, national, regional and global levels, with the participation of all relevant stakeholders, under the guidance of the United Nations Statistical Commission, by harmonizing methodologies for data collection, and strengthening analysis and dissemination of migration-related data and indicators.
- b. Improve international comparability and compatibility of migration statistics and national data systems,including by further developing and applying the statistical definition of an international migrant, elaborating a set of standards to measure migrant stocks and flows, and documenting migration patterns and trends, characteristics of migrants,as well as drivers and impacts of migration.
- c. Develop a global programme to build and enhance national capacities in dat
  • Lookup table relating GCM Objectives to SRF Outputs. For instance, given a particular GCM Objective:
load_gcms_lut()['1']
['1a31',
 '1a32',
 '1b11',
 '3b31',
 '3c13',
 '3c21',
 '3c22',
 '3c31',
 '3c32',
 '3c41',
 '3c43',
 '3d11']

SRF Formatting

Format SRF enablers, cross-cutting priorities, and outputs for LLM consumption with full hierarchical context. These functions produce markdown with headers and descriptions suitable for including in prompts.


fmt_enb_ccp


def fmt_enb_ccp(
    items:list, # List of enabler/CCP dicts with id, title, description
    typ:str, # Type of item (enabler or CCP)
)->str: # Formatted theme

Format enablers or cross-cutting priorities for LLM

Exported source
fmt_enbs = partial(fmt_enb_ccp, typ='SRF Enabler')
fmt_ccps = partial(fmt_enb_ccp, typ='SRF Cross-Cutting Priority')
print(fmt_enbs(load_enbs()[:1]))
## Workforce
**Type:** SRF Enabler
**ID:** 1

IOM’s diverse and capable people are our most valued asset. Through investing in better workforce planning and people management, we will facilitate their professional development and improve their daily workplace experience. IOM will have flexible systems and procedures in place to ensure it can adapt to the future of work while ensuring the safety, security and well-being of its staff. IOM will strengthen its security posture and foster an inclusive and enabling work environment. Our leadership will have the ability to connect, motivate and inspire a sense of our shared vision and values.

get_srf_out


def get_srf_out(
    objectives:list, # SRF objectives structure
    output_id:str, # Output ID to find
)->dict | None: # SRF Output of interest

Retrieve single SRF output with hierarchy

srf_outs = load_srf_outs()
out = get_srf_out(srf_outs, '1a11')
out['output']['title']
'Crisis-affected populations in-need receive dignified shelter and settlement support.'

fmt_srf_out


def fmt_srf_out(
    output_ctx:dict, # Dict with obj, lt_out, st_out, and output fields
)->str: # Formatted SRF output

Format SRF output with hierarchical context for LLM

print(fmt_srf_out(out))
## SRF Output 1a11: Crisis-affected populations in-need receive dignified shelter and settlement support.
### Hierarchical Context
**Objective 1**: Saving lives and protecting people on the move.
**Long-term Outcome 1a:** Human suffering is alleviated while the dignity and rights of people affected by crises are upheld.
**Short-term Outcome 1a1:** Crisis-affected populations have their basic needs met and have minimum living conditions with reduced barriers to access for marginalized and vulnerable individuals.

fmt_srf_outs


def fmt_srf_outs(
    objectives:list, # SRF objectives structure
    output_ids:list, # List of output IDs to format
)->str: # Multiple SRF outputs formatted

Format multiple SRF outputs

print(fmt_srf_outs(srf_outs, ['1a11', '1a31']))
## SRF Output 1a11: Crisis-affected populations in-need receive dignified shelter and settlement support.
### Hierarchical Context
**Objective 1**: Saving lives and protecting people on the move.
**Long-term Outcome 1a:** Human suffering is alleviated while the dignity and rights of people affected by crises are upheld.
**Short-term Outcome 1a1:** Crisis-affected populations have their basic needs met and have minimum living conditions with reduced barriers to access for marginalized and vulnerable individuals.

## SRF Output 1a31: Guidelines on data and information collection, sharing and management are in place that adhere to data protection standards, principles of confidentiality and a defined purpose, to protect the individuals and groups providing information from harm.
### Hierarchical Context
**Objective 1**: Saving lives and protecting people on the move.
**Long-term Outcome 1a:** Human suffering is alleviated while the dignity and rights of people affected by crises are upheld.
**Short-term Outcome 1a3:** Decision makers and responders responsibly use data and its analysis to inform the delivery of assistance to crisis-affected populations.

GCM Functions

Link Global Compact for Migration (GCM) objectives to SRF outputs. The lookup table maps GCM objective IDs to their corresponding SRF output IDs.


get_srf_outs


def get_srf_outs(
    lut:dict, # GCM to SRF lookup dict
    gcm_ids:list, # List of GCM IDs to filter by
)->L: # List of SRF output IDs

Get SRF output IDs filtered by GCM IDs

gcm_lut = load_gcms_lut()
out_ids = get_srf_outs(gcm_lut, ['1', '4'])
out_ids[:5]
['1a31', '1a32', '1b11', '3b31', '3c13']

Convenience Functions

Load all themes at once for quick setup.


load_all_thms


def load_all_thms(
    path:str=None, # Directory containing theme JSON files
)->AttrDict: # Dict with enablers, ccp, gcms, srf_outs, gcm_lut

Load all theme data from path

all_themes = load_all_thms()
all_themes.keys()
dict_keys(['enbs', 'ccps', 'gcms', 'outs', 'gcm_lut'])