-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push notebook for remote multiopti runs
- Loading branch information
1 parent
01124dc
commit cd87bb9
Showing
1 changed file
with
196 additions
and
0 deletions.
There are no files selected for viewing
196 changes: 196 additions & 0 deletions
196
notebooks/user/rragonnet/project_specific/School_Closure/remote/sb_multi_opti.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f5408fea", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from autumn.infrastructure.remote import springboard\n", | ||
"from autumn.projects.sm_covid2.common_school.runner_tools import INCLUDED_COUNTRIES\n", | ||
"from autumn.projects.sm_covid2.common_school.runner_tools import multi_country_optimise, print_continuous_status, download_analysis" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "af76753d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"iso3_list = list(INCLUDED_COUNTRIES['google_mobility'].keys())\n", | ||
"len(iso3_list)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a31106a5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"iso3_list = iso3_list[:48]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d0149785", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"len(iso3_list)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5337273f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"N_CPUS = 64\n", | ||
"N_OPTI_WORKERS = 8\n", | ||
"assert N_CPUS % N_OPTI_WORKERS == 0" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "47d05a73", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def remote_multi_opti_task(bridge: springboard.task.TaskBridge, iso3_list: list):\n", | ||
" \n", | ||
" import multiprocessing as mp\n", | ||
" mp.set_start_method('forkserver')\n", | ||
"\n", | ||
" bridge.logger.info(f\"Running optimisation for {len(iso3_list)} countries.\")\n", | ||
"\n", | ||
" n_parallel_opti_jobs = N_CPUS / N_OPTI_WORKERS\n", | ||
"\n", | ||
" multi_country_optimise(\n", | ||
" iso3_list=iso3_list, \n", | ||
" num_workers = 8, \n", | ||
" search_iterations = 15000, \n", | ||
" parallel_opti_jobs = int(n_parallel_opti_jobs), \n", | ||
" out_path=bridge.out_path,\n", | ||
" logger=bridge.logger\n", | ||
" )\n", | ||
" \n", | ||
" bridge.logger.info(\"Full analysis complete\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1a1207a8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"mspec = springboard.EC2MachineSpec(N_CPUS, 4, \"compute\")\n", | ||
"task_kwargs = {\n", | ||
" \"iso3_list\": iso3_list,\n", | ||
"}\n", | ||
"tspec = springboard.TaskSpec(remote_multi_opti_task, task_kwargs)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e12adbec", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"analysis_title = \"multi_opti_first48_60dupdate\"\n", | ||
"run_path = springboard.launch.get_autumn_project_run_path(\"school_project\", \"multicountry\", analysis_title)\n", | ||
"run_path" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "16657a60", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"runner = springboard.launch.launch_synced_autumn_task(tspec, mspec, run_path)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b416f02f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"runner.s3.get_status()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9ba7f60c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# runner.sshr.run(\"sudo shutdown now\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bc0faa03", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# wait function with status printing\n", | ||
"print_continuous_status(runner)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f8019dfb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# run_path = 'projects/school_project/multicountry/2023-07-05T2142-multi_opti'\n", | ||
"# run_path = 'projects/school_project/multicountry/2023-07-07T1117-multi_opti_first48_60dupdate'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a8d31fe3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"download_analysis(run_path)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.11" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |