Themes

Load the SRF and GCM theme files, and format themes as Markdown for the mapping prompts

source

load_thm

def load_thm(
    fname:str, # File name, such as `'srf_enablers.json'`
    path:str=None, # Folder of theme files; `None` uses the files shipped with the package
    md:bool=False, # Return the file's text instead of parsing it as JSON?
)->dict | str: # Parsed JSON, or the text with `md=True`

Load the theme file fname from path

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')

The package ships the theme files of the SRF and the GCM, and each theme set has its own loader. The SRF files are JSON. The GCM objectives are a Markdown file, and the GCM prompt uses it as it is.

load_enbs loads the SRF enablers:

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.'}

load_ccps loads the SRF cross-cutting priorities:

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.'}

load_srf_outs loads the SRF objectives. Each objective contains long-term outcomes, each long-term outcome contains short-term outcomes, and each short-term outcome contains SRF outputs:

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.'}]}]}]}

load_gcms loads the objectives of the Global Compact for Migration (GCM) as Markdown:

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

load_gcms_lut loads the table that links each GCM objective ID to the IDs of related SRF outputs. For GCM objective 1:

load_gcms_lut()['1']
['1a31',
 '1a32',
 '1b11',
 '3b31',
 '3c13',
 '3c21',
 '3c22',
 '3c31',
 '3c32',
 '3c41',
 '3c43',
 '3d11']

SRF formatting

The mapping prompts list the themes as Markdown. fmt_enbs and fmt_ccps format each enabler or priority with its title, type, ID and description. fmt_srf_outs formats each output with the titles of the objective and outcomes above it.


source

fmt_enb_ccp

def fmt_enb_ccp(
    items:list, # Enablers or priorities, each a dict with `id`, `title` and `description`
    typ:str, # Label for the `Type:` line, such as `'SRF Enabler'`
)->str: # One Markdown section per item

Format enablers or cross-cutting priorities as Markdown

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.

source

get_srf_out

def get_srf_out(
    objectives:list, # SRF objectives from `load_srf_outs`
    output_id:str, # Output ID, such as `'1a11'`
)->dict | None: # The output with its objective and outcomes; `None` if not found

Find the SRF output output_id and the objective and outcomes above it

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.'

source

fmt_srf_out

def fmt_srf_out(
    output_ctx:dict, # Output and its context, from `get_srf_out`
)->str: # Markdown section for the output

Format an SRF output as Markdown, with the titles of its objective and outcomes

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.

source

fmt_srf_outs

def fmt_srf_outs(
    objectives:list, # SRF objectives from `load_srf_outs`
    output_ids:list, # Output IDs; each must exist in `objectives`
)->str: # One Markdown section per output

Format the SRF outputs output_ids as Markdown

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.

SRF outputs linked to GCM objectives

The pipeline maps a report against the SRF outputs linked to its top GCM objective, not against every output. get_srf_outs looks up those outputs in the table from load_gcms_lut.


source

get_srf_outs

def get_srf_outs(
    lut:dict, # GCM objective ID to SRF output IDs, from `load_gcms_lut`
    gcm_ids:list, # GCM objective IDs
)->fastcore.foundation.L: # SRF output IDs, in table order; an output linked to two objectives appears twice

Get the IDs of the SRF outputs linked to gcm_ids

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

Loading every theme


source

load_all_thms

def load_all_thms(
    path:str=None, # Folder of theme files; `None` uses the files shipped with the package
)->fastcore.basics.AttrDict: # `enbs`, `ccps`, `gcms`, `outs` and `gcm_lut`

Load every theme file from path

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