Skip to content

Instantly share code, notes, and snippets.

@annawoodard
Created April 24, 2020 19:12
Show Gist options
  • Save annawoodard/4bdda9fe36fa0adb001ab4eaa7478b61 to your computer and use it in GitHub Desktop.
Save annawoodard/4bdda9fe36fa0adb001ab4eaa7478b61 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<parsl.dataflow.dflow.DataFlowKernel at 0x7f2150135278>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import parsl\n",
"from parsl import python_app\n",
"\n",
"\n",
"from parsl.configs.htex_local import config\n",
"config.executors[0].max_workers = 4\n",
"parsl.load(config)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"@python_app\n",
"def get_ones(shape):\n",
" import numpy as np\n",
" \n",
" return np.ones(shape)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"futures = [get_ones((1, 2)) for i in range(2)]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[1. 1.]]\n",
"[[1. 1.]]\n"
]
}
],
"source": [
"for f in futures:\n",
" try:\n",
" print(f.result())\n",
" except Exception as e:\n",
" print(e)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"futures = [get_ones((100, 2)) for i in range(2)]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Task failure due to loss of worker 2 on host kg15-9\n",
"Task failure due to loss of worker 3 on host kg15-9\n"
]
}
],
"source": [
"for f in futures:\n",
" try:\n",
" print(f.result())\n",
" except Exception as e:\n",
" print(e)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"np.ones((100, 2))"
]
}
],
"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.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment