Downloaders

Download the documents of IOM evaluations, one folder per evaluation

download_eval saves every document of an Evaluation in dst/<id>/, named after the last part of its URL. Report.download in the pipeline uses it. download_evals runs it on many evaluations in parallel. Both read the evaluation’s fields through cfg, which defaults to default_config.


source

download_eval

def download_eval(
    eval:iomeval.readers.Evaluation, # Evaluation whose documents to download
    dst:str='files/test/eval_reports', # Folder to create the evaluation's folder in
    cfg:dict={'id': 'id', 'docs': 'docs', 'url': 'url'}, # Names of the `id`, `docs` and `url` fields
)->pathlib.Path: # The evaluation's folder, `dst/<id>/`

Download every document of eval to dst/<id>/, overwriting files with the same name

fname = 'files/test/evaluations.json'
evals = load_evals(fname)
evl = evals[0]
evl

EVALUATION OF IOM’S MIGRATION DATA STRATEGY

Year: 2025 | Organization: IOM | Countries: Worldwide

Documents: 2 available
ID: 9992310969aa2f428bc8aba29f865cf3

eval_dir = download_eval(evals[0])
eval_dir.ls()
(#2) [Path('files/test/eval_reports/9992310969aa2f428bc8aba29f865cf3/Annex%20VII%20Case%20Study%20-%20RDH%20Asia-Pacific.pdf'),Path('files/test/eval_reports/9992310969aa2f428bc8aba29f865cf3/Annex%20VI%20Case%20Study%20-%20RDH%20East%2C%20Horn%20and%20Southern%20Africa.pdf')]
%ls files/test/eval_reports/*
files/test/eval_reports/2b297bc904ed1e542fbe67f62a8ea7cf:
Meta-Evaluation-Infographics.pdf
Meta-evaluation%202020-2024%20-%20Evaluation%20Brief_0.pdf
Meta-evaluation%202020-2024%20report%20-%20clean.pdf

files/test/eval_reports/8faad6edb0414cfc8f35415a93726e36:
CS1137-CS1138_Evaluation%20Brief_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Evaluation%20ToR_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Final%20Report_French_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Final%20Report_Spanish_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Inception%20Report_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Management%20Response%20Plan_Javier%20SANCHEZ%20MARTI.pdf

files/test/eval_reports/9992310969aa2f428bc8aba29f865cf3:
Annex%20VI%20Case%20Study%20-%20RDH%20East%2C%20Horn%20and%20Southern%20Africa.pdf
Annex%20VII%20Case%20Study%20-%20RDH%20Asia-Pacific.pdf

source

download_evals

def download_evals(
    evals:fastcore.foundation.L, # Evaluations, or a single `Evaluation`
    dst:str='files/test/eval_reports', # Folder to create the evaluations' folders in
    cfg:dict={'id': 'id', 'docs': 'docs', 'url': 'url'}, # Names of the `id`, `docs` and `url` fields
    n_workers:int=4, # Number of parallel downloads
)->fastcore.foundation.L: # The evaluations' folders

Download the documents of evals in parallel, one folder per evaluation

eval_dirs = download_evals(evals[:3])
eval_dirs
(#3) [Path('files/test/eval_reports/9992310969aa2f428bc8aba29f865cf3'),Path('files/test/eval_reports/2b297bc904ed1e542fbe67f62a8ea7cf'),Path('files/test/eval_reports/8faad6edb0414cfc8f35415a93726e36')]
%ls files/test/eval_reports/*
files/test/eval_reports/2b297bc904ed1e542fbe67f62a8ea7cf:
Meta-Evaluation-Infographics.pdf
Meta-evaluation%202020-2024%20-%20Evaluation%20Brief_0.pdf
Meta-evaluation%202020-2024%20report%20-%20clean.pdf

files/test/eval_reports/8faad6edb0414cfc8f35415a93726e36:
CS1137-CS1138_Evaluation%20Brief_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Evaluation%20ToR_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Final%20Report_French_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Final%20Report_Spanish_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Inception%20Report_Javier%20SANCHEZ%20MARTI.pdf
CS1137-CS1138_Management%20Response%20Plan_Javier%20SANCHEZ%20MARTI.pdf

files/test/eval_reports/9992310969aa2f428bc8aba29f865cf3:
Annex%20VI%20Case%20Study%20-%20RDH%20East%2C%20Horn%20and%20Southern%20Africa.pdf
Annex%20VII%20Case%20Study%20-%20RDH%20Asia-Pacific.pdf