source
download_eval
download_eval (eval:evaluatr.readers.Evaluation,
base_path:str='files/test/eval_reports', cfg:dict={'id':
'id', 'docs': 'docs', 'url': 'url'})
Download all documents for an evaluation to base_path/eval_id/
eval
Evaluation
Evaluation object
base_path
str
files/test/eval_reports
Base path to save files
cfg
dict
{‘id’: ‘id’, ‘docs’: ‘docs’, ‘url’: ‘url’}
Configuration dictionary
Exported source
def download_eval(
eval :Evaluation, # Evaluation object
base_path:str = 'files/test/eval_reports' , # Base path to save files
cfg:dict = default_config # Configuration dictionary
):
"Download all documents for an evaluation to base_path/eval_id/"
eval_dir = Path(base_path)/ getattr (eval , cfg.id )
eval_dir.mkdir(parents= True , exist_ok= True )
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' }
for doc in getattr (eval , cfg.docs):
url = doc[cfg.url]
fname = Path(urlparse(url).path).name
dest = eval_dir/ fname
urlsave(url, dest, headers= headers)
return eval_dir
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')]
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
download_evals (evals:fastcore.foundation.L,
base_path:str='files/test/eval_reports', cfg:dict={'id':
'id', 'docs': 'docs', 'url': 'url'}, n_workers:int=4)
Download all documents for multiple evaluations in parallel
evals
L
list of evaluation records
base_path
str
files/test/eval_reports
base path to save documents
cfg
dict
{‘id’: ‘id’, ‘docs’: ‘docs’, ‘url’: ‘url’}
config dictionary
n_workers
int
4
number of workers to use
Exported source
def download_evals(
evals:L, # list of evaluation records
base_path:str = 'files/test/eval_reports' , # base path to save documents
cfg:dict = default_config, # config dictionary
n_workers:int = 4 # number of workers to use
):
"Download all documents for multiple evaluations in parallel"
return parallel(partial(download_eval, base_path= base_path, cfg= cfg), evals, n_workers= n_workers, progress= True )
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')]
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