From 3177ae1f9b8241fb4e99afca0eea9855cf3d7e9d Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Tue, 31 Aug 2021 20:47:04 -0400 Subject: [PATCH 01/17] add search method --- escalateclient/escalateclient.py | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/escalateclient/escalateclient.py b/escalateclient/escalateclient.py index 56f5c3c..ed7d4cb 100644 --- a/escalateclient/escalateclient.py +++ b/escalateclient/escalateclient.py @@ -54,6 +54,66 @@ def get(self, return r.json()['results'] print('Returning response object') return r + + def search(self, + endpoint='', + search_field='', + criteria= '', + data=None, + exact=False, + parse_json=True, + content_type='application/json'): + + if exact==True: + if data == None: + r = requests.get(f'{self.base_url}/api/{endpoint}/?{search_field}={criteria}', + headers={**self._token_header, + 'content-type': content_type}) + else: + i=0 + string='' + while i= 1: + print(f"Found {resp_json['count']} resources, returning list of dicts)") + return r.json()['results'] + print('Returning response object') + return r def post(self, endpoint, From a7cc72a703f7bc5c0497637214aa4e3dfd0e4860 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Thu, 2 Sep 2021 12:45:26 -0400 Subject: [PATCH 02/17] Update search and add patch --- escalateclient/escalateclient.py | 179 +++++++++++++++++++++++++------ 1 file changed, 149 insertions(+), 30 deletions(-) diff --git a/escalateclient/escalateclient.py b/escalateclient/escalateclient.py index ed7d4cb..4fa7cc2 100644 --- a/escalateclient/escalateclient.py +++ b/escalateclient/escalateclient.py @@ -56,44 +56,151 @@ def get(self, return r def search(self, - endpoint='', + endpoint='', + related_ep=None, #for cross-searches search_field='', criteria= '', - data=None, + data=None, #must be a list exact=False, + negate=False, parse_json=True, content_type='application/json'): + + if negate==False: + + if exact==True: + if data == None: + '''Returns all fields for exact match''' + if related_ep == None: + + r = requests.get(f'{self.base_url}/api/{endpoint}/?{search_field}={criteria}', + headers={**self._token_header, + 'content-type': content_type}) + else: #cross-search + r = requests.get(f'{self.base_url}/api/{endpoint}/?{related_ep}__{search_field}={criteria}', + headers={**self._token_header, + 'content-type': content_type}) + + else: + '''Returns requested field(s) for exact match''' + i=0 + data_string='' + while i Date: Thu, 2 Sep 2021 12:50:44 -0400 Subject: [PATCH 03/17] add search() and patch() descriptions to basic usage --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8e57ac0..833725d 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,11 @@ escalate=ESCALATEClient(escalate_url, escalate.list_endpoints() +escalate.search(endpoint, search_field, criteria, data=[], exact=False, negate=False) + escalate.get(endpoint, data={}) escalate.post(endpoint, data={}) +escalate.patch(resource_url, data={}) escalate.put(resource_url, data={}) escalate.delete(resource_url) ``` From a7ced01630fab5e477e2bf1524c194e9a6539911 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:25:51 -0400 Subject: [PATCH 04/17] Create basic --- Demos/basic | 1 + 1 file changed, 1 insertion(+) create mode 100644 Demos/basic diff --git a/Demos/basic b/Demos/basic new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Demos/basic @@ -0,0 +1 @@ + From aed2b91eb35818eb01a83f40ac07fc4b76c176f7 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:26:30 -0400 Subject: [PATCH 05/17] Add files via upload --- ...I Demo - Using the Client Library(1).ipynb | 1111 +++++++++++++++++ 1 file changed, 1111 insertions(+) create mode 100644 Demos/REST API Demo - Using the Client Library(1).ipynb diff --git a/Demos/REST API Demo - Using the Client Library(1).ipynb b/Demos/REST API Demo - Using the Client Library(1).ipynb new file mode 100644 index 0000000..809d341 --- /dev/null +++ b/Demos/REST API Demo - Using the Client Library(1).ipynb @@ -0,0 +1,1111 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Using the ESCALATEClient REST API Client\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "#factor this out when it's imported into the client\n", + "\n", + "import json\n", + "import os\n", + "\n", + "from pprint import pprint\n", + "import pandas as pd\n", + "import requests\n", + "\n", + "class ESCALATEClient():\n", + " \"\"\"ESCALATE API Client\"\"\"\n", + " \n", + " def __init__(self, base_url, username, password):\n", + " self.base_url = base_url\n", + " self.username = username\n", + " self.password = password\n", + " self._token = None\n", + " self._is_logged_in = False\n", + " self._login()\n", + " \n", + " def _login(self):\n", + " r_login = requests.post(f'{self.base_url}/api/login', \n", + " data={'username': self.username, \n", + " 'password': self.password})\n", + " self._token = r_login.json()['token']\n", + " self._token_header = {'Authorization': f'Token {self._token}'}\n", + " self._is_logged_in = True\n", + " \n", + " def get(self, \n", + " endpoint='', \n", + " data=None, \n", + " parse_json=True, \n", + " content_type='application/json'):\n", + " \"\"\"Make GET request with `data` to `endpoint` in ESCALATE API\n", + " \n", + " return: (dict|list|requests.Response), bool\n", + " \"\"\"\n", + " data = {} if data is None else data\n", + " r = requests.get(f'{self.base_url}/api/{endpoint}',\n", + " params=data, \n", + " headers={**self._token_header, \n", + " 'content-type': content_type})\n", + " if r.ok: \n", + " print('GET: OK')\n", + " else: \n", + " print('GET: FAILED')\n", + " \n", + " if r.ok and parse_json:\n", + " resp_json = r.json() \n", + " # handle cases: no vs one vs many results\n", + " count = resp_json.get('count')\n", + " if count is None or count == 0:\n", + " return r.json()\n", + " elif count == 1: \n", + " print('Found one resource, returning dict')\n", + " return resp_json['results'][0]\n", + " elif count >= 1: \n", + " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", + " return r.json()['results']\n", + " print('Returning response object') \n", + " return r\n", + " \n", + " def post(self, \n", + " endpoint, \n", + " data, \n", + " content_type='application/json'):\n", + " \"\"\"POST `data` to `endpoint`in ESCALATE API using `content_type`\n", + " return: (dict|requests.Response), bool\n", + " \"\"\"\n", + " \n", + " if not self._is_logged_in:\n", + " raise ValueError(\"Not logged in: cannot post\")\n", + " \n", + " r = requests.api.post(\n", + " f'{self.base_url}/api/{endpoint}', \n", + " data=json.dumps(data), \n", + " headers={**self._token_header,\n", + " 'content-type': content_type})\n", + " print(r)\n", + " if r.ok: \n", + " print('POST: OK, returning new resource dict')\n", + " return r.json()\n", + " print('POST: FAILED, returning response object')\n", + " return r\n", + " \n", + " def put(self, url=None, endpoint=None, resource_id=None, data=None):\n", + " \"\"\"Update a complete resource\n", + " Either provide a url or an endpoint and resource id\n", + " \"\"\"\n", + " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", + " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", + " \n", + " if url is None: \n", + " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", + " r = requests.api.put(url, data, headers=self._token_header)\n", + " return r\n", + " \n", + " def patch(self, url=None, endpoint=None, resource_id=None, data=None):\n", + " \"\"\"Update parts of a resource\n", + " Either provide a url or an endpoint and resource id\n", + " \"\"\"\n", + " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", + " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", + " \n", + " if url is None: \n", + " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", + " r = requests.api.patch(url, data, headers=self._token_header)\n", + " return r\n", + " \n", + " def delete(self, url=None, endpoint=None, resource_id=None):\n", + " \"\"\"Delete a resource\n", + " Either provide a url or an endpoint and resource id\n", + " \"\"\"\n", + " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", + " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", + " if url is None: \n", + " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", + " r = requests.api.delete(url, headers=self._token_header)\n", + " return r\n", + " \n", + " def search(self, \n", + " endpoint='',\n", + " related_ep=None, #for cross-searches\n", + " search_field='',\n", + " criteria= '',\n", + " data=None, #must be a list\n", + " exact=False,\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json'):\n", + " \n", + " if negate==False:\n", + "\n", + " if exact==True:\n", + " if data == None:\n", + " '''Returns all fields for exact match'''\n", + " if related_ep == None:\n", + "\n", + " r = requests.get(f'{self.base_url}/api/{endpoint}/?{search_field}={criteria}', \n", + " headers={**self._token_header, \n", + " 'content-type': content_type})\n", + " else: #cross-search \n", + " r = requests.get(f'{self.base_url}/api/{endpoint}/?{related_ep}__{search_field}={criteria}', \n", + " headers={**self._token_header, \n", + " 'content-type': content_type})\n", + "\n", + " else:\n", + " '''Returns requested field(s) for exact match'''\n", + " i=0\n", + " data_string=''\n", + " while i= 1: \n", + " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", + " return r.json()['results']\n", + " print('Returning response object') \n", + " return r\n", + " \n", + " def list_endpoints(self):\n", + " return self.get()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import the API Client." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import escalateclient\n", + "from escalateclient import ESCALATEClient" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Enter your ESCALATE username and password, and the port number at which the server is running. Then run the following cell. This will create an instance of the API Client and set up a token to interact with the REST API." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "username= 'nsmina'\n", + "password= 'password11'\n", + "port='8000'\n", + "\n", + "escalate = ESCALATEClient(\n", + " f'http://localhost:{port}',\n", + " username,\n", + " password\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To see all the model endpoints (this is also a good way to verify that you are connected):" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n" + ] + }, + { + "data": { + "text/plain": [ + "{'action': 'http://localhost:8000/api/action/',\n", + " 'actiondef': 'http://localhost:8000/api/action-def/',\n", + " 'actionunit': 'http://localhost:8000/api/action-unit/',\n", + " 'actor': 'http://localhost:8000/api/actor/',\n", + " 'basebommaterial': 'http://localhost:8000/api/base-bom-material/',\n", + " 'billofmaterials': 'http://localhost:8000/api/bill-of-materials/',\n", + " 'bomcompositematerial': 'http://localhost:8000/api/bom-composite-material/',\n", + " 'bommaterial': 'http://localhost:8000/api/bom-material/',\n", + " 'calculation': 'http://localhost:8000/api/calculation/',\n", + " 'calculationdef': 'http://localhost:8000/api/calculation-def/',\n", + " 'condition': 'http://localhost:8000/api/condition/',\n", + " 'conditiondef': 'http://localhost:8000/api/condition-def/',\n", + " 'experiment': 'http://localhost:8000/api/experiment/',\n", + " 'experimentinstance': 'http://localhost:8000/api/experiment-instance/',\n", + " 'experimenttemplate': 'http://localhost:8000/api/experiment-template/',\n", + " 'experimenttype': 'http://localhost:8000/api/experiment-type/',\n", + " 'experimentworkflow': 'http://localhost:8000/api/experiment-workflow/',\n", + " 'inventory': 'http://localhost:8000/api/inventory/',\n", + " 'inventorymaterial': 'http://localhost:8000/api/inventory-material/',\n", + " 'material': 'http://localhost:8000/api/material/',\n", + " 'materialidentifier': 'http://localhost:8000/api/material-identifier/',\n", + " 'materialidentifierdef': 'http://localhost:8000/api/material-identifier-def/',\n", + " 'materialtype': 'http://localhost:8000/api/material-type/',\n", + " 'measure': 'http://localhost:8000/api/measure/',\n", + " 'measuredef': 'http://localhost:8000/api/measure-def/',\n", + " 'measuretype': 'http://localhost:8000/api/measure-type/',\n", + " 'mixture': 'http://localhost:8000/api/mixture/',\n", + " 'organization': 'http://localhost:8000/api/organization/',\n", + " 'outcome': 'http://localhost:8000/api/outcome/',\n", + " 'parameterdef': 'http://localhost:8000/api/parameter-def/',\n", + " 'person': 'http://localhost:8000/api/person/',\n", + " 'propertydef': 'http://localhost:8000/api/property-def/',\n", + " 'status': 'http://localhost:8000/api/status/',\n", + " 'systemtool': 'http://localhost:8000/api/systemtool/',\n", + " 'systemtooltype': 'http://localhost:8000/api/systemtool-type/',\n", + " 'tag': 'http://localhost:8000/api/tag/',\n", + " 'tagtype': 'http://localhost:8000/api/tag-type/',\n", + " 'typedef': 'http://localhost:8000/api/type-def/',\n", + " 'udfdef': 'http://localhost:8000/api/udf-def/',\n", + " 'unittype': 'http://localhost:8000/api/unit-type/',\n", + " 'vessel': 'http://localhost:8000/api/vessel/',\n", + " 'workflow': 'http://localhost:8000/api/workflow/',\n", + " 'workflowactionset': 'http://localhost:8000/api/workflow-action-set/',\n", + " 'workflowobject': 'http://localhost:8000/api/workflow-object/',\n", + " 'workflowstep': 'http://localhost:8000/api/workflow-step/',\n", + " 'workflowtype': 'http://localhost:8000/api/workflow-type/'}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.list_endpoints()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Searching the database\n", + "\n", + "To search the database for an existing material (or action, or workflow, or any endpoint)... enter the endpoint below. Make sure it is one of the existing endpoints in the database. \n", + "\n", + "Choose a field by which to search this database. For instance, you can look up a material by its description (which corresponds to the name of the material). Enter that as well. Then enter your search criteria and whether it is exact (True or False). \n", + "\n", + "Suppose that we want to look up Lead Diiodide and return all the exact matches. Note that exact match searches are case-sensitive, so if you did not capitalize the first letter of each word in the name, you would get no results." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", + " 'uuid': '28fe860b-44ae-4737-9fc9-b1714facc07d',\n", + " 'edocs': [],\n", + " 'tags': [],\n", + " 'notes': [],\n", + " 'property': [],\n", + " 'add_date': '2021-08-31T18:59:22.626532',\n", + " 'mod_date': '2021-08-31T18:59:22.626551',\n", + " 'description': 'Lead Diiodide',\n", + " 'consumable': True,\n", + " 'material_class': 'model',\n", + " 'internal_slug': 'lead-diiodide',\n", + " 'status': 'http://localhost:8000/api/status/0547fd81-cea5-4413-aa50-684c4624a503/',\n", + " 'actor': None,\n", + " 'identifier': ['http://localhost:8000/api/material-identifier/125b2798-2216-4f9b-9671-070ede6e1620/',\n", + " 'http://localhost:8000/api/material-identifier/d240f536-0388-4d48-8678-4ab678b8f226/',\n", + " 'http://localhost:8000/api/material-identifier/e44f7760-3383-4aa2-b101-d80a8bb4a513/',\n", + " 'http://localhost:8000/api/material-identifier/b6686937-f3d3-4112-89dd-29e606414166/',\n", + " 'http://localhost:8000/api/material-identifier/545f1643-f0b8-46ec-83b4-eda59f826b6c/',\n", + " 'http://localhost:8000/api/material-identifier/83eb17cb-e6da-4ed6-b150-444f8d04f955/'],\n", + " 'material_type': ['http://localhost:8000/api/material-type/11a353d3-cf68-4816-bd32-e75d21375cb2/',\n", + " 'http://localhost:8000/api/material-type/52e2ab9f-3561-4ded-8737-4f126d65ae61/']}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search( \n", + " endpoint='material', #we are looking in the material database table\n", + " related_ep=None,\n", + " search_field='description', #we are searching by description\n", + " criteria= 'Lead Diiodide', #we want the description of the material to be 'Lead Diiodide'\n", + " data=None, \n", + " exact=True, #exact matches only\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note this returns every single field associated with Lead Diiodide. Maybe we just want the url and the description. We would enter these, in list form, as data, and then run our search again." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", + " 'description': 'Lead Diiodide'}" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search(endpoint='material',\n", + " related_ep=None, \n", + " search_field='description',\n", + " criteria= 'Lead Diiodide',\n", + " data=['url', 'description'], #specify the fields for the search to return, in list form\n", + " exact=True,\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Suppose we instead want to know how many materials in the inventory contain the word \"lead\" in their names. We would change our criteria, and also change exact to False. Note that the search criteria is no longer case sensitive." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found 3 resources, returning list of dicts)\n" + ] + }, + { + "data": { + "text/plain": [ + "[{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", + " 'description': 'Lead Diiodide'},\n", + " {'url': 'http://localhost:8000/api/material/dccde9ad-1b5b-4433-af52-412d02362b38/',\n", + " 'description': 'Lead(II) bromide'},\n", + " {'url': 'http://localhost:8000/api/material/bdb2b329-6f54-4228-a0f4-c5facb4bc36f/',\n", + " 'description': 'Lead(II) acetate trihydrate'}]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search(endpoint='material',\n", + " related_ep=None, \n", + " search_field='description',\n", + " criteria= 'lead', #not case-sensitive\n", + " data=['url', 'description'], \n", + " exact=False, #the search will return anything that contains \"lead\" in the name\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If we want to search by a property other than name, we must do a cross-search within the material-identifier table. Let's demonstrate using the INCHI key for lead diiodide. Note this requires specifying the endpoint of the material identifier table `(related_ep)`." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", + " 'description': 'Lead Diiodide'}" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search( endpoint='material',\n", + " related_ep='identifier', #endpoint of related table in which we are searching \n", + " search_field='description',\n", + " criteria= 'RQQRAHKHDFPBMC-UHFFFAOYSA-L', #inchi key\n", + " data=['url', 'description'],\n", + " exact=False,\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Lastly, we have the option to search for all entries within a data table that do NOT contain the specified criteria. Let's demonstrate this using the Action endpoint. Here we find all actions that do not contain the word \"heat\" in their description." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found 184 resources, returning list of dicts)\n" + ] + }, + { + "data": { + "text/plain": [ + "[{'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: B2'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: B1'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: B2'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: B1'},\n", + " {'description': 'Dispense Sample H2O: H2O ->'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: B1'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: B2'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: B1'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A1 -> Assay Sample Plate 1: Plate well#: A1'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A2 -> Assay Sample Plate 1: Plate well#: A2'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A3 -> Assay Sample Plate 1: Plate well#: A3'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: D1'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A4 -> Assay Sample Plate 1: Plate well#: A4'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A5 -> Assay Sample Plate 1: Plate well#: A5'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A6 -> Assay Sample Plate 1: Plate well#: A6'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: B1 -> Assay Sample Plate 1: Plate well#: B1'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: B2 -> Assay Sample Plate 1: Plate well#: B2'},\n", + " {'description': 'Add Resin: ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A1 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A2 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A3 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A4 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A5 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A6 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: B1 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: B2 ->'},\n", + " {'description': 'Dispense Solvent: Solvent -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Solvent: Solvent -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Stock A: Stock A -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Stock A: Stock A -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Stock B: Stock B -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Stock B: Stock B -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Acid Vol 1: Acid -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Acid Vol 1: Acid -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Acid Vol 2: Acid -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Acid Vol 2: Acid -> Plate: Plate well#: A2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A1'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A3'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A4'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A5'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A6'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B1'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B3'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B4'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B5'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B6'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C1'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C3'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C4'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C5'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C6'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D1'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D3'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D4'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D5'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D6'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B1'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B2'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B3'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B4'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B5'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B6'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C1'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C2'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C3'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C4'}]" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search( \n", + " endpoint='action',\n", + " related_ep=None, \n", + " search_field='description',\n", + " criteria= 'heat',\n", + " data=['description'], #let's return the descriptions only, for readability\n", + " exact=False,\n", + " negate=True, #this makes the search return everything that DOES NOT contain 'heat'\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### GET - for simple, fast searches\n", + "\n", + "Alternatively, for simple searches where we might not want to worry about setting all the filters, we can just use `Get`. It takes an endpoint, search field, criteria, and a list of data fields to return" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/597e1e3d-aea7-4f62-8636-9863ee4f86cf/',\n", + " 'description': 'Formic Acid'}" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.get(endpoint='material',\n", + " data={'description': 'Formic Acid', #data={search field: criteria\n", + " 'fields': ['url', 'description']}) #,fields to return}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Posting new data\n", + "\n", + "To add a new material to the inventory, we use `Post`. For this function, the data is entered as a dictionary, with keys corresponding to field names and items corresponding to the entries of those fields. You can choose which fields to fill in data for. \n", + "\n", + "Let's post ammonium iodide, NH4. We will populate the description, material class, and the fact that it is consumable." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r= escalate.post(endpoint='material/', \n", + " data={'description': 'Ammonium Iodide', \n", + " 'material_class': 'model',\n", + " 'consumable': True} \n", + " )\n", + "\n", + "r" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Suppose we accidentally run the above cell twice - this will duplicate the ammonium iodide entry in the materials inventory. We can then make use of `delete` to remove one of the entries - we simply pass in the argument of the url of the entry that we want to remove:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "escalate.delete(r['url'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#re-run this cell if you deleted the entry, so that NH4I exists (once) in the inventory for purposes of the rest of the demo\n", + "\n", + "escalate.post(endpoint='material/', \n", + " data={'description': 'Ammonium Iodide', \n", + " 'material_class': 'model',\n", + " 'consumable': True} \n", + " )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Associating data across tables\n", + "\n", + "For a new entry that we post, we might want to also add identifiers like the chemical formula and/or the INCHI key to the material_identifiers table, so that the entry is more complete and it's easier to find in future searches.\n", + "\n", + "First we have to find the descriptions of these identifiers." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'InChIKey': 'http://localhost:8000/api/material-identifier-def/881e02c5-36ec-4034-8a1e-15be1bb9f45f/',\n", + " 'Molecular_Formula': 'http://localhost:8000/api/material-identifier-def/8e312939-ddc4-4bfa-b1a6-d90d1d5f4feb/'}" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ids = {'InChIKey': 'UKFWSNCTAHXBQN-UHFFFAOYSA-N', 'Molecular_Formula': 'NH4I'}\n", + "\n", + "def_urls={}\n", + "\n", + "#use a loop to search for all the identifiers at once, and then store all their URLs in a dictionary\n", + "\n", + "for i in ids.keys():\n", + " r = escalate.get(endpoint='material-identifier-def',\n", + " data={'description': i, #data={search field: criteria\n", + " 'fields': ['url']}) #,fields to return}\n", + " def_urls[i]=r['url']\n", + " \n", + "def_urls" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we have a dictionary containing the urls of the material identifier definitions that we want to associate with our specific material, Ammonium Iodide. We have to create instances of each of these definitions. The endpoint is material-identifier." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "for key,val in def_urls.items():\n", + " escalate.post(endpoint='material-identifier/', \n", + " data={'description': ids[key], \n", + " 'material_identifier_def': val} \n", + " )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's check if this worked." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/material-identifier/a45582ee-9dac-42c3-be0a-94a2eaa3c7ed/', 'description': 'UKFWSNCTAHXBQN-UHFFFAOYSA-N'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/material-identifier/e03bb825-b43e-42ed-97b4-614154cfc30f/', 'description': 'NH4I'}\n" + ] + } + ], + "source": [ + "id_urls={}\n", + "\n", + "for key, val in ids.items(): #loop across the list containing the material identifier descriptions we just posted\n", + " \n", + " r = escalate.get(endpoint='material-identifier',\n", + " data={'description': val, \n", + " 'fields': ['description', 'url']})\n", + " id_urls[key] = r['url']\n", + " \n", + " print(r)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'InChIKey': 'http://localhost:8000/api/material-identifier/a45582ee-9dac-42c3-be0a-94a2eaa3c7ed/',\n", + " 'Molecular_Formula': 'http://localhost:8000/api/material-identifier/e03bb825-b43e-42ed-97b4-614154cfc30f/'}" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id_urls" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Success! And if we were to navigate to each url, we'd see an associated material identifier definition url. So for our instance of the molecular formula, there is the url that corresponds to the material identifier definition for molecular formula.\n", + "\n", + "Lastly, we need to associate each of these identifiers with the material (at the material endpoint). To do so, we use `Patch`, which will update the identifier field of our material entry." + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "'http://localhost:8000/api/material/d240c1f3-4f71-41b7-922b-370abe60e710/'" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#obtain url for the material using Get\n", + "mat_url = escalate.get(endpoint='material',\n", + " data={'description': 'Ammonium Iodide', \n", + " 'fields': ['url', 'description']})['url']\n", + "\n", + "mat_url" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n" + ] + } + ], + "source": [ + "for val in id_urls.values():\n", + " r = escalate.patch(url=mat_url, \n", + " data={'identifier': val \n", + " })\n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**issue: as of now, each patch request overwrites the previous one**" + ] + } + ], + "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.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From b63ee1c0f1976182f1c351ed28435033165ab204 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:27:38 -0400 Subject: [PATCH 06/17] Delete basic --- Demos/basic | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Demos/basic diff --git a/Demos/basic b/Demos/basic deleted file mode 100644 index 8b13789..0000000 --- a/Demos/basic +++ /dev/null @@ -1 +0,0 @@ - From 7388a52dc0db7f26bb2befb13566553297dd3dfa Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:32:54 -0400 Subject: [PATCH 07/17] upload basic client demo --- ...brary(1).ipynb => basic_client_demo.ipynb} | 298 +----------------- 1 file changed, 1 insertion(+), 297 deletions(-) rename Demos/{REST API Demo - Using the Client Library(1).ipynb => basic_client_demo.ipynb} (68%) diff --git a/Demos/REST API Demo - Using the Client Library(1).ipynb b/Demos/basic_client_demo.ipynb similarity index 68% rename from Demos/REST API Demo - Using the Client Library(1).ipynb rename to Demos/basic_client_demo.ipynb index 809d341..1f93cb6 100644 --- a/Demos/REST API Demo - Using the Client Library(1).ipynb +++ b/Demos/basic_client_demo.ipynb @@ -7,303 +7,7 @@ "# Using the ESCALATEClient REST API Client\n" ] }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "#factor this out when it's imported into the client\n", - "\n", - "import json\n", - "import os\n", - "\n", - "from pprint import pprint\n", - "import pandas as pd\n", - "import requests\n", - "\n", - "class ESCALATEClient():\n", - " \"\"\"ESCALATE API Client\"\"\"\n", - " \n", - " def __init__(self, base_url, username, password):\n", - " self.base_url = base_url\n", - " self.username = username\n", - " self.password = password\n", - " self._token = None\n", - " self._is_logged_in = False\n", - " self._login()\n", - " \n", - " def _login(self):\n", - " r_login = requests.post(f'{self.base_url}/api/login', \n", - " data={'username': self.username, \n", - " 'password': self.password})\n", - " self._token = r_login.json()['token']\n", - " self._token_header = {'Authorization': f'Token {self._token}'}\n", - " self._is_logged_in = True\n", - " \n", - " def get(self, \n", - " endpoint='', \n", - " data=None, \n", - " parse_json=True, \n", - " content_type='application/json'):\n", - " \"\"\"Make GET request with `data` to `endpoint` in ESCALATE API\n", - " \n", - " return: (dict|list|requests.Response), bool\n", - " \"\"\"\n", - " data = {} if data is None else data\n", - " r = requests.get(f'{self.base_url}/api/{endpoint}',\n", - " params=data, \n", - " headers={**self._token_header, \n", - " 'content-type': content_type})\n", - " if r.ok: \n", - " print('GET: OK')\n", - " else: \n", - " print('GET: FAILED')\n", - " \n", - " if r.ok and parse_json:\n", - " resp_json = r.json() \n", - " # handle cases: no vs one vs many results\n", - " count = resp_json.get('count')\n", - " if count is None or count == 0:\n", - " return r.json()\n", - " elif count == 1: \n", - " print('Found one resource, returning dict')\n", - " return resp_json['results'][0]\n", - " elif count >= 1: \n", - " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", - " return r.json()['results']\n", - " print('Returning response object') \n", - " return r\n", - " \n", - " def post(self, \n", - " endpoint, \n", - " data, \n", - " content_type='application/json'):\n", - " \"\"\"POST `data` to `endpoint`in ESCALATE API using `content_type`\n", - " return: (dict|requests.Response), bool\n", - " \"\"\"\n", - " \n", - " if not self._is_logged_in:\n", - " raise ValueError(\"Not logged in: cannot post\")\n", - " \n", - " r = requests.api.post(\n", - " f'{self.base_url}/api/{endpoint}', \n", - " data=json.dumps(data), \n", - " headers={**self._token_header,\n", - " 'content-type': content_type})\n", - " print(r)\n", - " if r.ok: \n", - " print('POST: OK, returning new resource dict')\n", - " return r.json()\n", - " print('POST: FAILED, returning response object')\n", - " return r\n", - " \n", - " def put(self, url=None, endpoint=None, resource_id=None, data=None):\n", - " \"\"\"Update a complete resource\n", - " Either provide a url or an endpoint and resource id\n", - " \"\"\"\n", - " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", - " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", - " \n", - " if url is None: \n", - " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", - " r = requests.api.put(url, data, headers=self._token_header)\n", - " return r\n", - " \n", - " def patch(self, url=None, endpoint=None, resource_id=None, data=None):\n", - " \"\"\"Update parts of a resource\n", - " Either provide a url or an endpoint and resource id\n", - " \"\"\"\n", - " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", - " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", - " \n", - " if url is None: \n", - " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", - " r = requests.api.patch(url, data, headers=self._token_header)\n", - " return r\n", - " \n", - " def delete(self, url=None, endpoint=None, resource_id=None):\n", - " \"\"\"Delete a resource\n", - " Either provide a url or an endpoint and resource id\n", - " \"\"\"\n", - " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", - " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", - " if url is None: \n", - " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", - " r = requests.api.delete(url, headers=self._token_header)\n", - " return r\n", - " \n", - " def search(self, \n", - " endpoint='',\n", - " related_ep=None, #for cross-searches\n", - " search_field='',\n", - " criteria= '',\n", - " data=None, #must be a list\n", - " exact=False,\n", - " negate=False,\n", - " parse_json=True, \n", - " content_type='application/json'):\n", - " \n", - " if negate==False:\n", - "\n", - " if exact==True:\n", - " if data == None:\n", - " '''Returns all fields for exact match'''\n", - " if related_ep == None:\n", - "\n", - " r = requests.get(f'{self.base_url}/api/{endpoint}/?{search_field}={criteria}', \n", - " headers={**self._token_header, \n", - " 'content-type': content_type})\n", - " else: #cross-search \n", - " r = requests.get(f'{self.base_url}/api/{endpoint}/?{related_ep}__{search_field}={criteria}', \n", - " headers={**self._token_header, \n", - " 'content-type': content_type})\n", - "\n", - " else:\n", - " '''Returns requested field(s) for exact match'''\n", - " i=0\n", - " data_string=''\n", - " while i= 1: \n", - " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", - " return r.json()['results']\n", - " print('Returning response object') \n", - " return r\n", - " \n", - " def list_endpoints(self):\n", - " return self.get()" - ] - }, + { "cell_type": "markdown", "metadata": {}, From 800075873a4cd7b9998ad8777dce11c3eeaa8779 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:35:26 -0400 Subject: [PATCH 08/17] Create basic_client_demo.ipynb --- demos/basic_client_demo.ipynb | 815 ++++++++++++++++++++++++++++++++++ 1 file changed, 815 insertions(+) create mode 100644 demos/basic_client_demo.ipynb diff --git a/demos/basic_client_demo.ipynb b/demos/basic_client_demo.ipynb new file mode 100644 index 0000000..1f93cb6 --- /dev/null +++ b/demos/basic_client_demo.ipynb @@ -0,0 +1,815 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Using the ESCALATEClient REST API Client\n" + ] + }, + + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import the API Client." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import escalateclient\n", + "from escalateclient import ESCALATEClient" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Enter your ESCALATE username and password, and the port number at which the server is running. Then run the following cell. This will create an instance of the API Client and set up a token to interact with the REST API." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "username= 'nsmina'\n", + "password= 'password11'\n", + "port='8000'\n", + "\n", + "escalate = ESCALATEClient(\n", + " f'http://localhost:{port}',\n", + " username,\n", + " password\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To see all the model endpoints (this is also a good way to verify that you are connected):" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n" + ] + }, + { + "data": { + "text/plain": [ + "{'action': 'http://localhost:8000/api/action/',\n", + " 'actiondef': 'http://localhost:8000/api/action-def/',\n", + " 'actionunit': 'http://localhost:8000/api/action-unit/',\n", + " 'actor': 'http://localhost:8000/api/actor/',\n", + " 'basebommaterial': 'http://localhost:8000/api/base-bom-material/',\n", + " 'billofmaterials': 'http://localhost:8000/api/bill-of-materials/',\n", + " 'bomcompositematerial': 'http://localhost:8000/api/bom-composite-material/',\n", + " 'bommaterial': 'http://localhost:8000/api/bom-material/',\n", + " 'calculation': 'http://localhost:8000/api/calculation/',\n", + " 'calculationdef': 'http://localhost:8000/api/calculation-def/',\n", + " 'condition': 'http://localhost:8000/api/condition/',\n", + " 'conditiondef': 'http://localhost:8000/api/condition-def/',\n", + " 'experiment': 'http://localhost:8000/api/experiment/',\n", + " 'experimentinstance': 'http://localhost:8000/api/experiment-instance/',\n", + " 'experimenttemplate': 'http://localhost:8000/api/experiment-template/',\n", + " 'experimenttype': 'http://localhost:8000/api/experiment-type/',\n", + " 'experimentworkflow': 'http://localhost:8000/api/experiment-workflow/',\n", + " 'inventory': 'http://localhost:8000/api/inventory/',\n", + " 'inventorymaterial': 'http://localhost:8000/api/inventory-material/',\n", + " 'material': 'http://localhost:8000/api/material/',\n", + " 'materialidentifier': 'http://localhost:8000/api/material-identifier/',\n", + " 'materialidentifierdef': 'http://localhost:8000/api/material-identifier-def/',\n", + " 'materialtype': 'http://localhost:8000/api/material-type/',\n", + " 'measure': 'http://localhost:8000/api/measure/',\n", + " 'measuredef': 'http://localhost:8000/api/measure-def/',\n", + " 'measuretype': 'http://localhost:8000/api/measure-type/',\n", + " 'mixture': 'http://localhost:8000/api/mixture/',\n", + " 'organization': 'http://localhost:8000/api/organization/',\n", + " 'outcome': 'http://localhost:8000/api/outcome/',\n", + " 'parameterdef': 'http://localhost:8000/api/parameter-def/',\n", + " 'person': 'http://localhost:8000/api/person/',\n", + " 'propertydef': 'http://localhost:8000/api/property-def/',\n", + " 'status': 'http://localhost:8000/api/status/',\n", + " 'systemtool': 'http://localhost:8000/api/systemtool/',\n", + " 'systemtooltype': 'http://localhost:8000/api/systemtool-type/',\n", + " 'tag': 'http://localhost:8000/api/tag/',\n", + " 'tagtype': 'http://localhost:8000/api/tag-type/',\n", + " 'typedef': 'http://localhost:8000/api/type-def/',\n", + " 'udfdef': 'http://localhost:8000/api/udf-def/',\n", + " 'unittype': 'http://localhost:8000/api/unit-type/',\n", + " 'vessel': 'http://localhost:8000/api/vessel/',\n", + " 'workflow': 'http://localhost:8000/api/workflow/',\n", + " 'workflowactionset': 'http://localhost:8000/api/workflow-action-set/',\n", + " 'workflowobject': 'http://localhost:8000/api/workflow-object/',\n", + " 'workflowstep': 'http://localhost:8000/api/workflow-step/',\n", + " 'workflowtype': 'http://localhost:8000/api/workflow-type/'}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.list_endpoints()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Searching the database\n", + "\n", + "To search the database for an existing material (or action, or workflow, or any endpoint)... enter the endpoint below. Make sure it is one of the existing endpoints in the database. \n", + "\n", + "Choose a field by which to search this database. For instance, you can look up a material by its description (which corresponds to the name of the material). Enter that as well. Then enter your search criteria and whether it is exact (True or False). \n", + "\n", + "Suppose that we want to look up Lead Diiodide and return all the exact matches. Note that exact match searches are case-sensitive, so if you did not capitalize the first letter of each word in the name, you would get no results." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", + " 'uuid': '28fe860b-44ae-4737-9fc9-b1714facc07d',\n", + " 'edocs': [],\n", + " 'tags': [],\n", + " 'notes': [],\n", + " 'property': [],\n", + " 'add_date': '2021-08-31T18:59:22.626532',\n", + " 'mod_date': '2021-08-31T18:59:22.626551',\n", + " 'description': 'Lead Diiodide',\n", + " 'consumable': True,\n", + " 'material_class': 'model',\n", + " 'internal_slug': 'lead-diiodide',\n", + " 'status': 'http://localhost:8000/api/status/0547fd81-cea5-4413-aa50-684c4624a503/',\n", + " 'actor': None,\n", + " 'identifier': ['http://localhost:8000/api/material-identifier/125b2798-2216-4f9b-9671-070ede6e1620/',\n", + " 'http://localhost:8000/api/material-identifier/d240f536-0388-4d48-8678-4ab678b8f226/',\n", + " 'http://localhost:8000/api/material-identifier/e44f7760-3383-4aa2-b101-d80a8bb4a513/',\n", + " 'http://localhost:8000/api/material-identifier/b6686937-f3d3-4112-89dd-29e606414166/',\n", + " 'http://localhost:8000/api/material-identifier/545f1643-f0b8-46ec-83b4-eda59f826b6c/',\n", + " 'http://localhost:8000/api/material-identifier/83eb17cb-e6da-4ed6-b150-444f8d04f955/'],\n", + " 'material_type': ['http://localhost:8000/api/material-type/11a353d3-cf68-4816-bd32-e75d21375cb2/',\n", + " 'http://localhost:8000/api/material-type/52e2ab9f-3561-4ded-8737-4f126d65ae61/']}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search( \n", + " endpoint='material', #we are looking in the material database table\n", + " related_ep=None,\n", + " search_field='description', #we are searching by description\n", + " criteria= 'Lead Diiodide', #we want the description of the material to be 'Lead Diiodide'\n", + " data=None, \n", + " exact=True, #exact matches only\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note this returns every single field associated with Lead Diiodide. Maybe we just want the url and the description. We would enter these, in list form, as data, and then run our search again." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", + " 'description': 'Lead Diiodide'}" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search(endpoint='material',\n", + " related_ep=None, \n", + " search_field='description',\n", + " criteria= 'Lead Diiodide',\n", + " data=['url', 'description'], #specify the fields for the search to return, in list form\n", + " exact=True,\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Suppose we instead want to know how many materials in the inventory contain the word \"lead\" in their names. We would change our criteria, and also change exact to False. Note that the search criteria is no longer case sensitive." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found 3 resources, returning list of dicts)\n" + ] + }, + { + "data": { + "text/plain": [ + "[{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", + " 'description': 'Lead Diiodide'},\n", + " {'url': 'http://localhost:8000/api/material/dccde9ad-1b5b-4433-af52-412d02362b38/',\n", + " 'description': 'Lead(II) bromide'},\n", + " {'url': 'http://localhost:8000/api/material/bdb2b329-6f54-4228-a0f4-c5facb4bc36f/',\n", + " 'description': 'Lead(II) acetate trihydrate'}]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search(endpoint='material',\n", + " related_ep=None, \n", + " search_field='description',\n", + " criteria= 'lead', #not case-sensitive\n", + " data=['url', 'description'], \n", + " exact=False, #the search will return anything that contains \"lead\" in the name\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If we want to search by a property other than name, we must do a cross-search within the material-identifier table. Let's demonstrate using the INCHI key for lead diiodide. Note this requires specifying the endpoint of the material identifier table `(related_ep)`." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", + " 'description': 'Lead Diiodide'}" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search( endpoint='material',\n", + " related_ep='identifier', #endpoint of related table in which we are searching \n", + " search_field='description',\n", + " criteria= 'RQQRAHKHDFPBMC-UHFFFAOYSA-L', #inchi key\n", + " data=['url', 'description'],\n", + " exact=False,\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Lastly, we have the option to search for all entries within a data table that do NOT contain the specified criteria. Let's demonstrate this using the Action endpoint. Here we find all actions that do not contain the word \"heat\" in their description." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found 184 resources, returning list of dicts)\n" + ] + }, + { + "data": { + "text/plain": [ + "[{'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: B2'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: B1'},\n", + " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: B2'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: B1'},\n", + " {'description': 'Dispense Sample H2O: H2O ->'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: B1'},\n", + " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: B2'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: B1'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A1 -> Assay Sample Plate 1: Plate well#: A1'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A2 -> Assay Sample Plate 1: Plate well#: A2'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A3 -> Assay Sample Plate 1: Plate well#: A3'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: D1'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A4 -> Assay Sample Plate 1: Plate well#: A4'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A5 -> Assay Sample Plate 1: Plate well#: A5'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A6 -> Assay Sample Plate 1: Plate well#: A6'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: B1 -> Assay Sample Plate 1: Plate well#: B1'},\n", + " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: B2 -> Assay Sample Plate 1: Plate well#: B2'},\n", + " {'description': 'Add Resin: ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A1 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A2 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A3 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A4 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A5 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A6 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: B1 ->'},\n", + " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: B2 ->'},\n", + " {'description': 'Dispense Solvent: Solvent -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Solvent: Solvent -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Stock A: Stock A -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Stock A: Stock A -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Stock B: Stock B -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Stock B: Stock B -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Acid Vol 1: Acid -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Acid Vol 1: Acid -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Acid Vol 2: Acid -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Acid Vol 2: Acid -> Plate: Plate well#: A2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A1'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A3'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A4'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A5'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A6'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B1'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B3'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B4'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B5'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B6'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C1'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C3'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C4'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C5'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C6'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D1'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D2'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D3'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D4'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D5'},\n", + " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D6'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A1'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A2'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A3'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A4'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A5'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A6'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B1'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B2'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B3'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B4'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B5'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B6'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C1'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C2'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C3'},\n", + " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C4'}]" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.search( \n", + " endpoint='action',\n", + " related_ep=None, \n", + " search_field='description',\n", + " criteria= 'heat',\n", + " data=['description'], #let's return the descriptions only, for readability\n", + " exact=False,\n", + " negate=True, #this makes the search return everything that DOES NOT contain 'heat'\n", + " parse_json=True, \n", + " content_type='application/json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### GET - for simple, fast searches\n", + "\n", + "Alternatively, for simple searches where we might not want to worry about setting all the filters, we can just use `Get`. It takes an endpoint, search field, criteria, and a list of data fields to return" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/597e1e3d-aea7-4f62-8636-9863ee4f86cf/',\n", + " 'description': 'Formic Acid'}" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.get(endpoint='material',\n", + " data={'description': 'Formic Acid', #data={search field: criteria\n", + " 'fields': ['url', 'description']}) #,fields to return}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Posting new data\n", + "\n", + "To add a new material to the inventory, we use `Post`. For this function, the data is entered as a dictionary, with keys corresponding to field names and items corresponding to the entries of those fields. You can choose which fields to fill in data for. \n", + "\n", + "Let's post ammonium iodide, NH4. We will populate the description, material class, and the fact that it is consumable." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r= escalate.post(endpoint='material/', \n", + " data={'description': 'Ammonium Iodide', \n", + " 'material_class': 'model',\n", + " 'consumable': True} \n", + " )\n", + "\n", + "r" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Suppose we accidentally run the above cell twice - this will duplicate the ammonium iodide entry in the materials inventory. We can then make use of `delete` to remove one of the entries - we simply pass in the argument of the url of the entry that we want to remove:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "escalate.delete(r['url'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#re-run this cell if you deleted the entry, so that NH4I exists (once) in the inventory for purposes of the rest of the demo\n", + "\n", + "escalate.post(endpoint='material/', \n", + " data={'description': 'Ammonium Iodide', \n", + " 'material_class': 'model',\n", + " 'consumable': True} \n", + " )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Associating data across tables\n", + "\n", + "For a new entry that we post, we might want to also add identifiers like the chemical formula and/or the INCHI key to the material_identifiers table, so that the entry is more complete and it's easier to find in future searches.\n", + "\n", + "First we have to find the descriptions of these identifiers." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'InChIKey': 'http://localhost:8000/api/material-identifier-def/881e02c5-36ec-4034-8a1e-15be1bb9f45f/',\n", + " 'Molecular_Formula': 'http://localhost:8000/api/material-identifier-def/8e312939-ddc4-4bfa-b1a6-d90d1d5f4feb/'}" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ids = {'InChIKey': 'UKFWSNCTAHXBQN-UHFFFAOYSA-N', 'Molecular_Formula': 'NH4I'}\n", + "\n", + "def_urls={}\n", + "\n", + "#use a loop to search for all the identifiers at once, and then store all their URLs in a dictionary\n", + "\n", + "for i in ids.keys():\n", + " r = escalate.get(endpoint='material-identifier-def',\n", + " data={'description': i, #data={search field: criteria\n", + " 'fields': ['url']}) #,fields to return}\n", + " def_urls[i]=r['url']\n", + " \n", + "def_urls" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we have a dictionary containing the urls of the material identifier definitions that we want to associate with our specific material, Ammonium Iodide. We have to create instances of each of these definitions. The endpoint is material-identifier." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "for key,val in def_urls.items():\n", + " escalate.post(endpoint='material-identifier/', \n", + " data={'description': ids[key], \n", + " 'material_identifier_def': val} \n", + " )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's check if this worked." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/material-identifier/a45582ee-9dac-42c3-be0a-94a2eaa3c7ed/', 'description': 'UKFWSNCTAHXBQN-UHFFFAOYSA-N'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/material-identifier/e03bb825-b43e-42ed-97b4-614154cfc30f/', 'description': 'NH4I'}\n" + ] + } + ], + "source": [ + "id_urls={}\n", + "\n", + "for key, val in ids.items(): #loop across the list containing the material identifier descriptions we just posted\n", + " \n", + " r = escalate.get(endpoint='material-identifier',\n", + " data={'description': val, \n", + " 'fields': ['description', 'url']})\n", + " id_urls[key] = r['url']\n", + " \n", + " print(r)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'InChIKey': 'http://localhost:8000/api/material-identifier/a45582ee-9dac-42c3-be0a-94a2eaa3c7ed/',\n", + " 'Molecular_Formula': 'http://localhost:8000/api/material-identifier/e03bb825-b43e-42ed-97b4-614154cfc30f/'}" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "id_urls" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Success! And if we were to navigate to each url, we'd see an associated material identifier definition url. So for our instance of the molecular formula, there is the url that corresponds to the material identifier definition for molecular formula.\n", + "\n", + "Lastly, we need to associate each of these identifiers with the material (at the material endpoint). To do so, we use `Patch`, which will update the identifier field of our material entry." + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "'http://localhost:8000/api/material/d240c1f3-4f71-41b7-922b-370abe60e710/'" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#obtain url for the material using Get\n", + "mat_url = escalate.get(endpoint='material',\n", + " data={'description': 'Ammonium Iodide', \n", + " 'fields': ['url', 'description']})['url']\n", + "\n", + "mat_url" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n" + ] + } + ], + "source": [ + "for val in id_urls.values():\n", + " r = escalate.patch(url=mat_url, \n", + " data={'identifier': val \n", + " })\n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**issue: as of now, each patch request overwrites the previous one**" + ] + } + ], + "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.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 09f68d43606007fec474a84191e78fc12067c007 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:36:00 -0400 Subject: [PATCH 09/17] Delete Demos directory --- Demos/basic_client_demo.ipynb | 815 ---------------------------------- 1 file changed, 815 deletions(-) delete mode 100644 Demos/basic_client_demo.ipynb diff --git a/Demos/basic_client_demo.ipynb b/Demos/basic_client_demo.ipynb deleted file mode 100644 index 1f93cb6..0000000 --- a/Demos/basic_client_demo.ipynb +++ /dev/null @@ -1,815 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Using the ESCALATEClient REST API Client\n" - ] - }, - - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "First import the API Client." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import escalateclient\n", - "from escalateclient import ESCALATEClient" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Enter your ESCALATE username and password, and the port number at which the server is running. Then run the following cell. This will create an instance of the API Client and set up a token to interact with the REST API." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "username= 'nsmina'\n", - "password= 'password11'\n", - "port='8000'\n", - "\n", - "escalate = ESCALATEClient(\n", - " f'http://localhost:{port}',\n", - " username,\n", - " password\n", - ")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "To see all the model endpoints (this is also a good way to verify that you are connected):" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n" - ] - }, - { - "data": { - "text/plain": [ - "{'action': 'http://localhost:8000/api/action/',\n", - " 'actiondef': 'http://localhost:8000/api/action-def/',\n", - " 'actionunit': 'http://localhost:8000/api/action-unit/',\n", - " 'actor': 'http://localhost:8000/api/actor/',\n", - " 'basebommaterial': 'http://localhost:8000/api/base-bom-material/',\n", - " 'billofmaterials': 'http://localhost:8000/api/bill-of-materials/',\n", - " 'bomcompositematerial': 'http://localhost:8000/api/bom-composite-material/',\n", - " 'bommaterial': 'http://localhost:8000/api/bom-material/',\n", - " 'calculation': 'http://localhost:8000/api/calculation/',\n", - " 'calculationdef': 'http://localhost:8000/api/calculation-def/',\n", - " 'condition': 'http://localhost:8000/api/condition/',\n", - " 'conditiondef': 'http://localhost:8000/api/condition-def/',\n", - " 'experiment': 'http://localhost:8000/api/experiment/',\n", - " 'experimentinstance': 'http://localhost:8000/api/experiment-instance/',\n", - " 'experimenttemplate': 'http://localhost:8000/api/experiment-template/',\n", - " 'experimenttype': 'http://localhost:8000/api/experiment-type/',\n", - " 'experimentworkflow': 'http://localhost:8000/api/experiment-workflow/',\n", - " 'inventory': 'http://localhost:8000/api/inventory/',\n", - " 'inventorymaterial': 'http://localhost:8000/api/inventory-material/',\n", - " 'material': 'http://localhost:8000/api/material/',\n", - " 'materialidentifier': 'http://localhost:8000/api/material-identifier/',\n", - " 'materialidentifierdef': 'http://localhost:8000/api/material-identifier-def/',\n", - " 'materialtype': 'http://localhost:8000/api/material-type/',\n", - " 'measure': 'http://localhost:8000/api/measure/',\n", - " 'measuredef': 'http://localhost:8000/api/measure-def/',\n", - " 'measuretype': 'http://localhost:8000/api/measure-type/',\n", - " 'mixture': 'http://localhost:8000/api/mixture/',\n", - " 'organization': 'http://localhost:8000/api/organization/',\n", - " 'outcome': 'http://localhost:8000/api/outcome/',\n", - " 'parameterdef': 'http://localhost:8000/api/parameter-def/',\n", - " 'person': 'http://localhost:8000/api/person/',\n", - " 'propertydef': 'http://localhost:8000/api/property-def/',\n", - " 'status': 'http://localhost:8000/api/status/',\n", - " 'systemtool': 'http://localhost:8000/api/systemtool/',\n", - " 'systemtooltype': 'http://localhost:8000/api/systemtool-type/',\n", - " 'tag': 'http://localhost:8000/api/tag/',\n", - " 'tagtype': 'http://localhost:8000/api/tag-type/',\n", - " 'typedef': 'http://localhost:8000/api/type-def/',\n", - " 'udfdef': 'http://localhost:8000/api/udf-def/',\n", - " 'unittype': 'http://localhost:8000/api/unit-type/',\n", - " 'vessel': 'http://localhost:8000/api/vessel/',\n", - " 'workflow': 'http://localhost:8000/api/workflow/',\n", - " 'workflowactionset': 'http://localhost:8000/api/workflow-action-set/',\n", - " 'workflowobject': 'http://localhost:8000/api/workflow-object/',\n", - " 'workflowstep': 'http://localhost:8000/api/workflow-step/',\n", - " 'workflowtype': 'http://localhost:8000/api/workflow-type/'}" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.list_endpoints()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Searching the database\n", - "\n", - "To search the database for an existing material (or action, or workflow, or any endpoint)... enter the endpoint below. Make sure it is one of the existing endpoints in the database. \n", - "\n", - "Choose a field by which to search this database. For instance, you can look up a material by its description (which corresponds to the name of the material). Enter that as well. Then enter your search criteria and whether it is exact (True or False). \n", - "\n", - "Suppose that we want to look up Lead Diiodide and return all the exact matches. Note that exact match searches are case-sensitive, so if you did not capitalize the first letter of each word in the name, you would get no results." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", - " 'uuid': '28fe860b-44ae-4737-9fc9-b1714facc07d',\n", - " 'edocs': [],\n", - " 'tags': [],\n", - " 'notes': [],\n", - " 'property': [],\n", - " 'add_date': '2021-08-31T18:59:22.626532',\n", - " 'mod_date': '2021-08-31T18:59:22.626551',\n", - " 'description': 'Lead Diiodide',\n", - " 'consumable': True,\n", - " 'material_class': 'model',\n", - " 'internal_slug': 'lead-diiodide',\n", - " 'status': 'http://localhost:8000/api/status/0547fd81-cea5-4413-aa50-684c4624a503/',\n", - " 'actor': None,\n", - " 'identifier': ['http://localhost:8000/api/material-identifier/125b2798-2216-4f9b-9671-070ede6e1620/',\n", - " 'http://localhost:8000/api/material-identifier/d240f536-0388-4d48-8678-4ab678b8f226/',\n", - " 'http://localhost:8000/api/material-identifier/e44f7760-3383-4aa2-b101-d80a8bb4a513/',\n", - " 'http://localhost:8000/api/material-identifier/b6686937-f3d3-4112-89dd-29e606414166/',\n", - " 'http://localhost:8000/api/material-identifier/545f1643-f0b8-46ec-83b4-eda59f826b6c/',\n", - " 'http://localhost:8000/api/material-identifier/83eb17cb-e6da-4ed6-b150-444f8d04f955/'],\n", - " 'material_type': ['http://localhost:8000/api/material-type/11a353d3-cf68-4816-bd32-e75d21375cb2/',\n", - " 'http://localhost:8000/api/material-type/52e2ab9f-3561-4ded-8737-4f126d65ae61/']}" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.search( \n", - " endpoint='material', #we are looking in the material database table\n", - " related_ep=None,\n", - " search_field='description', #we are searching by description\n", - " criteria= 'Lead Diiodide', #we want the description of the material to be 'Lead Diiodide'\n", - " data=None, \n", - " exact=True, #exact matches only\n", - " negate=False,\n", - " parse_json=True, \n", - " content_type='application/json')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Note this returns every single field associated with Lead Diiodide. Maybe we just want the url and the description. We would enter these, in list form, as data, and then run our search again." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", - " 'description': 'Lead Diiodide'}" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.search(endpoint='material',\n", - " related_ep=None, \n", - " search_field='description',\n", - " criteria= 'Lead Diiodide',\n", - " data=['url', 'description'], #specify the fields for the search to return, in list form\n", - " exact=True,\n", - " negate=False,\n", - " parse_json=True, \n", - " content_type='application/json')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Suppose we instead want to know how many materials in the inventory contain the word \"lead\" in their names. We would change our criteria, and also change exact to False. Note that the search criteria is no longer case sensitive." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found 3 resources, returning list of dicts)\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", - " 'description': 'Lead Diiodide'},\n", - " {'url': 'http://localhost:8000/api/material/dccde9ad-1b5b-4433-af52-412d02362b38/',\n", - " 'description': 'Lead(II) bromide'},\n", - " {'url': 'http://localhost:8000/api/material/bdb2b329-6f54-4228-a0f4-c5facb4bc36f/',\n", - " 'description': 'Lead(II) acetate trihydrate'}]" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.search(endpoint='material',\n", - " related_ep=None, \n", - " search_field='description',\n", - " criteria= 'lead', #not case-sensitive\n", - " data=['url', 'description'], \n", - " exact=False, #the search will return anything that contains \"lead\" in the name\n", - " negate=False,\n", - " parse_json=True, \n", - " content_type='application/json')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If we want to search by a property other than name, we must do a cross-search within the material-identifier table. Let's demonstrate using the INCHI key for lead diiodide. Note this requires specifying the endpoint of the material identifier table `(related_ep)`." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'url': 'http://localhost:8000/api/material/28fe860b-44ae-4737-9fc9-b1714facc07d/',\n", - " 'description': 'Lead Diiodide'}" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.search( endpoint='material',\n", - " related_ep='identifier', #endpoint of related table in which we are searching \n", - " search_field='description',\n", - " criteria= 'RQQRAHKHDFPBMC-UHFFFAOYSA-L', #inchi key\n", - " data=['url', 'description'],\n", - " exact=False,\n", - " negate=False,\n", - " parse_json=True, \n", - " content_type='application/json')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Lastly, we have the option to search for all entries within a data table that do NOT contain the specified criteria. Let's demonstrate this using the Action endpoint. Here we find all actions that do not contain the word \"heat\" in their description." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found 184 resources, returning list of dicts)\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: B2'},\n", - " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A2'},\n", - " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A3'},\n", - " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A4'},\n", - " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A5'},\n", - " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: A6'},\n", - " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: B1'},\n", - " {'description': 'Dispense Resin: Resin -> Resin Plate: Plate well#: B2'},\n", - " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A2'},\n", - " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A3'},\n", - " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A4'},\n", - " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A5'},\n", - " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: A6'},\n", - " {'description': 'Dispense Sample H2O: H2O -> Sample Prep Plate: Plate well#: B1'},\n", - " {'description': 'Dispense Sample H2O: H2O ->'},\n", - " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A2'},\n", - " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A3'},\n", - " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A4'},\n", - " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A5'},\n", - " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: A6'},\n", - " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: B1'},\n", - " {'description': 'Dispense Sample HCl: HCl-12M -> Sample Prep Plate: Plate well#: B2'},\n", - " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A2'},\n", - " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A3'},\n", - " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A4'},\n", - " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A5'},\n", - " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: A6'},\n", - " {'description': 'Dispense Metal Stock: -> Sample Prep Plate: Plate well#: B1'},\n", - " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A1 -> Assay Sample Plate 1: Plate well#: A1'},\n", - " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A2 -> Assay Sample Plate 1: Plate well#: A2'},\n", - " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A3 -> Assay Sample Plate 1: Plate well#: A3'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: D1'},\n", - " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A4 -> Assay Sample Plate 1: Plate well#: A4'},\n", - " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A5 -> Assay Sample Plate 1: Plate well#: A5'},\n", - " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: A6 -> Assay Sample Plate 1: Plate well#: A6'},\n", - " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: B1 -> Assay Sample Plate 1: Plate well#: B1'},\n", - " {'description': 'Transfer Sample for Assay: Sample Prep Plate: Plate well#: B2 -> Assay Sample Plate 1: Plate well#: B2'},\n", - " {'description': 'Add Resin: ->'},\n", - " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A1 ->'},\n", - " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A2 ->'},\n", - " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A3 ->'},\n", - " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A4 ->'},\n", - " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A5 ->'},\n", - " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: A6 ->'},\n", - " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: B1 ->'},\n", - " {'description': 'Sample to Resin: Sample Prep Plate: Plate well#: B2 ->'},\n", - " {'description': 'Dispense Solvent: Solvent -> Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Solvent: Solvent -> Plate: Plate well#: A2'},\n", - " {'description': 'Dispense Stock A: Stock A -> Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Stock A: Stock A -> Plate: Plate well#: A2'},\n", - " {'description': 'Dispense Stock B: Stock B -> Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Stock B: Stock B -> Plate: Plate well#: A2'},\n", - " {'description': 'Dispense Acid Vol 1: Acid -> Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Acid Vol 1: Acid -> Plate: Plate well#: A2'},\n", - " {'description': 'Dispense Acid Vol 2: Acid -> Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Acid Vol 2: Acid -> Plate: Plate well#: A2'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A1'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A2'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A3'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A4'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A5'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: A6'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B1'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B2'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B3'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B4'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B5'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: B6'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C1'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C2'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C3'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C4'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C5'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: C6'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D1'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D2'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D3'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D4'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D5'},\n", - " {'description': 'Perovskite Demo: Dispense Solvent: Solvent -> Plate: Plate well#: D6'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A1'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A2'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A3'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A4'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A5'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: A6'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B1'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B2'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B3'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B4'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B5'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: B6'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C1'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C2'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C3'},\n", - " {'description': 'Dispense Stock A: Stock A Vial -> Plate: Plate well#: C4'}]" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.search( \n", - " endpoint='action',\n", - " related_ep=None, \n", - " search_field='description',\n", - " criteria= 'heat',\n", - " data=['description'], #let's return the descriptions only, for readability\n", - " exact=False,\n", - " negate=True, #this makes the search return everything that DOES NOT contain 'heat'\n", - " parse_json=True, \n", - " content_type='application/json')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### GET - for simple, fast searches\n", - "\n", - "Alternatively, for simple searches where we might not want to worry about setting all the filters, we can just use `Get`. It takes an endpoint, search field, criteria, and a list of data fields to return" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'url': 'http://localhost:8000/api/material/597e1e3d-aea7-4f62-8636-9863ee4f86cf/',\n", - " 'description': 'Formic Acid'}" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.get(endpoint='material',\n", - " data={'description': 'Formic Acid', #data={search field: criteria\n", - " 'fields': ['url', 'description']}) #,fields to return}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Posting new data\n", - "\n", - "To add a new material to the inventory, we use `Post`. For this function, the data is entered as a dictionary, with keys corresponding to field names and items corresponding to the entries of those fields. You can choose which fields to fill in data for. \n", - "\n", - "Let's post ammonium iodide, NH4. We will populate the description, material class, and the fact that it is consumable." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "r= escalate.post(endpoint='material/', \n", - " data={'description': 'Ammonium Iodide', \n", - " 'material_class': 'model',\n", - " 'consumable': True} \n", - " )\n", - "\n", - "r" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Suppose we accidentally run the above cell twice - this will duplicate the ammonium iodide entry in the materials inventory. We can then make use of `delete` to remove one of the entries - we simply pass in the argument of the url of the entry that we want to remove:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "escalate.delete(r['url'])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#re-run this cell if you deleted the entry, so that NH4I exists (once) in the inventory for purposes of the rest of the demo\n", - "\n", - "escalate.post(endpoint='material/', \n", - " data={'description': 'Ammonium Iodide', \n", - " 'material_class': 'model',\n", - " 'consumable': True} \n", - " )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Associating data across tables\n", - "\n", - "For a new entry that we post, we might want to also add identifiers like the chemical formula and/or the INCHI key to the material_identifiers table, so that the entry is more complete and it's easier to find in future searches.\n", - "\n", - "First we have to find the descriptions of these identifiers." - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'InChIKey': 'http://localhost:8000/api/material-identifier-def/881e02c5-36ec-4034-8a1e-15be1bb9f45f/',\n", - " 'Molecular_Formula': 'http://localhost:8000/api/material-identifier-def/8e312939-ddc4-4bfa-b1a6-d90d1d5f4feb/'}" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "ids = {'InChIKey': 'UKFWSNCTAHXBQN-UHFFFAOYSA-N', 'Molecular_Formula': 'NH4I'}\n", - "\n", - "def_urls={}\n", - "\n", - "#use a loop to search for all the identifiers at once, and then store all their URLs in a dictionary\n", - "\n", - "for i in ids.keys():\n", - " r = escalate.get(endpoint='material-identifier-def',\n", - " data={'description': i, #data={search field: criteria\n", - " 'fields': ['url']}) #,fields to return}\n", - " def_urls[i]=r['url']\n", - " \n", - "def_urls" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we have a dictionary containing the urls of the material identifier definitions that we want to associate with our specific material, Ammonium Iodide. We have to create instances of each of these definitions. The endpoint is material-identifier." - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - } - ], - "source": [ - "for key,val in def_urls.items():\n", - " escalate.post(endpoint='material-identifier/', \n", - " data={'description': ids[key], \n", - " 'material_identifier_def': val} \n", - " )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's check if this worked." - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/material-identifier/a45582ee-9dac-42c3-be0a-94a2eaa3c7ed/', 'description': 'UKFWSNCTAHXBQN-UHFFFAOYSA-N'}\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/material-identifier/e03bb825-b43e-42ed-97b4-614154cfc30f/', 'description': 'NH4I'}\n" - ] - } - ], - "source": [ - "id_urls={}\n", - "\n", - "for key, val in ids.items(): #loop across the list containing the material identifier descriptions we just posted\n", - " \n", - " r = escalate.get(endpoint='material-identifier',\n", - " data={'description': val, \n", - " 'fields': ['description', 'url']})\n", - " id_urls[key] = r['url']\n", - " \n", - " print(r)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'InChIKey': 'http://localhost:8000/api/material-identifier/a45582ee-9dac-42c3-be0a-94a2eaa3c7ed/',\n", - " 'Molecular_Formula': 'http://localhost:8000/api/material-identifier/e03bb825-b43e-42ed-97b4-614154cfc30f/'}" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "id_urls" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Success! And if we were to navigate to each url, we'd see an associated material identifier definition url. So for our instance of the molecular formula, there is the url that corresponds to the material identifier definition for molecular formula.\n", - "\n", - "Lastly, we need to associate each of these identifiers with the material (at the material endpoint). To do so, we use `Patch`, which will update the identifier field of our material entry." - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "'http://localhost:8000/api/material/d240c1f3-4f71-41b7-922b-370abe60e710/'" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#obtain url for the material using Get\n", - "mat_url = escalate.get(endpoint='material',\n", - " data={'description': 'Ammonium Iodide', \n", - " 'fields': ['url', 'description']})['url']\n", - "\n", - "mat_url" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n" - ] - } - ], - "source": [ - "for val in id_urls.values():\n", - " r = escalate.patch(url=mat_url, \n", - " data={'identifier': val \n", - " })\n", - " print(r)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**issue: as of now, each patch request overwrites the previous one**" - ] - } - ], - "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.4" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} From acedbdec7fbdd19e60ee16b7ee381d2c077891d7 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Fri, 3 Sep 2021 18:55:49 -0400 Subject: [PATCH 10/17] fix post() json; delete search() --- escalateclient/escalateclient.py | 169 +------------------------------ 1 file changed, 1 insertion(+), 168 deletions(-) diff --git a/escalateclient/escalateclient.py b/escalateclient/escalateclient.py index 4fa7cc2..e8dc3b7 100644 --- a/escalateclient/escalateclient.py +++ b/escalateclient/escalateclient.py @@ -54,173 +54,6 @@ def get(self, return r.json()['results'] print('Returning response object') return r - - def search(self, - endpoint='', - related_ep=None, #for cross-searches - search_field='', - criteria= '', - data=None, #must be a list - exact=False, - negate=False, - parse_json=True, - content_type='application/json'): - - if negate==False: - - if exact==True: - if data == None: - '''Returns all fields for exact match''' - if related_ep == None: - - r = requests.get(f'{self.base_url}/api/{endpoint}/?{search_field}={criteria}', - headers={**self._token_header, - 'content-type': content_type}) - else: #cross-search - r = requests.get(f'{self.base_url}/api/{endpoint}/?{related_ep}__{search_field}={criteria}', - headers={**self._token_header, - 'content-type': content_type}) - - else: - '''Returns requested field(s) for exact match''' - i=0 - data_string='' - while i= 1: - print(f"Found {resp_json['count']} resources, returning list of dicts)") - return r.json()['results'] - print('Returning response object') - return r def post(self, endpoint, @@ -235,7 +68,7 @@ def post(self, r = requests.api.post( f'{self.base_url}/api/{endpoint}', - data=json.dumps(data), + json=data, headers={**self._token_header, 'content-type': content_type}) print(r) From ae133028ccf2c0363c3d7ef4a39addd2eb1a52a7 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Fri, 3 Sep 2021 18:56:12 -0400 Subject: [PATCH 11/17] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 833725d..e8ab121 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,6 @@ escalate=ESCALATEClient(escalate_url, escalate.list_endpoints() -escalate.search(endpoint, search_field, criteria, data=[], exact=False, negate=False) - escalate.get(endpoint, data={}) escalate.post(endpoint, data={}) escalate.patch(resource_url, data={}) From 96c1e242db3c273275d1f3bef7b56692b098c2ff Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Tue, 7 Sep 2021 15:20:25 -0400 Subject: [PATCH 12/17] pass json keyword into put() and patch() --- escalateclient/escalateclient.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/escalateclient/escalateclient.py b/escalateclient/escalateclient.py index e8dc3b7..b7dae8e 100644 --- a/escalateclient/escalateclient.py +++ b/escalateclient/escalateclient.py @@ -78,8 +78,8 @@ def post(self, print('POST: FAILED, returning response object') return r - def put(self, url=None, endpoint=None, resource_id=None, data=None): - """Update a complete resource + def put(self, data, url=None, endpoint=None, resource_id=None): + """Update a resource Either provide a url or an endpoint and resource id """ if not ((url is not None) or (endpoint is not None and resource_id is not None)): @@ -87,10 +87,10 @@ def put(self, url=None, endpoint=None, resource_id=None, data=None): if url is None: url = f'{self.base_url}/api/{endpoint}/{resource_id}' - r = requests.api.put(url, data, headers=self._token_header) + r = requests.api.put(url, json=data, headers=self._token_header) return r - def patch(self, url=None, endpoint=None, resource_id=None, data=None): + def patch(self, data, url=None, endpoint=None, resource_id=None): """Update parts of a resource Either provide a url or an endpoint and resource id """ @@ -99,7 +99,7 @@ def patch(self, url=None, endpoint=None, resource_id=None, data=None): if url is None: url = f'{self.base_url}/api/{endpoint}/{resource_id}' - r = requests.api.patch(url, data, headers=self._token_header) + r = requests.api.patch(url, json=data, headers=self._token_header) return r def delete(self, url=None, endpoint=None, resource_id=None): From 6e9c217fcb74850b84e11854baed46b13ec8c2d5 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Tue, 7 Sep 2021 15:22:55 -0400 Subject: [PATCH 13/17] Add files via upload --- demos/workflow_experiment_demo.ipynb | 3844 ++++++++++++++++++++++++++ 1 file changed, 3844 insertions(+) create mode 100644 demos/workflow_experiment_demo.ipynb diff --git a/demos/workflow_experiment_demo.ipynb b/demos/workflow_experiment_demo.ipynb new file mode 100644 index 0000000..304c7ea --- /dev/null +++ b/demos/workflow_experiment_demo.ipynb @@ -0,0 +1,3844 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Creating experiment templates through ESCALATE REST\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "#factor this out when it's imported into the client\n", + "\n", + "import requests\n", + "\n", + "class ESCALATEClient():\n", + " \"\"\"ESCALATE API Client\"\"\"\n", + " \n", + " def __init__(self, base_url, username, password):\n", + " self.base_url = base_url\n", + " self.username = username\n", + " self.password = password\n", + " self._token = None\n", + " self._is_logged_in = False\n", + " self._login()\n", + " \n", + " def _login(self):\n", + " r_login = requests.post(f'{self.base_url}/api/login', \n", + " data={'username': self.username, \n", + " 'password': self.password})\n", + " self._token = r_login.json()['token']\n", + " self._token_header = {'Authorization': f'Token {self._token}'}\n", + " self._is_logged_in = True\n", + " \n", + " def get(self, \n", + " endpoint='', \n", + " data=None, \n", + " parse_json=True, \n", + " content_type='application/json'):\n", + " \"\"\"Make GET request with `data` to `endpoint` in ESCALATE API\n", + " \n", + " return: (dict|list|requests.Response), bool\n", + " \"\"\"\n", + " data = {} if data is None else data\n", + " r = requests.get(f'{self.base_url}/api/{endpoint}',\n", + " params=data, \n", + " headers={**self._token_header, \n", + " 'content-type': content_type})\n", + " if r.ok: \n", + " print('GET: OK')\n", + " else: \n", + " print('GET: FAILED')\n", + " \n", + " if r.ok and parse_json:\n", + " resp_json = r.json() \n", + " # handle cases: no vs one vs many results\n", + " count = resp_json.get('count')\n", + " if count is None or count == 0:\n", + " return r.json()\n", + " elif count == 1: \n", + " print('Found one resource, returning dict')\n", + " return resp_json['results'][0]\n", + " elif count >= 1: \n", + " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", + " return r.json()['results']\n", + " print('Returning response object') \n", + " return r\n", + " \n", + " def post(self, \n", + " endpoint, \n", + " data, \n", + " content_type='application/json'):\n", + " \"\"\"POST `data` to `endpoint`in ESCALATE API using `content_type`\n", + " return: (dict|requests.Response), bool\n", + " \"\"\"\n", + " \n", + " if not self._is_logged_in:\n", + " raise ValueError(\"Not logged in: cannot post\")\n", + " \n", + " r = requests.api.post(\n", + " f'{self.base_url}/api/{endpoint}', \n", + " json=data, \n", + " headers={**self._token_header,\n", + " 'content-type': content_type})\n", + " print(r)\n", + " if r.ok: \n", + " print('POST: OK, returning new resource dict')\n", + " return r.json()\n", + " print('POST: FAILED, returning response object')\n", + " return r\n", + " \n", + " def put(self, data, url=None, endpoint=None, resource_id=None):\n", + " \"\"\"Update a resource\n", + " Either provide a url or an endpoint and resource id\n", + " \"\"\"\n", + " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", + " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", + " \n", + " if url is None: \n", + " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", + " r = requests.api.put(url, json=data, headers=self._token_header)\n", + " return r\n", + " \n", + " def patch(self, data, url=None, endpoint=None, resource_id=None):\n", + " \"\"\"Update parts of a resource\n", + " Either provide a url or an endpoint and resource id\n", + " \"\"\"\n", + " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", + " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", + " \n", + " if url is None: \n", + " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", + " r = requests.api.patch(url, json=data, headers=self._token_header)\n", + " return r\n", + " \n", + " def delete(self, url=None, endpoint=None, resource_id=None):\n", + " \"\"\"Delete a resource\n", + " Either provide a url or an endpoint and resource id\n", + " \"\"\"\n", + " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", + " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", + " if url is None: \n", + " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", + " r = requests.api.delete(url, headers=self._token_header)\n", + " return r\n", + " \n", + " def list_endpoints(self):\n", + " return self.get()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def search(self, \n", + " endpoint='',\n", + " related_ep=None, #for cross-searches\n", + " search_field='',\n", + " criteria= '',\n", + " data=None, #must be a list\n", + " exact=False,\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json'):\n", + " \n", + " if negate==False:\n", + "\n", + " if exact==True:\n", + " if data == None:\n", + " '''Returns all fields for exact match'''\n", + " if related_ep == None:\n", + " \n", + " r = requests.get(f'{self.base_url}/api/{endpoint}/?{search_field}={criteria}', \n", + " headers={**self._token_header, \n", + " 'content-type': content_type})\n", + " else: #cross-search \n", + " r = requests.get(f'{self.base_url}/api/{endpoint}/?{related_ep}__{search_field}={criteria}', \n", + " headers={**self._token_header, \n", + " 'content-type': content_type})\n", + "\n", + " else:\n", + " '''Returns requested field(s) for exact match'''\n", + " i=0\n", + " data_string=''\n", + " while i= 1: \n", + " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", + " return r.json()['results']\n", + " print('Returning response object') \n", + " return r" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import the REST API Client." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import escalateclient\n", + "from escalateclient import ESCALATEClient" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Enter your ESCALATE username and password, and the port number at which the server is running. Then run the following cell. This will create an instance of the API Client and set up a token to interact with the REST API." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "username= 'nsmina'\n", + "password= 'password11'\n", + "port='8000'\n", + "\n", + "escalate = ESCALATEClient(\n", + " f'http://localhost:{port}',\n", + " username,\n", + " password\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To see all the model endpoints (this is also a good way to verify that you are connected):" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n" + ] + }, + { + "data": { + "text/plain": [ + "{'action': 'http://localhost:8000/api/action/',\n", + " 'actiondef': 'http://localhost:8000/api/action-def/',\n", + " 'actionunit': 'http://localhost:8000/api/action-unit/',\n", + " 'actor': 'http://localhost:8000/api/actor/',\n", + " 'basebommaterial': 'http://localhost:8000/api/base-bom-material/',\n", + " 'billofmaterials': 'http://localhost:8000/api/bill-of-materials/',\n", + " 'bomcompositematerial': 'http://localhost:8000/api/bom-composite-material/',\n", + " 'bommaterial': 'http://localhost:8000/api/bom-material/',\n", + " 'calculation': 'http://localhost:8000/api/calculation/',\n", + " 'calculationdef': 'http://localhost:8000/api/calculation-def/',\n", + " 'condition': 'http://localhost:8000/api/condition/',\n", + " 'conditiondef': 'http://localhost:8000/api/condition-def/',\n", + " 'experiment': 'http://localhost:8000/api/experiment/',\n", + " 'experimentinstance': 'http://localhost:8000/api/experiment-instance/',\n", + " 'experimenttemplate': 'http://localhost:8000/api/experiment-template/',\n", + " 'experimenttype': 'http://localhost:8000/api/experiment-type/',\n", + " 'experimentworkflow': 'http://localhost:8000/api/experiment-workflow/',\n", + " 'inventory': 'http://localhost:8000/api/inventory/',\n", + " 'inventorymaterial': 'http://localhost:8000/api/inventory-material/',\n", + " 'material': 'http://localhost:8000/api/material/',\n", + " 'materialidentifier': 'http://localhost:8000/api/material-identifier/',\n", + " 'materialidentifierdef': 'http://localhost:8000/api/material-identifier-def/',\n", + " 'materialtype': 'http://localhost:8000/api/material-type/',\n", + " 'measure': 'http://localhost:8000/api/measure/',\n", + " 'measuredef': 'http://localhost:8000/api/measure-def/',\n", + " 'measuretype': 'http://localhost:8000/api/measure-type/',\n", + " 'mixture': 'http://localhost:8000/api/mixture/',\n", + " 'organization': 'http://localhost:8000/api/organization/',\n", + " 'outcome': 'http://localhost:8000/api/outcome/',\n", + " 'parameterdef': 'http://localhost:8000/api/parameter-def/',\n", + " 'person': 'http://localhost:8000/api/person/',\n", + " 'propertydef': 'http://localhost:8000/api/property-def/',\n", + " 'status': 'http://localhost:8000/api/status/',\n", + " 'systemtool': 'http://localhost:8000/api/systemtool/',\n", + " 'systemtooltype': 'http://localhost:8000/api/systemtool-type/',\n", + " 'tag': 'http://localhost:8000/api/tag/',\n", + " 'tagtype': 'http://localhost:8000/api/tag-type/',\n", + " 'typedef': 'http://localhost:8000/api/type-def/',\n", + " 'udfdef': 'http://localhost:8000/api/udf-def/',\n", + " 'unittype': 'http://localhost:8000/api/unit-type/',\n", + " 'vessel': 'http://localhost:8000/api/vessel/',\n", + " 'workflow': 'http://localhost:8000/api/workflow/',\n", + " 'workflowactionset': 'http://localhost:8000/api/workflow-action-set/',\n", + " 'workflowobject': 'http://localhost:8000/api/workflow-object/',\n", + " 'workflowstep': 'http://localhost:8000/api/workflow-step/',\n", + " 'workflowtype': 'http://localhost:8000/api/workflow-type/'}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.list_endpoints()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create an Experiment" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "'http://localhost:8000/api/experiment/4e7ec69d-b124-45a0-b5ca-8682cad3bb27/'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r = escalate.post('experiment/', {'description': 'Workflow 1 Demo', 'ref_uid': 'wf1_demo'})\n", + "\n", + "exp = r['url']\n", + "exp" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Create workflows to go with the experiment. (These correspond to parts of the procedure)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Reagent Preparation': 'http://localhost:8000/api/workflow/0841e1c1-5aa3-4962-ae27-2d8b94bab5f6/',\n", + " 'Synthesis': 'http://localhost:8000/api/workflow/279458f4-e4c8-42cc-a6f9-22b91964d48a/'}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "wfs = {name: escalate.post('workflow/', \n", + " {'experiment': exp, \n", + " 'description': name\n", + " })['url']\n", + " for name in ['Reagent Preparation', 'Synthesis']\n", + " }\n", + "\n", + "wfs" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Gather Materials\n", + "\n", + "* Search the database using `Get()` with filters to determine if the materials exist. If not, `Post()` them\n", + "\n", + "We need lead (II) iodide (PbI2), ammonium iodide (NH4I), Gamma-butyrolactone (GBL), and formic acid (HCOOH)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/material/b9ad5eeb-9ab8-458f-b7cf-e9200b7964ad/', 'description': 'Gamma-Butyrolactone'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/material/758d9a15-69d6-4439-9d58-087a46d3d890/', 'description': 'Formic Acid'}\n" + ] + } + ], + "source": [ + "mat_name_searches = ['Lead (II) Iodide', 'Ammonium Iodide', 'Gamma-Butyrolactone', 'Formic Acid']\n", + "\n", + "for i in mat_name_searches: \n", + " r = escalate.get('material', data={'fields': ['description', 'url'],\n", + " 'description': i}) \n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Searching for lead (II) iodide by exact name returned no results; let's expand our search criteria and do a cross-search by InChI key in the material identifer table to verify whether it's in the inventory." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/56665bf9-566d-41dc-b8dd-6f74174e7435/',\n", + " 'description': 'Lead Diiodide'}" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r = escalate.get('material', data={'fields': ['description', 'url'],\n", + " 'identifier__description': 'RQQRAHKHDFPBMC-UHFFFAOYSA-L'}) \n", + "r" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "So it does exist, just not under the name we expected.\n", + "\n", + "For ammonium iodide, which doesn't exist, we have to `Post()`. Note we could also associate identifiers like molecular formula and InChI with our new material, but for the scope of this tutorial it's enough to just post it with a description." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/e5e68e17-9c15-4d36-8e54-e6f27efafe00/',\n", + " 'uuid': 'e5e68e17-9c15-4d36-8e54-e6f27efafe00',\n", + " 'edocs': [],\n", + " 'tags': [],\n", + " 'notes': [],\n", + " 'property': [],\n", + " 'add_date': '2021-09-07T17:37:30.589089',\n", + " 'mod_date': '2021-09-07T17:37:30.589110',\n", + " 'description': 'Ammonium Iodide',\n", + " 'consumable': True,\n", + " 'material_class': 'model',\n", + " 'internal_slug': 'ammonium-iodide',\n", + " 'status': None,\n", + " 'actor': None,\n", + " 'identifier': [],\n", + " 'material_type': []}" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.post(endpoint='material/', \n", + " data={'description': 'Ammonium Iodide', \n", + " 'material_class': 'model',\n", + " 'consumable': True} \n", + " )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Collect the materials within an inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Lead Diiodide': 'http://localhost:8000/api/material/56665bf9-566d-41dc-b8dd-6f74174e7435/',\n", + " 'Ammonium Iodide': 'http://localhost:8000/api/material/e5e68e17-9c15-4d36-8e54-e6f27efafe00/',\n", + " 'Gamma-Butyrolactone': 'http://localhost:8000/api/material/b9ad5eeb-9ab8-458f-b7cf-e9200b7964ad/',\n", + " 'Formic Acid': 'http://localhost:8000/api/material/758d9a15-69d6-4439-9d58-087a46d3d890/'}" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#make life easier and just use the exact names that were returned by our searches\n", + "mat_names = ['Lead Diiodide', 'Ammonium Iodide', 'Gamma-Butyrolactone', 'Formic Acid']\n", + "\n", + "materials = {name: escalate.get('material', {'description': name})['url']\n", + " for name in mat_names\n", + " }\n", + "\n", + "materials" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "'http://localhost:8000/api/inventory/4a75a47b-dc21-47ff-90b0-63c99ffbd01e/'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventory = escalate.post('inventory/', data={'description': 'Workflow 1 Demo'})['url']\n", + "\n", + "inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Lead Diiodide': 'http://localhost:8000/api/inventory-material/9e5dc29b-e3eb-4e92-a5b6-734913d6e612/',\n", + " 'Ammonium Iodide': 'http://localhost:8000/api/inventory-material/4f84deb8-123f-4fd9-85f3-2594112d9239/',\n", + " 'Gamma-Butyrolactone': 'http://localhost:8000/api/inventory-material/dc090731-4464-481a-a27c-53ea0880116f/',\n", + " 'Formic Acid': 'http://localhost:8000/api/inventory-material/3615c1aa-8f53-4661-9369-391b663d72d2/'}" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventory_materials = {description: escalate.post('inventory-material/', \n", + " {'description': description, \n", + " 'material': url,\n", + " 'inventory': inventory})['url']\n", + " for description, url in materials.items()}\n", + "\n", + "inventory_materials" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Create a bill of materials from the inventory, for the specific experiment" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Lead Diiodide': 'http://localhost:8000/api/base-bom-material/2ab45132-0cc3-4262-a884-3a2db82fd624/',\n", + " 'Ammonium Iodide': 'http://localhost:8000/api/base-bom-material/e7e0a9d4-9d5e-4798-a2e1-496a6aedb1d4/',\n", + " 'Gamma-Butyrolactone': 'http://localhost:8000/api/base-bom-material/046a9bae-d9a9-4302-a08e-f8cc2e55e0d3/',\n", + " 'Formic Acid': 'http://localhost:8000/api/base-bom-material/471d0e15-d4fe-4757-b886-151d44ba7bf9/'}" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom = escalate.post('bill-of-materials/', {'description': 'Workflow 1 Demo', \n", + " 'experiment': exp})['url']\n", + "\n", + "bom_materials = {name: escalate.post('bom-material/', \n", + " {'bom': bom, 'inventory_material': im}\n", + " )['url']\n", + " for name, im in inventory_materials.items()}\n", + "\n", + "bom_materials" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Gather Containers\n", + "\n", + "Currently containers are treated as materials. So we follow the same process of `Post()`ing first to the materials endpoint, then to the inventory, then to the BOM\n", + "\n", + "We'll need four stock containers (let's call them tubes) and one 96-well plate. We can use one overall plate material and just create 96 wells in the BOM. For the tubes, we can create a generic stock tube. We can assume all four tubes for our experiment are identical, material-wise, and just create several instances with different names in the BOM." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "tube_material = escalate.post('material/',\n", + " {'description': 'tube', 'material_class':'model'})" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "plate_material = escalate.post('material/',\n", + " {'description': '96 well plate', 'material_class':'model'})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Collect the containers within an inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/inventory-material/39514fe7-fa9a-4237-9483-b17e7a3749ac/\n" + ] + } + ], + "source": [ + "cont_names= ['tube', '96 well plate']\n", + "\n", + "for name in cont_names:\n", + "\n", + " cont_im = escalate.post('inventory-material/', \n", + " {'description': name, \n", + " 'material':escalate.get('material', data={'description': name})['url'],\n", + " 'inventory': inventory})['url']\n", + " \n", + " print(cont_im)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Create a bill of materials from the inventory, for the specific experiment" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Stock Tube 1': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/',\n", + " 'Stock Tube 2': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/',\n", + " 'Stock Container 3': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/',\n", + " 'Stock Container 4': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/'}" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tube_names=['Stock Tube 1', 'Stock Tube 2', 'Stock Container 3', 'Stock Container 4']\n", + "\n", + "tube_inventory={}\n", + "for name in tube_names:\n", + " tube_inventory[name]= escalate.get('inventory-material', data={'description': 'tube'})['url']\n", + " \n", + "tube_inventory" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**NEED TO ADD DESCRIPTIONS WHEN I POST THESE**" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Stock Tube 1': 'http://localhost:8000/api/base-bom-material/198b3a32-dd37-44a9-aafb-3411bc05afd6/',\n", + " 'Stock Tube 2': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/',\n", + " 'Stock Container 3': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/',\n", + " 'Stock Container 4': 'http://localhost:8000/api/base-bom-material/d5ac3fe5-356c-4411-a900-c63669bf23a4/'}" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom_tubes = {name: escalate.post('bom-material/', \n", + " {'bom': bom, \n", + " 'inventory_material': url}\n", + " )['url']\n", + " for name, url in tube_inventory.items()}\n", + "\n", + "bom_tubes" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "ename": "NameError", + "evalue": "name 'bom_wells' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 16\u001b[0m for name, url in well_inventory.items()}\n\u001b[1;32m 17\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 18\u001b[0;31m \u001b[0mbom_wells\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mNameError\u001b[0m: name 'bom_wells' is not defined" + ] + } + ], + "source": [ + "idx=[]\n", + "for i in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']:\n", + " for j in range(1,13):\n", + " idx.append(i + str(j))\n", + "\n", + "plate_url=escalate.get('inventory-material', {'description': '96 well plate'})['url']\n", + "\n", + "well_inventory={}\n", + "for well in idx:\n", + " well_inventory[well]=plate_url\n", + "\n", + "bom_wellss = {name: escalate.post('bom-material/', \n", + " {'bom': bom, \n", + " 'inventory_material': url}\n", + " )['url']\n", + " for name, url in well_inventory.items()}\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'A1': 'http://localhost:8000/api/base-bom-material/3429cdfb-a140-4a60-8825-f40142b1328f/',\n", + " 'A2': 'http://localhost:8000/api/base-bom-material/d22f6fef-8388-430a-bcff-fcf58a34cdff/',\n", + " 'A3': 'http://localhost:8000/api/base-bom-material/c0a710e3-4c09-4bde-9fa4-eef8f4505079/',\n", + " 'A4': 'http://localhost:8000/api/base-bom-material/599d7d7a-5942-4e5c-bcc5-94022e07e607/',\n", + " 'A5': 'http://localhost:8000/api/base-bom-material/f7bd3a08-4f85-4e60-b520-26fd43231518/',\n", + " 'A6': 'http://localhost:8000/api/base-bom-material/5a8589ad-5d4f-4236-a3bd-abeba58c23bd/',\n", + " 'A7': 'http://localhost:8000/api/base-bom-material/2317cebe-595b-464c-b3a0-4e1504603c48/',\n", + " 'A8': 'http://localhost:8000/api/base-bom-material/fe3e35e3-3a5f-4bd7-ae7f-f332179f94d3/',\n", + " 'A9': 'http://localhost:8000/api/base-bom-material/a509b29c-3d43-45ec-90b1-8d629700b630/',\n", + " 'A10': 'http://localhost:8000/api/base-bom-material/1dacbb4b-9843-4241-a782-2095738a83ad/',\n", + " 'A11': 'http://localhost:8000/api/base-bom-material/547ac41d-e574-449f-b106-0eeecf8bcdac/',\n", + " 'A12': 'http://localhost:8000/api/base-bom-material/05922650-de21-4259-878e-ba02346d530c/',\n", + " 'B1': 'http://localhost:8000/api/base-bom-material/2beb55f3-ab21-4d31-ac64-2ad4b4771b39/',\n", + " 'B2': 'http://localhost:8000/api/base-bom-material/3f0542fe-9455-4cea-9bac-ac7e281620c6/',\n", + " 'B3': 'http://localhost:8000/api/base-bom-material/0fbc8401-952f-412c-bc47-75af0220d2a6/',\n", + " 'B4': 'http://localhost:8000/api/base-bom-material/167a01bc-3451-4fac-afb8-654b3564b1ec/',\n", + " 'B5': 'http://localhost:8000/api/base-bom-material/edd061b0-385a-463f-9772-4ff46a3b12ea/',\n", + " 'B6': 'http://localhost:8000/api/base-bom-material/a199a25c-1fb2-405f-b277-4e0033773a1c/',\n", + " 'B7': 'http://localhost:8000/api/base-bom-material/63eef2e9-14e9-47ea-8d1c-09fd83f4c7f6/',\n", + " 'B8': 'http://localhost:8000/api/base-bom-material/a6e7d78b-815c-40c3-87b7-fa88069cc1d9/',\n", + " 'B9': 'http://localhost:8000/api/base-bom-material/b08c0ee9-5336-49c4-8a6f-4ed4ee46afe3/',\n", + " 'B10': 'http://localhost:8000/api/base-bom-material/4918f791-3c00-406f-ab87-e13eb6082d02/',\n", + " 'B11': 'http://localhost:8000/api/base-bom-material/3d77a845-b58f-48bb-b0c2-005b5aad655e/',\n", + " 'B12': 'http://localhost:8000/api/base-bom-material/49886321-4596-4f89-ada1-5c42415eb781/',\n", + " 'C1': 'http://localhost:8000/api/base-bom-material/070b4db1-e1f7-4f2a-8bdc-a836010e6e2f/',\n", + " 'C2': 'http://localhost:8000/api/base-bom-material/d92e3501-a230-4fe2-8899-2576458dbf78/',\n", + " 'C3': 'http://localhost:8000/api/base-bom-material/7aab999e-4fa4-432b-ae24-486101d414da/',\n", + " 'C4': 'http://localhost:8000/api/base-bom-material/000be119-0fc4-4f88-b800-59b06958cd66/',\n", + " 'C5': 'http://localhost:8000/api/base-bom-material/393c9476-05a3-4cdf-9e8d-8213ec479e16/',\n", + " 'C6': 'http://localhost:8000/api/base-bom-material/85638498-e236-44dd-b499-445ad47ba09c/',\n", + " 'C7': 'http://localhost:8000/api/base-bom-material/10776786-f9d0-4e3f-8af8-1d825c01172a/',\n", + " 'C8': 'http://localhost:8000/api/base-bom-material/6ec4ace6-14ed-4946-b535-3b525189ca02/',\n", + " 'C9': 'http://localhost:8000/api/base-bom-material/69ed4658-bec0-4e42-9c41-3fc3ae64a31a/',\n", + " 'C10': 'http://localhost:8000/api/base-bom-material/95213548-150a-40b9-b2f0-1ac0d19da7b8/',\n", + " 'C11': 'http://localhost:8000/api/base-bom-material/f6c00d7d-36d9-477f-a9e7-0acdf4ff5e8b/',\n", + " 'C12': 'http://localhost:8000/api/base-bom-material/79ed4929-dfc4-4ae4-b0d4-b394535c7eff/',\n", + " 'D1': 'http://localhost:8000/api/base-bom-material/5af0eb22-ccdd-4a10-94c7-ca32d25b3fa8/',\n", + " 'D2': 'http://localhost:8000/api/base-bom-material/d5c442cf-249d-4562-8765-352c25b08b6d/',\n", + " 'D3': 'http://localhost:8000/api/base-bom-material/0e4a7df5-af76-4433-94da-15a5e42b8c55/',\n", + " 'D4': 'http://localhost:8000/api/base-bom-material/ec681f7d-cfca-4513-b5fe-1e7b7d649a91/',\n", + " 'D5': 'http://localhost:8000/api/base-bom-material/9c7a2796-ac07-42d2-a911-db64593da3d9/',\n", + " 'D6': 'http://localhost:8000/api/base-bom-material/c183d1fc-fe4b-4637-884a-63ff6b8c0132/',\n", + " 'D7': 'http://localhost:8000/api/base-bom-material/14e69706-4f79-4995-a13f-91d5ef3ade61/',\n", + " 'D8': 'http://localhost:8000/api/base-bom-material/9ea3cb10-1ee9-49a9-b5b6-155bd9eacbf2/',\n", + " 'D9': 'http://localhost:8000/api/base-bom-material/7f6e55dc-b55d-402e-baf8-db71d8c8fdf6/',\n", + " 'D10': 'http://localhost:8000/api/base-bom-material/506539be-bf32-4bd8-80c8-df56e82312c5/',\n", + " 'D11': 'http://localhost:8000/api/base-bom-material/33766468-2792-4481-bb29-457fe43cafe7/',\n", + " 'D12': 'http://localhost:8000/api/base-bom-material/d33a69b1-70a9-425c-b7d3-170aa7e3ba29/',\n", + " 'E1': 'http://localhost:8000/api/base-bom-material/b53c6292-c4ae-4b59-9e96-c7b7d62eb2eb/',\n", + " 'E2': 'http://localhost:8000/api/base-bom-material/3256ff6d-8df0-4015-a2ed-45682e205d3f/',\n", + " 'E3': 'http://localhost:8000/api/base-bom-material/70cac8bf-c2a1-4be3-bf3d-c7deb136dbb3/',\n", + " 'E4': 'http://localhost:8000/api/base-bom-material/5ecb727e-3943-458a-848c-ffbb34e0d0f7/',\n", + " 'E5': 'http://localhost:8000/api/base-bom-material/d522b3c4-523e-44e5-b0ad-43e13b46af6e/',\n", + " 'E6': 'http://localhost:8000/api/base-bom-material/70c527fc-63cb-47e1-9586-93eb8cfbfbd8/',\n", + " 'E7': 'http://localhost:8000/api/base-bom-material/3f0893bb-9fd0-4470-ba61-acaaf7f7af51/',\n", + " 'E8': 'http://localhost:8000/api/base-bom-material/ffd75695-d009-4b0a-b599-602b50353c7b/',\n", + " 'E9': 'http://localhost:8000/api/base-bom-material/f0eb8c17-fc58-429e-88dc-7564a49e70ea/',\n", + " 'E10': 'http://localhost:8000/api/base-bom-material/22113f50-3e30-4887-9c63-909cd33aa0b6/',\n", + " 'E11': 'http://localhost:8000/api/base-bom-material/435fa952-ad58-4201-a076-060aceac1ecb/',\n", + " 'E12': 'http://localhost:8000/api/base-bom-material/ab0e66a5-205d-49f4-8407-51d0201c607c/',\n", + " 'F1': 'http://localhost:8000/api/base-bom-material/89262578-2216-4d70-a2f8-c51e89f3ad33/',\n", + " 'F2': 'http://localhost:8000/api/base-bom-material/835d7505-c502-4e16-a1c8-21f20a9e5c05/',\n", + " 'F3': 'http://localhost:8000/api/base-bom-material/ec7339ad-21bb-47f9-8951-a1b1c71407ee/',\n", + " 'F4': 'http://localhost:8000/api/base-bom-material/7f7a5b0b-de47-4a27-97e8-d9e9be4d0275/',\n", + " 'F5': 'http://localhost:8000/api/base-bom-material/339dcf81-aa62-43a4-8e92-45419ef6ab3c/',\n", + " 'F6': 'http://localhost:8000/api/base-bom-material/effe5111-b1ba-4777-ab83-aaa0d53c6219/',\n", + " 'F7': 'http://localhost:8000/api/base-bom-material/4d90e72b-9b22-4841-94eb-cd5b89ca001d/',\n", + " 'F8': 'http://localhost:8000/api/base-bom-material/41676005-1024-4ee6-88de-b96defb81208/',\n", + " 'F9': 'http://localhost:8000/api/base-bom-material/524a460e-5932-4c64-8797-2ff7cea85c30/',\n", + " 'F10': 'http://localhost:8000/api/base-bom-material/52dca674-b010-4419-86fd-558cc71e34f7/',\n", + " 'F11': 'http://localhost:8000/api/base-bom-material/9f19985c-8ab2-4815-adfe-7c01a874df68/',\n", + " 'F12': 'http://localhost:8000/api/base-bom-material/3d75ee6b-b299-4653-8a25-894c1ea92441/',\n", + " 'G1': 'http://localhost:8000/api/base-bom-material/3313b807-5ebb-4cca-a384-4e6e353c952b/',\n", + " 'G2': 'http://localhost:8000/api/base-bom-material/033f99e9-e986-4862-b709-400a37d92759/',\n", + " 'G3': 'http://localhost:8000/api/base-bom-material/1b7851e3-6544-4691-a47a-a222899ad618/',\n", + " 'G4': 'http://localhost:8000/api/base-bom-material/2ad0acc7-bb7a-475d-a3cd-b127d4122425/',\n", + " 'G5': 'http://localhost:8000/api/base-bom-material/c5c29c81-8892-48d2-bebf-148839ec2fa0/',\n", + " 'G6': 'http://localhost:8000/api/base-bom-material/8b0e2fa3-5952-4b85-b7e6-7f473d15bc2a/',\n", + " 'G7': 'http://localhost:8000/api/base-bom-material/0e5cc62e-b63d-40ef-bd73-e74a889ce4ef/',\n", + " 'G8': 'http://localhost:8000/api/base-bom-material/b370e6a3-c921-4f98-a3a4-f525f945d3c3/',\n", + " 'G9': 'http://localhost:8000/api/base-bom-material/279b8aea-4a8d-40aa-bf53-579d5b9d37ec/',\n", + " 'G10': 'http://localhost:8000/api/base-bom-material/2eb3a4a9-8ccc-423f-8959-99190673775a/',\n", + " 'G11': 'http://localhost:8000/api/base-bom-material/09afccc6-da67-411a-be1d-b299feba4157/',\n", + " 'G12': 'http://localhost:8000/api/base-bom-material/b9c929ae-fdc8-4af8-9ced-215ea676d765/',\n", + " 'H1': 'http://localhost:8000/api/base-bom-material/5f60152e-9566-4322-8119-3123927fba90/',\n", + " 'H2': 'http://localhost:8000/api/base-bom-material/07114655-147e-431d-a1a2-3f93085eb8b7/',\n", + " 'H3': 'http://localhost:8000/api/base-bom-material/52b04956-91ed-47f6-b531-f0dfe17b378c/',\n", + " 'H4': 'http://localhost:8000/api/base-bom-material/8bd4bb8d-664d-49ee-b832-c090b4b52930/',\n", + " 'H5': 'http://localhost:8000/api/base-bom-material/2f39fab4-2b8c-478e-ae74-02ce0c478637/',\n", + " 'H6': 'http://localhost:8000/api/base-bom-material/779770c8-f74f-4c84-9227-a9b2f7369ec9/',\n", + " 'H7': 'http://localhost:8000/api/base-bom-material/c729d49f-e2de-47f7-9d61-28c3148fa317/',\n", + " 'H8': 'http://localhost:8000/api/base-bom-material/9dd291cb-a4bf-45d1-876f-96f1ab2f628d/',\n", + " 'H9': 'http://localhost:8000/api/base-bom-material/d11c1e98-c90e-4daa-86b7-0a23840ddd04/',\n", + " 'H10': 'http://localhost:8000/api/base-bom-material/0b0d2b93-ad8a-4528-9b1c-7a7851fe5c54/',\n", + " 'H11': 'http://localhost:8000/api/base-bom-material/71356862-75e8-4d3f-8585-bbbe9d2ac9c4/',\n", + " 'H12': 'http://localhost:8000/api/base-bom-material/86219b01-bc1e-4479-a68d-a573edf2c544/'}" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom_wellss" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set Up Actions\n", + "\n", + "* Determine all actions needed for the experiment procedure. Use `Get()` to search the database for definitions of these actions (action-def). `Post()` new ones as needed" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/action-def/0ccac627-5e68-4010-84b4-d1db19adabf9/', 'description': 'dispense_solid'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/action-def/030d508f-49a4-4eab-a83b-fb1635f3e793/', 'description': 'heat'}\n", + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n" + ] + } + ], + "source": [ + "action_def_names = ['dispense_liquid', 'dispense_solid', 'heat', 'cool', 'transfer', 'stir']\n", + "\n", + "for i in action_def_names: \n", + " r = escalate.get('action-def', data={'fields': ['description', 'url'],\n", + " 'description': i}) \n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Looks like we have definitions for heating and for dispensing solid ... there's heat-stir but not just stir, and the other ones are completely missing. So we `Post()`." + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "missing = ['dispense_liquid', 'cool', 'transfer', 'stir']\n", + "\n", + "for i in missing:\n", + " r = escalate.post('action-def/', {'description': i, \n", + " 'status': escalate.get('status', {'description':'test'})['url']}\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'dispense_liquid': 'http://localhost:8000/api/action-def/60677fdb-6cd2-4239-9915-400e35ff184f/',\n", + " 'dispense_solid': 'http://localhost:8000/api/action-def/0ccac627-5e68-4010-84b4-d1db19adabf9/',\n", + " 'heat': 'http://localhost:8000/api/action-def/030d508f-49a4-4eab-a83b-fb1635f3e793/',\n", + " 'cool': 'http://localhost:8000/api/action-def/7abb21cd-1fff-495c-ace9-e5d81ecf99af/',\n", + " 'transfer': 'http://localhost:8000/api/action-def/e270c81e-b94d-49ae-b68f-2e8a86c31ee8/',\n", + " 'stir': 'http://localhost:8000/api/action-def/bf3bcb09-0a6e-4006-8688-73586036ff85/'}" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "actions = {\n", + " name: escalate.get('action-def', data={'description': name})['url'] \n", + " for name in action_def_names}\n", + "\n", + "actions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Determine the parameters (e.g. temperature, stir speed) that you'll need to specify for each action. Search if these exist, and post new ones as needed\n", + "\n", + "We want temperature for heating/cooling, speed/duration for stirring, and mass and volume for the dispense and transfer actions. Let's use the case-insensitive containtment filter `__icontains` for our search because we don't know exactly what the parameter definitions are called." + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/parameter-def/e4db0901-aabd-4abe-87a3-64a38d9a8217/', 'description': 'temperature'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/parameter-def/1e51d3cd-7cf6-4765-bfc1-e7d54540696f/', 'description': 'speed'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/parameter-def/2cc0ed35-abaf-4ea5-b4c2-c848b0359129/', 'description': 'duration'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/parameter-def/2d9eb6b7-9e17-4e5f-855f-656687c80327/', 'description': 'mass'}\n", + "GET: OK\n", + "Found 6 resources, returning list of dicts)\n", + "[{'url': 'http://localhost:8000/api/parameter-def/79df4ee7-776f-4544-9636-6c37df64cc96/', 'description': 'volume'}, {'url': 'http://localhost:8000/api/parameter-def/73dfd457-1b05-490c-9d6f-3d6cbcce3ad3/', 'description': 'Sample Solvent Volume'}, {'url': 'http://localhost:8000/api/parameter-def/b701f73d-74b3-48ad-be8e-57bd3ed7c45c/', 'description': 'Sample Stock A Volume'}, {'url': 'http://localhost:8000/api/parameter-def/070ad2bf-dd15-49ee-bc33-0ee764ed5106/', 'description': 'Sample Stock B Volume'}, {'url': 'http://localhost:8000/api/parameter-def/72eca483-d496-46bd-9a14-cc32c68a12e1/', 'description': 'Sample Acid Volume 1'}, {'url': 'http://localhost:8000/api/parameter-def/fafa6957-b9c6-4f78-b09e-76eb5d224156/', 'description': 'Sample Acid Volume 2'}]\n" + ] + } + ], + "source": [ + "param_names = ['temperature', 'speed', 'duration', 'mass', 'volume']\n", + "\n", + "for i in param_names: \n", + " r = escalate.get('parameter-def', data={'fields': ['description', 'url'],\n", + " 'description__icontains': i}) \n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Looks like there are several volume-related parameters; the one we want is just \"volume\".\n", + "\n", + "* Associate the action definitions and parameter definitions using `Patch()`" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.patch(url=actions['heat'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'temperature'})['url'], \n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['cool'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'temperature'})['url'],\n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['stir'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'speed'})['url'],\n", + " escalate.get('parameter-def', \n", + " {'description': 'duration'})['url'] \n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['dispense_solid'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'mass'})['url'],\n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['dispense_liquid'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'volume'})['url'],\n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['transfer'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'mass'})['url'],\n", + " escalate.get('parameter-def', \n", + " {'description': 'volume'})['url'] \n", + " ]\n", + " })" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**For transfer we can just have a volume param!**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Create action instances for each action definition\n", + "\n", + "(The instance is linked to an action definition (e.g. dispense solid) and to the desired workflow)" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/cb509d82-18e9-453a-ac75-9951fd6f0225/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/d68f6c57-61dd-4ea1-8075-a068cc347883/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/27280834-dc27-4e8d-9047-d4635ed4cd26/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/8232790d-3791-4a11-952f-6b2bdd5f230b/\n" + ] + } + ], + "source": [ + "prep_actions = ['dispense_solid', 'dispense_liquid', 'cool', 'stir']\n", + "\n", + "action_inst1={}\n", + "\n", + "for action in prep_actions:\n", + " r = escalate.post('action/', \n", + " {'workflow': wfs['Reagent Preparation'], \n", + " 'action_def': actions[action],\n", + " }\n", + " )['url']\n", + " \n", + " action_inst1[action]=r\n", + " \n", + " print(r)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/634146e1-9072-4749-b8d3-d95491a0b9d5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/9284c4fb-3e4d-4d94-9a77-ed04dc9b3ad5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/e5393a85-9b90-4eb7-8fce-2a73783fbc79/\n" + ] + } + ], + "source": [ + "synthesis_actions= ['heat', 'transfer', 'stir']\n", + "\n", + "action_inst2={}\n", + "\n", + "for action in synthesis_actions:\n", + " r = escalate.post('action/', \n", + " {'workflow': wfs['Synthesis'], \n", + " 'action_def': actions[action],\n", + " }\n", + " )['url']\n", + " \n", + " action_inst2[action]=r\n", + " \n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Implement steps of the procedure\n", + "\n", + "* Generate action units for each step " + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "#reagent prep steps of workflow\n", + "#step 1: add 25 mL GBL to stock tube 1\n", + "\n", + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_liquid'],\n", + " 'source_material': bom_materials['Gamma-Butyrolactone'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Tube 1'] #container, from BOM\n", + " })" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For this action, we are dispensing liquid, so we want to know how much. That means we need to specify the (actual) value of the volume parameter. To do so, we use `Patch()`. Once this is done, if we navigate to the url of the specific action unit instance AND to the url of the parameter instance, we should see the (actual) parameter value for volume listed as 25 mL." + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [], + "source": [ + "param_url= r['parameter'][0]['url']\n", + "\n", + "param_url\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 25, 'unit': 'mL', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Stock Tube 1': 'http://localhost:8000/api/base-bom-material/198b3a32-dd37-44a9-aafb-3411bc05afd6/',\n", + " 'Stock Tube 2': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/',\n", + " 'Stock Container 3': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/',\n", + " 'Stock Container 4': 'http://localhost:8000/api/base-bom-material/d5ac3fe5-356c-4411-a900-c63669bf23a4/'}" + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom_tubes" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 68, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#step 2: add 10 mL formic acid to Stock Container 4\n", + "\n", + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_liquid'],\n", + " 'source_material': bom_materials['Formic Acid'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Container 4'] #container, from BOM\n", + " })\n", + "\n", + "param_url= r['parameter'][0]['url']\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 10, 'unit': 'mL', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "r" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "When we have a mixture of different materials in a container we will need several dispensing steps, one for each material. We can handle all the solids in a loop, since the action unit is of the same type." + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c309b221-c8e5-49ac-a09e-4fe02c8a4312/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/666fe60a-e62f-44c3-aa57-ca104a3ebc09/\n" + ] + } + ], + "source": [ + "#step 3 = add 0.5 g PbI2, 0.5 g NH4I, 10 ml GBL to Stock Tube 2\n", + "\n", + "solids={'Lead Diiodide': 0.5, 'Ammonium Iodide': 0.5}\n", + "for key, val in solids.items():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_solid'],\n", + " 'source_material': bom_materials[key], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Tube 2'] #container, from BOM\n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + " \n", + " print(param_url)\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': val, 'unit': 'g', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_liquid'],\n", + " 'source_material': bom_materials['Gamma-Butyrolactone'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Tube 2'] #container, from BOM\n", + " })\n", + "\n", + "param_url= r['parameter'][0]['url']\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 10, 'unit': 'mL', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#step 4 = add 1 g NH4I, 10 mL GBL to Stock Tube 3\n", + "\n", + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_solid'],\n", + " 'source_material': bom_materials['Ammonium Iodide'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Container 3'] #container, from BOM\n", + " })\n", + "\n", + "param_url= r['parameter'][0]['url']\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 1, 'unit': 'g', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_liquid'],\n", + " 'source_material': bom_materials['Gamma-Butyrolactone'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Container 3'] #container, from BOM\n", + " })\n", + "\n", + "param_url= r['parameter'][0]['url']\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 10, 'unit': 'mL', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Stock Tube 1': 'http://localhost:8000/api/base-bom-material/198b3a32-dd37-44a9-aafb-3411bc05afd6/',\n", + " 'Stock Tube 2': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/',\n", + " 'Stock Container 3': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/',\n", + " 'Stock Container 4': 'http://localhost:8000/api/base-bom-material/d5ac3fe5-356c-4411-a900-c63669bf23a4/'}" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom_tubes" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "{'url': 'http://localhost:8000/api/action-unit/766a6d8f-26ce-4d6f-9aea-b238cc078519/', 'uuid': '766a6d8f-26ce-4d6f-9aea-b238cc078519', 'edocs': [], 'tags': [], 'notes': [], 'parameter': [{'url': 'http://localhost:8000/api/parameter/cad773b9-4b6c-4acf-a2d0-61c9b6d39cb3/', 'uuid': 'cad773b9-4b6c-4acf-a2d0-61c9b6d39cb3', 'add_date': '2021-09-07T18:52:41.933830', 'mod_date': '2021-09-07T18:52:41.933849', 'parameter_val_nominal': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/2cc0ed35-abaf-4ea5-b4c2-c848b0359129/', 'action_unit': 'http://localhost:8000/api/action-unit/766a6d8f-26ce-4d6f-9aea-b238cc078519/'}, {'url': 'http://localhost:8000/api/parameter/a9cdbdda-5a5e-4360-b96f-6128272cb6eb/', 'uuid': 'a9cdbdda-5a5e-4360-b96f-6128272cb6eb', 'add_date': '2021-09-07T18:52:41.938966', 'mod_date': '2021-09-07T18:52:41.938985', 'parameter_val_nominal': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/1e51d3cd-7cf6-4765-bfc1-e7d54540696f/', 'action_unit': 'http://localhost:8000/api/action-unit/766a6d8f-26ce-4d6f-9aea-b238cc078519/'}], 'add_date': '2021-09-07T18:52:41.893009', 'mod_date': '2021-09-07T18:52:41.893030', 'description': None, 'internal_slug': 'workflow-1-demo-workflow-1-demo-workflow-1-demo-tube-6-reagent-preparation-stir-2', 'status': None, 'actor': None, 'action': 'http://localhost:8000/api/action/8232790d-3791-4a11-952f-6b2bdd5f230b/', 'source_material': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/', 'destination_material': None}\n", + "\n", + "POST: OK, returning new resource dict\n", + "{'url': 'http://localhost:8000/api/action-unit/8131ecf6-0b00-4bce-bac6-915d052517ad/', 'uuid': '8131ecf6-0b00-4bce-bac6-915d052517ad', 'edocs': [], 'tags': [], 'notes': [], 'parameter': [{'url': 'http://localhost:8000/api/parameter/dd389646-07cb-4a45-977f-3e4b2c23c04a/', 'uuid': 'dd389646-07cb-4a45-977f-3e4b2c23c04a', 'add_date': '2021-09-07T18:52:42.044834', 'mod_date': '2021-09-07T18:52:42.044853', 'parameter_val_nominal': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/2cc0ed35-abaf-4ea5-b4c2-c848b0359129/', 'action_unit': 'http://localhost:8000/api/action-unit/8131ecf6-0b00-4bce-bac6-915d052517ad/'}, {'url': 'http://localhost:8000/api/parameter/13fa6063-1946-43c5-8288-350a892ebf86/', 'uuid': '13fa6063-1946-43c5-8288-350a892ebf86', 'add_date': '2021-09-07T18:52:42.049118', 'mod_date': '2021-09-07T18:52:42.049137', 'parameter_val_nominal': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/1e51d3cd-7cf6-4765-bfc1-e7d54540696f/', 'action_unit': 'http://localhost:8000/api/action-unit/8131ecf6-0b00-4bce-bac6-915d052517ad/'}], 'add_date': '2021-09-07T18:52:42.014590', 'mod_date': '2021-09-07T18:52:42.014608', 'description': None, 'internal_slug': 'workflow-1-demo-workflow-1-demo-workflow-1-demo-tube-7-reagent-preparation-stir', 'status': None, 'actor': None, 'action': 'http://localhost:8000/api/action/8232790d-3791-4a11-952f-6b2bdd5f230b/', 'source_material': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/', 'destination_material': None}\n" + ] + } + ], + "source": [ + "#stir reagents in containers 2 and 3 until contents dissolve\n", + "conts=['Stock Tube 2', 'Stock Container 3']\n", + "\n", + "for cont in conts:\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst1['stir'],\n", + " 'source_material': bom_tubes[cont], \n", + " 'destination_material': None \n", + " })\n", + " print(r)" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "#cool containers 2 and 3 to room temp\n", + "\n", + "for cont in conts:\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst1['cool'],\n", + " 'source_material': bom_tubes[cont], \n", + " 'destination_material': None \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': 25, 'unit': 'deqC', 'type': 'num'}}\n", + "\n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5bcf6bd9-d53e-44da-b890-5f67636526ae/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0c86fd3c-15df-44d1-b38c-57cef8622513/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7483c06d-94d0-4a86-b157-ee94b97e8d7f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/fae8ba52-7ddb-416d-a71f-9acc60dc9705/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5fb42a6b-7ef6-4d36-885d-2890485d6bac/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/55bec7ba-c22d-4538-897a-73f9520c8fb7/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f94373d2-5b60-43c0-9b17-2b9c4237a5b5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/29ec14eb-0b00-4df0-9d36-212545cea1e3/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f7001e70-2159-4e40-a907-6af26589bb84/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/bbc1f272-27dd-45cb-b844-61c13c9f84d1/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f6e1d960-821f-404d-a7c0-9e5370a09cb7/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2c61b76d-200a-41eb-a6be-529304cba391/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b74a849d-0c32-4abb-9473-00453db12167/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/31034025-6122-4547-8ef5-9ab12843b735/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0989b46d-4ea7-46ea-aac0-428e7ac09584/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/cd9a26ee-da64-4ec1-aeb1-c00a9048a984/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/18a41166-979f-4a9c-8f51-b1b90db2d7eb/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a67f6c71-bb32-420a-8440-385df474bd1e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/595a3ab6-83e8-4963-84e4-074cfc9d495f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d38f3e2f-c32f-4b55-a83e-4a759744c78c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ac01cf75-abac-414d-abb2-3fb349b784c3/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7a498b1b-5101-4342-8b7e-524953b98e3b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3682a61f-a0b3-410f-8cc9-cb7260cf9e35/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/dd2768c0-7543-41fb-bfaa-0d167573e0cc/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/21be0aaf-8046-4beb-86ef-d5038a8472af/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4833c1f4-4273-4ee1-beb4-476de9d61346/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6d6f2c4a-46e9-4488-99f1-6fe4f36a3c6f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e4d518ea-6dca-4a67-9438-488b238d2137/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/42b5136a-217f-4e6c-959d-8ac2c1b793b4/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4ea3edb8-0738-4c24-b109-fef16ee0c520/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a960c11a-d437-4591-9960-d8c17fe6c9da/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7d38f384-392d-4f3d-9e12-7407229157e8/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/726fbc1e-890e-4dca-bedc-6083e6925733/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/574b292a-bb23-4cc6-a7e7-02146c1db440/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0b084a6b-70de-4c2a-9b86-b6e5c8b73030/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/1d103ac8-6206-40de-9ad5-2a42420647ff/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5a906ab8-3bc2-4280-91b1-2f163e0e0456/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4042b5b3-928f-4a3a-9803-65c3194bcfad/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d37d1402-a98a-4fc0-a58b-1aa2aad525b4/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7a4838ef-4ca1-498f-9218-cde767538f2c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ed47b022-ac18-45c1-8275-2be38433fc7a/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/849ab35a-fdda-47d3-91ef-52f116a09869/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9e209e11-1cbd-4bad-84d6-7d13703073ce/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/18ca654c-2dee-46de-a749-d65ca6bc503b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/19409529-507c-4e7d-94e6-f72cd77d1199/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3c720bfb-6461-4bab-befc-3ac90d7ec647/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9cf6fe44-2ea0-430a-b746-48f404abf2ba/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8b2191a9-9b47-4b12-af1e-2b93ca8c2bb9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/38eccccc-ed36-413e-881c-d3e05d981616/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6650a648-aee1-4a63-a40d-8b60206757ee/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/1a5fe95e-6a13-4eef-bf59-57ec11643e24/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d5fdf9d7-cc1b-4d6c-bd61-823dbaa1c88f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4984161b-2637-4f54-ab1e-d72bd4dcd3fc/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/1ea6dbfc-5893-49b3-9a0f-26187cd410a5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7eeec597-cf70-4ef7-8378-532fe3e9123b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ee651453-04d4-4a42-87c8-9b4d6f9c845d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/19bbb741-ccc2-4d7c-944b-71ccfcee76a2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ace521f4-88a1-4f2d-944d-14146d255b2b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/926d3166-4c06-4dad-b3bc-77bdbc45c38f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/00d67df9-00af-4f84-b62a-fe28c839facf/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d8c90670-0034-4512-ae9a-e2f39c100c90/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/85a86c7b-3003-4fe7-ba5b-c339fabe4924/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/dda50cf5-e30d-4471-bb65-0bb76b7ac81f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b14eb1bf-4d78-4c38-8e2b-e8406ed6efcd/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/107f3343-797e-49aa-a99d-b97f5f3c24dc/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8315aa14-9310-4869-8d70-416744224d5d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/09ca8dec-78fa-4801-9edb-a9a796e2779f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ddaf7988-047e-42b4-ba27-c3e4dd403fbd/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/55d519b9-4e40-4539-89e3-b75f4556c27f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d8d2c93e-afa0-4588-a532-bcb19593bbec/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4bae796e-a78e-4ef9-b666-eb90b44a2523/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/38ce9322-bd63-44bc-9977-1fe6be937d6c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/07458353-e295-4e42-8f9f-7aea18738b51/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3481c662-3200-48c0-99ef-91a5e0c24a8a/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d4293c8e-da2a-4799-9ea1-cb2b28e8a66b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/81db6c1d-c5b9-4e86-a26b-719f0f38e06b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e8c5b7c5-a539-4cbc-b35e-5ed7178eed58/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6309bb46-bc1f-4d82-9249-6a9f21ea89ae/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/743dec43-7495-4de8-a006-a9f1efbbf913/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b345238e-9180-46ab-bd80-fce942809742/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4b99527c-86af-4022-a80f-200ecb00a6ba/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/96baa4ed-0017-4883-9491-af3ec9adabef/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7837dc98-a003-43e1-895f-7b0c71349dd2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/279b5688-db9a-4b4b-aacf-936bbf08a333/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f1bbadc8-7ab6-4291-9d4e-2b59ccb3a6ee/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/83b5762d-0230-428f-a505-c6f45370832e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9ffbf29e-7797-4078-aed7-0edcd7705847/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6c00bee0-066f-4a76-afcc-0242514bbfa6/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6037e3ee-a57b-424b-9420-2ac20f25e1d6/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/87a34653-9bd7-4e19-848c-40828dd242b9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/cba62da5-c6bb-43b6-bce7-44373cf073c1/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0a377b75-8642-4fbc-8536-6e2a5f972dec/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6b7b8926-4f11-4014-a869-7814b8b16e0d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c1c63090-5d58-4980-b211-f3f1522df44b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3de26033-d850-4425-a3b9-561403ad1c6b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e4f3f7a1-2edc-4e85-aefa-63834b5203e1/\n" + ] + } + ], + "source": [ + "##synthesis portion of workflow\n", + "#heat well plate to 105 (actual temp is 95... how to distinguish this?)\n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['heat'],\n", + " 'source_material': bom_wellss[well], \n", + " 'destination_material': None \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + " \n", + " #print(param_url)\n", + "\n", + " patch_data = {'parameter_val_nominal': {'value': 105, 'unit': 'deqC', 'type': 'num'}}\n", + "\n", + " r = escalate.patch(data=patch_data, url=param_url)\n", + " \n", + " patch_data = {'parameter_val_actual': {'value': 95, 'unit': 'deqC', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b079abb9-2241-4c94-b479-798d7ec5b19e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7672708b-cdfb-4097-8df5-ecf3ca688b5f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b630a785-7964-4403-949f-91315327288f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e3cb9367-0760-4d40-ac0f-512334375818/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4d1a57ca-ff92-4a4e-a437-543801b1f9a5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ed1818dd-f44c-43c4-a55a-39ea0081e6a7/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/80c6ecdd-c9d7-4916-b674-e16e8587ee1e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d7a8e0a4-3626-4515-a82b-9c2dd6884242/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d7893705-7507-4f6a-b7b5-552353ac84c8/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7b7d6b6a-f598-47d5-b8a8-c842e021bce2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/44c57d46-d028-479d-96fc-0a0b95ee58b3/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/17511bd3-15d8-4e9e-a16b-dee37f1e73ab/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3302cf68-fd57-491f-a1f9-f9905bac07a5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/01fd71ab-ac6a-4893-b1a5-a67797a42fb7/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d8c0e372-8591-4368-9044-98c9d0b24fad/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3389df42-8ad9-4fe4-b71b-2c580d6c29f8/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7dcf638f-515f-4d06-9d59-94224f3dcaf2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a03e4c39-2ac3-47f4-8baa-5241ba541d2d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b58acf91-566a-4d43-8858-05662cd09451/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/212f18e0-0d28-43b4-84b3-7af7c8e20a36/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8ea80686-822c-4c9c-9c92-7464b923f0e2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9a162061-e660-4c6f-9905-92480833e243/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a8a8ac12-bcb8-4886-97e2-f4de34a15309/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2879899d-31b4-41d2-b13f-64d390b5ea9b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/18bb126b-abf5-4837-908e-fa03e1c7bfa5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ff7ee525-effe-492e-af99-1f39e840f58e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ff0fb650-7ee0-4d45-b43b-35c1fc92dade/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/63bc22be-5f24-4065-bde6-9818539b567a/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3646b095-73bd-4e68-8e05-b5ef11a2c07c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8541dd4c-d0a2-446f-bb5b-2d91989779d4/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/961533ff-9801-4409-8a5a-34713879acd3/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4cfb9919-fe26-4bdd-b5c7-a1ab060508cc/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/308a3364-b18e-4709-83da-bff31cc9ffdd/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0673964f-491d-401e-b622-f25a96854c2d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e2d3f153-6c43-47fc-8f79-7c41259b24a9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/11c73d9a-a9a8-4af7-98f0-1ef64ccf4797/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ea3fc8d5-f31c-45b8-9fdc-d482ca065b3c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/89f8cd55-5490-4bee-81e1-b2da27932c13/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2df77800-083f-4374-a3ed-b2e4945d81a5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e4dfb34c-9416-406d-ad0e-59854f242b1c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/da4266bf-3c20-4169-8a06-8fcb3ec9eb7e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/238baab8-1fa0-45b3-8bef-23baa3ab1f10/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/00774978-727e-4389-a8fc-f2e240234492/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0b0499b1-d63f-4850-b816-be8ffd38bf86/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f4d6e515-c905-49ca-bcf8-f3794819db06/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/afb97886-770b-4e2e-811d-00eb888132fa/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c00a8dfc-286b-4873-87f3-f8dc3c8ea780/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/82b887f4-9ac8-469a-9738-8040b8a22d50/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9eb2f1f8-1628-453e-b0ff-bbb58712fdda/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/70449d49-45a5-448b-86a8-022ae0455f7e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4ead632a-5aee-4fc0-9032-92b1892bc338/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2806ada2-70d7-4d9c-9f24-80308c675853/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e7a6c2a3-680c-4ef4-ab00-2e3e1782c4ee/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/80777d99-b201-4756-b83d-34e86643e6df/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/15a27a88-92b6-4b47-b6b8-7bd2cb948111/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/bb68d711-6a54-49ea-901d-e8fe6b9b8457/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/628a9af6-7f71-4257-a089-4f167c2979ed/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0bd921df-9d2d-468e-98ef-8456ec4f59b0/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4792a10c-4551-401d-a296-a9ee315eb4e2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/aa336387-3955-42f4-8123-94fd05af33b2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2cbb7a30-dc4a-42dd-b66a-4b68863ad81d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c721c586-161d-4195-ad0a-dbbede695f6a/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3d3a1b3f-ee9d-4934-b406-841f9e901b25/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/29d5ed53-517b-4fc7-ac2f-986e4a836d18/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c68896b6-1d14-4122-a6a4-f2664efda96f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/feed4be4-07cf-4633-a0eb-2f5cc4a1f98c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/30260164-a853-46d7-97f9-e7959f21deac/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/50dab7ed-6927-496e-b8ca-4514d4b6290b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b7edb177-78de-4224-9d98-85515eb7a242/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8f27002d-2877-4315-99e6-ddf692653a31/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/276c1c82-c395-4a21-a8b5-8f4a1f3a8cc0/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5450869f-bf2f-4e44-94a4-6734977a5ba4/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8b483c21-2483-4c0e-8ae8-c683c11b9039/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a2f43292-94ae-4aac-8fa0-23c1b217d3a0/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/78c72588-e943-42de-9654-9ab0a82a70cd/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f45307ab-bd9e-4e7f-bfd3-54e054b91158/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/63221d19-7be4-4a1c-893e-756a1eb53fd6/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/91797b9d-9943-44d3-a344-e8a4f5fd98d5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f26e0f9e-279e-4651-b8fc-fbfb1bc56e26/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d2764d54-7598-4bcb-a8e7-ec6acfa66937/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2c182e17-a275-4463-ad25-0b4dedcad014/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ad605fab-b93f-42a1-994c-a20af104d3da/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/01d3d5f8-61dc-4845-ad16-9b50fe144735/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/55a0c8cc-b6a8-4520-aedd-b69c847f44b9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/21baba30-4cd4-4c66-a30c-3b177f4cb0f1/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6d0717e2-6697-4fdd-b802-f2f20d33069c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e8129a5d-b96b-4a6d-ba70-54b24e37ea6b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3dc1ee9b-bc8a-49c0-80d4-ec66e57486d5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7ada33e7-1fe4-45f7-a30b-f41ca9c34328/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/fa0baabe-7d1e-4c9c-bf48-04730713f1eb/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/27a66ee9-eb66-46f1-a7ff-0254a2dbdd4d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/05dc8857-3acb-413c-87e8-c373be0d55c9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5e79e1ec-baea-4ba1-9e68-a179f32ba1ce/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9fc380f6-ae5c-4b62-90c3-3b75ac7862e2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/eb619fb8-2e62-4832-9803-feb3151af4fe/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/78011400-f239-447a-ac6d-5eaa9f0d56e3/\n" + ] + } + ], + "source": [ + "#add 1 microliter of reagent 1 to each of the plates \n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Tube 1'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + " \n", + " print(param_url)\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .001, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "#add 1 microliter of reagent 2 to each of the plates \n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Tube 2'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .001, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "#add 1 microliter of reagent 3 to each of the plates\n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Container 3'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .001, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "#add .6 microliter of reagent 4 to each of the plates\n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Container 4'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .0006, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#stir well-plate for 15 min at 750 rpm" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**need to distinguish between time and speed params in the index loop**" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "#add 0.6 microliters of reagent 4 to each of the plates\n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Container 4'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .0006, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#stir well-plate for 20 min at 750 rpm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Associate action units with actions and workflows \n", + "\n", + "**I need help here**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Gather Vessels\n", + "\n", + "[pending]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "type_well96 = ContainerType(name='96-well PCR plate', is_tube=False, well_count=96, well_depth_mm=None, well_volume_ul=Unit(1.0, 'milliliter'), well_coating=None, sterile=None, cover_types=None, seal_types=['ultra-clear', 'foil'], capabilities=['liquid_handle', 'sangerseq', 'spin', 'thermocycle', 'incubate', 'gel_separate', 'gel_purify', 'seal', 'dispense'], shortname='96-pcr', col_count=12, dead_volume_ul=Unit(3, 'microliter'), safe_min_volume_ul=Unit(5, 'microliter'))\n", + "\n", + "wellplate96 = ContainerModel(container_type=type_well96, name='96-well plate')\n", + "\n", + "\n", + "type_beaker50 = ContainerType(name='50 mL beaker', is_tube=True, well_count=1, well_depth_mm=None, well_volume_ul=Unit(50, 'milliliter'), well_coating=None, sterile=None, cover_types=None, seal_types=['ultra-clear', 'foil'], capabilities=['liquid_handle', 'sangerseq', 'spin', 'thermocycle', 'incubate', 'gel_separate', 'gel_purify', 'seal', 'dispense'], shortname='beaker', col_count=0, dead_volume_ul=Unit(3, 'microliter'), safe_min_volume_ul=Unit(5, 'microliter'))\n", + "\n", + "beaker = ContainerModel(container_type=type_beaker50, name='50-mL beaker')\n", + "\n", + "\n", + "type_tube = ContainerType(name='centrifuge tube', is_tube=True, well_count=1, well_depth_mm=None, well_volume_ul=Unit(15, 'milliliter'), well_coating=None, sterile=None, cover_types=None, seal_types=['ultra-clear', 'foil'], capabilities=['liquid_handle', 'sangerseq', 'spin', 'thermocycle', 'incubate', 'gel_separate', 'gel_purify', 'seal', 'dispense'], shortname='beaker', col_count=0, dead_volume_ul=Unit(3, 'microliter'), safe_min_volume_ul=Unit(5, 'microliter'))\n", + "\n", + "tube = ContainerModel(container_type=type_tube, name='centrifuge tube')\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for container in [tube, beaker]:\n", + " \n", + " r = escalate.post('vessel/', {'description': container.name, \n", + " 'plate_name': 'null', 'well_number': 'null'}['url']\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r = escalate.post('vessel/', {'description': 'beaker', 'plate_name': 'null', 'well_number': 'null'})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "so we've created a beaker using prototype ContainerModel and using conventional POST method to REST API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for well in wellplate96.wells:\n", + " \n", + " r = escalate.post('vessel/', {'description': 'null', \n", + " 'plate_name': '96wellplate', 'well_number': well.index}\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'plate_name', 'well_number'],\n", + " 'plate_name__icontains': '96wellplate'})\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vessels={}\n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'plate_name', 'well_number'],\n", + " 'plate_name__icontains': '96wellplate'})\n", + "for i in r:\n", + " vessels[i['well_number']]=i['url']\n", + " \n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': '50-mL beaker'})\n", + "\n", + "vessels[r['description']]=r['url']\n", + "\n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': 'tube'})\n", + "\n", + "vessels[r['description']]=r['url']\n", + "\n", + "vessels" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "we need a second beaker and a second tube" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for container in [tube, beaker]:\n", + " \n", + " r = escalate.post('vessel/', {'description': container.name+'2', \n", + " 'plate_name': 'null', 'well_number': 'null'}\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': '50-mL beaker'})\n", + "\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vessels={}\n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'plate_name', 'well_number'],\n", + " 'plate_name__icontains': '96wellplate'})\n", + "for i in r:\n", + " vessels[i['well_number']]=i['url']\n", + " \n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': '50-mL beaker'})\n", + "\n", + "for i in r:\n", + " vessels[i['description']]=i['url']\n", + "\n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': 'tube'})\n", + "\n", + "for i in r:\n", + " vessels[i['description']]=i['url']\n", + "\n", + "vessels" + ] + } + ], + "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.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From db316706626656f335535280390d7ec37a5ab455 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Tue, 7 Sep 2021 15:25:04 -0400 Subject: [PATCH 14/17] Update workflow_experiment_demo.ipynb --- demos/workflow_experiment_demo.ipynb | 482 +-------------------------- 1 file changed, 1 insertion(+), 481 deletions(-) diff --git a/demos/workflow_experiment_demo.ipynb b/demos/workflow_experiment_demo.ipynb index 304c7ea..c05d2a1 100644 --- a/demos/workflow_experiment_demo.ipynb +++ b/demos/workflow_experiment_demo.ipynb @@ -7,305 +7,6 @@ "# Creating experiment templates through ESCALATE REST\n" ] }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "#factor this out when it's imported into the client\n", - "\n", - "import requests\n", - "\n", - "class ESCALATEClient():\n", - " \"\"\"ESCALATE API Client\"\"\"\n", - " \n", - " def __init__(self, base_url, username, password):\n", - " self.base_url = base_url\n", - " self.username = username\n", - " self.password = password\n", - " self._token = None\n", - " self._is_logged_in = False\n", - " self._login()\n", - " \n", - " def _login(self):\n", - " r_login = requests.post(f'{self.base_url}/api/login', \n", - " data={'username': self.username, \n", - " 'password': self.password})\n", - " self._token = r_login.json()['token']\n", - " self._token_header = {'Authorization': f'Token {self._token}'}\n", - " self._is_logged_in = True\n", - " \n", - " def get(self, \n", - " endpoint='', \n", - " data=None, \n", - " parse_json=True, \n", - " content_type='application/json'):\n", - " \"\"\"Make GET request with `data` to `endpoint` in ESCALATE API\n", - " \n", - " return: (dict|list|requests.Response), bool\n", - " \"\"\"\n", - " data = {} if data is None else data\n", - " r = requests.get(f'{self.base_url}/api/{endpoint}',\n", - " params=data, \n", - " headers={**self._token_header, \n", - " 'content-type': content_type})\n", - " if r.ok: \n", - " print('GET: OK')\n", - " else: \n", - " print('GET: FAILED')\n", - " \n", - " if r.ok and parse_json:\n", - " resp_json = r.json() \n", - " # handle cases: no vs one vs many results\n", - " count = resp_json.get('count')\n", - " if count is None or count == 0:\n", - " return r.json()\n", - " elif count == 1: \n", - " print('Found one resource, returning dict')\n", - " return resp_json['results'][0]\n", - " elif count >= 1: \n", - " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", - " return r.json()['results']\n", - " print('Returning response object') \n", - " return r\n", - " \n", - " def post(self, \n", - " endpoint, \n", - " data, \n", - " content_type='application/json'):\n", - " \"\"\"POST `data` to `endpoint`in ESCALATE API using `content_type`\n", - " return: (dict|requests.Response), bool\n", - " \"\"\"\n", - " \n", - " if not self._is_logged_in:\n", - " raise ValueError(\"Not logged in: cannot post\")\n", - " \n", - " r = requests.api.post(\n", - " f'{self.base_url}/api/{endpoint}', \n", - " json=data, \n", - " headers={**self._token_header,\n", - " 'content-type': content_type})\n", - " print(r)\n", - " if r.ok: \n", - " print('POST: OK, returning new resource dict')\n", - " return r.json()\n", - " print('POST: FAILED, returning response object')\n", - " return r\n", - " \n", - " def put(self, data, url=None, endpoint=None, resource_id=None):\n", - " \"\"\"Update a resource\n", - " Either provide a url or an endpoint and resource id\n", - " \"\"\"\n", - " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", - " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", - " \n", - " if url is None: \n", - " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", - " r = requests.api.put(url, json=data, headers=self._token_header)\n", - " return r\n", - " \n", - " def patch(self, data, url=None, endpoint=None, resource_id=None):\n", - " \"\"\"Update parts of a resource\n", - " Either provide a url or an endpoint and resource id\n", - " \"\"\"\n", - " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", - " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", - " \n", - " if url is None: \n", - " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", - " r = requests.api.patch(url, json=data, headers=self._token_header)\n", - " return r\n", - " \n", - " def delete(self, url=None, endpoint=None, resource_id=None):\n", - " \"\"\"Delete a resource\n", - " Either provide a url or an endpoint and resource id\n", - " \"\"\"\n", - " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", - " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", - " if url is None: \n", - " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", - " r = requests.api.delete(url, headers=self._token_header)\n", - " return r\n", - " \n", - " def list_endpoints(self):\n", - " return self.get()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def search(self, \n", - " endpoint='',\n", - " related_ep=None, #for cross-searches\n", - " search_field='',\n", - " criteria= '',\n", - " data=None, #must be a list\n", - " exact=False,\n", - " negate=False,\n", - " parse_json=True, \n", - " content_type='application/json'):\n", - " \n", - " if negate==False:\n", - "\n", - " if exact==True:\n", - " if data == None:\n", - " '''Returns all fields for exact match'''\n", - " if related_ep == None:\n", - " \n", - " r = requests.get(f'{self.base_url}/api/{endpoint}/?{search_field}={criteria}', \n", - " headers={**self._token_header, \n", - " 'content-type': content_type})\n", - " else: #cross-search \n", - " r = requests.get(f'{self.base_url}/api/{endpoint}/?{related_ep}__{search_field}={criteria}', \n", - " headers={**self._token_header, \n", - " 'content-type': content_type})\n", - "\n", - " else:\n", - " '''Returns requested field(s) for exact match'''\n", - " i=0\n", - " data_string=''\n", - " while i= 1: \n", - " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", - " return r.json()['results']\n", - " print('Returning response object') \n", - " return r" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -3638,188 +3339,7 @@ "**I need help here**" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Gather Vessels\n", - "\n", - "[pending]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "type_well96 = ContainerType(name='96-well PCR plate', is_tube=False, well_count=96, well_depth_mm=None, well_volume_ul=Unit(1.0, 'milliliter'), well_coating=None, sterile=None, cover_types=None, seal_types=['ultra-clear', 'foil'], capabilities=['liquid_handle', 'sangerseq', 'spin', 'thermocycle', 'incubate', 'gel_separate', 'gel_purify', 'seal', 'dispense'], shortname='96-pcr', col_count=12, dead_volume_ul=Unit(3, 'microliter'), safe_min_volume_ul=Unit(5, 'microliter'))\n", - "\n", - "wellplate96 = ContainerModel(container_type=type_well96, name='96-well plate')\n", - "\n", - "\n", - "type_beaker50 = ContainerType(name='50 mL beaker', is_tube=True, well_count=1, well_depth_mm=None, well_volume_ul=Unit(50, 'milliliter'), well_coating=None, sterile=None, cover_types=None, seal_types=['ultra-clear', 'foil'], capabilities=['liquid_handle', 'sangerseq', 'spin', 'thermocycle', 'incubate', 'gel_separate', 'gel_purify', 'seal', 'dispense'], shortname='beaker', col_count=0, dead_volume_ul=Unit(3, 'microliter'), safe_min_volume_ul=Unit(5, 'microliter'))\n", - "\n", - "beaker = ContainerModel(container_type=type_beaker50, name='50-mL beaker')\n", - "\n", - "\n", - "type_tube = ContainerType(name='centrifuge tube', is_tube=True, well_count=1, well_depth_mm=None, well_volume_ul=Unit(15, 'milliliter'), well_coating=None, sterile=None, cover_types=None, seal_types=['ultra-clear', 'foil'], capabilities=['liquid_handle', 'sangerseq', 'spin', 'thermocycle', 'incubate', 'gel_separate', 'gel_purify', 'seal', 'dispense'], shortname='beaker', col_count=0, dead_volume_ul=Unit(3, 'microliter'), safe_min_volume_ul=Unit(5, 'microliter'))\n", - "\n", - "tube = ContainerModel(container_type=type_tube, name='centrifuge tube')\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for container in [tube, beaker]:\n", - " \n", - " r = escalate.post('vessel/', {'description': container.name, \n", - " 'plate_name': 'null', 'well_number': 'null'}['url']\n", - " )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "r = escalate.post('vessel/', {'description': 'beaker', 'plate_name': 'null', 'well_number': 'null'})" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "so we've created a beaker using prototype ContainerModel and using conventional POST method to REST API" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for well in wellplate96.wells:\n", - " \n", - " r = escalate.post('vessel/', {'description': 'null', \n", - " 'plate_name': '96wellplate', 'well_number': well.index}\n", - " )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "r = escalate.get('vessel',\n", - " data={'fields': ['url', 'plate_name', 'well_number'],\n", - " 'plate_name__icontains': '96wellplate'})\n", - "r" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vessels={}\n", - "\n", - "r = escalate.get('vessel',\n", - " data={'fields': ['url', 'plate_name', 'well_number'],\n", - " 'plate_name__icontains': '96wellplate'})\n", - "for i in r:\n", - " vessels[i['well_number']]=i['url']\n", - " \n", - "\n", - "r = escalate.get('vessel',\n", - " data={'fields': ['url', 'description'],\n", - " 'description__icontains': '50-mL beaker'})\n", - "\n", - "vessels[r['description']]=r['url']\n", - "\n", - "\n", - "r = escalate.get('vessel',\n", - " data={'fields': ['url', 'description'],\n", - " 'description__icontains': 'tube'})\n", - "\n", - "vessels[r['description']]=r['url']\n", - "\n", - "vessels" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "we need a second beaker and a second tube" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for container in [tube, beaker]:\n", - " \n", - " r = escalate.post('vessel/', {'description': container.name+'2', \n", - " 'plate_name': 'null', 'well_number': 'null'}\n", - " )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "r = escalate.get('vessel',\n", - " data={'fields': ['url', 'description'],\n", - " 'description__icontains': '50-mL beaker'})\n", - "\n", - "r" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vessels={}\n", - "\n", - "r = escalate.get('vessel',\n", - " data={'fields': ['url', 'plate_name', 'well_number'],\n", - " 'plate_name__icontains': '96wellplate'})\n", - "for i in r:\n", - " vessels[i['well_number']]=i['url']\n", - " \n", - "\n", - "r = escalate.get('vessel',\n", - " data={'fields': ['url', 'description'],\n", - " 'description__icontains': '50-mL beaker'})\n", - "\n", - "for i in r:\n", - " vessels[i['description']]=i['url']\n", - "\n", - "\n", - "r = escalate.get('vessel',\n", - " data={'fields': ['url', 'description'],\n", - " 'description__icontains': 'tube'})\n", - "\n", - "for i in r:\n", - " vessels[i['description']]=i['url']\n", - "\n", - "vessels" - ] - } - ], + "metadata": { "kernelspec": { "display_name": "Python 3", From e874cd9960bd38d807aa74090e0e49d9d0917dfc Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Tue, 7 Sep 2021 15:26:25 -0400 Subject: [PATCH 15/17] Delete workflow_experiment_demo.ipynb --- demos/workflow_experiment_demo.ipynb | 3364 -------------------------- 1 file changed, 3364 deletions(-) delete mode 100644 demos/workflow_experiment_demo.ipynb diff --git a/demos/workflow_experiment_demo.ipynb b/demos/workflow_experiment_demo.ipynb deleted file mode 100644 index c05d2a1..0000000 --- a/demos/workflow_experiment_demo.ipynb +++ /dev/null @@ -1,3364 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Creating experiment templates through ESCALATE REST\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "First import the REST API Client." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import escalateclient\n", - "from escalateclient import ESCALATEClient" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Enter your ESCALATE username and password, and the port number at which the server is running. Then run the following cell. This will create an instance of the API Client and set up a token to interact with the REST API." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "username= 'nsmina'\n", - "password= 'password11'\n", - "port='8000'\n", - "\n", - "escalate = ESCALATEClient(\n", - " f'http://localhost:{port}',\n", - " username,\n", - " password\n", - ")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "To see all the model endpoints (this is also a good way to verify that you are connected):" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n" - ] - }, - { - "data": { - "text/plain": [ - "{'action': 'http://localhost:8000/api/action/',\n", - " 'actiondef': 'http://localhost:8000/api/action-def/',\n", - " 'actionunit': 'http://localhost:8000/api/action-unit/',\n", - " 'actor': 'http://localhost:8000/api/actor/',\n", - " 'basebommaterial': 'http://localhost:8000/api/base-bom-material/',\n", - " 'billofmaterials': 'http://localhost:8000/api/bill-of-materials/',\n", - " 'bomcompositematerial': 'http://localhost:8000/api/bom-composite-material/',\n", - " 'bommaterial': 'http://localhost:8000/api/bom-material/',\n", - " 'calculation': 'http://localhost:8000/api/calculation/',\n", - " 'calculationdef': 'http://localhost:8000/api/calculation-def/',\n", - " 'condition': 'http://localhost:8000/api/condition/',\n", - " 'conditiondef': 'http://localhost:8000/api/condition-def/',\n", - " 'experiment': 'http://localhost:8000/api/experiment/',\n", - " 'experimentinstance': 'http://localhost:8000/api/experiment-instance/',\n", - " 'experimenttemplate': 'http://localhost:8000/api/experiment-template/',\n", - " 'experimenttype': 'http://localhost:8000/api/experiment-type/',\n", - " 'experimentworkflow': 'http://localhost:8000/api/experiment-workflow/',\n", - " 'inventory': 'http://localhost:8000/api/inventory/',\n", - " 'inventorymaterial': 'http://localhost:8000/api/inventory-material/',\n", - " 'material': 'http://localhost:8000/api/material/',\n", - " 'materialidentifier': 'http://localhost:8000/api/material-identifier/',\n", - " 'materialidentifierdef': 'http://localhost:8000/api/material-identifier-def/',\n", - " 'materialtype': 'http://localhost:8000/api/material-type/',\n", - " 'measure': 'http://localhost:8000/api/measure/',\n", - " 'measuredef': 'http://localhost:8000/api/measure-def/',\n", - " 'measuretype': 'http://localhost:8000/api/measure-type/',\n", - " 'mixture': 'http://localhost:8000/api/mixture/',\n", - " 'organization': 'http://localhost:8000/api/organization/',\n", - " 'outcome': 'http://localhost:8000/api/outcome/',\n", - " 'parameterdef': 'http://localhost:8000/api/parameter-def/',\n", - " 'person': 'http://localhost:8000/api/person/',\n", - " 'propertydef': 'http://localhost:8000/api/property-def/',\n", - " 'status': 'http://localhost:8000/api/status/',\n", - " 'systemtool': 'http://localhost:8000/api/systemtool/',\n", - " 'systemtooltype': 'http://localhost:8000/api/systemtool-type/',\n", - " 'tag': 'http://localhost:8000/api/tag/',\n", - " 'tagtype': 'http://localhost:8000/api/tag-type/',\n", - " 'typedef': 'http://localhost:8000/api/type-def/',\n", - " 'udfdef': 'http://localhost:8000/api/udf-def/',\n", - " 'unittype': 'http://localhost:8000/api/unit-type/',\n", - " 'vessel': 'http://localhost:8000/api/vessel/',\n", - " 'workflow': 'http://localhost:8000/api/workflow/',\n", - " 'workflowactionset': 'http://localhost:8000/api/workflow-action-set/',\n", - " 'workflowobject': 'http://localhost:8000/api/workflow-object/',\n", - " 'workflowstep': 'http://localhost:8000/api/workflow-step/',\n", - " 'workflowtype': 'http://localhost:8000/api/workflow-type/'}" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.list_endpoints()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Create an Experiment" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "'http://localhost:8000/api/experiment/4e7ec69d-b124-45a0-b5ca-8682cad3bb27/'" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "r = escalate.post('experiment/', {'description': 'Workflow 1 Demo', 'ref_uid': 'wf1_demo'})\n", - "\n", - "exp = r['url']\n", - "exp" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Create workflows to go with the experiment. (These correspond to parts of the procedure)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'Reagent Preparation': 'http://localhost:8000/api/workflow/0841e1c1-5aa3-4962-ae27-2d8b94bab5f6/',\n", - " 'Synthesis': 'http://localhost:8000/api/workflow/279458f4-e4c8-42cc-a6f9-22b91964d48a/'}" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "wfs = {name: escalate.post('workflow/', \n", - " {'experiment': exp, \n", - " 'description': name\n", - " })['url']\n", - " for name in ['Reagent Preparation', 'Synthesis']\n", - " }\n", - "\n", - "wfs" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Gather Materials\n", - "\n", - "* Search the database using `Get()` with filters to determine if the materials exist. If not, `Post()` them\n", - "\n", - "We need lead (II) iodide (PbI2), ammonium iodide (NH4I), Gamma-butyrolactone (GBL), and formic acid (HCOOH)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", - "GET: OK\n", - "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/material/b9ad5eeb-9ab8-458f-b7cf-e9200b7964ad/', 'description': 'Gamma-Butyrolactone'}\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/material/758d9a15-69d6-4439-9d58-087a46d3d890/', 'description': 'Formic Acid'}\n" - ] - } - ], - "source": [ - "mat_name_searches = ['Lead (II) Iodide', 'Ammonium Iodide', 'Gamma-Butyrolactone', 'Formic Acid']\n", - "\n", - "for i in mat_name_searches: \n", - " r = escalate.get('material', data={'fields': ['description', 'url'],\n", - " 'description': i}) \n", - " print(r)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Searching for lead (II) iodide by exact name returned no results; let's expand our search criteria and do a cross-search by InChI key in the material identifer table to verify whether it's in the inventory." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'url': 'http://localhost:8000/api/material/56665bf9-566d-41dc-b8dd-6f74174e7435/',\n", - " 'description': 'Lead Diiodide'}" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "r = escalate.get('material', data={'fields': ['description', 'url'],\n", - " 'identifier__description': 'RQQRAHKHDFPBMC-UHFFFAOYSA-L'}) \n", - "r" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "So it does exist, just not under the name we expected.\n", - "\n", - "For ammonium iodide, which doesn't exist, we have to `Post()`. Note we could also associate identifiers like molecular formula and InChI with our new material, but for the scope of this tutorial it's enough to just post it with a description." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'url': 'http://localhost:8000/api/material/e5e68e17-9c15-4d36-8e54-e6f27efafe00/',\n", - " 'uuid': 'e5e68e17-9c15-4d36-8e54-e6f27efafe00',\n", - " 'edocs': [],\n", - " 'tags': [],\n", - " 'notes': [],\n", - " 'property': [],\n", - " 'add_date': '2021-09-07T17:37:30.589089',\n", - " 'mod_date': '2021-09-07T17:37:30.589110',\n", - " 'description': 'Ammonium Iodide',\n", - " 'consumable': True,\n", - " 'material_class': 'model',\n", - " 'internal_slug': 'ammonium-iodide',\n", - " 'status': None,\n", - " 'actor': None,\n", - " 'identifier': [],\n", - " 'material_type': []}" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.post(endpoint='material/', \n", - " data={'description': 'Ammonium Iodide', \n", - " 'material_class': 'model',\n", - " 'consumable': True} \n", - " )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Collect the materials within an inventory" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'Lead Diiodide': 'http://localhost:8000/api/material/56665bf9-566d-41dc-b8dd-6f74174e7435/',\n", - " 'Ammonium Iodide': 'http://localhost:8000/api/material/e5e68e17-9c15-4d36-8e54-e6f27efafe00/',\n", - " 'Gamma-Butyrolactone': 'http://localhost:8000/api/material/b9ad5eeb-9ab8-458f-b7cf-e9200b7964ad/',\n", - " 'Formic Acid': 'http://localhost:8000/api/material/758d9a15-69d6-4439-9d58-087a46d3d890/'}" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#make life easier and just use the exact names that were returned by our searches\n", - "mat_names = ['Lead Diiodide', 'Ammonium Iodide', 'Gamma-Butyrolactone', 'Formic Acid']\n", - "\n", - "materials = {name: escalate.get('material', {'description': name})['url']\n", - " for name in mat_names\n", - " }\n", - "\n", - "materials" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "'http://localhost:8000/api/inventory/4a75a47b-dc21-47ff-90b0-63c99ffbd01e/'" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "inventory = escalate.post('inventory/', data={'description': 'Workflow 1 Demo'})['url']\n", - "\n", - "inventory" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'Lead Diiodide': 'http://localhost:8000/api/inventory-material/9e5dc29b-e3eb-4e92-a5b6-734913d6e612/',\n", - " 'Ammonium Iodide': 'http://localhost:8000/api/inventory-material/4f84deb8-123f-4fd9-85f3-2594112d9239/',\n", - " 'Gamma-Butyrolactone': 'http://localhost:8000/api/inventory-material/dc090731-4464-481a-a27c-53ea0880116f/',\n", - " 'Formic Acid': 'http://localhost:8000/api/inventory-material/3615c1aa-8f53-4661-9369-391b663d72d2/'}" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "inventory_materials = {description: escalate.post('inventory-material/', \n", - " {'description': description, \n", - " 'material': url,\n", - " 'inventory': inventory})['url']\n", - " for description, url in materials.items()}\n", - "\n", - "inventory_materials" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Create a bill of materials from the inventory, for the specific experiment" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'Lead Diiodide': 'http://localhost:8000/api/base-bom-material/2ab45132-0cc3-4262-a884-3a2db82fd624/',\n", - " 'Ammonium Iodide': 'http://localhost:8000/api/base-bom-material/e7e0a9d4-9d5e-4798-a2e1-496a6aedb1d4/',\n", - " 'Gamma-Butyrolactone': 'http://localhost:8000/api/base-bom-material/046a9bae-d9a9-4302-a08e-f8cc2e55e0d3/',\n", - " 'Formic Acid': 'http://localhost:8000/api/base-bom-material/471d0e15-d4fe-4757-b886-151d44ba7bf9/'}" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "bom = escalate.post('bill-of-materials/', {'description': 'Workflow 1 Demo', \n", - " 'experiment': exp})['url']\n", - "\n", - "bom_materials = {name: escalate.post('bom-material/', \n", - " {'bom': bom, 'inventory_material': im}\n", - " )['url']\n", - " for name, im in inventory_materials.items()}\n", - "\n", - "bom_materials" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Gather Containers\n", - "\n", - "Currently containers are treated as materials. So we follow the same process of `Post()`ing first to the materials endpoint, then to the inventory, then to the BOM\n", - "\n", - "We'll need four stock containers (let's call them tubes) and one 96-well plate. We can use one overall plate material and just create 96 wells in the BOM. For the tubes, we can create a generic stock tube. We can assume all four tubes for our experiment are identical, material-wise, and just create several instances with different names in the BOM." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "tube_material = escalate.post('material/',\n", - " {'description': 'tube', 'material_class':'model'})" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n" - ] - } - ], - "source": [ - "plate_material = escalate.post('material/',\n", - " {'description': '96 well plate', 'material_class':'model'})" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Collect the containers within an inventory" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/inventory-material/39514fe7-fa9a-4237-9483-b17e7a3749ac/\n" - ] - } - ], - "source": [ - "cont_names= ['tube', '96 well plate']\n", - "\n", - "for name in cont_names:\n", - "\n", - " cont_im = escalate.post('inventory-material/', \n", - " {'description': name, \n", - " 'material':escalate.get('material', data={'description': name})['url'],\n", - " 'inventory': inventory})['url']\n", - " \n", - " print(cont_im)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Create a bill of materials from the inventory, for the specific experiment" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'Stock Tube 1': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/',\n", - " 'Stock Tube 2': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/',\n", - " 'Stock Container 3': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/',\n", - " 'Stock Container 4': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/'}" - ] - }, - "execution_count": 38, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tube_names=['Stock Tube 1', 'Stock Tube 2', 'Stock Container 3', 'Stock Container 4']\n", - "\n", - "tube_inventory={}\n", - "for name in tube_names:\n", - " tube_inventory[name]= escalate.get('inventory-material', data={'description': 'tube'})['url']\n", - " \n", - "tube_inventory" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**NEED TO ADD DESCRIPTIONS WHEN I POST THESE**" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'Stock Tube 1': 'http://localhost:8000/api/base-bom-material/198b3a32-dd37-44a9-aafb-3411bc05afd6/',\n", - " 'Stock Tube 2': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/',\n", - " 'Stock Container 3': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/',\n", - " 'Stock Container 4': 'http://localhost:8000/api/base-bom-material/d5ac3fe5-356c-4411-a900-c63669bf23a4/'}" - ] - }, - "execution_count": 41, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "bom_tubes = {name: escalate.post('bom-material/', \n", - " {'bom': bom, \n", - " 'inventory_material': url}\n", - " )['url']\n", - " for name, url in tube_inventory.items()}\n", - "\n", - "bom_tubes" - ] - }, - { - "cell_type": "code", - "execution_count": 50, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "ename": "NameError", - "evalue": "name 'bom_wells' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 16\u001b[0m for name, url in well_inventory.items()}\n\u001b[1;32m 17\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 18\u001b[0;31m \u001b[0mbom_wells\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mNameError\u001b[0m: name 'bom_wells' is not defined" - ] - } - ], - "source": [ - "idx=[]\n", - "for i in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']:\n", - " for j in range(1,13):\n", - " idx.append(i + str(j))\n", - "\n", - "plate_url=escalate.get('inventory-material', {'description': '96 well plate'})['url']\n", - "\n", - "well_inventory={}\n", - "for well in idx:\n", - " well_inventory[well]=plate_url\n", - "\n", - "bom_wellss = {name: escalate.post('bom-material/', \n", - " {'bom': bom, \n", - " 'inventory_material': url}\n", - " )['url']\n", - " for name, url in well_inventory.items()}\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": 51, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'A1': 'http://localhost:8000/api/base-bom-material/3429cdfb-a140-4a60-8825-f40142b1328f/',\n", - " 'A2': 'http://localhost:8000/api/base-bom-material/d22f6fef-8388-430a-bcff-fcf58a34cdff/',\n", - " 'A3': 'http://localhost:8000/api/base-bom-material/c0a710e3-4c09-4bde-9fa4-eef8f4505079/',\n", - " 'A4': 'http://localhost:8000/api/base-bom-material/599d7d7a-5942-4e5c-bcc5-94022e07e607/',\n", - " 'A5': 'http://localhost:8000/api/base-bom-material/f7bd3a08-4f85-4e60-b520-26fd43231518/',\n", - " 'A6': 'http://localhost:8000/api/base-bom-material/5a8589ad-5d4f-4236-a3bd-abeba58c23bd/',\n", - " 'A7': 'http://localhost:8000/api/base-bom-material/2317cebe-595b-464c-b3a0-4e1504603c48/',\n", - " 'A8': 'http://localhost:8000/api/base-bom-material/fe3e35e3-3a5f-4bd7-ae7f-f332179f94d3/',\n", - " 'A9': 'http://localhost:8000/api/base-bom-material/a509b29c-3d43-45ec-90b1-8d629700b630/',\n", - " 'A10': 'http://localhost:8000/api/base-bom-material/1dacbb4b-9843-4241-a782-2095738a83ad/',\n", - " 'A11': 'http://localhost:8000/api/base-bom-material/547ac41d-e574-449f-b106-0eeecf8bcdac/',\n", - " 'A12': 'http://localhost:8000/api/base-bom-material/05922650-de21-4259-878e-ba02346d530c/',\n", - " 'B1': 'http://localhost:8000/api/base-bom-material/2beb55f3-ab21-4d31-ac64-2ad4b4771b39/',\n", - " 'B2': 'http://localhost:8000/api/base-bom-material/3f0542fe-9455-4cea-9bac-ac7e281620c6/',\n", - " 'B3': 'http://localhost:8000/api/base-bom-material/0fbc8401-952f-412c-bc47-75af0220d2a6/',\n", - " 'B4': 'http://localhost:8000/api/base-bom-material/167a01bc-3451-4fac-afb8-654b3564b1ec/',\n", - " 'B5': 'http://localhost:8000/api/base-bom-material/edd061b0-385a-463f-9772-4ff46a3b12ea/',\n", - " 'B6': 'http://localhost:8000/api/base-bom-material/a199a25c-1fb2-405f-b277-4e0033773a1c/',\n", - " 'B7': 'http://localhost:8000/api/base-bom-material/63eef2e9-14e9-47ea-8d1c-09fd83f4c7f6/',\n", - " 'B8': 'http://localhost:8000/api/base-bom-material/a6e7d78b-815c-40c3-87b7-fa88069cc1d9/',\n", - " 'B9': 'http://localhost:8000/api/base-bom-material/b08c0ee9-5336-49c4-8a6f-4ed4ee46afe3/',\n", - " 'B10': 'http://localhost:8000/api/base-bom-material/4918f791-3c00-406f-ab87-e13eb6082d02/',\n", - " 'B11': 'http://localhost:8000/api/base-bom-material/3d77a845-b58f-48bb-b0c2-005b5aad655e/',\n", - " 'B12': 'http://localhost:8000/api/base-bom-material/49886321-4596-4f89-ada1-5c42415eb781/',\n", - " 'C1': 'http://localhost:8000/api/base-bom-material/070b4db1-e1f7-4f2a-8bdc-a836010e6e2f/',\n", - " 'C2': 'http://localhost:8000/api/base-bom-material/d92e3501-a230-4fe2-8899-2576458dbf78/',\n", - " 'C3': 'http://localhost:8000/api/base-bom-material/7aab999e-4fa4-432b-ae24-486101d414da/',\n", - " 'C4': 'http://localhost:8000/api/base-bom-material/000be119-0fc4-4f88-b800-59b06958cd66/',\n", - " 'C5': 'http://localhost:8000/api/base-bom-material/393c9476-05a3-4cdf-9e8d-8213ec479e16/',\n", - " 'C6': 'http://localhost:8000/api/base-bom-material/85638498-e236-44dd-b499-445ad47ba09c/',\n", - " 'C7': 'http://localhost:8000/api/base-bom-material/10776786-f9d0-4e3f-8af8-1d825c01172a/',\n", - " 'C8': 'http://localhost:8000/api/base-bom-material/6ec4ace6-14ed-4946-b535-3b525189ca02/',\n", - " 'C9': 'http://localhost:8000/api/base-bom-material/69ed4658-bec0-4e42-9c41-3fc3ae64a31a/',\n", - " 'C10': 'http://localhost:8000/api/base-bom-material/95213548-150a-40b9-b2f0-1ac0d19da7b8/',\n", - " 'C11': 'http://localhost:8000/api/base-bom-material/f6c00d7d-36d9-477f-a9e7-0acdf4ff5e8b/',\n", - " 'C12': 'http://localhost:8000/api/base-bom-material/79ed4929-dfc4-4ae4-b0d4-b394535c7eff/',\n", - " 'D1': 'http://localhost:8000/api/base-bom-material/5af0eb22-ccdd-4a10-94c7-ca32d25b3fa8/',\n", - " 'D2': 'http://localhost:8000/api/base-bom-material/d5c442cf-249d-4562-8765-352c25b08b6d/',\n", - " 'D3': 'http://localhost:8000/api/base-bom-material/0e4a7df5-af76-4433-94da-15a5e42b8c55/',\n", - " 'D4': 'http://localhost:8000/api/base-bom-material/ec681f7d-cfca-4513-b5fe-1e7b7d649a91/',\n", - " 'D5': 'http://localhost:8000/api/base-bom-material/9c7a2796-ac07-42d2-a911-db64593da3d9/',\n", - " 'D6': 'http://localhost:8000/api/base-bom-material/c183d1fc-fe4b-4637-884a-63ff6b8c0132/',\n", - " 'D7': 'http://localhost:8000/api/base-bom-material/14e69706-4f79-4995-a13f-91d5ef3ade61/',\n", - " 'D8': 'http://localhost:8000/api/base-bom-material/9ea3cb10-1ee9-49a9-b5b6-155bd9eacbf2/',\n", - " 'D9': 'http://localhost:8000/api/base-bom-material/7f6e55dc-b55d-402e-baf8-db71d8c8fdf6/',\n", - " 'D10': 'http://localhost:8000/api/base-bom-material/506539be-bf32-4bd8-80c8-df56e82312c5/',\n", - " 'D11': 'http://localhost:8000/api/base-bom-material/33766468-2792-4481-bb29-457fe43cafe7/',\n", - " 'D12': 'http://localhost:8000/api/base-bom-material/d33a69b1-70a9-425c-b7d3-170aa7e3ba29/',\n", - " 'E1': 'http://localhost:8000/api/base-bom-material/b53c6292-c4ae-4b59-9e96-c7b7d62eb2eb/',\n", - " 'E2': 'http://localhost:8000/api/base-bom-material/3256ff6d-8df0-4015-a2ed-45682e205d3f/',\n", - " 'E3': 'http://localhost:8000/api/base-bom-material/70cac8bf-c2a1-4be3-bf3d-c7deb136dbb3/',\n", - " 'E4': 'http://localhost:8000/api/base-bom-material/5ecb727e-3943-458a-848c-ffbb34e0d0f7/',\n", - " 'E5': 'http://localhost:8000/api/base-bom-material/d522b3c4-523e-44e5-b0ad-43e13b46af6e/',\n", - " 'E6': 'http://localhost:8000/api/base-bom-material/70c527fc-63cb-47e1-9586-93eb8cfbfbd8/',\n", - " 'E7': 'http://localhost:8000/api/base-bom-material/3f0893bb-9fd0-4470-ba61-acaaf7f7af51/',\n", - " 'E8': 'http://localhost:8000/api/base-bom-material/ffd75695-d009-4b0a-b599-602b50353c7b/',\n", - " 'E9': 'http://localhost:8000/api/base-bom-material/f0eb8c17-fc58-429e-88dc-7564a49e70ea/',\n", - " 'E10': 'http://localhost:8000/api/base-bom-material/22113f50-3e30-4887-9c63-909cd33aa0b6/',\n", - " 'E11': 'http://localhost:8000/api/base-bom-material/435fa952-ad58-4201-a076-060aceac1ecb/',\n", - " 'E12': 'http://localhost:8000/api/base-bom-material/ab0e66a5-205d-49f4-8407-51d0201c607c/',\n", - " 'F1': 'http://localhost:8000/api/base-bom-material/89262578-2216-4d70-a2f8-c51e89f3ad33/',\n", - " 'F2': 'http://localhost:8000/api/base-bom-material/835d7505-c502-4e16-a1c8-21f20a9e5c05/',\n", - " 'F3': 'http://localhost:8000/api/base-bom-material/ec7339ad-21bb-47f9-8951-a1b1c71407ee/',\n", - " 'F4': 'http://localhost:8000/api/base-bom-material/7f7a5b0b-de47-4a27-97e8-d9e9be4d0275/',\n", - " 'F5': 'http://localhost:8000/api/base-bom-material/339dcf81-aa62-43a4-8e92-45419ef6ab3c/',\n", - " 'F6': 'http://localhost:8000/api/base-bom-material/effe5111-b1ba-4777-ab83-aaa0d53c6219/',\n", - " 'F7': 'http://localhost:8000/api/base-bom-material/4d90e72b-9b22-4841-94eb-cd5b89ca001d/',\n", - " 'F8': 'http://localhost:8000/api/base-bom-material/41676005-1024-4ee6-88de-b96defb81208/',\n", - " 'F9': 'http://localhost:8000/api/base-bom-material/524a460e-5932-4c64-8797-2ff7cea85c30/',\n", - " 'F10': 'http://localhost:8000/api/base-bom-material/52dca674-b010-4419-86fd-558cc71e34f7/',\n", - " 'F11': 'http://localhost:8000/api/base-bom-material/9f19985c-8ab2-4815-adfe-7c01a874df68/',\n", - " 'F12': 'http://localhost:8000/api/base-bom-material/3d75ee6b-b299-4653-8a25-894c1ea92441/',\n", - " 'G1': 'http://localhost:8000/api/base-bom-material/3313b807-5ebb-4cca-a384-4e6e353c952b/',\n", - " 'G2': 'http://localhost:8000/api/base-bom-material/033f99e9-e986-4862-b709-400a37d92759/',\n", - " 'G3': 'http://localhost:8000/api/base-bom-material/1b7851e3-6544-4691-a47a-a222899ad618/',\n", - " 'G4': 'http://localhost:8000/api/base-bom-material/2ad0acc7-bb7a-475d-a3cd-b127d4122425/',\n", - " 'G5': 'http://localhost:8000/api/base-bom-material/c5c29c81-8892-48d2-bebf-148839ec2fa0/',\n", - " 'G6': 'http://localhost:8000/api/base-bom-material/8b0e2fa3-5952-4b85-b7e6-7f473d15bc2a/',\n", - " 'G7': 'http://localhost:8000/api/base-bom-material/0e5cc62e-b63d-40ef-bd73-e74a889ce4ef/',\n", - " 'G8': 'http://localhost:8000/api/base-bom-material/b370e6a3-c921-4f98-a3a4-f525f945d3c3/',\n", - " 'G9': 'http://localhost:8000/api/base-bom-material/279b8aea-4a8d-40aa-bf53-579d5b9d37ec/',\n", - " 'G10': 'http://localhost:8000/api/base-bom-material/2eb3a4a9-8ccc-423f-8959-99190673775a/',\n", - " 'G11': 'http://localhost:8000/api/base-bom-material/09afccc6-da67-411a-be1d-b299feba4157/',\n", - " 'G12': 'http://localhost:8000/api/base-bom-material/b9c929ae-fdc8-4af8-9ced-215ea676d765/',\n", - " 'H1': 'http://localhost:8000/api/base-bom-material/5f60152e-9566-4322-8119-3123927fba90/',\n", - " 'H2': 'http://localhost:8000/api/base-bom-material/07114655-147e-431d-a1a2-3f93085eb8b7/',\n", - " 'H3': 'http://localhost:8000/api/base-bom-material/52b04956-91ed-47f6-b531-f0dfe17b378c/',\n", - " 'H4': 'http://localhost:8000/api/base-bom-material/8bd4bb8d-664d-49ee-b832-c090b4b52930/',\n", - " 'H5': 'http://localhost:8000/api/base-bom-material/2f39fab4-2b8c-478e-ae74-02ce0c478637/',\n", - " 'H6': 'http://localhost:8000/api/base-bom-material/779770c8-f74f-4c84-9227-a9b2f7369ec9/',\n", - " 'H7': 'http://localhost:8000/api/base-bom-material/c729d49f-e2de-47f7-9d61-28c3148fa317/',\n", - " 'H8': 'http://localhost:8000/api/base-bom-material/9dd291cb-a4bf-45d1-876f-96f1ab2f628d/',\n", - " 'H9': 'http://localhost:8000/api/base-bom-material/d11c1e98-c90e-4daa-86b7-0a23840ddd04/',\n", - " 'H10': 'http://localhost:8000/api/base-bom-material/0b0d2b93-ad8a-4528-9b1c-7a7851fe5c54/',\n", - " 'H11': 'http://localhost:8000/api/base-bom-material/71356862-75e8-4d3f-8585-bbbe9d2ac9c4/',\n", - " 'H12': 'http://localhost:8000/api/base-bom-material/86219b01-bc1e-4479-a68d-a573edf2c544/'}" - ] - }, - "execution_count": 51, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "bom_wellss" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Set Up Actions\n", - "\n", - "* Determine all actions needed for the experiment procedure. Use `Get()` to search the database for definitions of these actions (action-def). `Post()` new ones as needed" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/action-def/0ccac627-5e68-4010-84b4-d1db19adabf9/', 'description': 'dispense_solid'}\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/action-def/030d508f-49a4-4eab-a83b-fb1635f3e793/', 'description': 'heat'}\n", - "GET: OK\n", - "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", - "GET: OK\n", - "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", - "GET: OK\n", - "{'count': 0, 'next': None, 'previous': None, 'results': []}\n" - ] - } - ], - "source": [ - "action_def_names = ['dispense_liquid', 'dispense_solid', 'heat', 'cool', 'transfer', 'stir']\n", - "\n", - "for i in action_def_names: \n", - " r = escalate.get('action-def', data={'fields': ['description', 'url'],\n", - " 'description': i}) \n", - " print(r)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Looks like we have definitions for heating and for dispensing solid ... there's heat-stir but not just stir, and the other ones are completely missing. So we `Post()`." - ] - }, - { - "cell_type": "code", - "execution_count": 53, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - } - ], - "source": [ - "missing = ['dispense_liquid', 'cool', 'transfer', 'stir']\n", - "\n", - "for i in missing:\n", - " r = escalate.post('action-def/', {'description': i, \n", - " 'status': escalate.get('status', {'description':'test'})['url']}\n", - " )" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": { - "tags": [] - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "{'dispense_liquid': 'http://localhost:8000/api/action-def/60677fdb-6cd2-4239-9915-400e35ff184f/',\n", - " 'dispense_solid': 'http://localhost:8000/api/action-def/0ccac627-5e68-4010-84b4-d1db19adabf9/',\n", - " 'heat': 'http://localhost:8000/api/action-def/030d508f-49a4-4eab-a83b-fb1635f3e793/',\n", - " 'cool': 'http://localhost:8000/api/action-def/7abb21cd-1fff-495c-ace9-e5d81ecf99af/',\n", - " 'transfer': 'http://localhost:8000/api/action-def/e270c81e-b94d-49ae-b68f-2e8a86c31ee8/',\n", - " 'stir': 'http://localhost:8000/api/action-def/bf3bcb09-0a6e-4006-8688-73586036ff85/'}" - ] - }, - "execution_count": 54, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "actions = {\n", - " name: escalate.get('action-def', data={'description': name})['url'] \n", - " for name in action_def_names}\n", - "\n", - "actions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Determine the parameters (e.g. temperature, stir speed) that you'll need to specify for each action. Search if these exist, and post new ones as needed\n", - "\n", - "We want temperature for heating/cooling, speed/duration for stirring, and mass and volume for the dispense and transfer actions. Let's use the case-insensitive containtment filter `__icontains` for our search because we don't know exactly what the parameter definitions are called." - ] - }, - { - "cell_type": "code", - "execution_count": 55, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/parameter-def/e4db0901-aabd-4abe-87a3-64a38d9a8217/', 'description': 'temperature'}\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/parameter-def/1e51d3cd-7cf6-4765-bfc1-e7d54540696f/', 'description': 'speed'}\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/parameter-def/2cc0ed35-abaf-4ea5-b4c2-c848b0359129/', 'description': 'duration'}\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "{'url': 'http://localhost:8000/api/parameter-def/2d9eb6b7-9e17-4e5f-855f-656687c80327/', 'description': 'mass'}\n", - "GET: OK\n", - "Found 6 resources, returning list of dicts)\n", - "[{'url': 'http://localhost:8000/api/parameter-def/79df4ee7-776f-4544-9636-6c37df64cc96/', 'description': 'volume'}, {'url': 'http://localhost:8000/api/parameter-def/73dfd457-1b05-490c-9d6f-3d6cbcce3ad3/', 'description': 'Sample Solvent Volume'}, {'url': 'http://localhost:8000/api/parameter-def/b701f73d-74b3-48ad-be8e-57bd3ed7c45c/', 'description': 'Sample Stock A Volume'}, {'url': 'http://localhost:8000/api/parameter-def/070ad2bf-dd15-49ee-bc33-0ee764ed5106/', 'description': 'Sample Stock B Volume'}, {'url': 'http://localhost:8000/api/parameter-def/72eca483-d496-46bd-9a14-cc32c68a12e1/', 'description': 'Sample Acid Volume 1'}, {'url': 'http://localhost:8000/api/parameter-def/fafa6957-b9c6-4f78-b09e-76eb5d224156/', 'description': 'Sample Acid Volume 2'}]\n" - ] - } - ], - "source": [ - "param_names = ['temperature', 'speed', 'duration', 'mass', 'volume']\n", - "\n", - "for i in param_names: \n", - " r = escalate.get('parameter-def', data={'fields': ['description', 'url'],\n", - " 'description__icontains': i}) \n", - " print(r)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Looks like there are several volume-related parameters; the one we want is just \"volume\".\n", - "\n", - "* Associate the action definitions and parameter definitions using `Patch()`" - ] - }, - { - "cell_type": "code", - "execution_count": 56, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n", - "GET: OK\n", - "Found one resource, returning dict\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 56, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "escalate.patch(url=actions['heat'], \n", - " data={'parameter_def': [escalate.get('parameter-def', \n", - " {'description': 'temperature'})['url'], \n", - " ]\n", - " })\n", - "\n", - "escalate.patch(url=actions['cool'], \n", - " data={'parameter_def': [escalate.get('parameter-def', \n", - " {'description': 'temperature'})['url'],\n", - " ]\n", - " })\n", - "\n", - "escalate.patch(url=actions['stir'], \n", - " data={'parameter_def': [escalate.get('parameter-def', \n", - " {'description': 'speed'})['url'],\n", - " escalate.get('parameter-def', \n", - " {'description': 'duration'})['url'] \n", - " ]\n", - " })\n", - "\n", - "escalate.patch(url=actions['dispense_solid'], \n", - " data={'parameter_def': [escalate.get('parameter-def', \n", - " {'description': 'mass'})['url'],\n", - " ]\n", - " })\n", - "\n", - "escalate.patch(url=actions['dispense_liquid'], \n", - " data={'parameter_def': [escalate.get('parameter-def', \n", - " {'description': 'volume'})['url'],\n", - " ]\n", - " })\n", - "\n", - "escalate.patch(url=actions['transfer'], \n", - " data={'parameter_def': [escalate.get('parameter-def', \n", - " {'description': 'mass'})['url'],\n", - " escalate.get('parameter-def', \n", - " {'description': 'volume'})['url'] \n", - " ]\n", - " })" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**For transfer we can just have a volume param!**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Create action instances for each action definition\n", - "\n", - "(The instance is linked to an action definition (e.g. dispense solid) and to the desired workflow)" - ] - }, - { - "cell_type": "code", - "execution_count": 57, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/action/cb509d82-18e9-453a-ac75-9951fd6f0225/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/action/d68f6c57-61dd-4ea1-8075-a068cc347883/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/action/27280834-dc27-4e8d-9047-d4635ed4cd26/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/action/8232790d-3791-4a11-952f-6b2bdd5f230b/\n" - ] - } - ], - "source": [ - "prep_actions = ['dispense_solid', 'dispense_liquid', 'cool', 'stir']\n", - "\n", - "action_inst1={}\n", - "\n", - "for action in prep_actions:\n", - " r = escalate.post('action/', \n", - " {'workflow': wfs['Reagent Preparation'], \n", - " 'action_def': actions[action],\n", - " }\n", - " )['url']\n", - " \n", - " action_inst1[action]=r\n", - " \n", - " print(r)" - ] - }, - { - "cell_type": "code", - "execution_count": 58, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/action/634146e1-9072-4749-b8d3-d95491a0b9d5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/action/9284c4fb-3e4d-4d94-9a77-ed04dc9b3ad5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/action/e5393a85-9b90-4eb7-8fce-2a73783fbc79/\n" - ] - } - ], - "source": [ - "synthesis_actions= ['heat', 'transfer', 'stir']\n", - "\n", - "action_inst2={}\n", - "\n", - "for action in synthesis_actions:\n", - " r = escalate.post('action/', \n", - " {'workflow': wfs['Synthesis'], \n", - " 'action_def': actions[action],\n", - " }\n", - " )['url']\n", - " \n", - " action_inst2[action]=r\n", - " \n", - " print(r)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Implement steps of the procedure\n", - "\n", - "* Generate action units for each step " - ] - }, - { - "cell_type": "code", - "execution_count": 61, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n" - ] - } - ], - "source": [ - "#reagent prep steps of workflow\n", - "#step 1: add 25 mL GBL to stock tube 1\n", - "\n", - "r= escalate.post('action-unit/', \n", - " {'action': action_inst1['dispense_liquid'],\n", - " 'source_material': bom_materials['Gamma-Butyrolactone'], #material, from BOM\n", - " 'destination_material': bom_tubes['Stock Tube 1'] #container, from BOM\n", - " })" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For this action, we are dispensing liquid, so we want to know how much. That means we need to specify the (actual) value of the volume parameter. To do so, we use `Patch()`. Once this is done, if we navigate to the url of the specific action unit instance AND to the url of the parameter instance, we should see the (actual) parameter value for volume listed as 25 mL." - ] - }, - { - "cell_type": "code", - "execution_count": 63, - "metadata": {}, - "outputs": [], - "source": [ - "param_url= r['parameter'][0]['url']\n", - "\n", - "param_url\n", - "\n", - "patch_data = {'parameter_val_actual': {'value': 25, 'unit': 'mL', 'type': 'num'}}\n", - "\n", - "r = escalate.patch(data=patch_data, url=param_url)" - ] - }, - { - "cell_type": "code", - "execution_count": 67, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'Stock Tube 1': 'http://localhost:8000/api/base-bom-material/198b3a32-dd37-44a9-aafb-3411bc05afd6/',\n", - " 'Stock Tube 2': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/',\n", - " 'Stock Container 3': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/',\n", - " 'Stock Container 4': 'http://localhost:8000/api/base-bom-material/d5ac3fe5-356c-4411-a900-c63669bf23a4/'}" - ] - }, - "execution_count": 67, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "bom_tubes" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 68, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#step 2: add 10 mL formic acid to Stock Container 4\n", - "\n", - "r= escalate.post('action-unit/', \n", - " {'action': action_inst1['dispense_liquid'],\n", - " 'source_material': bom_materials['Formic Acid'], #material, from BOM\n", - " 'destination_material': bom_tubes['Stock Container 4'] #container, from BOM\n", - " })\n", - "\n", - "param_url= r['parameter'][0]['url']\n", - "\n", - "patch_data = {'parameter_val_actual': {'value': 10, 'unit': 'mL', 'type': 'num'}}\n", - "\n", - "r = escalate.patch(data=patch_data, url=param_url)\n", - "\n", - "r" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "When we have a mixture of different materials in a container we will need several dispensing steps, one for each material. We can handle all the solids in a loop, since the action unit is of the same type." - ] - }, - { - "cell_type": "code", - "execution_count": 72, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/c309b221-c8e5-49ac-a09e-4fe02c8a4312/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/666fe60a-e62f-44c3-aa57-ca104a3ebc09/\n" - ] - } - ], - "source": [ - "#step 3 = add 0.5 g PbI2, 0.5 g NH4I, 10 ml GBL to Stock Tube 2\n", - "\n", - "solids={'Lead Diiodide': 0.5, 'Ammonium Iodide': 0.5}\n", - "for key, val in solids.items():\n", - " r= escalate.post('action-unit/', \n", - " {'action': action_inst1['dispense_solid'],\n", - " 'source_material': bom_materials[key], #material, from BOM\n", - " 'destination_material': bom_tubes['Stock Tube 2'] #container, from BOM\n", - " })\n", - " \n", - " param_url= r['parameter'][0]['url']\n", - " \n", - " print(param_url)\n", - "\n", - " patch_data = {'parameter_val_actual': {'value': val, 'unit': 'g', 'type': 'num'}}\n", - " \n", - " r = escalate.patch(data=patch_data, url=param_url)" - ] - }, - { - "cell_type": "code", - "execution_count": 73, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 73, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "r= escalate.post('action-unit/', \n", - " {'action': action_inst1['dispense_liquid'],\n", - " 'source_material': bom_materials['Gamma-Butyrolactone'], #material, from BOM\n", - " 'destination_material': bom_tubes['Stock Tube 2'] #container, from BOM\n", - " })\n", - "\n", - "param_url= r['parameter'][0]['url']\n", - "\n", - "patch_data = {'parameter_val_actual': {'value': 10, 'unit': 'mL', 'type': 'num'}}\n", - "\n", - "r = escalate.patch(data=patch_data, url=param_url)\n", - "\n", - "r" - ] - }, - { - "cell_type": "code", - "execution_count": 77, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 77, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#step 4 = add 1 g NH4I, 10 mL GBL to Stock Tube 3\n", - "\n", - "r= escalate.post('action-unit/', \n", - " {'action': action_inst1['dispense_solid'],\n", - " 'source_material': bom_materials['Ammonium Iodide'], #material, from BOM\n", - " 'destination_material': bom_tubes['Stock Container 3'] #container, from BOM\n", - " })\n", - "\n", - "param_url= r['parameter'][0]['url']\n", - "\n", - "patch_data = {'parameter_val_actual': {'value': 1, 'unit': 'g', 'type': 'num'}}\n", - "\n", - "r = escalate.patch(data=patch_data, url=param_url)\n", - "\n", - "r" - ] - }, - { - "cell_type": "code", - "execution_count": 76, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 76, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "r= escalate.post('action-unit/', \n", - " {'action': action_inst1['dispense_liquid'],\n", - " 'source_material': bom_materials['Gamma-Butyrolactone'], #material, from BOM\n", - " 'destination_material': bom_tubes['Stock Container 3'] #container, from BOM\n", - " })\n", - "\n", - "param_url= r['parameter'][0]['url']\n", - "\n", - "patch_data = {'parameter_val_actual': {'value': 10, 'unit': 'mL', 'type': 'num'}}\n", - "\n", - "r = escalate.patch(data=patch_data, url=param_url)\n", - "\n", - "r" - ] - }, - { - "cell_type": "code", - "execution_count": 87, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'Stock Tube 1': 'http://localhost:8000/api/base-bom-material/198b3a32-dd37-44a9-aafb-3411bc05afd6/',\n", - " 'Stock Tube 2': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/',\n", - " 'Stock Container 3': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/',\n", - " 'Stock Container 4': 'http://localhost:8000/api/base-bom-material/d5ac3fe5-356c-4411-a900-c63669bf23a4/'}" - ] - }, - "execution_count": 87, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "bom_tubes" - ] - }, - { - "cell_type": "code", - "execution_count": 86, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "{'url': 'http://localhost:8000/api/action-unit/766a6d8f-26ce-4d6f-9aea-b238cc078519/', 'uuid': '766a6d8f-26ce-4d6f-9aea-b238cc078519', 'edocs': [], 'tags': [], 'notes': [], 'parameter': [{'url': 'http://localhost:8000/api/parameter/cad773b9-4b6c-4acf-a2d0-61c9b6d39cb3/', 'uuid': 'cad773b9-4b6c-4acf-a2d0-61c9b6d39cb3', 'add_date': '2021-09-07T18:52:41.933830', 'mod_date': '2021-09-07T18:52:41.933849', 'parameter_val_nominal': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/2cc0ed35-abaf-4ea5-b4c2-c848b0359129/', 'action_unit': 'http://localhost:8000/api/action-unit/766a6d8f-26ce-4d6f-9aea-b238cc078519/'}, {'url': 'http://localhost:8000/api/parameter/a9cdbdda-5a5e-4360-b96f-6128272cb6eb/', 'uuid': 'a9cdbdda-5a5e-4360-b96f-6128272cb6eb', 'add_date': '2021-09-07T18:52:41.938966', 'mod_date': '2021-09-07T18:52:41.938985', 'parameter_val_nominal': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/1e51d3cd-7cf6-4765-bfc1-e7d54540696f/', 'action_unit': 'http://localhost:8000/api/action-unit/766a6d8f-26ce-4d6f-9aea-b238cc078519/'}], 'add_date': '2021-09-07T18:52:41.893009', 'mod_date': '2021-09-07T18:52:41.893030', 'description': None, 'internal_slug': 'workflow-1-demo-workflow-1-demo-workflow-1-demo-tube-6-reagent-preparation-stir-2', 'status': None, 'actor': None, 'action': 'http://localhost:8000/api/action/8232790d-3791-4a11-952f-6b2bdd5f230b/', 'source_material': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/', 'destination_material': None}\n", - "\n", - "POST: OK, returning new resource dict\n", - "{'url': 'http://localhost:8000/api/action-unit/8131ecf6-0b00-4bce-bac6-915d052517ad/', 'uuid': '8131ecf6-0b00-4bce-bac6-915d052517ad', 'edocs': [], 'tags': [], 'notes': [], 'parameter': [{'url': 'http://localhost:8000/api/parameter/dd389646-07cb-4a45-977f-3e4b2c23c04a/', 'uuid': 'dd389646-07cb-4a45-977f-3e4b2c23c04a', 'add_date': '2021-09-07T18:52:42.044834', 'mod_date': '2021-09-07T18:52:42.044853', 'parameter_val_nominal': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/2cc0ed35-abaf-4ea5-b4c2-c848b0359129/', 'action_unit': 'http://localhost:8000/api/action-unit/8131ecf6-0b00-4bce-bac6-915d052517ad/'}, {'url': 'http://localhost:8000/api/parameter/13fa6063-1946-43c5-8288-350a892ebf86/', 'uuid': '13fa6063-1946-43c5-8288-350a892ebf86', 'add_date': '2021-09-07T18:52:42.049118', 'mod_date': '2021-09-07T18:52:42.049137', 'parameter_val_nominal': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/1e51d3cd-7cf6-4765-bfc1-e7d54540696f/', 'action_unit': 'http://localhost:8000/api/action-unit/8131ecf6-0b00-4bce-bac6-915d052517ad/'}], 'add_date': '2021-09-07T18:52:42.014590', 'mod_date': '2021-09-07T18:52:42.014608', 'description': None, 'internal_slug': 'workflow-1-demo-workflow-1-demo-workflow-1-demo-tube-7-reagent-preparation-stir', 'status': None, 'actor': None, 'action': 'http://localhost:8000/api/action/8232790d-3791-4a11-952f-6b2bdd5f230b/', 'source_material': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/', 'destination_material': None}\n" - ] - } - ], - "source": [ - "#stir reagents in containers 2 and 3 until contents dissolve\n", - "conts=['Stock Tube 2', 'Stock Container 3']\n", - "\n", - "for cont in conts:\n", - " r= escalate.post('action-unit/', \n", - " {'action': action_inst1['stir'],\n", - " 'source_material': bom_tubes[cont], \n", - " 'destination_material': None \n", - " })\n", - " print(r)" - ] - }, - { - "cell_type": "code", - "execution_count": 90, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - } - ], - "source": [ - "#cool containers 2 and 3 to room temp\n", - "\n", - "for cont in conts:\n", - " r= escalate.post('action-unit/', \n", - " {'action': action_inst1['cool'],\n", - " 'source_material': bom_tubes[cont], \n", - " 'destination_material': None \n", - " })\n", - " \n", - " param_url= r['parameter'][0]['url']\n", - "\n", - " patch_data = {'parameter_val_actual': {'value': 25, 'unit': 'deqC', 'type': 'num'}}\n", - "\n", - " r = escalate.patch(data=patch_data, url=param_url)" - ] - }, - { - "cell_type": "code", - "execution_count": 95, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/5bcf6bd9-d53e-44da-b890-5f67636526ae/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/0c86fd3c-15df-44d1-b38c-57cef8622513/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7483c06d-94d0-4a86-b157-ee94b97e8d7f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/fae8ba52-7ddb-416d-a71f-9acc60dc9705/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/5fb42a6b-7ef6-4d36-885d-2890485d6bac/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/55bec7ba-c22d-4538-897a-73f9520c8fb7/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/f94373d2-5b60-43c0-9b17-2b9c4237a5b5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/29ec14eb-0b00-4df0-9d36-212545cea1e3/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/f7001e70-2159-4e40-a907-6af26589bb84/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/bbc1f272-27dd-45cb-b844-61c13c9f84d1/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/f6e1d960-821f-404d-a7c0-9e5370a09cb7/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/2c61b76d-200a-41eb-a6be-529304cba391/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/b74a849d-0c32-4abb-9473-00453db12167/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/31034025-6122-4547-8ef5-9ab12843b735/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/0989b46d-4ea7-46ea-aac0-428e7ac09584/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/cd9a26ee-da64-4ec1-aeb1-c00a9048a984/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/18a41166-979f-4a9c-8f51-b1b90db2d7eb/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/a67f6c71-bb32-420a-8440-385df474bd1e/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/595a3ab6-83e8-4963-84e4-074cfc9d495f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d38f3e2f-c32f-4b55-a83e-4a759744c78c/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ac01cf75-abac-414d-abb2-3fb349b784c3/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7a498b1b-5101-4342-8b7e-524953b98e3b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/3682a61f-a0b3-410f-8cc9-cb7260cf9e35/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/dd2768c0-7543-41fb-bfaa-0d167573e0cc/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/21be0aaf-8046-4beb-86ef-d5038a8472af/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4833c1f4-4273-4ee1-beb4-476de9d61346/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/6d6f2c4a-46e9-4488-99f1-6fe4f36a3c6f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/e4d518ea-6dca-4a67-9438-488b238d2137/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/42b5136a-217f-4e6c-959d-8ac2c1b793b4/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4ea3edb8-0738-4c24-b109-fef16ee0c520/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/a960c11a-d437-4591-9960-d8c17fe6c9da/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7d38f384-392d-4f3d-9e12-7407229157e8/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/726fbc1e-890e-4dca-bedc-6083e6925733/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/574b292a-bb23-4cc6-a7e7-02146c1db440/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/0b084a6b-70de-4c2a-9b86-b6e5c8b73030/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/1d103ac8-6206-40de-9ad5-2a42420647ff/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/5a906ab8-3bc2-4280-91b1-2f163e0e0456/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4042b5b3-928f-4a3a-9803-65c3194bcfad/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d37d1402-a98a-4fc0-a58b-1aa2aad525b4/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7a4838ef-4ca1-498f-9218-cde767538f2c/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ed47b022-ac18-45c1-8275-2be38433fc7a/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/849ab35a-fdda-47d3-91ef-52f116a09869/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/9e209e11-1cbd-4bad-84d6-7d13703073ce/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/18ca654c-2dee-46de-a749-d65ca6bc503b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/19409529-507c-4e7d-94e6-f72cd77d1199/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/3c720bfb-6461-4bab-befc-3ac90d7ec647/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/9cf6fe44-2ea0-430a-b746-48f404abf2ba/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/8b2191a9-9b47-4b12-af1e-2b93ca8c2bb9/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/38eccccc-ed36-413e-881c-d3e05d981616/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/6650a648-aee1-4a63-a40d-8b60206757ee/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/1a5fe95e-6a13-4eef-bf59-57ec11643e24/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d5fdf9d7-cc1b-4d6c-bd61-823dbaa1c88f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4984161b-2637-4f54-ab1e-d72bd4dcd3fc/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/1ea6dbfc-5893-49b3-9a0f-26187cd410a5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7eeec597-cf70-4ef7-8378-532fe3e9123b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ee651453-04d4-4a42-87c8-9b4d6f9c845d/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/19bbb741-ccc2-4d7c-944b-71ccfcee76a2/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ace521f4-88a1-4f2d-944d-14146d255b2b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/926d3166-4c06-4dad-b3bc-77bdbc45c38f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/00d67df9-00af-4f84-b62a-fe28c839facf/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d8c90670-0034-4512-ae9a-e2f39c100c90/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/85a86c7b-3003-4fe7-ba5b-c339fabe4924/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/dda50cf5-e30d-4471-bb65-0bb76b7ac81f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/b14eb1bf-4d78-4c38-8e2b-e8406ed6efcd/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/107f3343-797e-49aa-a99d-b97f5f3c24dc/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/8315aa14-9310-4869-8d70-416744224d5d/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/09ca8dec-78fa-4801-9edb-a9a796e2779f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ddaf7988-047e-42b4-ba27-c3e4dd403fbd/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/55d519b9-4e40-4539-89e3-b75f4556c27f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d8d2c93e-afa0-4588-a532-bcb19593bbec/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4bae796e-a78e-4ef9-b666-eb90b44a2523/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/38ce9322-bd63-44bc-9977-1fe6be937d6c/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/07458353-e295-4e42-8f9f-7aea18738b51/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/3481c662-3200-48c0-99ef-91a5e0c24a8a/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d4293c8e-da2a-4799-9ea1-cb2b28e8a66b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/81db6c1d-c5b9-4e86-a26b-719f0f38e06b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/e8c5b7c5-a539-4cbc-b35e-5ed7178eed58/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/6309bb46-bc1f-4d82-9249-6a9f21ea89ae/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/743dec43-7495-4de8-a006-a9f1efbbf913/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/b345238e-9180-46ab-bd80-fce942809742/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4b99527c-86af-4022-a80f-200ecb00a6ba/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/96baa4ed-0017-4883-9491-af3ec9adabef/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7837dc98-a003-43e1-895f-7b0c71349dd2/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/279b5688-db9a-4b4b-aacf-936bbf08a333/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/f1bbadc8-7ab6-4291-9d4e-2b59ccb3a6ee/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/83b5762d-0230-428f-a505-c6f45370832e/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/9ffbf29e-7797-4078-aed7-0edcd7705847/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/6c00bee0-066f-4a76-afcc-0242514bbfa6/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/6037e3ee-a57b-424b-9420-2ac20f25e1d6/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/87a34653-9bd7-4e19-848c-40828dd242b9/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/cba62da5-c6bb-43b6-bce7-44373cf073c1/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/0a377b75-8642-4fbc-8536-6e2a5f972dec/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/6b7b8926-4f11-4014-a869-7814b8b16e0d/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/c1c63090-5d58-4980-b211-f3f1522df44b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/3de26033-d850-4425-a3b9-561403ad1c6b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/e4f3f7a1-2edc-4e85-aefa-63834b5203e1/\n" - ] - } - ], - "source": [ - "##synthesis portion of workflow\n", - "#heat well plate to 105 (actual temp is 95... how to distinguish this?)\n", - "\n", - "for well in bom_wellss.keys():\n", - " r= escalate.post('action-unit/', \n", - " {'action': action_inst2['heat'],\n", - " 'source_material': bom_wellss[well], \n", - " 'destination_material': None \n", - " })\n", - " \n", - " param_url= r['parameter'][0]['url']\n", - " \n", - " #print(param_url)\n", - "\n", - " patch_data = {'parameter_val_nominal': {'value': 105, 'unit': 'deqC', 'type': 'num'}}\n", - "\n", - " r = escalate.patch(data=patch_data, url=param_url)\n", - " \n", - " patch_data = {'parameter_val_actual': {'value': 95, 'unit': 'deqC', 'type': 'num'}}\n", - " \n", - " r = escalate.patch(data=patch_data, url=param_url)" - ] - }, - { - "cell_type": "code", - "execution_count": 96, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/b079abb9-2241-4c94-b479-798d7ec5b19e/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7672708b-cdfb-4097-8df5-ecf3ca688b5f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/b630a785-7964-4403-949f-91315327288f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/e3cb9367-0760-4d40-ac0f-512334375818/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4d1a57ca-ff92-4a4e-a437-543801b1f9a5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ed1818dd-f44c-43c4-a55a-39ea0081e6a7/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/80c6ecdd-c9d7-4916-b674-e16e8587ee1e/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d7a8e0a4-3626-4515-a82b-9c2dd6884242/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d7893705-7507-4f6a-b7b5-552353ac84c8/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7b7d6b6a-f598-47d5-b8a8-c842e021bce2/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/44c57d46-d028-479d-96fc-0a0b95ee58b3/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/17511bd3-15d8-4e9e-a16b-dee37f1e73ab/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/3302cf68-fd57-491f-a1f9-f9905bac07a5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/01fd71ab-ac6a-4893-b1a5-a67797a42fb7/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d8c0e372-8591-4368-9044-98c9d0b24fad/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/3389df42-8ad9-4fe4-b71b-2c580d6c29f8/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7dcf638f-515f-4d06-9d59-94224f3dcaf2/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/a03e4c39-2ac3-47f4-8baa-5241ba541d2d/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/b58acf91-566a-4d43-8858-05662cd09451/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/212f18e0-0d28-43b4-84b3-7af7c8e20a36/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/8ea80686-822c-4c9c-9c92-7464b923f0e2/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/9a162061-e660-4c6f-9905-92480833e243/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/a8a8ac12-bcb8-4886-97e2-f4de34a15309/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/2879899d-31b4-41d2-b13f-64d390b5ea9b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/18bb126b-abf5-4837-908e-fa03e1c7bfa5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ff7ee525-effe-492e-af99-1f39e840f58e/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ff0fb650-7ee0-4d45-b43b-35c1fc92dade/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/63bc22be-5f24-4065-bde6-9818539b567a/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/3646b095-73bd-4e68-8e05-b5ef11a2c07c/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/8541dd4c-d0a2-446f-bb5b-2d91989779d4/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/961533ff-9801-4409-8a5a-34713879acd3/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4cfb9919-fe26-4bdd-b5c7-a1ab060508cc/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/308a3364-b18e-4709-83da-bff31cc9ffdd/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/0673964f-491d-401e-b622-f25a96854c2d/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/e2d3f153-6c43-47fc-8f79-7c41259b24a9/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/11c73d9a-a9a8-4af7-98f0-1ef64ccf4797/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ea3fc8d5-f31c-45b8-9fdc-d482ca065b3c/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/89f8cd55-5490-4bee-81e1-b2da27932c13/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/2df77800-083f-4374-a3ed-b2e4945d81a5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/e4dfb34c-9416-406d-ad0e-59854f242b1c/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/da4266bf-3c20-4169-8a06-8fcb3ec9eb7e/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/238baab8-1fa0-45b3-8bef-23baa3ab1f10/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/00774978-727e-4389-a8fc-f2e240234492/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/0b0499b1-d63f-4850-b816-be8ffd38bf86/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/f4d6e515-c905-49ca-bcf8-f3794819db06/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/afb97886-770b-4e2e-811d-00eb888132fa/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/c00a8dfc-286b-4873-87f3-f8dc3c8ea780/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/82b887f4-9ac8-469a-9738-8040b8a22d50/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/9eb2f1f8-1628-453e-b0ff-bbb58712fdda/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/70449d49-45a5-448b-86a8-022ae0455f7e/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4ead632a-5aee-4fc0-9032-92b1892bc338/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/2806ada2-70d7-4d9c-9f24-80308c675853/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/e7a6c2a3-680c-4ef4-ab00-2e3e1782c4ee/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/80777d99-b201-4756-b83d-34e86643e6df/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/15a27a88-92b6-4b47-b6b8-7bd2cb948111/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/bb68d711-6a54-49ea-901d-e8fe6b9b8457/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/628a9af6-7f71-4257-a089-4f167c2979ed/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/0bd921df-9d2d-468e-98ef-8456ec4f59b0/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/4792a10c-4551-401d-a296-a9ee315eb4e2/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/aa336387-3955-42f4-8123-94fd05af33b2/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/2cbb7a30-dc4a-42dd-b66a-4b68863ad81d/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/c721c586-161d-4195-ad0a-dbbede695f6a/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/3d3a1b3f-ee9d-4934-b406-841f9e901b25/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/29d5ed53-517b-4fc7-ac2f-986e4a836d18/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/c68896b6-1d14-4122-a6a4-f2664efda96f/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/feed4be4-07cf-4633-a0eb-2f5cc4a1f98c/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/30260164-a853-46d7-97f9-e7959f21deac/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/50dab7ed-6927-496e-b8ca-4514d4b6290b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/b7edb177-78de-4224-9d98-85515eb7a242/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/8f27002d-2877-4315-99e6-ddf692653a31/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/276c1c82-c395-4a21-a8b5-8f4a1f3a8cc0/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/5450869f-bf2f-4e44-94a4-6734977a5ba4/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/8b483c21-2483-4c0e-8ae8-c683c11b9039/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/a2f43292-94ae-4aac-8fa0-23c1b217d3a0/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/78c72588-e943-42de-9654-9ab0a82a70cd/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/f45307ab-bd9e-4e7f-bfd3-54e054b91158/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/63221d19-7be4-4a1c-893e-756a1eb53fd6/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/91797b9d-9943-44d3-a344-e8a4f5fd98d5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/f26e0f9e-279e-4651-b8fc-fbfb1bc56e26/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/d2764d54-7598-4bcb-a8e7-ec6acfa66937/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/2c182e17-a275-4463-ad25-0b4dedcad014/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/ad605fab-b93f-42a1-994c-a20af104d3da/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/01d3d5f8-61dc-4845-ad16-9b50fe144735/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/55a0c8cc-b6a8-4520-aedd-b69c847f44b9/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/21baba30-4cd4-4c66-a30c-3b177f4cb0f1/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/6d0717e2-6697-4fdd-b802-f2f20d33069c/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/e8129a5d-b96b-4a6d-ba70-54b24e37ea6b/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/3dc1ee9b-bc8a-49c0-80d4-ec66e57486d5/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/7ada33e7-1fe4-45f7-a30b-f41ca9c34328/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/fa0baabe-7d1e-4c9c-bf48-04730713f1eb/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/27a66ee9-eb66-46f1-a7ff-0254a2dbdd4d/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/05dc8857-3acb-413c-87e8-c373be0d55c9/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/5e79e1ec-baea-4ba1-9e68-a179f32ba1ce/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/9fc380f6-ae5c-4b62-90c3-3b75ac7862e2/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/eb619fb8-2e62-4832-9803-feb3151af4fe/\n", - "\n", - "POST: OK, returning new resource dict\n", - "http://localhost:8000/api/parameter/78011400-f239-447a-ac6d-5eaa9f0d56e3/\n" - ] - } - ], - "source": [ - "#add 1 microliter of reagent 1 to each of the plates \n", - "\n", - "for well in bom_wellss.keys():\n", - " r= escalate.post('action-unit/', \n", - " {'action': action_inst2['transfer'],\n", - " 'source_material': bom_tubes['Stock Tube 1'], \n", - " 'destination_material': bom_wellss[well] \n", - " })\n", - " \n", - " param_url= r['parameter'][0]['url']\n", - " \n", - " print(param_url)\n", - "\n", - " patch_data = {'parameter_val_actual': {'value': .001, 'unit': 'mL', 'type': 'num'}}\n", - " \n", - " r = escalate.patch(data=patch_data, url=param_url)" - ] - }, - { - "cell_type": "code", - "execution_count": 97, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - } - ], - "source": [ - "#add 1 microliter of reagent 2 to each of the plates \n", - "\n", - "for well in bom_wellss.keys():\n", - " r= escalate.post('action-unit/', \n", - " {'action': action_inst2['transfer'],\n", - " 'source_material': bom_tubes['Stock Tube 2'], \n", - " 'destination_material': bom_wellss[well] \n", - " })\n", - " \n", - " param_url= r['parameter'][0]['url']\n", - "\n", - " patch_data = {'parameter_val_actual': {'value': .001, 'unit': 'mL', 'type': 'num'}}\n", - " \n", - " r = escalate.patch(data=patch_data, url=param_url)\n", - "\n", - "#add 1 microliter of reagent 3 to each of the plates\n", - "\n", - "for well in bom_wellss.keys():\n", - " r= escalate.post('action-unit/', \n", - " {'action': action_inst2['transfer'],\n", - " 'source_material': bom_tubes['Stock Container 3'], \n", - " 'destination_material': bom_wellss[well] \n", - " })\n", - " \n", - " param_url= r['parameter'][0]['url']\n", - "\n", - " patch_data = {'parameter_val_actual': {'value': .001, 'unit': 'mL', 'type': 'num'}}\n", - " \n", - " r = escalate.patch(data=patch_data, url=param_url)\n", - "\n", - "#add .6 microliter of reagent 4 to each of the plates\n", - "\n", - "for well in bom_wellss.keys():\n", - " r= escalate.post('action-unit/', \n", - " {'action': action_inst2['transfer'],\n", - " 'source_material': bom_tubes['Stock Container 4'], \n", - " 'destination_material': bom_wellss[well] \n", - " })\n", - " \n", - " param_url= r['parameter'][0]['url']\n", - "\n", - " patch_data = {'parameter_val_actual': {'value': .0006, 'unit': 'mL', 'type': 'num'}}\n", - " \n", - " r = escalate.patch(data=patch_data, url=param_url)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#stir well-plate for 15 min at 750 rpm" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**need to distinguish between time and speed params in the index loop**" - ] - }, - { - "cell_type": "code", - "execution_count": 99, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n", - "\n", - "POST: OK, returning new resource dict\n" - ] - } - ], - "source": [ - "#add 0.6 microliters of reagent 4 to each of the plates\n", - "\n", - "for well in bom_wellss.keys():\n", - " r= escalate.post('action-unit/', \n", - " {'action': action_inst2['transfer'],\n", - " 'source_material': bom_tubes['Stock Container 4'], \n", - " 'destination_material': bom_wellss[well] \n", - " })\n", - " \n", - " param_url= r['parameter'][0]['url']\n", - "\n", - " patch_data = {'parameter_val_actual': {'value': .0006, 'unit': 'mL', 'type': 'num'}}\n", - " \n", - " r = escalate.patch(data=patch_data, url=param_url)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#stir well-plate for 20 min at 750 rpm" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Associate action units with actions and workflows \n", - "\n", - "**I need help here**" - ] - }, - - "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.4" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} From b0cadfae364f3ecbe7893c94f6050c8dcd72e962 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Tue, 7 Sep 2021 15:26:43 -0400 Subject: [PATCH 16/17] Add files via upload --- demos/workflow_experiment_demo.ipynb | 3844 ++++++++++++++++++++++++++ 1 file changed, 3844 insertions(+) create mode 100644 demos/workflow_experiment_demo.ipynb diff --git a/demos/workflow_experiment_demo.ipynb b/demos/workflow_experiment_demo.ipynb new file mode 100644 index 0000000..304c7ea --- /dev/null +++ b/demos/workflow_experiment_demo.ipynb @@ -0,0 +1,3844 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Creating experiment templates through ESCALATE REST\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "#factor this out when it's imported into the client\n", + "\n", + "import requests\n", + "\n", + "class ESCALATEClient():\n", + " \"\"\"ESCALATE API Client\"\"\"\n", + " \n", + " def __init__(self, base_url, username, password):\n", + " self.base_url = base_url\n", + " self.username = username\n", + " self.password = password\n", + " self._token = None\n", + " self._is_logged_in = False\n", + " self._login()\n", + " \n", + " def _login(self):\n", + " r_login = requests.post(f'{self.base_url}/api/login', \n", + " data={'username': self.username, \n", + " 'password': self.password})\n", + " self._token = r_login.json()['token']\n", + " self._token_header = {'Authorization': f'Token {self._token}'}\n", + " self._is_logged_in = True\n", + " \n", + " def get(self, \n", + " endpoint='', \n", + " data=None, \n", + " parse_json=True, \n", + " content_type='application/json'):\n", + " \"\"\"Make GET request with `data` to `endpoint` in ESCALATE API\n", + " \n", + " return: (dict|list|requests.Response), bool\n", + " \"\"\"\n", + " data = {} if data is None else data\n", + " r = requests.get(f'{self.base_url}/api/{endpoint}',\n", + " params=data, \n", + " headers={**self._token_header, \n", + " 'content-type': content_type})\n", + " if r.ok: \n", + " print('GET: OK')\n", + " else: \n", + " print('GET: FAILED')\n", + " \n", + " if r.ok and parse_json:\n", + " resp_json = r.json() \n", + " # handle cases: no vs one vs many results\n", + " count = resp_json.get('count')\n", + " if count is None or count == 0:\n", + " return r.json()\n", + " elif count == 1: \n", + " print('Found one resource, returning dict')\n", + " return resp_json['results'][0]\n", + " elif count >= 1: \n", + " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", + " return r.json()['results']\n", + " print('Returning response object') \n", + " return r\n", + " \n", + " def post(self, \n", + " endpoint, \n", + " data, \n", + " content_type='application/json'):\n", + " \"\"\"POST `data` to `endpoint`in ESCALATE API using `content_type`\n", + " return: (dict|requests.Response), bool\n", + " \"\"\"\n", + " \n", + " if not self._is_logged_in:\n", + " raise ValueError(\"Not logged in: cannot post\")\n", + " \n", + " r = requests.api.post(\n", + " f'{self.base_url}/api/{endpoint}', \n", + " json=data, \n", + " headers={**self._token_header,\n", + " 'content-type': content_type})\n", + " print(r)\n", + " if r.ok: \n", + " print('POST: OK, returning new resource dict')\n", + " return r.json()\n", + " print('POST: FAILED, returning response object')\n", + " return r\n", + " \n", + " def put(self, data, url=None, endpoint=None, resource_id=None):\n", + " \"\"\"Update a resource\n", + " Either provide a url or an endpoint and resource id\n", + " \"\"\"\n", + " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", + " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", + " \n", + " if url is None: \n", + " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", + " r = requests.api.put(url, json=data, headers=self._token_header)\n", + " return r\n", + " \n", + " def patch(self, data, url=None, endpoint=None, resource_id=None):\n", + " \"\"\"Update parts of a resource\n", + " Either provide a url or an endpoint and resource id\n", + " \"\"\"\n", + " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", + " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", + " \n", + " if url is None: \n", + " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", + " r = requests.api.patch(url, json=data, headers=self._token_header)\n", + " return r\n", + " \n", + " def delete(self, url=None, endpoint=None, resource_id=None):\n", + " \"\"\"Delete a resource\n", + " Either provide a url or an endpoint and resource id\n", + " \"\"\"\n", + " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", + " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", + " if url is None: \n", + " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", + " r = requests.api.delete(url, headers=self._token_header)\n", + " return r\n", + " \n", + " def list_endpoints(self):\n", + " return self.get()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def search(self, \n", + " endpoint='',\n", + " related_ep=None, #for cross-searches\n", + " search_field='',\n", + " criteria= '',\n", + " data=None, #must be a list\n", + " exact=False,\n", + " negate=False,\n", + " parse_json=True, \n", + " content_type='application/json'):\n", + " \n", + " if negate==False:\n", + "\n", + " if exact==True:\n", + " if data == None:\n", + " '''Returns all fields for exact match'''\n", + " if related_ep == None:\n", + " \n", + " r = requests.get(f'{self.base_url}/api/{endpoint}/?{search_field}={criteria}', \n", + " headers={**self._token_header, \n", + " 'content-type': content_type})\n", + " else: #cross-search \n", + " r = requests.get(f'{self.base_url}/api/{endpoint}/?{related_ep}__{search_field}={criteria}', \n", + " headers={**self._token_header, \n", + " 'content-type': content_type})\n", + "\n", + " else:\n", + " '''Returns requested field(s) for exact match'''\n", + " i=0\n", + " data_string=''\n", + " while i= 1: \n", + " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", + " return r.json()['results']\n", + " print('Returning response object') \n", + " return r" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import the REST API Client." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import escalateclient\n", + "from escalateclient import ESCALATEClient" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Enter your ESCALATE username and password, and the port number at which the server is running. Then run the following cell. This will create an instance of the API Client and set up a token to interact with the REST API." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "username= 'nsmina'\n", + "password= 'password11'\n", + "port='8000'\n", + "\n", + "escalate = ESCALATEClient(\n", + " f'http://localhost:{port}',\n", + " username,\n", + " password\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To see all the model endpoints (this is also a good way to verify that you are connected):" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n" + ] + }, + { + "data": { + "text/plain": [ + "{'action': 'http://localhost:8000/api/action/',\n", + " 'actiondef': 'http://localhost:8000/api/action-def/',\n", + " 'actionunit': 'http://localhost:8000/api/action-unit/',\n", + " 'actor': 'http://localhost:8000/api/actor/',\n", + " 'basebommaterial': 'http://localhost:8000/api/base-bom-material/',\n", + " 'billofmaterials': 'http://localhost:8000/api/bill-of-materials/',\n", + " 'bomcompositematerial': 'http://localhost:8000/api/bom-composite-material/',\n", + " 'bommaterial': 'http://localhost:8000/api/bom-material/',\n", + " 'calculation': 'http://localhost:8000/api/calculation/',\n", + " 'calculationdef': 'http://localhost:8000/api/calculation-def/',\n", + " 'condition': 'http://localhost:8000/api/condition/',\n", + " 'conditiondef': 'http://localhost:8000/api/condition-def/',\n", + " 'experiment': 'http://localhost:8000/api/experiment/',\n", + " 'experimentinstance': 'http://localhost:8000/api/experiment-instance/',\n", + " 'experimenttemplate': 'http://localhost:8000/api/experiment-template/',\n", + " 'experimenttype': 'http://localhost:8000/api/experiment-type/',\n", + " 'experimentworkflow': 'http://localhost:8000/api/experiment-workflow/',\n", + " 'inventory': 'http://localhost:8000/api/inventory/',\n", + " 'inventorymaterial': 'http://localhost:8000/api/inventory-material/',\n", + " 'material': 'http://localhost:8000/api/material/',\n", + " 'materialidentifier': 'http://localhost:8000/api/material-identifier/',\n", + " 'materialidentifierdef': 'http://localhost:8000/api/material-identifier-def/',\n", + " 'materialtype': 'http://localhost:8000/api/material-type/',\n", + " 'measure': 'http://localhost:8000/api/measure/',\n", + " 'measuredef': 'http://localhost:8000/api/measure-def/',\n", + " 'measuretype': 'http://localhost:8000/api/measure-type/',\n", + " 'mixture': 'http://localhost:8000/api/mixture/',\n", + " 'organization': 'http://localhost:8000/api/organization/',\n", + " 'outcome': 'http://localhost:8000/api/outcome/',\n", + " 'parameterdef': 'http://localhost:8000/api/parameter-def/',\n", + " 'person': 'http://localhost:8000/api/person/',\n", + " 'propertydef': 'http://localhost:8000/api/property-def/',\n", + " 'status': 'http://localhost:8000/api/status/',\n", + " 'systemtool': 'http://localhost:8000/api/systemtool/',\n", + " 'systemtooltype': 'http://localhost:8000/api/systemtool-type/',\n", + " 'tag': 'http://localhost:8000/api/tag/',\n", + " 'tagtype': 'http://localhost:8000/api/tag-type/',\n", + " 'typedef': 'http://localhost:8000/api/type-def/',\n", + " 'udfdef': 'http://localhost:8000/api/udf-def/',\n", + " 'unittype': 'http://localhost:8000/api/unit-type/',\n", + " 'vessel': 'http://localhost:8000/api/vessel/',\n", + " 'workflow': 'http://localhost:8000/api/workflow/',\n", + " 'workflowactionset': 'http://localhost:8000/api/workflow-action-set/',\n", + " 'workflowobject': 'http://localhost:8000/api/workflow-object/',\n", + " 'workflowstep': 'http://localhost:8000/api/workflow-step/',\n", + " 'workflowtype': 'http://localhost:8000/api/workflow-type/'}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.list_endpoints()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create an Experiment" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "'http://localhost:8000/api/experiment/4e7ec69d-b124-45a0-b5ca-8682cad3bb27/'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r = escalate.post('experiment/', {'description': 'Workflow 1 Demo', 'ref_uid': 'wf1_demo'})\n", + "\n", + "exp = r['url']\n", + "exp" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Create workflows to go with the experiment. (These correspond to parts of the procedure)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Reagent Preparation': 'http://localhost:8000/api/workflow/0841e1c1-5aa3-4962-ae27-2d8b94bab5f6/',\n", + " 'Synthesis': 'http://localhost:8000/api/workflow/279458f4-e4c8-42cc-a6f9-22b91964d48a/'}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "wfs = {name: escalate.post('workflow/', \n", + " {'experiment': exp, \n", + " 'description': name\n", + " })['url']\n", + " for name in ['Reagent Preparation', 'Synthesis']\n", + " }\n", + "\n", + "wfs" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Gather Materials\n", + "\n", + "* Search the database using `Get()` with filters to determine if the materials exist. If not, `Post()` them\n", + "\n", + "We need lead (II) iodide (PbI2), ammonium iodide (NH4I), Gamma-butyrolactone (GBL), and formic acid (HCOOH)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/material/b9ad5eeb-9ab8-458f-b7cf-e9200b7964ad/', 'description': 'Gamma-Butyrolactone'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/material/758d9a15-69d6-4439-9d58-087a46d3d890/', 'description': 'Formic Acid'}\n" + ] + } + ], + "source": [ + "mat_name_searches = ['Lead (II) Iodide', 'Ammonium Iodide', 'Gamma-Butyrolactone', 'Formic Acid']\n", + "\n", + "for i in mat_name_searches: \n", + " r = escalate.get('material', data={'fields': ['description', 'url'],\n", + " 'description': i}) \n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Searching for lead (II) iodide by exact name returned no results; let's expand our search criteria and do a cross-search by InChI key in the material identifer table to verify whether it's in the inventory." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/56665bf9-566d-41dc-b8dd-6f74174e7435/',\n", + " 'description': 'Lead Diiodide'}" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r = escalate.get('material', data={'fields': ['description', 'url'],\n", + " 'identifier__description': 'RQQRAHKHDFPBMC-UHFFFAOYSA-L'}) \n", + "r" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "So it does exist, just not under the name we expected.\n", + "\n", + "For ammonium iodide, which doesn't exist, we have to `Post()`. Note we could also associate identifiers like molecular formula and InChI with our new material, but for the scope of this tutorial it's enough to just post it with a description." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'url': 'http://localhost:8000/api/material/e5e68e17-9c15-4d36-8e54-e6f27efafe00/',\n", + " 'uuid': 'e5e68e17-9c15-4d36-8e54-e6f27efafe00',\n", + " 'edocs': [],\n", + " 'tags': [],\n", + " 'notes': [],\n", + " 'property': [],\n", + " 'add_date': '2021-09-07T17:37:30.589089',\n", + " 'mod_date': '2021-09-07T17:37:30.589110',\n", + " 'description': 'Ammonium Iodide',\n", + " 'consumable': True,\n", + " 'material_class': 'model',\n", + " 'internal_slug': 'ammonium-iodide',\n", + " 'status': None,\n", + " 'actor': None,\n", + " 'identifier': [],\n", + " 'material_type': []}" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.post(endpoint='material/', \n", + " data={'description': 'Ammonium Iodide', \n", + " 'material_class': 'model',\n", + " 'consumable': True} \n", + " )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Collect the materials within an inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Lead Diiodide': 'http://localhost:8000/api/material/56665bf9-566d-41dc-b8dd-6f74174e7435/',\n", + " 'Ammonium Iodide': 'http://localhost:8000/api/material/e5e68e17-9c15-4d36-8e54-e6f27efafe00/',\n", + " 'Gamma-Butyrolactone': 'http://localhost:8000/api/material/b9ad5eeb-9ab8-458f-b7cf-e9200b7964ad/',\n", + " 'Formic Acid': 'http://localhost:8000/api/material/758d9a15-69d6-4439-9d58-087a46d3d890/'}" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#make life easier and just use the exact names that were returned by our searches\n", + "mat_names = ['Lead Diiodide', 'Ammonium Iodide', 'Gamma-Butyrolactone', 'Formic Acid']\n", + "\n", + "materials = {name: escalate.get('material', {'description': name})['url']\n", + " for name in mat_names\n", + " }\n", + "\n", + "materials" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "'http://localhost:8000/api/inventory/4a75a47b-dc21-47ff-90b0-63c99ffbd01e/'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventory = escalate.post('inventory/', data={'description': 'Workflow 1 Demo'})['url']\n", + "\n", + "inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Lead Diiodide': 'http://localhost:8000/api/inventory-material/9e5dc29b-e3eb-4e92-a5b6-734913d6e612/',\n", + " 'Ammonium Iodide': 'http://localhost:8000/api/inventory-material/4f84deb8-123f-4fd9-85f3-2594112d9239/',\n", + " 'Gamma-Butyrolactone': 'http://localhost:8000/api/inventory-material/dc090731-4464-481a-a27c-53ea0880116f/',\n", + " 'Formic Acid': 'http://localhost:8000/api/inventory-material/3615c1aa-8f53-4661-9369-391b663d72d2/'}" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventory_materials = {description: escalate.post('inventory-material/', \n", + " {'description': description, \n", + " 'material': url,\n", + " 'inventory': inventory})['url']\n", + " for description, url in materials.items()}\n", + "\n", + "inventory_materials" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Create a bill of materials from the inventory, for the specific experiment" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Lead Diiodide': 'http://localhost:8000/api/base-bom-material/2ab45132-0cc3-4262-a884-3a2db82fd624/',\n", + " 'Ammonium Iodide': 'http://localhost:8000/api/base-bom-material/e7e0a9d4-9d5e-4798-a2e1-496a6aedb1d4/',\n", + " 'Gamma-Butyrolactone': 'http://localhost:8000/api/base-bom-material/046a9bae-d9a9-4302-a08e-f8cc2e55e0d3/',\n", + " 'Formic Acid': 'http://localhost:8000/api/base-bom-material/471d0e15-d4fe-4757-b886-151d44ba7bf9/'}" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom = escalate.post('bill-of-materials/', {'description': 'Workflow 1 Demo', \n", + " 'experiment': exp})['url']\n", + "\n", + "bom_materials = {name: escalate.post('bom-material/', \n", + " {'bom': bom, 'inventory_material': im}\n", + " )['url']\n", + " for name, im in inventory_materials.items()}\n", + "\n", + "bom_materials" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Gather Containers\n", + "\n", + "Currently containers are treated as materials. So we follow the same process of `Post()`ing first to the materials endpoint, then to the inventory, then to the BOM\n", + "\n", + "We'll need four stock containers (let's call them tubes) and one 96-well plate. We can use one overall plate material and just create 96 wells in the BOM. For the tubes, we can create a generic stock tube. We can assume all four tubes for our experiment are identical, material-wise, and just create several instances with different names in the BOM." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "tube_material = escalate.post('material/',\n", + " {'description': 'tube', 'material_class':'model'})" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "plate_material = escalate.post('material/',\n", + " {'description': '96 well plate', 'material_class':'model'})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Collect the containers within an inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/inventory-material/39514fe7-fa9a-4237-9483-b17e7a3749ac/\n" + ] + } + ], + "source": [ + "cont_names= ['tube', '96 well plate']\n", + "\n", + "for name in cont_names:\n", + "\n", + " cont_im = escalate.post('inventory-material/', \n", + " {'description': name, \n", + " 'material':escalate.get('material', data={'description': name})['url'],\n", + " 'inventory': inventory})['url']\n", + " \n", + " print(cont_im)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Create a bill of materials from the inventory, for the specific experiment" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Stock Tube 1': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/',\n", + " 'Stock Tube 2': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/',\n", + " 'Stock Container 3': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/',\n", + " 'Stock Container 4': 'http://localhost:8000/api/inventory-material/a7978e88-daa5-4c95-8b63-ec4c4725b71b/'}" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tube_names=['Stock Tube 1', 'Stock Tube 2', 'Stock Container 3', 'Stock Container 4']\n", + "\n", + "tube_inventory={}\n", + "for name in tube_names:\n", + " tube_inventory[name]= escalate.get('inventory-material', data={'description': 'tube'})['url']\n", + " \n", + "tube_inventory" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**NEED TO ADD DESCRIPTIONS WHEN I POST THESE**" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'Stock Tube 1': 'http://localhost:8000/api/base-bom-material/198b3a32-dd37-44a9-aafb-3411bc05afd6/',\n", + " 'Stock Tube 2': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/',\n", + " 'Stock Container 3': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/',\n", + " 'Stock Container 4': 'http://localhost:8000/api/base-bom-material/d5ac3fe5-356c-4411-a900-c63669bf23a4/'}" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom_tubes = {name: escalate.post('bom-material/', \n", + " {'bom': bom, \n", + " 'inventory_material': url}\n", + " )['url']\n", + " for name, url in tube_inventory.items()}\n", + "\n", + "bom_tubes" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "ename": "NameError", + "evalue": "name 'bom_wells' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 16\u001b[0m for name, url in well_inventory.items()}\n\u001b[1;32m 17\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 18\u001b[0;31m \u001b[0mbom_wells\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mNameError\u001b[0m: name 'bom_wells' is not defined" + ] + } + ], + "source": [ + "idx=[]\n", + "for i in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']:\n", + " for j in range(1,13):\n", + " idx.append(i + str(j))\n", + "\n", + "plate_url=escalate.get('inventory-material', {'description': '96 well plate'})['url']\n", + "\n", + "well_inventory={}\n", + "for well in idx:\n", + " well_inventory[well]=plate_url\n", + "\n", + "bom_wellss = {name: escalate.post('bom-material/', \n", + " {'bom': bom, \n", + " 'inventory_material': url}\n", + " )['url']\n", + " for name, url in well_inventory.items()}\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'A1': 'http://localhost:8000/api/base-bom-material/3429cdfb-a140-4a60-8825-f40142b1328f/',\n", + " 'A2': 'http://localhost:8000/api/base-bom-material/d22f6fef-8388-430a-bcff-fcf58a34cdff/',\n", + " 'A3': 'http://localhost:8000/api/base-bom-material/c0a710e3-4c09-4bde-9fa4-eef8f4505079/',\n", + " 'A4': 'http://localhost:8000/api/base-bom-material/599d7d7a-5942-4e5c-bcc5-94022e07e607/',\n", + " 'A5': 'http://localhost:8000/api/base-bom-material/f7bd3a08-4f85-4e60-b520-26fd43231518/',\n", + " 'A6': 'http://localhost:8000/api/base-bom-material/5a8589ad-5d4f-4236-a3bd-abeba58c23bd/',\n", + " 'A7': 'http://localhost:8000/api/base-bom-material/2317cebe-595b-464c-b3a0-4e1504603c48/',\n", + " 'A8': 'http://localhost:8000/api/base-bom-material/fe3e35e3-3a5f-4bd7-ae7f-f332179f94d3/',\n", + " 'A9': 'http://localhost:8000/api/base-bom-material/a509b29c-3d43-45ec-90b1-8d629700b630/',\n", + " 'A10': 'http://localhost:8000/api/base-bom-material/1dacbb4b-9843-4241-a782-2095738a83ad/',\n", + " 'A11': 'http://localhost:8000/api/base-bom-material/547ac41d-e574-449f-b106-0eeecf8bcdac/',\n", + " 'A12': 'http://localhost:8000/api/base-bom-material/05922650-de21-4259-878e-ba02346d530c/',\n", + " 'B1': 'http://localhost:8000/api/base-bom-material/2beb55f3-ab21-4d31-ac64-2ad4b4771b39/',\n", + " 'B2': 'http://localhost:8000/api/base-bom-material/3f0542fe-9455-4cea-9bac-ac7e281620c6/',\n", + " 'B3': 'http://localhost:8000/api/base-bom-material/0fbc8401-952f-412c-bc47-75af0220d2a6/',\n", + " 'B4': 'http://localhost:8000/api/base-bom-material/167a01bc-3451-4fac-afb8-654b3564b1ec/',\n", + " 'B5': 'http://localhost:8000/api/base-bom-material/edd061b0-385a-463f-9772-4ff46a3b12ea/',\n", + " 'B6': 'http://localhost:8000/api/base-bom-material/a199a25c-1fb2-405f-b277-4e0033773a1c/',\n", + " 'B7': 'http://localhost:8000/api/base-bom-material/63eef2e9-14e9-47ea-8d1c-09fd83f4c7f6/',\n", + " 'B8': 'http://localhost:8000/api/base-bom-material/a6e7d78b-815c-40c3-87b7-fa88069cc1d9/',\n", + " 'B9': 'http://localhost:8000/api/base-bom-material/b08c0ee9-5336-49c4-8a6f-4ed4ee46afe3/',\n", + " 'B10': 'http://localhost:8000/api/base-bom-material/4918f791-3c00-406f-ab87-e13eb6082d02/',\n", + " 'B11': 'http://localhost:8000/api/base-bom-material/3d77a845-b58f-48bb-b0c2-005b5aad655e/',\n", + " 'B12': 'http://localhost:8000/api/base-bom-material/49886321-4596-4f89-ada1-5c42415eb781/',\n", + " 'C1': 'http://localhost:8000/api/base-bom-material/070b4db1-e1f7-4f2a-8bdc-a836010e6e2f/',\n", + " 'C2': 'http://localhost:8000/api/base-bom-material/d92e3501-a230-4fe2-8899-2576458dbf78/',\n", + " 'C3': 'http://localhost:8000/api/base-bom-material/7aab999e-4fa4-432b-ae24-486101d414da/',\n", + " 'C4': 'http://localhost:8000/api/base-bom-material/000be119-0fc4-4f88-b800-59b06958cd66/',\n", + " 'C5': 'http://localhost:8000/api/base-bom-material/393c9476-05a3-4cdf-9e8d-8213ec479e16/',\n", + " 'C6': 'http://localhost:8000/api/base-bom-material/85638498-e236-44dd-b499-445ad47ba09c/',\n", + " 'C7': 'http://localhost:8000/api/base-bom-material/10776786-f9d0-4e3f-8af8-1d825c01172a/',\n", + " 'C8': 'http://localhost:8000/api/base-bom-material/6ec4ace6-14ed-4946-b535-3b525189ca02/',\n", + " 'C9': 'http://localhost:8000/api/base-bom-material/69ed4658-bec0-4e42-9c41-3fc3ae64a31a/',\n", + " 'C10': 'http://localhost:8000/api/base-bom-material/95213548-150a-40b9-b2f0-1ac0d19da7b8/',\n", + " 'C11': 'http://localhost:8000/api/base-bom-material/f6c00d7d-36d9-477f-a9e7-0acdf4ff5e8b/',\n", + " 'C12': 'http://localhost:8000/api/base-bom-material/79ed4929-dfc4-4ae4-b0d4-b394535c7eff/',\n", + " 'D1': 'http://localhost:8000/api/base-bom-material/5af0eb22-ccdd-4a10-94c7-ca32d25b3fa8/',\n", + " 'D2': 'http://localhost:8000/api/base-bom-material/d5c442cf-249d-4562-8765-352c25b08b6d/',\n", + " 'D3': 'http://localhost:8000/api/base-bom-material/0e4a7df5-af76-4433-94da-15a5e42b8c55/',\n", + " 'D4': 'http://localhost:8000/api/base-bom-material/ec681f7d-cfca-4513-b5fe-1e7b7d649a91/',\n", + " 'D5': 'http://localhost:8000/api/base-bom-material/9c7a2796-ac07-42d2-a911-db64593da3d9/',\n", + " 'D6': 'http://localhost:8000/api/base-bom-material/c183d1fc-fe4b-4637-884a-63ff6b8c0132/',\n", + " 'D7': 'http://localhost:8000/api/base-bom-material/14e69706-4f79-4995-a13f-91d5ef3ade61/',\n", + " 'D8': 'http://localhost:8000/api/base-bom-material/9ea3cb10-1ee9-49a9-b5b6-155bd9eacbf2/',\n", + " 'D9': 'http://localhost:8000/api/base-bom-material/7f6e55dc-b55d-402e-baf8-db71d8c8fdf6/',\n", + " 'D10': 'http://localhost:8000/api/base-bom-material/506539be-bf32-4bd8-80c8-df56e82312c5/',\n", + " 'D11': 'http://localhost:8000/api/base-bom-material/33766468-2792-4481-bb29-457fe43cafe7/',\n", + " 'D12': 'http://localhost:8000/api/base-bom-material/d33a69b1-70a9-425c-b7d3-170aa7e3ba29/',\n", + " 'E1': 'http://localhost:8000/api/base-bom-material/b53c6292-c4ae-4b59-9e96-c7b7d62eb2eb/',\n", + " 'E2': 'http://localhost:8000/api/base-bom-material/3256ff6d-8df0-4015-a2ed-45682e205d3f/',\n", + " 'E3': 'http://localhost:8000/api/base-bom-material/70cac8bf-c2a1-4be3-bf3d-c7deb136dbb3/',\n", + " 'E4': 'http://localhost:8000/api/base-bom-material/5ecb727e-3943-458a-848c-ffbb34e0d0f7/',\n", + " 'E5': 'http://localhost:8000/api/base-bom-material/d522b3c4-523e-44e5-b0ad-43e13b46af6e/',\n", + " 'E6': 'http://localhost:8000/api/base-bom-material/70c527fc-63cb-47e1-9586-93eb8cfbfbd8/',\n", + " 'E7': 'http://localhost:8000/api/base-bom-material/3f0893bb-9fd0-4470-ba61-acaaf7f7af51/',\n", + " 'E8': 'http://localhost:8000/api/base-bom-material/ffd75695-d009-4b0a-b599-602b50353c7b/',\n", + " 'E9': 'http://localhost:8000/api/base-bom-material/f0eb8c17-fc58-429e-88dc-7564a49e70ea/',\n", + " 'E10': 'http://localhost:8000/api/base-bom-material/22113f50-3e30-4887-9c63-909cd33aa0b6/',\n", + " 'E11': 'http://localhost:8000/api/base-bom-material/435fa952-ad58-4201-a076-060aceac1ecb/',\n", + " 'E12': 'http://localhost:8000/api/base-bom-material/ab0e66a5-205d-49f4-8407-51d0201c607c/',\n", + " 'F1': 'http://localhost:8000/api/base-bom-material/89262578-2216-4d70-a2f8-c51e89f3ad33/',\n", + " 'F2': 'http://localhost:8000/api/base-bom-material/835d7505-c502-4e16-a1c8-21f20a9e5c05/',\n", + " 'F3': 'http://localhost:8000/api/base-bom-material/ec7339ad-21bb-47f9-8951-a1b1c71407ee/',\n", + " 'F4': 'http://localhost:8000/api/base-bom-material/7f7a5b0b-de47-4a27-97e8-d9e9be4d0275/',\n", + " 'F5': 'http://localhost:8000/api/base-bom-material/339dcf81-aa62-43a4-8e92-45419ef6ab3c/',\n", + " 'F6': 'http://localhost:8000/api/base-bom-material/effe5111-b1ba-4777-ab83-aaa0d53c6219/',\n", + " 'F7': 'http://localhost:8000/api/base-bom-material/4d90e72b-9b22-4841-94eb-cd5b89ca001d/',\n", + " 'F8': 'http://localhost:8000/api/base-bom-material/41676005-1024-4ee6-88de-b96defb81208/',\n", + " 'F9': 'http://localhost:8000/api/base-bom-material/524a460e-5932-4c64-8797-2ff7cea85c30/',\n", + " 'F10': 'http://localhost:8000/api/base-bom-material/52dca674-b010-4419-86fd-558cc71e34f7/',\n", + " 'F11': 'http://localhost:8000/api/base-bom-material/9f19985c-8ab2-4815-adfe-7c01a874df68/',\n", + " 'F12': 'http://localhost:8000/api/base-bom-material/3d75ee6b-b299-4653-8a25-894c1ea92441/',\n", + " 'G1': 'http://localhost:8000/api/base-bom-material/3313b807-5ebb-4cca-a384-4e6e353c952b/',\n", + " 'G2': 'http://localhost:8000/api/base-bom-material/033f99e9-e986-4862-b709-400a37d92759/',\n", + " 'G3': 'http://localhost:8000/api/base-bom-material/1b7851e3-6544-4691-a47a-a222899ad618/',\n", + " 'G4': 'http://localhost:8000/api/base-bom-material/2ad0acc7-bb7a-475d-a3cd-b127d4122425/',\n", + " 'G5': 'http://localhost:8000/api/base-bom-material/c5c29c81-8892-48d2-bebf-148839ec2fa0/',\n", + " 'G6': 'http://localhost:8000/api/base-bom-material/8b0e2fa3-5952-4b85-b7e6-7f473d15bc2a/',\n", + " 'G7': 'http://localhost:8000/api/base-bom-material/0e5cc62e-b63d-40ef-bd73-e74a889ce4ef/',\n", + " 'G8': 'http://localhost:8000/api/base-bom-material/b370e6a3-c921-4f98-a3a4-f525f945d3c3/',\n", + " 'G9': 'http://localhost:8000/api/base-bom-material/279b8aea-4a8d-40aa-bf53-579d5b9d37ec/',\n", + " 'G10': 'http://localhost:8000/api/base-bom-material/2eb3a4a9-8ccc-423f-8959-99190673775a/',\n", + " 'G11': 'http://localhost:8000/api/base-bom-material/09afccc6-da67-411a-be1d-b299feba4157/',\n", + " 'G12': 'http://localhost:8000/api/base-bom-material/b9c929ae-fdc8-4af8-9ced-215ea676d765/',\n", + " 'H1': 'http://localhost:8000/api/base-bom-material/5f60152e-9566-4322-8119-3123927fba90/',\n", + " 'H2': 'http://localhost:8000/api/base-bom-material/07114655-147e-431d-a1a2-3f93085eb8b7/',\n", + " 'H3': 'http://localhost:8000/api/base-bom-material/52b04956-91ed-47f6-b531-f0dfe17b378c/',\n", + " 'H4': 'http://localhost:8000/api/base-bom-material/8bd4bb8d-664d-49ee-b832-c090b4b52930/',\n", + " 'H5': 'http://localhost:8000/api/base-bom-material/2f39fab4-2b8c-478e-ae74-02ce0c478637/',\n", + " 'H6': 'http://localhost:8000/api/base-bom-material/779770c8-f74f-4c84-9227-a9b2f7369ec9/',\n", + " 'H7': 'http://localhost:8000/api/base-bom-material/c729d49f-e2de-47f7-9d61-28c3148fa317/',\n", + " 'H8': 'http://localhost:8000/api/base-bom-material/9dd291cb-a4bf-45d1-876f-96f1ab2f628d/',\n", + " 'H9': 'http://localhost:8000/api/base-bom-material/d11c1e98-c90e-4daa-86b7-0a23840ddd04/',\n", + " 'H10': 'http://localhost:8000/api/base-bom-material/0b0d2b93-ad8a-4528-9b1c-7a7851fe5c54/',\n", + " 'H11': 'http://localhost:8000/api/base-bom-material/71356862-75e8-4d3f-8585-bbbe9d2ac9c4/',\n", + " 'H12': 'http://localhost:8000/api/base-bom-material/86219b01-bc1e-4479-a68d-a573edf2c544/'}" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom_wellss" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set Up Actions\n", + "\n", + "* Determine all actions needed for the experiment procedure. Use `Get()` to search the database for definitions of these actions (action-def). `Post()` new ones as needed" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/action-def/0ccac627-5e68-4010-84b4-d1db19adabf9/', 'description': 'dispense_solid'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/action-def/030d508f-49a4-4eab-a83b-fb1635f3e793/', 'description': 'heat'}\n", + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n", + "GET: OK\n", + "{'count': 0, 'next': None, 'previous': None, 'results': []}\n" + ] + } + ], + "source": [ + "action_def_names = ['dispense_liquid', 'dispense_solid', 'heat', 'cool', 'transfer', 'stir']\n", + "\n", + "for i in action_def_names: \n", + " r = escalate.get('action-def', data={'fields': ['description', 'url'],\n", + " 'description': i}) \n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Looks like we have definitions for heating and for dispensing solid ... there's heat-stir but not just stir, and the other ones are completely missing. So we `Post()`." + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "missing = ['dispense_liquid', 'cool', 'transfer', 'stir']\n", + "\n", + "for i in missing:\n", + " r = escalate.post('action-def/', {'description': i, \n", + " 'status': escalate.get('status', {'description':'test'})['url']}\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "{'dispense_liquid': 'http://localhost:8000/api/action-def/60677fdb-6cd2-4239-9915-400e35ff184f/',\n", + " 'dispense_solid': 'http://localhost:8000/api/action-def/0ccac627-5e68-4010-84b4-d1db19adabf9/',\n", + " 'heat': 'http://localhost:8000/api/action-def/030d508f-49a4-4eab-a83b-fb1635f3e793/',\n", + " 'cool': 'http://localhost:8000/api/action-def/7abb21cd-1fff-495c-ace9-e5d81ecf99af/',\n", + " 'transfer': 'http://localhost:8000/api/action-def/e270c81e-b94d-49ae-b68f-2e8a86c31ee8/',\n", + " 'stir': 'http://localhost:8000/api/action-def/bf3bcb09-0a6e-4006-8688-73586036ff85/'}" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "actions = {\n", + " name: escalate.get('action-def', data={'description': name})['url'] \n", + " for name in action_def_names}\n", + "\n", + "actions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Determine the parameters (e.g. temperature, stir speed) that you'll need to specify for each action. Search if these exist, and post new ones as needed\n", + "\n", + "We want temperature for heating/cooling, speed/duration for stirring, and mass and volume for the dispense and transfer actions. Let's use the case-insensitive containtment filter `__icontains` for our search because we don't know exactly what the parameter definitions are called." + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/parameter-def/e4db0901-aabd-4abe-87a3-64a38d9a8217/', 'description': 'temperature'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/parameter-def/1e51d3cd-7cf6-4765-bfc1-e7d54540696f/', 'description': 'speed'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/parameter-def/2cc0ed35-abaf-4ea5-b4c2-c848b0359129/', 'description': 'duration'}\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "{'url': 'http://localhost:8000/api/parameter-def/2d9eb6b7-9e17-4e5f-855f-656687c80327/', 'description': 'mass'}\n", + "GET: OK\n", + "Found 6 resources, returning list of dicts)\n", + "[{'url': 'http://localhost:8000/api/parameter-def/79df4ee7-776f-4544-9636-6c37df64cc96/', 'description': 'volume'}, {'url': 'http://localhost:8000/api/parameter-def/73dfd457-1b05-490c-9d6f-3d6cbcce3ad3/', 'description': 'Sample Solvent Volume'}, {'url': 'http://localhost:8000/api/parameter-def/b701f73d-74b3-48ad-be8e-57bd3ed7c45c/', 'description': 'Sample Stock A Volume'}, {'url': 'http://localhost:8000/api/parameter-def/070ad2bf-dd15-49ee-bc33-0ee764ed5106/', 'description': 'Sample Stock B Volume'}, {'url': 'http://localhost:8000/api/parameter-def/72eca483-d496-46bd-9a14-cc32c68a12e1/', 'description': 'Sample Acid Volume 1'}, {'url': 'http://localhost:8000/api/parameter-def/fafa6957-b9c6-4f78-b09e-76eb5d224156/', 'description': 'Sample Acid Volume 2'}]\n" + ] + } + ], + "source": [ + "param_names = ['temperature', 'speed', 'duration', 'mass', 'volume']\n", + "\n", + "for i in param_names: \n", + " r = escalate.get('parameter-def', data={'fields': ['description', 'url'],\n", + " 'description__icontains': i}) \n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Looks like there are several volume-related parameters; the one we want is just \"volume\".\n", + "\n", + "* Associate the action definitions and parameter definitions using `Patch()`" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n", + "GET: OK\n", + "Found one resource, returning dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "escalate.patch(url=actions['heat'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'temperature'})['url'], \n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['cool'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'temperature'})['url'],\n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['stir'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'speed'})['url'],\n", + " escalate.get('parameter-def', \n", + " {'description': 'duration'})['url'] \n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['dispense_solid'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'mass'})['url'],\n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['dispense_liquid'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'volume'})['url'],\n", + " ]\n", + " })\n", + "\n", + "escalate.patch(url=actions['transfer'], \n", + " data={'parameter_def': [escalate.get('parameter-def', \n", + " {'description': 'mass'})['url'],\n", + " escalate.get('parameter-def', \n", + " {'description': 'volume'})['url'] \n", + " ]\n", + " })" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**For transfer we can just have a volume param!**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Create action instances for each action definition\n", + "\n", + "(The instance is linked to an action definition (e.g. dispense solid) and to the desired workflow)" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/cb509d82-18e9-453a-ac75-9951fd6f0225/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/d68f6c57-61dd-4ea1-8075-a068cc347883/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/27280834-dc27-4e8d-9047-d4635ed4cd26/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/8232790d-3791-4a11-952f-6b2bdd5f230b/\n" + ] + } + ], + "source": [ + "prep_actions = ['dispense_solid', 'dispense_liquid', 'cool', 'stir']\n", + "\n", + "action_inst1={}\n", + "\n", + "for action in prep_actions:\n", + " r = escalate.post('action/', \n", + " {'workflow': wfs['Reagent Preparation'], \n", + " 'action_def': actions[action],\n", + " }\n", + " )['url']\n", + " \n", + " action_inst1[action]=r\n", + " \n", + " print(r)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/634146e1-9072-4749-b8d3-d95491a0b9d5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/9284c4fb-3e4d-4d94-9a77-ed04dc9b3ad5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/action/e5393a85-9b90-4eb7-8fce-2a73783fbc79/\n" + ] + } + ], + "source": [ + "synthesis_actions= ['heat', 'transfer', 'stir']\n", + "\n", + "action_inst2={}\n", + "\n", + "for action in synthesis_actions:\n", + " r = escalate.post('action/', \n", + " {'workflow': wfs['Synthesis'], \n", + " 'action_def': actions[action],\n", + " }\n", + " )['url']\n", + " \n", + " action_inst2[action]=r\n", + " \n", + " print(r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Implement steps of the procedure\n", + "\n", + "* Generate action units for each step " + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "#reagent prep steps of workflow\n", + "#step 1: add 25 mL GBL to stock tube 1\n", + "\n", + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_liquid'],\n", + " 'source_material': bom_materials['Gamma-Butyrolactone'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Tube 1'] #container, from BOM\n", + " })" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For this action, we are dispensing liquid, so we want to know how much. That means we need to specify the (actual) value of the volume parameter. To do so, we use `Patch()`. Once this is done, if we navigate to the url of the specific action unit instance AND to the url of the parameter instance, we should see the (actual) parameter value for volume listed as 25 mL." + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [], + "source": [ + "param_url= r['parameter'][0]['url']\n", + "\n", + "param_url\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 25, 'unit': 'mL', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Stock Tube 1': 'http://localhost:8000/api/base-bom-material/198b3a32-dd37-44a9-aafb-3411bc05afd6/',\n", + " 'Stock Tube 2': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/',\n", + " 'Stock Container 3': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/',\n", + " 'Stock Container 4': 'http://localhost:8000/api/base-bom-material/d5ac3fe5-356c-4411-a900-c63669bf23a4/'}" + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom_tubes" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 68, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#step 2: add 10 mL formic acid to Stock Container 4\n", + "\n", + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_liquid'],\n", + " 'source_material': bom_materials['Formic Acid'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Container 4'] #container, from BOM\n", + " })\n", + "\n", + "param_url= r['parameter'][0]['url']\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 10, 'unit': 'mL', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "r" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "When we have a mixture of different materials in a container we will need several dispensing steps, one for each material. We can handle all the solids in a loop, since the action unit is of the same type." + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c309b221-c8e5-49ac-a09e-4fe02c8a4312/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/666fe60a-e62f-44c3-aa57-ca104a3ebc09/\n" + ] + } + ], + "source": [ + "#step 3 = add 0.5 g PbI2, 0.5 g NH4I, 10 ml GBL to Stock Tube 2\n", + "\n", + "solids={'Lead Diiodide': 0.5, 'Ammonium Iodide': 0.5}\n", + "for key, val in solids.items():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_solid'],\n", + " 'source_material': bom_materials[key], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Tube 2'] #container, from BOM\n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + " \n", + " print(param_url)\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': val, 'unit': 'g', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_liquid'],\n", + " 'source_material': bom_materials['Gamma-Butyrolactone'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Tube 2'] #container, from BOM\n", + " })\n", + "\n", + "param_url= r['parameter'][0]['url']\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 10, 'unit': 'mL', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#step 4 = add 1 g NH4I, 10 mL GBL to Stock Tube 3\n", + "\n", + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_solid'],\n", + " 'source_material': bom_materials['Ammonium Iodide'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Container 3'] #container, from BOM\n", + " })\n", + "\n", + "param_url= r['parameter'][0]['url']\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 1, 'unit': 'g', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r= escalate.post('action-unit/', \n", + " {'action': action_inst1['dispense_liquid'],\n", + " 'source_material': bom_materials['Gamma-Butyrolactone'], #material, from BOM\n", + " 'destination_material': bom_tubes['Stock Container 3'] #container, from BOM\n", + " })\n", + "\n", + "param_url= r['parameter'][0]['url']\n", + "\n", + "patch_data = {'parameter_val_actual': {'value': 10, 'unit': 'mL', 'type': 'num'}}\n", + "\n", + "r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Stock Tube 1': 'http://localhost:8000/api/base-bom-material/198b3a32-dd37-44a9-aafb-3411bc05afd6/',\n", + " 'Stock Tube 2': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/',\n", + " 'Stock Container 3': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/',\n", + " 'Stock Container 4': 'http://localhost:8000/api/base-bom-material/d5ac3fe5-356c-4411-a900-c63669bf23a4/'}" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bom_tubes" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "{'url': 'http://localhost:8000/api/action-unit/766a6d8f-26ce-4d6f-9aea-b238cc078519/', 'uuid': '766a6d8f-26ce-4d6f-9aea-b238cc078519', 'edocs': [], 'tags': [], 'notes': [], 'parameter': [{'url': 'http://localhost:8000/api/parameter/cad773b9-4b6c-4acf-a2d0-61c9b6d39cb3/', 'uuid': 'cad773b9-4b6c-4acf-a2d0-61c9b6d39cb3', 'add_date': '2021-09-07T18:52:41.933830', 'mod_date': '2021-09-07T18:52:41.933849', 'parameter_val_nominal': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/2cc0ed35-abaf-4ea5-b4c2-c848b0359129/', 'action_unit': 'http://localhost:8000/api/action-unit/766a6d8f-26ce-4d6f-9aea-b238cc078519/'}, {'url': 'http://localhost:8000/api/parameter/a9cdbdda-5a5e-4360-b96f-6128272cb6eb/', 'uuid': 'a9cdbdda-5a5e-4360-b96f-6128272cb6eb', 'add_date': '2021-09-07T18:52:41.938966', 'mod_date': '2021-09-07T18:52:41.938985', 'parameter_val_nominal': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/1e51d3cd-7cf6-4765-bfc1-e7d54540696f/', 'action_unit': 'http://localhost:8000/api/action-unit/766a6d8f-26ce-4d6f-9aea-b238cc078519/'}], 'add_date': '2021-09-07T18:52:41.893009', 'mod_date': '2021-09-07T18:52:41.893030', 'description': None, 'internal_slug': 'workflow-1-demo-workflow-1-demo-workflow-1-demo-tube-6-reagent-preparation-stir-2', 'status': None, 'actor': None, 'action': 'http://localhost:8000/api/action/8232790d-3791-4a11-952f-6b2bdd5f230b/', 'source_material': 'http://localhost:8000/api/base-bom-material/82aa8f24-bd54-450e-bcdb-ea66d42017fc/', 'destination_material': None}\n", + "\n", + "POST: OK, returning new resource dict\n", + "{'url': 'http://localhost:8000/api/action-unit/8131ecf6-0b00-4bce-bac6-915d052517ad/', 'uuid': '8131ecf6-0b00-4bce-bac6-915d052517ad', 'edocs': [], 'tags': [], 'notes': [], 'parameter': [{'url': 'http://localhost:8000/api/parameter/dd389646-07cb-4a45-977f-3e4b2c23c04a/', 'uuid': 'dd389646-07cb-4a45-977f-3e4b2c23c04a', 'add_date': '2021-09-07T18:52:42.044834', 'mod_date': '2021-09-07T18:52:42.044853', 'parameter_val_nominal': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'mins', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/2cc0ed35-abaf-4ea5-b4c2-c848b0359129/', 'action_unit': 'http://localhost:8000/api/action-unit/8131ecf6-0b00-4bce-bac6-915d052517ad/'}, {'url': 'http://localhost:8000/api/parameter/13fa6063-1946-43c5-8288-350a892ebf86/', 'uuid': '13fa6063-1946-43c5-8288-350a892ebf86', 'add_date': '2021-09-07T18:52:42.049118', 'mod_date': '2021-09-07T18:52:42.049137', 'parameter_val_nominal': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'parameter_val_actual': {'value': 0.0, 'unit': 'rpm', 'type': 'num'}, 'status': 'http://localhost:8000/api/status/3e3396c5-5bfe-4ecd-a72a-5e65f90dd04b/', 'actor': None, 'parameter_def': 'http://localhost:8000/api/parameter-def/1e51d3cd-7cf6-4765-bfc1-e7d54540696f/', 'action_unit': 'http://localhost:8000/api/action-unit/8131ecf6-0b00-4bce-bac6-915d052517ad/'}], 'add_date': '2021-09-07T18:52:42.014590', 'mod_date': '2021-09-07T18:52:42.014608', 'description': None, 'internal_slug': 'workflow-1-demo-workflow-1-demo-workflow-1-demo-tube-7-reagent-preparation-stir', 'status': None, 'actor': None, 'action': 'http://localhost:8000/api/action/8232790d-3791-4a11-952f-6b2bdd5f230b/', 'source_material': 'http://localhost:8000/api/base-bom-material/3be9b368-f21e-49ff-b6a5-2ccada38a1ea/', 'destination_material': None}\n" + ] + } + ], + "source": [ + "#stir reagents in containers 2 and 3 until contents dissolve\n", + "conts=['Stock Tube 2', 'Stock Container 3']\n", + "\n", + "for cont in conts:\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst1['stir'],\n", + " 'source_material': bom_tubes[cont], \n", + " 'destination_material': None \n", + " })\n", + " print(r)" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "#cool containers 2 and 3 to room temp\n", + "\n", + "for cont in conts:\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst1['cool'],\n", + " 'source_material': bom_tubes[cont], \n", + " 'destination_material': None \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': 25, 'unit': 'deqC', 'type': 'num'}}\n", + "\n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5bcf6bd9-d53e-44da-b890-5f67636526ae/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0c86fd3c-15df-44d1-b38c-57cef8622513/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7483c06d-94d0-4a86-b157-ee94b97e8d7f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/fae8ba52-7ddb-416d-a71f-9acc60dc9705/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5fb42a6b-7ef6-4d36-885d-2890485d6bac/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/55bec7ba-c22d-4538-897a-73f9520c8fb7/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f94373d2-5b60-43c0-9b17-2b9c4237a5b5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/29ec14eb-0b00-4df0-9d36-212545cea1e3/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f7001e70-2159-4e40-a907-6af26589bb84/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/bbc1f272-27dd-45cb-b844-61c13c9f84d1/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f6e1d960-821f-404d-a7c0-9e5370a09cb7/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2c61b76d-200a-41eb-a6be-529304cba391/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b74a849d-0c32-4abb-9473-00453db12167/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/31034025-6122-4547-8ef5-9ab12843b735/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0989b46d-4ea7-46ea-aac0-428e7ac09584/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/cd9a26ee-da64-4ec1-aeb1-c00a9048a984/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/18a41166-979f-4a9c-8f51-b1b90db2d7eb/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a67f6c71-bb32-420a-8440-385df474bd1e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/595a3ab6-83e8-4963-84e4-074cfc9d495f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d38f3e2f-c32f-4b55-a83e-4a759744c78c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ac01cf75-abac-414d-abb2-3fb349b784c3/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7a498b1b-5101-4342-8b7e-524953b98e3b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3682a61f-a0b3-410f-8cc9-cb7260cf9e35/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/dd2768c0-7543-41fb-bfaa-0d167573e0cc/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/21be0aaf-8046-4beb-86ef-d5038a8472af/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4833c1f4-4273-4ee1-beb4-476de9d61346/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6d6f2c4a-46e9-4488-99f1-6fe4f36a3c6f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e4d518ea-6dca-4a67-9438-488b238d2137/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/42b5136a-217f-4e6c-959d-8ac2c1b793b4/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4ea3edb8-0738-4c24-b109-fef16ee0c520/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a960c11a-d437-4591-9960-d8c17fe6c9da/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7d38f384-392d-4f3d-9e12-7407229157e8/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/726fbc1e-890e-4dca-bedc-6083e6925733/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/574b292a-bb23-4cc6-a7e7-02146c1db440/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0b084a6b-70de-4c2a-9b86-b6e5c8b73030/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/1d103ac8-6206-40de-9ad5-2a42420647ff/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5a906ab8-3bc2-4280-91b1-2f163e0e0456/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4042b5b3-928f-4a3a-9803-65c3194bcfad/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d37d1402-a98a-4fc0-a58b-1aa2aad525b4/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7a4838ef-4ca1-498f-9218-cde767538f2c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ed47b022-ac18-45c1-8275-2be38433fc7a/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/849ab35a-fdda-47d3-91ef-52f116a09869/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9e209e11-1cbd-4bad-84d6-7d13703073ce/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/18ca654c-2dee-46de-a749-d65ca6bc503b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/19409529-507c-4e7d-94e6-f72cd77d1199/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3c720bfb-6461-4bab-befc-3ac90d7ec647/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9cf6fe44-2ea0-430a-b746-48f404abf2ba/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8b2191a9-9b47-4b12-af1e-2b93ca8c2bb9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/38eccccc-ed36-413e-881c-d3e05d981616/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6650a648-aee1-4a63-a40d-8b60206757ee/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/1a5fe95e-6a13-4eef-bf59-57ec11643e24/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d5fdf9d7-cc1b-4d6c-bd61-823dbaa1c88f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4984161b-2637-4f54-ab1e-d72bd4dcd3fc/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/1ea6dbfc-5893-49b3-9a0f-26187cd410a5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7eeec597-cf70-4ef7-8378-532fe3e9123b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ee651453-04d4-4a42-87c8-9b4d6f9c845d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/19bbb741-ccc2-4d7c-944b-71ccfcee76a2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ace521f4-88a1-4f2d-944d-14146d255b2b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/926d3166-4c06-4dad-b3bc-77bdbc45c38f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/00d67df9-00af-4f84-b62a-fe28c839facf/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d8c90670-0034-4512-ae9a-e2f39c100c90/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/85a86c7b-3003-4fe7-ba5b-c339fabe4924/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/dda50cf5-e30d-4471-bb65-0bb76b7ac81f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b14eb1bf-4d78-4c38-8e2b-e8406ed6efcd/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/107f3343-797e-49aa-a99d-b97f5f3c24dc/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8315aa14-9310-4869-8d70-416744224d5d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/09ca8dec-78fa-4801-9edb-a9a796e2779f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ddaf7988-047e-42b4-ba27-c3e4dd403fbd/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/55d519b9-4e40-4539-89e3-b75f4556c27f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d8d2c93e-afa0-4588-a532-bcb19593bbec/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4bae796e-a78e-4ef9-b666-eb90b44a2523/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/38ce9322-bd63-44bc-9977-1fe6be937d6c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/07458353-e295-4e42-8f9f-7aea18738b51/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3481c662-3200-48c0-99ef-91a5e0c24a8a/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d4293c8e-da2a-4799-9ea1-cb2b28e8a66b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/81db6c1d-c5b9-4e86-a26b-719f0f38e06b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e8c5b7c5-a539-4cbc-b35e-5ed7178eed58/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6309bb46-bc1f-4d82-9249-6a9f21ea89ae/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/743dec43-7495-4de8-a006-a9f1efbbf913/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b345238e-9180-46ab-bd80-fce942809742/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4b99527c-86af-4022-a80f-200ecb00a6ba/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/96baa4ed-0017-4883-9491-af3ec9adabef/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7837dc98-a003-43e1-895f-7b0c71349dd2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/279b5688-db9a-4b4b-aacf-936bbf08a333/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f1bbadc8-7ab6-4291-9d4e-2b59ccb3a6ee/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/83b5762d-0230-428f-a505-c6f45370832e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9ffbf29e-7797-4078-aed7-0edcd7705847/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6c00bee0-066f-4a76-afcc-0242514bbfa6/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6037e3ee-a57b-424b-9420-2ac20f25e1d6/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/87a34653-9bd7-4e19-848c-40828dd242b9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/cba62da5-c6bb-43b6-bce7-44373cf073c1/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0a377b75-8642-4fbc-8536-6e2a5f972dec/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6b7b8926-4f11-4014-a869-7814b8b16e0d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c1c63090-5d58-4980-b211-f3f1522df44b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3de26033-d850-4425-a3b9-561403ad1c6b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e4f3f7a1-2edc-4e85-aefa-63834b5203e1/\n" + ] + } + ], + "source": [ + "##synthesis portion of workflow\n", + "#heat well plate to 105 (actual temp is 95... how to distinguish this?)\n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['heat'],\n", + " 'source_material': bom_wellss[well], \n", + " 'destination_material': None \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + " \n", + " #print(param_url)\n", + "\n", + " patch_data = {'parameter_val_nominal': {'value': 105, 'unit': 'deqC', 'type': 'num'}}\n", + "\n", + " r = escalate.patch(data=patch_data, url=param_url)\n", + " \n", + " patch_data = {'parameter_val_actual': {'value': 95, 'unit': 'deqC', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b079abb9-2241-4c94-b479-798d7ec5b19e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7672708b-cdfb-4097-8df5-ecf3ca688b5f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b630a785-7964-4403-949f-91315327288f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e3cb9367-0760-4d40-ac0f-512334375818/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4d1a57ca-ff92-4a4e-a437-543801b1f9a5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ed1818dd-f44c-43c4-a55a-39ea0081e6a7/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/80c6ecdd-c9d7-4916-b674-e16e8587ee1e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d7a8e0a4-3626-4515-a82b-9c2dd6884242/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d7893705-7507-4f6a-b7b5-552353ac84c8/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7b7d6b6a-f598-47d5-b8a8-c842e021bce2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/44c57d46-d028-479d-96fc-0a0b95ee58b3/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/17511bd3-15d8-4e9e-a16b-dee37f1e73ab/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3302cf68-fd57-491f-a1f9-f9905bac07a5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/01fd71ab-ac6a-4893-b1a5-a67797a42fb7/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d8c0e372-8591-4368-9044-98c9d0b24fad/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3389df42-8ad9-4fe4-b71b-2c580d6c29f8/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7dcf638f-515f-4d06-9d59-94224f3dcaf2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a03e4c39-2ac3-47f4-8baa-5241ba541d2d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b58acf91-566a-4d43-8858-05662cd09451/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/212f18e0-0d28-43b4-84b3-7af7c8e20a36/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8ea80686-822c-4c9c-9c92-7464b923f0e2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9a162061-e660-4c6f-9905-92480833e243/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a8a8ac12-bcb8-4886-97e2-f4de34a15309/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2879899d-31b4-41d2-b13f-64d390b5ea9b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/18bb126b-abf5-4837-908e-fa03e1c7bfa5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ff7ee525-effe-492e-af99-1f39e840f58e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ff0fb650-7ee0-4d45-b43b-35c1fc92dade/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/63bc22be-5f24-4065-bde6-9818539b567a/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3646b095-73bd-4e68-8e05-b5ef11a2c07c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8541dd4c-d0a2-446f-bb5b-2d91989779d4/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/961533ff-9801-4409-8a5a-34713879acd3/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4cfb9919-fe26-4bdd-b5c7-a1ab060508cc/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/308a3364-b18e-4709-83da-bff31cc9ffdd/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0673964f-491d-401e-b622-f25a96854c2d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e2d3f153-6c43-47fc-8f79-7c41259b24a9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/11c73d9a-a9a8-4af7-98f0-1ef64ccf4797/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ea3fc8d5-f31c-45b8-9fdc-d482ca065b3c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/89f8cd55-5490-4bee-81e1-b2da27932c13/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2df77800-083f-4374-a3ed-b2e4945d81a5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e4dfb34c-9416-406d-ad0e-59854f242b1c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/da4266bf-3c20-4169-8a06-8fcb3ec9eb7e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/238baab8-1fa0-45b3-8bef-23baa3ab1f10/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/00774978-727e-4389-a8fc-f2e240234492/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0b0499b1-d63f-4850-b816-be8ffd38bf86/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f4d6e515-c905-49ca-bcf8-f3794819db06/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/afb97886-770b-4e2e-811d-00eb888132fa/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c00a8dfc-286b-4873-87f3-f8dc3c8ea780/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/82b887f4-9ac8-469a-9738-8040b8a22d50/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9eb2f1f8-1628-453e-b0ff-bbb58712fdda/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/70449d49-45a5-448b-86a8-022ae0455f7e/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4ead632a-5aee-4fc0-9032-92b1892bc338/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2806ada2-70d7-4d9c-9f24-80308c675853/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e7a6c2a3-680c-4ef4-ab00-2e3e1782c4ee/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/80777d99-b201-4756-b83d-34e86643e6df/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/15a27a88-92b6-4b47-b6b8-7bd2cb948111/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/bb68d711-6a54-49ea-901d-e8fe6b9b8457/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/628a9af6-7f71-4257-a089-4f167c2979ed/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/0bd921df-9d2d-468e-98ef-8456ec4f59b0/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/4792a10c-4551-401d-a296-a9ee315eb4e2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/aa336387-3955-42f4-8123-94fd05af33b2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2cbb7a30-dc4a-42dd-b66a-4b68863ad81d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c721c586-161d-4195-ad0a-dbbede695f6a/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3d3a1b3f-ee9d-4934-b406-841f9e901b25/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/29d5ed53-517b-4fc7-ac2f-986e4a836d18/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/c68896b6-1d14-4122-a6a4-f2664efda96f/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/feed4be4-07cf-4633-a0eb-2f5cc4a1f98c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/30260164-a853-46d7-97f9-e7959f21deac/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/50dab7ed-6927-496e-b8ca-4514d4b6290b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/b7edb177-78de-4224-9d98-85515eb7a242/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8f27002d-2877-4315-99e6-ddf692653a31/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/276c1c82-c395-4a21-a8b5-8f4a1f3a8cc0/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5450869f-bf2f-4e44-94a4-6734977a5ba4/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/8b483c21-2483-4c0e-8ae8-c683c11b9039/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/a2f43292-94ae-4aac-8fa0-23c1b217d3a0/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/78c72588-e943-42de-9654-9ab0a82a70cd/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f45307ab-bd9e-4e7f-bfd3-54e054b91158/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/63221d19-7be4-4a1c-893e-756a1eb53fd6/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/91797b9d-9943-44d3-a344-e8a4f5fd98d5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/f26e0f9e-279e-4651-b8fc-fbfb1bc56e26/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/d2764d54-7598-4bcb-a8e7-ec6acfa66937/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/2c182e17-a275-4463-ad25-0b4dedcad014/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/ad605fab-b93f-42a1-994c-a20af104d3da/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/01d3d5f8-61dc-4845-ad16-9b50fe144735/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/55a0c8cc-b6a8-4520-aedd-b69c847f44b9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/21baba30-4cd4-4c66-a30c-3b177f4cb0f1/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/6d0717e2-6697-4fdd-b802-f2f20d33069c/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/e8129a5d-b96b-4a6d-ba70-54b24e37ea6b/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/3dc1ee9b-bc8a-49c0-80d4-ec66e57486d5/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/7ada33e7-1fe4-45f7-a30b-f41ca9c34328/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/fa0baabe-7d1e-4c9c-bf48-04730713f1eb/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/27a66ee9-eb66-46f1-a7ff-0254a2dbdd4d/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/05dc8857-3acb-413c-87e8-c373be0d55c9/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/5e79e1ec-baea-4ba1-9e68-a179f32ba1ce/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/9fc380f6-ae5c-4b62-90c3-3b75ac7862e2/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/eb619fb8-2e62-4832-9803-feb3151af4fe/\n", + "\n", + "POST: OK, returning new resource dict\n", + "http://localhost:8000/api/parameter/78011400-f239-447a-ac6d-5eaa9f0d56e3/\n" + ] + } + ], + "source": [ + "#add 1 microliter of reagent 1 to each of the plates \n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Tube 1'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + " \n", + " print(param_url)\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .001, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "#add 1 microliter of reagent 2 to each of the plates \n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Tube 2'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .001, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "#add 1 microliter of reagent 3 to each of the plates\n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Container 3'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .001, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)\n", + "\n", + "#add .6 microliter of reagent 4 to each of the plates\n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Container 4'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .0006, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#stir well-plate for 15 min at 750 rpm" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**need to distinguish between time and speed params in the index loop**" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n", + "\n", + "POST: OK, returning new resource dict\n" + ] + } + ], + "source": [ + "#add 0.6 microliters of reagent 4 to each of the plates\n", + "\n", + "for well in bom_wellss.keys():\n", + " r= escalate.post('action-unit/', \n", + " {'action': action_inst2['transfer'],\n", + " 'source_material': bom_tubes['Stock Container 4'], \n", + " 'destination_material': bom_wellss[well] \n", + " })\n", + " \n", + " param_url= r['parameter'][0]['url']\n", + "\n", + " patch_data = {'parameter_val_actual': {'value': .0006, 'unit': 'mL', 'type': 'num'}}\n", + " \n", + " r = escalate.patch(data=patch_data, url=param_url)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#stir well-plate for 20 min at 750 rpm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Associate action units with actions and workflows \n", + "\n", + "**I need help here**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Gather Vessels\n", + "\n", + "[pending]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "type_well96 = ContainerType(name='96-well PCR plate', is_tube=False, well_count=96, well_depth_mm=None, well_volume_ul=Unit(1.0, 'milliliter'), well_coating=None, sterile=None, cover_types=None, seal_types=['ultra-clear', 'foil'], capabilities=['liquid_handle', 'sangerseq', 'spin', 'thermocycle', 'incubate', 'gel_separate', 'gel_purify', 'seal', 'dispense'], shortname='96-pcr', col_count=12, dead_volume_ul=Unit(3, 'microliter'), safe_min_volume_ul=Unit(5, 'microliter'))\n", + "\n", + "wellplate96 = ContainerModel(container_type=type_well96, name='96-well plate')\n", + "\n", + "\n", + "type_beaker50 = ContainerType(name='50 mL beaker', is_tube=True, well_count=1, well_depth_mm=None, well_volume_ul=Unit(50, 'milliliter'), well_coating=None, sterile=None, cover_types=None, seal_types=['ultra-clear', 'foil'], capabilities=['liquid_handle', 'sangerseq', 'spin', 'thermocycle', 'incubate', 'gel_separate', 'gel_purify', 'seal', 'dispense'], shortname='beaker', col_count=0, dead_volume_ul=Unit(3, 'microliter'), safe_min_volume_ul=Unit(5, 'microliter'))\n", + "\n", + "beaker = ContainerModel(container_type=type_beaker50, name='50-mL beaker')\n", + "\n", + "\n", + "type_tube = ContainerType(name='centrifuge tube', is_tube=True, well_count=1, well_depth_mm=None, well_volume_ul=Unit(15, 'milliliter'), well_coating=None, sterile=None, cover_types=None, seal_types=['ultra-clear', 'foil'], capabilities=['liquid_handle', 'sangerseq', 'spin', 'thermocycle', 'incubate', 'gel_separate', 'gel_purify', 'seal', 'dispense'], shortname='beaker', col_count=0, dead_volume_ul=Unit(3, 'microliter'), safe_min_volume_ul=Unit(5, 'microliter'))\n", + "\n", + "tube = ContainerModel(container_type=type_tube, name='centrifuge tube')\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for container in [tube, beaker]:\n", + " \n", + " r = escalate.post('vessel/', {'description': container.name, \n", + " 'plate_name': 'null', 'well_number': 'null'}['url']\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r = escalate.post('vessel/', {'description': 'beaker', 'plate_name': 'null', 'well_number': 'null'})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "so we've created a beaker using prototype ContainerModel and using conventional POST method to REST API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for well in wellplate96.wells:\n", + " \n", + " r = escalate.post('vessel/', {'description': 'null', \n", + " 'plate_name': '96wellplate', 'well_number': well.index}\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'plate_name', 'well_number'],\n", + " 'plate_name__icontains': '96wellplate'})\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vessels={}\n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'plate_name', 'well_number'],\n", + " 'plate_name__icontains': '96wellplate'})\n", + "for i in r:\n", + " vessels[i['well_number']]=i['url']\n", + " \n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': '50-mL beaker'})\n", + "\n", + "vessels[r['description']]=r['url']\n", + "\n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': 'tube'})\n", + "\n", + "vessels[r['description']]=r['url']\n", + "\n", + "vessels" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "we need a second beaker and a second tube" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for container in [tube, beaker]:\n", + " \n", + " r = escalate.post('vessel/', {'description': container.name+'2', \n", + " 'plate_name': 'null', 'well_number': 'null'}\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': '50-mL beaker'})\n", + "\n", + "r" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vessels={}\n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'plate_name', 'well_number'],\n", + " 'plate_name__icontains': '96wellplate'})\n", + "for i in r:\n", + " vessels[i['well_number']]=i['url']\n", + " \n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': '50-mL beaker'})\n", + "\n", + "for i in r:\n", + " vessels[i['description']]=i['url']\n", + "\n", + "\n", + "r = escalate.get('vessel',\n", + " data={'fields': ['url', 'description'],\n", + " 'description__icontains': 'tube'})\n", + "\n", + "for i in r:\n", + " vessels[i['description']]=i['url']\n", + "\n", + "vessels" + ] + } + ], + "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.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From b4f8b9b6e1a34807286f485918c386d87a00ae98 Mon Sep 17 00:00:00 2001 From: nsmina914 <49839638+nsmina914@users.noreply.github.com> Date: Tue, 7 Sep 2021 15:27:28 -0400 Subject: [PATCH 17/17] Update workflow_experiment_demo.ipynb --- demos/workflow_experiment_demo.ipynb | 299 --------------------------- 1 file changed, 299 deletions(-) diff --git a/demos/workflow_experiment_demo.ipynb b/demos/workflow_experiment_demo.ipynb index 304c7ea..7e0143d 100644 --- a/demos/workflow_experiment_demo.ipynb +++ b/demos/workflow_experiment_demo.ipynb @@ -7,305 +7,6 @@ "# Creating experiment templates through ESCALATE REST\n" ] }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "#factor this out when it's imported into the client\n", - "\n", - "import requests\n", - "\n", - "class ESCALATEClient():\n", - " \"\"\"ESCALATE API Client\"\"\"\n", - " \n", - " def __init__(self, base_url, username, password):\n", - " self.base_url = base_url\n", - " self.username = username\n", - " self.password = password\n", - " self._token = None\n", - " self._is_logged_in = False\n", - " self._login()\n", - " \n", - " def _login(self):\n", - " r_login = requests.post(f'{self.base_url}/api/login', \n", - " data={'username': self.username, \n", - " 'password': self.password})\n", - " self._token = r_login.json()['token']\n", - " self._token_header = {'Authorization': f'Token {self._token}'}\n", - " self._is_logged_in = True\n", - " \n", - " def get(self, \n", - " endpoint='', \n", - " data=None, \n", - " parse_json=True, \n", - " content_type='application/json'):\n", - " \"\"\"Make GET request with `data` to `endpoint` in ESCALATE API\n", - " \n", - " return: (dict|list|requests.Response), bool\n", - " \"\"\"\n", - " data = {} if data is None else data\n", - " r = requests.get(f'{self.base_url}/api/{endpoint}',\n", - " params=data, \n", - " headers={**self._token_header, \n", - " 'content-type': content_type})\n", - " if r.ok: \n", - " print('GET: OK')\n", - " else: \n", - " print('GET: FAILED')\n", - " \n", - " if r.ok and parse_json:\n", - " resp_json = r.json() \n", - " # handle cases: no vs one vs many results\n", - " count = resp_json.get('count')\n", - " if count is None or count == 0:\n", - " return r.json()\n", - " elif count == 1: \n", - " print('Found one resource, returning dict')\n", - " return resp_json['results'][0]\n", - " elif count >= 1: \n", - " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", - " return r.json()['results']\n", - " print('Returning response object') \n", - " return r\n", - " \n", - " def post(self, \n", - " endpoint, \n", - " data, \n", - " content_type='application/json'):\n", - " \"\"\"POST `data` to `endpoint`in ESCALATE API using `content_type`\n", - " return: (dict|requests.Response), bool\n", - " \"\"\"\n", - " \n", - " if not self._is_logged_in:\n", - " raise ValueError(\"Not logged in: cannot post\")\n", - " \n", - " r = requests.api.post(\n", - " f'{self.base_url}/api/{endpoint}', \n", - " json=data, \n", - " headers={**self._token_header,\n", - " 'content-type': content_type})\n", - " print(r)\n", - " if r.ok: \n", - " print('POST: OK, returning new resource dict')\n", - " return r.json()\n", - " print('POST: FAILED, returning response object')\n", - " return r\n", - " \n", - " def put(self, data, url=None, endpoint=None, resource_id=None):\n", - " \"\"\"Update a resource\n", - " Either provide a url or an endpoint and resource id\n", - " \"\"\"\n", - " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", - " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", - " \n", - " if url is None: \n", - " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", - " r = requests.api.put(url, json=data, headers=self._token_header)\n", - " return r\n", - " \n", - " def patch(self, data, url=None, endpoint=None, resource_id=None):\n", - " \"\"\"Update parts of a resource\n", - " Either provide a url or an endpoint and resource id\n", - " \"\"\"\n", - " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", - " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", - " \n", - " if url is None: \n", - " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", - " r = requests.api.patch(url, json=data, headers=self._token_header)\n", - " return r\n", - " \n", - " def delete(self, url=None, endpoint=None, resource_id=None):\n", - " \"\"\"Delete a resource\n", - " Either provide a url or an endpoint and resource id\n", - " \"\"\"\n", - " if not ((url is not None) or (endpoint is not None and resource_id is not None)): \n", - " raise ValueError(\"Must specify either url or endpoint and resource_id\")\n", - " if url is None: \n", - " url = f'{self.base_url}/api/{endpoint}/{resource_id}' \n", - " r = requests.api.delete(url, headers=self._token_header)\n", - " return r\n", - " \n", - " def list_endpoints(self):\n", - " return self.get()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def search(self, \n", - " endpoint='',\n", - " related_ep=None, #for cross-searches\n", - " search_field='',\n", - " criteria= '',\n", - " data=None, #must be a list\n", - " exact=False,\n", - " negate=False,\n", - " parse_json=True, \n", - " content_type='application/json'):\n", - " \n", - " if negate==False:\n", - "\n", - " if exact==True:\n", - " if data == None:\n", - " '''Returns all fields for exact match'''\n", - " if related_ep == None:\n", - " \n", - " r = requests.get(f'{self.base_url}/api/{endpoint}/?{search_field}={criteria}', \n", - " headers={**self._token_header, \n", - " 'content-type': content_type})\n", - " else: #cross-search \n", - " r = requests.get(f'{self.base_url}/api/{endpoint}/?{related_ep}__{search_field}={criteria}', \n", - " headers={**self._token_header, \n", - " 'content-type': content_type})\n", - "\n", - " else:\n", - " '''Returns requested field(s) for exact match'''\n", - " i=0\n", - " data_string=''\n", - " while i= 1: \n", - " print(f\"Found {resp_json['count']} resources, returning list of dicts)\")\n", - " return r.json()['results']\n", - " print('Returning response object') \n", - " return r" - ] - }, { "cell_type": "markdown", "metadata": {},