Skip to content

Commit

Permalink
files documentation updated (#1565)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tansito authored Jan 7, 2025
1 parent f50a7f9 commit 62848f0
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 67 deletions.
70 changes: 45 additions & 25 deletions docs/getting_started/experimental/file_download.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@
"\n",
"In this tutorial we will describe a way to retrieve files produced by Qiskit Functions.\n",
"\n",
"This function provides a way to download files produced by functions during execution. All you need is to call `QiskitServerless.download` function and pass `tar` file name to start downloading the file. Or you can list all available files to you by calling `QiskitServerless.files`.\n",
"This function provides a way to download files produced by functions during execution. All you need is to call `QiskitServerless.file_download` function and pass a file name and the Qiskit Function to start downloading the file. Or you can list all available files to you by calling `QiskitServerless.files`.\n",
"\n",
"Limitations:\n",
"\n",
"- only `tar` and `h5` files are supported\n",
"- `tar` or `h5` file should be saved in `/data` directory during your function execution to be visible by `.files()` method call\n",
"- only `/data` directory is supported, `/data/other_folder` will not be visible\n",
"- files should be saved in `/data` directory during your function execution to be visible by `.files()` method call.\n",
"- only `/data` directory is supported, `/data/other_folder` will not be visible.\n",
"- as a provider you have access to `/function-data`, it works in a similar way as the `/data` folder with the distinction that users don't have access to it. Only the providers of the specific functions can see files under that path.\n",
"\n",
"> ⚠ This interface is experimental, therefore it is subjected to breaking changes.\n",
"- Qiskit Functions created by you and Qiskit Functions created by others don't share directories.\n",
"\n",
"> ⚠ This provider is set up with default credentials to a test cluster intended to run on your machine. For information on setting up infrastructure on your local machine, check out the guide on [local infrastructure setup](https://qiskit.github.io/qiskit-serverless/deployment/local.html)."
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "93717e14-d06e-4e11-bd5b-6cdc3f1b1abd",
"metadata": {},
"outputs": [
Expand All @@ -35,7 +33,7 @@
"<gateway-client>"
]
},
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -46,7 +44,7 @@
"\n",
"serverless = ServerlessClient(\n",
" token=os.environ.get(\"GATEWAY_TOKEN\", \"awesome_token\"),\n",
" host=os.environ.get(\"GATEWAY_HOST\", \"http://localhost:8000\"),\n",
" host=os.environ.get(\"GATEWAY_HOST\", \"http://localhost\"),\n",
" # If you are using the kubernetes approach the URL must be http://localhost\n",
")\n",
"serverless"
Expand All @@ -62,7 +60,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "8d93f33b-f7f1-475d-b46e-1106cbe45cae",
"metadata": {},
"outputs": [
Expand All @@ -72,7 +70,7 @@
"QiskitFunction(file-producer)"
]
},
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -87,29 +85,51 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "3577cc07",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"QiskitFunction(file-producer)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"my_function = serverless.get(\"file-producer\")\n",
"my_function"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "3fef0868-7574-4fbf-b8de-4a7889bdf5ec",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Job | 6be3ac4d-b20e-4493-9961-a187847cff49>"
"<Job | 4868d039-3342-4f3e-b843-c0d15ad52fe6>"
]
},
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"job = serverless.run(\"file-producer\")\n",
"job = my_function.run()\n",
"job"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"id": "ecd0bb68-4d3c-450e-b363-a58fd91880b3",
"metadata": {},
"outputs": [
Expand All @@ -119,7 +139,7 @@
"{'Message': 'my_file.txt archived into my_file.tar'}"
]
},
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -138,7 +158,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"id": "08205fd4-b3d6-44d1-a33c-fb3918c26b12",
"metadata": {},
"outputs": [
Expand All @@ -148,13 +168,13 @@
"['my_file.tar']"
]
},
"execution_count": 5,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"available_files = serverless.files()\n",
"available_files = serverless.files(my_function)\n",
"available_files"
]
},
Expand All @@ -168,30 +188,30 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 10,
"id": "39ca652d-77d7-49d2-97e9-42b60963a671",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 201/201 [00:00<00:00, 331kiB/s]\n"
"100%|██████████| 200/200 [00:00<00:00, 309kiB/s]\n"
]
},
{
"data": {
"text/plain": [
"'downloaded_91ea37d9_my_file.tar'"
"'downloaded_8d3f92ba_my_file.tar'"
]
},
"execution_count": 6,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"serverless.file_download(available_files[0])"
"serverless.file_download(available_files[0], my_function)"
]
}
],
Expand Down
Loading

0 comments on commit 62848f0

Please sign in to comment.