Skip to content

Commit

Permalink
Docs: guide on serverless configuration (#63)
Browse files Browse the repository at this point in the history
* Docs: guide on serverless configuration
  • Loading branch information
IceKhan13 authored Nov 16, 2022
1 parent 55b8122 commit c822ca4
Showing 1 changed file with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions docs/guides/03_configuring-quantum-serverless.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# Guide: configuring quantum serverless\n",
"\n",
"In order to use `QuantumServerless` with non-local resources, you need to configure `QuantumServerless` to work with them.\n",
"It is easy to do with constructor arguments.\n",
"\n",
"Let's see how to do that."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"First option is to pass configuration to constructor of `QuantumServerless`\n",
"\n",
"```python\n",
"serverless = QuantumServerless({\n",
"\t\"providers\": [{\n",
"\t\t\"name\": \"my_provider\", # name of provider\n",
"\t\t\"cluster\": { # main computational resource\n",
"\t\t\t\"name\": \"my_cluster\", # name of cluster\n",
"\t\t\t\"host\": \"HOST_ADDRESS_OF_CLUSTER_HEAD_NODE\", # host address of cluster, if you are using helm it will be DEPLOYMENT_NAME-kuberay-head-svc\n",
"\t\t\t\"port\": 10001 # port to connect\n",
"\t\t}\n",
"\t}]\n",
"})\n",
"```"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"Other option will be creating instance from configuration file, which has exactly the same structure as example above\n",
"\n",
"Example of `config.json`\n",
"```json\n",
"{\n",
"\t\"providers\": [{\n",
"\t\t\"name\": \"my_provider\",\n",
"\t\t\"cluster\": {\n",
"\t\t\t\"name\": \"my_cluster\",\n",
"\t\t\t\"host\": \"HOST_ADDRESS_OF_CLUSTER_HEAD_NODE\",\n",
"\t\t\t\"port\": 10001\n",
"\t\t}\n",
"\t}]\n",
"}\n",
"```\n",
"\n",
"Then load this file\n",
"\n",
"```python\n",
"serverless = QuantumServerless.load_configuration(\"./config.json\")\n",
"```"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"You can use it now\n",
"\n",
"```python\n",
"with serverless.provider(\"my_provider\"):\n",
" ...\n",
"```"
],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit c822ca4

Please sign in to comment.