Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Oct 24, 2024
1 parent 728d330 commit 860e5f9
Showing 1 changed file with 19 additions and 226 deletions.
245 changes: 19 additions & 226 deletions example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import adaptive_scheduler\n",
"import random\n",
"\n",
"\n",
"def h(x, width=0.01, offset=0):\n",
" for _ in range(10): # Burn some CPU time just because\n",
" np.linalg.eig(np.random.rand(10, 10))\n",
" return x + width**2 / (width**2 + (x - offset) ** 2)\n",
"\n",
" np.linalg.eig(np.random.rand(1000, 1000))\n",
" return x + width ** 2 / (width ** 2 + (x - offset) ** 2)\n",
"\n",
"# Define the sequence/samples we want to run\n",
"xs = np.linspace(0, 1, 10_000)\n",
Expand All @@ -42,221 +40,29 @@
" h, xs, n_learners=10\n",
")\n",
"\n",
"run_managers = [\n",
" adaptive_scheduler.slurm_run(\n",
" [learner],\n",
" [fname],\n",
" # Below are all optional arguments!\n",
" exclusive=False, # whether to run 1 job per node or not\n",
" nodes=1, # number of nodes per `learner`\n",
" cores_per_node=1, # number of cores on 1 node per `learner`\n",
" log_interval=5, # how often to produce a log message\n",
" save_interval=5, # how often to save the results\n",
" name=f\"test{i}\", \n",
" quiet=True,\n",
" ).start()\n",
" for i, (learner, fname) in enumerate(zip(learners, fnames))\n",
"]\n",
"from adaptive_scheduler.server_support import MultiRunManager"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7331cc1bb8784b67983cabeb564538ae",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='\\n <style>\\n .jupyter-widgets-output-area .output_scroll {\\n heig…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "49bfff5aad674e8b89443a37fe8cf0bf",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Button(button_style='info', description='Update All', style=ButtonStyle(), tooltip='Update all …"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rm = MultiRunManager(run_managers[:3])\n",
"rm.info()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5167829b42f64c47b2c0204833a5407e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='\\n <style>\\n .jupyter-widgets-output-area .output_scroll {\\n heig…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "693fbc17c9224e53a6eaa38f63072596",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(HTML(value='\\n <table>\\n <tr><th style=\"text-align: right; padding…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"w = run_managers[0].info()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(Button(description='update info', icon='refresh', layout=Layout(width='200px'), style=ButtonStyle(button_color='lightgreen')),\n",
" HBox(children=(Button(button_style='danger', description='cancel jobs', icon='stop', layout=Layout(width='200px'), style=ButtonStyle()),), layout=Layout(width='200px')),\n",
" HBox(children=(Button(button_style='danger', description='cleanup log and batch files', icon='remove', layout=Layout(width='200px'), style=ButtonStyle()),), layout=Layout(width='200px')),\n",
" Button(button_style='info', description='load learners', icon='download', layout=Layout(width='200px'), style=ButtonStyle()),\n",
" Button(button_style='info', description='show logs', icon='book', layout=Layout(width='200px'), style=ButtonStyle()),\n",
" Button(button_style='info', description='show queue', icon='tasks', layout=Layout(width='200px'), style=ButtonStyle()),\n",
" Button(button_style='info', description='show database', icon='database', layout=Layout(width='200px'), style=ButtonStyle()),\n",
" Button(button_style='info', description='show results', icon='table', layout=Layout(width='200px'), style=ButtonStyle()))"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"w.children[0].children[1].children"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"rm.remove_run_manager(\"test1\")"
"run_manager = adaptive_scheduler.slurm_run(\n",
" learners,\n",
" fnames,\n",
" # Below are all optional arguments!\n",
" exclusive=False, # whether to run 1 job per node or not\n",
" nodes=1, # number of nodes per `learner`\n",
" cores_per_node=1, # number of cores on 1 node per `learner`\n",
" log_interval=5, # how often to produce a log message\n",
" save_interval=5, # how often to save the results\n",
")\n",
"run_manager.start()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rm.add_run_manager(run_managers[5])"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e4338a7bdc094440ba8037c31f2d5514",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='\\n <style>\\n .jupyter-widgets-output-area .output_scroll {\\n heig…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7596123b8f894eb09dceb46b53a322a2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='\\n <style>\\n .jupyter-widgets-output-area .output_scroll {\\n heig…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7f85366fb5d34e0891cbdb3d09a75b24",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='\\n <style>\\n .jupyter-widgets-output-area .output_scroll {\\n heig…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "627e5ac5b49f4b54b5f6c37cf5efe6e7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Tab(children=(VBox(children=(HBox(children=(HTML(value='\\n <table>\\n <tr><th style=\"text-align: …"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rm.info()"
"# Print the results with\n",
"run_manager.load_dataframes()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -272,7 +78,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -659,22 +465,9 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.13.0"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 860e5f9

Please sign in to comment.