Skip to content
Snippets Groups Projects
pybis_example.ipynb 23 KiB
Newer Older
  • Learn to ignore specific revisions
  • {
     "cells": [
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 12,
    
       "metadata": {},
       "outputs": [],
       "source": [
        "from pybis import Openbis\n",
    
        "import getpass"
    
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "### Connecting to openBIS"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 13,
    
       "metadata": {},
       "outputs": [],
       "source": [
    
        "o = Openbis('https://127.0.0.1/openbis:8443', verify_certificates=False)"
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 14,
       "metadata": {},
       "outputs": [
        {
         "name": "stdin",
         "output_type": "stream",
         "text": [
          " ·············\n"
         ]
        }
       ],
    
        "username = 'hluetcke'\n",
    
        "pw = getpass.getpass()"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 15,
    
       "metadata": {},
       "outputs": [],
       "source": [
        "o.login(username, pw, save_token=True)   # saves the session token in ~/.pybis/example.com.token\n",
        "del pw"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 16,
       "metadata": {},
       "outputs": [
        {
         "data": {
          "text/plain": [
           "'hluetcke-210707114707411xDBE993550910BD60EE612EF16B373511'"
          ]
         },
         "execution_count": 16,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
    
       "source": [
        "o.token"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 17,
       "metadata": {},
       "outputs": [
        {
         "data": {
          "text/plain": [
           "True"
          ]
         },
         "execution_count": 17,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
    
       "source": [
        "o.is_session_active()"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 18,
       "metadata": {},
       "outputs": [
        {
         "data": {
          "text/html": [
           "<div>\n",
           "<style scoped>\n",
           "    .dataframe tbody tr th:only-of-type {\n",
           "        vertical-align: middle;\n",
           "    }\n",
           "\n",
           "    .dataframe tbody tr th {\n",
           "        vertical-align: top;\n",
           "    }\n",
           "\n",
           "    .dataframe thead th {\n",
           "        text-align: right;\n",
           "    }\n",
           "</style>\n",
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
           "      <th></th>\n",
           "      <th>code</th>\n",
           "      <th>downloadUrl</th>\n",
           "      <th>remoteUrl</th>\n",
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
           "    <tr>\n",
           "      <th>0</th>\n",
           "      <td>DSS1</td>\n",
           "      <td>https://127.0.0.1:443</td>\n",
           "      <td>http://127.0.0.1:8081</td>\n",
           "    </tr>\n",
           "  </tbody>\n",
           "</table>\n",
           "</div>"
          ],
          "text/plain": [
           "   code            downloadUrl              remoteUrl\n",
           "0  DSS1  https://127.0.0.1:443  http://127.0.0.1:8081"
          ]
         },
         "execution_count": 18,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
    
       "source": [
        "o.get_datastores()"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "### Masterdata"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": null,
       "metadata": {},
       "outputs": [],
    
       "source": [
        "o.get_experiment_types()"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "o.get_sample_types()"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "o.get_sample_type('PLATE')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "o.get_material_types()"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "o.get_dataset_types()"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "o.get_terms()"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "### Samples / objects"
    
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
    
        "o.get_sample_types()"
    
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
    
        "obj = o.new_object(type='UNKNOWN', space='MATLAB_TEST', code='12345')"
    
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
    
        "obj.save()"
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": null,
    
       "metadata": {},
       "outputs": [],
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "source": [
        "sample = o.get_sample('/MATLAB_TEST/911922')"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": null,
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "metadata": {},
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "outputs": [],
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "source": [
        "sample.delete('just a test')"
       ]
    
      },
      {
       "cell_type": "markdown",
       "metadata": {},
    
        "### List and get datasets"
    
    Henry Luetcke's avatar
    Henry Luetcke committed
      {
       "cell_type": "code",
    
       "execution_count": null,
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "metadata": {},
       "outputs": [],
       "source": [
    
        "datasets = o.get_datasets(type='HISTOLOGY')"
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "counter = 0\n",
        "for ds in datasets:\n",
        "    print(ds)\n",
        "    counter += 1\n",
        "    if counter > 10:\n",
        "        break"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "ds = o.get_dataset('20101105142049776-6512')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "ds.get_files(start_folder='original')"
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       ]
      },
    
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "### Experiments / collections"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": null,
       "metadata": {},
       "outputs": [],
    
       "source": [
        "o.get_experiments(\n",
        "    project='TEST_PROJECT',\n",
        "    space='MATLAB_TEST'\n",
        ")"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": null,
       "metadata": {},
       "outputs": [],
    
       "source": [
        "experiment = o.get_experiment('/MATLAB_TEST/TEST_PROJECT/E1300')\n",
        "experiment"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": null,
    
       "metadata": {},
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "outputs": [],
    
       "source": [
        "experiment.props"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 19,
    
       "metadata": {},
       "outputs": [],
       "source": [
    
        "experiment = o.new_experiment(type='UNKNOWN', code='EXP123456789', project='/HLUETCKE/PLAYGROUND')"
    
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 20,
       "metadata": {},
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "experiment successfully created.\n"
         ]
        },
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
           "                <th>attribute</th>\n",
           "                <th>value</th>\n",
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
           "        <tr> <td>code</td> <td>EXP123456789</td> </tr><tr> <td>permId</td> <td>20210707114742976-102</td> </tr><tr> <td>identifier</td> <td>/HLUETCKE/PLAYGROUND/EXP123456789</td> </tr><tr> <td>type</td> <td>UNKNOWN</td> </tr><tr> <td>project</td> <td>/HLUETCKE/PLAYGROUND</td> </tr><tr> <td>tags</td> <td>[]</td> </tr><tr> <td>registrator</td> <td>hluetcke</td> </tr><tr> <td>registrationDate</td> <td>2021-07-07 13:47:43</td> </tr><tr> <td>modifier</td> <td>hluetcke</td> </tr><tr> <td>modificationDate</td> <td>2021-07-07 13:47:43</td> </tr><tr> <td>frozen</td> <td>False</td> </tr><tr> <td>frozenForDataSets</td> <td>False</td> </tr><tr> <td>frozenForSamples</td> <td>False</td> </tr><tr><td>attachments</td><td></td></tr>\n",
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
           "attribute          value\n",
           "-----------------  ---------------------------------\n",
           "code               EXP123456789\n",
           "permId             20210707114742976-102\n",
           "identifier         /HLUETCKE/PLAYGROUND/EXP123456789\n",
           "type               UNKNOWN\n",
           "project            /HLUETCKE/PLAYGROUND\n",
           "tags               []\n",
           "registrator        hluetcke\n",
           "registrationDate   2021-07-07 13:47:43\n",
           "modifier           hluetcke\n",
           "modificationDate   2021-07-07 13:47:43\n",
           "frozen             False\n",
           "frozenForDataSets  False\n",
           "frozenForSamples   False"
          ]
         },
         "execution_count": 20,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
    
       "source": [
    
        "experiment.save()"
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 21,
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "experiment 20210707114742976-102 successfully deleted.\n"
         ]
        }
       ],
    
       "source": [
    
    Henry Luetcke's avatar
    Henry Luetcke committed
        "experiment.delete('bla')"
    
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": 22,
    
       "metadata": {},
       "outputs": [],
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "source": [
        "project = o.new_project('HLUETCKE', 'test_project', 'boring project')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 23,
       "metadata": {
        "tags": []
       },
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "project successfully created.\n"
         ]
        },
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
           "                <th>attribute</th>\n",
           "                <th>value</th>\n",
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
           "        <tr> <td>code</td> <td>TEST_PROJECT</td> </tr><tr> <td>description</td> <td>boring project</td> </tr><tr> <td>permId</td> <td>20210707120832998-103</td> </tr><tr> <td>identifier</td> <td>/HLUETCKE/TEST_PROJECT</td> </tr><tr> <td>space</td> <td>HLUETCKE</td> </tr><tr> <td>leader</td> <td></td> </tr><tr> <td>registrator</td> <td>hluetcke</td> </tr><tr> <td>registrationDate</td> <td>2021-07-07 14:08:33</td> </tr><tr> <td>modifier</td> <td>12</td> </tr><tr> <td>modificationDate</td> <td>2021-07-07 14:08:33</td> </tr><tr> <td>frozen</td> <td>False</td> </tr><tr> <td>frozenForExperiments</td> <td>False</td> </tr><tr> <td>frozenForSamples</td> <td>False</td> </tr><tr><td>attachments</td><td></td></tr>\n",
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
           "attribute             value\n",
           "--------------------  ----------------------\n",
           "code                  TEST_PROJECT\n",
           "description           boring project\n",
           "permId                20210707120832998-103\n",
           "identifier            /HLUETCKE/TEST_PROJECT\n",
           "space                 HLUETCKE\n",
           "leader\n",
           "registrator           hluetcke\n",
           "registrationDate      2021-07-07 14:08:33\n",
           "modifier              12\n",
           "modificationDate      2021-07-07 14:08:33\n",
           "frozen                False\n",
           "frozenForExperiments  False\n",
           "frozenForSamples      False"
          ]
         },
         "execution_count": 23,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
    
       "source": [
        "project.save()"
       ]
      },
    
    Henry Luetcke's avatar
    Henry Luetcke committed
      {
       "cell_type": "code",
       "execution_count": 24,
       "metadata": {},
       "outputs": [],
       "source": [
        "experiment = o.new_experiment(type='UNKNOWN', code='EXP333', project='/HLUETCKE/TEST_PROJECT')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 25,
       "metadata": {},
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "experiment successfully created.\n"
         ]
        },
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
           "                <th>attribute</th>\n",
           "                <th>value</th>\n",
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
           "        <tr> <td>code</td> <td>EXP333</td> </tr><tr> <td>permId</td> <td>20210707121043770-104</td> </tr><tr> <td>identifier</td> <td>/HLUETCKE/TEST_PROJECT/EXP333</td> </tr><tr> <td>type</td> <td>UNKNOWN</td> </tr><tr> <td>project</td> <td>/HLUETCKE/TEST_PROJECT</td> </tr><tr> <td>tags</td> <td>[]</td> </tr><tr> <td>registrator</td> <td>hluetcke</td> </tr><tr> <td>registrationDate</td> <td>2021-07-07 14:10:44</td> </tr><tr> <td>modifier</td> <td>hluetcke</td> </tr><tr> <td>modificationDate</td> <td>2021-07-07 14:10:44</td> </tr><tr> <td>frozen</td> <td>False</td> </tr><tr> <td>frozenForDataSets</td> <td>False</td> </tr><tr> <td>frozenForSamples</td> <td>False</td> </tr><tr><td>attachments</td><td></td></tr>\n",
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
           "attribute          value\n",
           "-----------------  -----------------------------\n",
           "code               EXP333\n",
           "permId             20210707121043770-104\n",
           "identifier         /HLUETCKE/TEST_PROJECT/EXP333\n",
           "type               UNKNOWN\n",
           "project            /HLUETCKE/TEST_PROJECT\n",
           "tags               []\n",
           "registrator        hluetcke\n",
           "registrationDate   2021-07-07 14:10:44\n",
           "modifier           hluetcke\n",
           "modificationDate   2021-07-07 14:10:44\n",
           "frozen             False\n",
           "frozenForDataSets  False\n",
           "frozenForSamples   False"
          ]
         },
         "execution_count": 25,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
        "experiment.save()"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 26,
       "metadata": {},
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "experiment 20210707121043770-104 successfully deleted.\n"
         ]
        }
       ],
       "source": [
        "experiment.delete('bla')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 27,
       "metadata": {},
       "outputs": [
        {
         "ename": "ValueError",
         "evalue": "Project 'TEST_PROJECT' can not be deleted because the following experiments are in the trash can: [EXP333] (Context: [])",
         "output_type": "error",
         "traceback": [
          "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
          "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
          "\u001b[0;32m<ipython-input-27-9412c08c33df>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mproject\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdelete\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'bla'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
          "\u001b[0;32m~/miniconda3/lib/python3.9/site-packages/pybis/openbis_object.py\u001b[0m in \u001b[0;36mdelete\u001b[0;34m(self, reason)\u001b[0m\n\u001b[1;32m    149\u001b[0m             \u001b[0;32mreturn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    150\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 151\u001b[0;31m         self.openbis.delete_openbis_entity(\n\u001b[0m\u001b[1;32m    152\u001b[0m             \u001b[0mentity\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_entity\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    153\u001b[0m             \u001b[0mobjectId\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'permId'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
          "\u001b[0;32m~/miniconda3/lib/python3.9/site-packages/pybis/pybis.py\u001b[0m in \u001b[0;36mdelete_openbis_entity\u001b[0;34m(self, entity, objectId, reason)\u001b[0m\n\u001b[1;32m   2559\u001b[0m             ]\n\u001b[1;32m   2560\u001b[0m         }\n\u001b[0;32m-> 2561\u001b[0;31m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_post_request\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mas_v3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrequest\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   2562\u001b[0m         \u001b[0;32mreturn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   2563\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
          "\u001b[0;32m~/miniconda3/lib/python3.9/site-packages/pybis/pybis.py\u001b[0m in \u001b[0;36m_post_request\u001b[0;34m(self, resource, request)\u001b[0m\n\u001b[1;32m   1064\u001b[0m         \u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1065\u001b[0m         \"\"\"\n\u001b[0;32m-> 1066\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_post_request_full_url\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murljoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mresource\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrequest\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1067\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1068\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0m_post_request_full_url\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfull_url\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrequest\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
          "\u001b[0;32m~/miniconda3/lib/python3.9/site-packages/pybis/pybis.py\u001b[0m in \u001b[0;36m_post_request_full_url\u001b[0;34m(self, full_url, request)\u001b[0m\n\u001b[1;32m   1090\u001b[0m                 \u001b[0;31m#print(full_url)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1091\u001b[0m                 \u001b[0;31m#print(json.dumps(request))\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1092\u001b[0;31m                 \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresp\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'error'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'message'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1093\u001b[0m             \u001b[0;32melif\u001b[0m \u001b[0;34m'result'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1094\u001b[0m                 \u001b[0;32mreturn\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'result'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
          "\u001b[0;31mValueError\u001b[0m: Project 'TEST_PROJECT' can not be deleted because the following experiments are in the trash can: [EXP333] (Context: [])"
         ]
        }
       ],
       "source": [
        "project.delete('bla')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
    
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "o.get_objects('SIS_HLUETCKE/')"
       ]
    
      },
      {
       "cell_type": "markdown",
       "metadata": {},
    
        "### Download and import files"
    
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
    
        "ds.download(files='', destination='data', wait_until_finished=True)"
    
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
    
        "plt.imshow(plt.imread('data/20101105142920015-6525/original/441_x40001.tif'))"
    
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "o.get_experiment_types()"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
        "o.get_dataset_types()"
       ]
    
      },
      {
       "cell_type": "code",
    
       "execution_count": null,
       "metadata": {},
       "outputs": [],
    
       "source": [
        "o.get_projects(space='MATLAB_TEST', code=None)"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": null,
    
       "metadata": {},
       "outputs": [],
       "source": [
        "project = o.new_project(space='MATLAB_TEST', code='ANOTHER_TEST', description='TGIF')"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": null,
       "metadata": {},
       "outputs": [],
    
       "source": [
        "project.save()"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": null,
       "metadata": {},
       "outputs": [],
    
       "source": [
        "project.delete('just a test')"
       ]
      },
    
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
    Henry Luetcke's avatar
    Henry Luetcke committed
        "### Create a new dataset"
    
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": null,
    
       "metadata": {},
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "outputs": [],
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "source": [
        "file_list = [\n",
        "    '/Users/Henry/Data/temp/file1.dat',\n",
        "    '/Users/Henry/Data/temp/file2.dat',\n",
        "    '/Users/Henry/Data/temp/file3.dat'\n",
        "]\n",
        "file_list"
       ]
      },
      {
       "cell_type": "code",
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "execution_count": null,
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "metadata": {},
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "outputs": [],
       "source": [
        "ds_new = o.new_dataset(type='ANALYZED_DATA', experiment='/HLUETCKE/DEMO/DEMO_EXP_1', sample='/HLUETCKE/DEMO/S43', files=file_list)"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": [
    
    Henry Luetcke's avatar
    Henry Luetcke committed
        "ds_new.save()"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "### Logout"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": null,
    
    Henry Luetcke's avatar
    Henry Luetcke committed
       "metadata": {},
    
       "outputs": [],
       "source": [
        "o.logout()"
       ]
      },
    
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
    
      }
     ],
     "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.9.1"
    
     "nbformat_minor": 4