From e443b9897b6f109195070fc950255a477ad8df03 Mon Sep 17 00:00:00 2001 From: radufalcusanStoneone <66017695+radufalcusanStoneone@users.noreply.github.com> Date: Tue, 16 Apr 2024 17:33:22 +0200 Subject: [PATCH] Update 02-local-development.ipynb fix: split the example notebook file into separate sections --- .../notebooks/02-local-development.ipynb | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/coding-templates/python/python-starter/notebooks/02-local-development.ipynb b/coding-templates/python/python-starter/notebooks/02-local-development.ipynb index 569fe95..85d81a5 100644 --- a/coding-templates/python/python-starter/notebooks/02-local-development.ipynb +++ b/coding-templates/python/python-starter/notebooks/02-local-development.ipynb @@ -37,6 +37,97 @@ "\n" ] }, + { + "cell_type": "markdown", + "id": "c8357df8-2375-4e7a-b005-2648a3a3c06d", + "metadata": {}, + "source": [ + "Below is a code snippet demonstrating how to create an instance of the PlanqkServiceClient." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e94dd115-e792-4974-8edb-161331249143", + "metadata": {}, + "outputs": [], + "source": [ + "from planqk.service.client import PlanqkServiceClient\n", + "\n", + "# Your consumer key and secret\n", + "consumer_key = \"your_consumer_key\"\n", + "consumer_secret = \"your_secret_key\"\n", + "\n", + "service_endpoint = \"http://localhost:8081/\"\n", + "\n", + "client = PlanqkServiceClient(service_endpoint, consumer_key, consumer_secret)" + ] + }, + { + "cell_type": "markdown", + "id": "e9c3c40a-44dd-4727-bdc1-f68594734ca0", + "metadata": {}, + "source": [ + "The following code prepares input data and parameters **data** and **params**, then starts an execution using a method **start_execution** with these data and parameters passed as arguments." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "24afa15c-52eb-4c2a-8a1a-9378a75cbaed", + "metadata": {}, + "outputs": [], + "source": [ + "data = {\"dataValue\" : [\"abc\", \"dce\"]}\n", + "params = {\"paramsValue\" : [\"abc\", \"dce\"]}\n", + "\n", + "job = client.start_execution(data=data, params=params)" + ] + }, + { + "cell_type": "markdown", + "id": "081dbdb8-6cb7-4cc8-9993-fcca36f2701b", + "metadata": {}, + "source": [ + "The following snippet utilizes the **get_status** method to retrieve the execution status based on a given ID." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "956ea044-2c83-4d8d-9a6c-fa2fc149f74b", + "metadata": {}, + "outputs": [], + "source": [ + "job = client.get_status(job.id)" + ] + }, + { + "cell_type": "markdown", + "id": "ae5752c4-df03-422d-9e8f-050637e353dc", + "metadata": {}, + "source": [ + "The following line fetches the result of an execution for a given ID using the **get_result** method." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c6ca5cb1-2d95-4d01-b010-42b55699e325", + "metadata": {}, + "outputs": [], + "source": [ + "result = client.get_result(job.id)" + ] + }, + { + "cell_type": "markdown", + "id": "5f1c63ac-a4e9-4594-8f2b-14ef180709b1", + "metadata": {}, + "source": [ + "Here is the full code to utilize the PlanQK Service for local development using PlanQK CLI:" + ] + }, { "cell_type": "code", "execution_count": 17,