Skip to content
Snippets Groups Projects
pybis demo.ipynb 139 KiB
Newer Older
  • Learn to ignore specific revisions
  •        "   'storageFormat': None},\n",
           "  'properties': {'@id': 8,\n",
           "   '@type': 'as.dto.property.fetchoptions.PropertyFetchOptions',\n",
           "   'cacheMode': 'NO_CACHE',\n",
           "   'count': None,\n",
           "   'from': None,\n",
           "   'sortBy': None},\n",
           "  'registrator': None,\n",
           "  'sample': {'@id': 7,\n",
           "   '@type': 'as.dto.sample.fetchoptions.SampleFetchOptions',\n",
           "   'attachments': None,\n",
           "   'cacheMode': 'NO_CACHE',\n",
           "   'children': None,\n",
           "   'components': None,\n",
           "   'container': None,\n",
           "   'count': None,\n",
           "   'dataSets': None,\n",
           "   'experiment': None,\n",
           "   'from': None,\n",
           "   'history': None,\n",
           "   'materialProperties': None,\n",
           "   'modifier': None,\n",
           "   'parents': None,\n",
           "   'properties': None,\n",
           "   'registrator': None,\n",
           "   'sort': None,\n",
           "   'sortBy': None,\n",
           "   'space': None,\n",
           "   'tags': None,\n",
           "   'type': None},\n",
           "  'sort': None,\n",
           "  'sortBy': None,\n",
           "  'tags': {'@id': 12,\n",
           "   '@type': 'as.dto.tag.fetchoptions.TagFetchOptions',\n",
           "   'cacheMode': 'NO_CACHE',\n",
           "   'count': None,\n",
           "   'dataSets': None,\n",
           "   'experiments': None,\n",
           "   'from': None,\n",
           "   'materials': None,\n",
           "   'owner': None,\n",
           "   'samples': None,\n",
           "   'sort': None,\n",
           "   'sortBy': None},\n",
           "  'type': None},\n",
           " 'history': None,\n",
           " 'linkedData': None,\n",
           " 'materialProperties': None,\n",
           " 'measured': True,\n",
           " 'modificationDate': 1478469560726,\n",
           " 'modifier': None,\n",
           " 'parents': [],\n",
           " 'permId': {'@id': 13,\n",
           "  '@type': 'as.dto.dataset.id.DataSetPermId',\n",
           "  'permId': '20160929145446460-367'},\n",
           " 'physicalData': None,\n",
           " 'postRegistered': True,\n",
           " 'properties': {'DESCRIPTION': 'should be aa4da9f7', 'NAME': 'crc32 check'},\n",
           " 'registrationDate': 1475153686645,\n",
           " 'registrator': None,\n",
           " 'sample': {'@id': 20,\n",
           "  '@type': 'as.dto.sample.Sample',\n",
           "  'attachments': None,\n",
           "  'children': None,\n",
           "  'code': 'HOW_WONDERFUL',\n",
           "  'components': None,\n",
           "  'container': None,\n",
           "  'dataSets': None,\n",
           "  'experiment': None,\n",
           "  'fetchOptions': {'@id': 21,\n",
           "   '@type': 'as.dto.sample.fetchoptions.SampleFetchOptions',\n",
           "   'attachments': None,\n",
           "   'cacheMode': 'NO_CACHE',\n",
           "   'children': None,\n",
           "   'components': None,\n",
           "   'container': None,\n",
           "   'count': None,\n",
           "   'dataSets': None,\n",
           "   'experiment': None,\n",
           "   'from': None,\n",
           "   'history': None,\n",
           "   'materialProperties': None,\n",
           "   'modifier': None,\n",
           "   'parents': None,\n",
           "   'properties': None,\n",
           "   'registrator': None,\n",
           "   'sort': None,\n",
           "   'sortBy': None,\n",
           "   'space': None,\n",
           "   'tags': None,\n",
           "   'type': None},\n",
           "  'history': None,\n",
           "  'identifier': {'@id': 23,\n",
           "   '@type': 'as.dto.sample.id.SampleIdentifier',\n",
           "   'identifier': '/VERMEUL/HOW_WONDERFUL'},\n",
           "  'materialProperties': None,\n",
           "  'modificationDate': 1479686038994,\n",
           "  'modifier': None,\n",
           "  'parents': None,\n",
           "  'permId': {'@id': 22,\n",
           "   '@type': 'as.dto.sample.id.SamplePermId',\n",
           "   'permId': '20160630105304285-81'},\n",
           "  'properties': None,\n",
           "  'registrationDate': 1467298384285,\n",
           "  'registrator': None,\n",
           "  'space': None,\n",
           "  'tags': None,\n",
           "  'type': None},\n",
           " 'tags': [],\n",
           " 'type': None}"
          ]
         },
         "execution_count": 12,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
        "dss[2].data"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 5,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "<div>\n",
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
           "      <th></th>\n",
           "      <th>isDirectory</th>\n",
           "      <th>pathInDataSet</th>\n",
           "      <th>fileSize</th>\n",
           "      <th>crc32Checksum</th>\n",
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
           "    <tr>\n",
           "      <th>0</th>\n",
           "      <td>True</td>\n",
           "      <td>original</td>\n",
           "      <td>-1</td>\n",
           "      <td>0</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>1</th>\n",
           "      <td>True</td>\n",
           "      <td>original/JUPYTER_NOTEBOOk</td>\n",
           "      <td>-1</td>\n",
           "      <td>0</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>2</th>\n",
           "      <td>False</td>\n",
           "      <td>original/JUPYTER_NOTEBOOk/pybis demo.ipynb</td>\n",
           "      <td>77667</td>\n",
    
           "      <td>1fae7b5a</td>\n",
    
           "    </tr>\n",
           "    <tr>\n",
           "      <th>3</th>\n",
           "      <td>True</td>\n",
           "      <td>original/JUPYTER_RESULT</td>\n",
           "      <td>-1</td>\n",
           "      <td>0</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>4</th>\n",
           "      <td>False</td>\n",
           "      <td>original/JUPYTER_RESULT/PLATE1_A01_06_GFP.jpg</td>\n",
           "      <td>426229</td>\n",
    
           "      <td>aa4da9f7</td>\n",
    
           "    </tr>\n",
           "  </tbody>\n",
           "</table>\n",
           "</div>"
          ],
          "text/plain": [
           "  isDirectory                                  pathInDataSet fileSize  \\\n",
           "0        True                                       original       -1   \n",
           "1        True                      original/JUPYTER_NOTEBOOk       -1   \n",
           "2       False     original/JUPYTER_NOTEBOOk/pybis demo.ipynb    77667   \n",
           "3        True                        original/JUPYTER_RESULT       -1   \n",
           "4       False  original/JUPYTER_RESULT/PLATE1_A01_06_GFP.jpg   426229   \n",
           "\n",
           "  crc32Checksum  \n",
           "0             0  \n",
           "1             0  \n",
    
           "2      1fae7b5a  \n",
    
           "4      aa4da9f7  "
    
         "execution_count": 5,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
        "files = ds.get_files()\n",
    
        "files[0]"
    
       "execution_count": 6,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "Files downloaded to: localhost/20160929145446460-367\n"
         ]
        }
       ],
       "source": [
        "ds.download()"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 7,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "localhost/20160929145446460-367\r\n",
          "localhost/20160929145446460-367/original\r\n",
          "localhost/20160929145446460-367/original/JUPYTER_RESULT\r\n",
          "localhost/20160929145446460-367/original/JUPYTER_RESULT/PLATE1_A01_06_GFP.jpg\r\n",
          "localhost/20160929145446460-367/original/JUPYTER_NOTEBOOk\r\n",
          "localhost/20160929145446460-367/original/JUPYTER_NOTEBOOk/pybis demo.ipynb\r\n"
         ]
        }
       ],
       "source": [
        "!find localhost/20160929145446460-367"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 10,
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/plain": [
           "[{'@id': 1,\n",
           "  '@type': 'FileInfoDssDTO',\n",
           "  'crc32Checksum': 1397688417,\n",
           "  'fileSize': '209715200',\n",
           "  'isDirectory': False,\n",
           "  'pathInDataSet': 'original/JUPYTER_RESULT/large_testfile',\n",
           "  'pathInListing': 'large_testfile'}]"
          ]
         },
         "execution_count": 10,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
        "ds2 = o.get_dataset('20160721002157457-271')\n",
        "ds2.get_file_list(start_folder='original/JUPYTER_RESULT/large_testfile')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 17,
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "Files downloaded to: localhost/20160721002157457-271\n"
         ]
        }
       ],
       "source": [
        "ds2.download('original/JUPYTER_RESULT/large_testfile')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 28,
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "Files downloaded to: localhost/20160721002157457-271\n"
         ]
        }
       ],
       "source": [
        "ds2.download()"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "## upload data to openBIS\n",
    
        "The pybis data ingestion service «jupyter-uploader-api» in the openBIS instance is needed in order to work. Files are first uploaded to session workspace, then the ingestion service is activated which in turn registers 3 datasets:\n",
        "- a JUPYTER_CONTAINER containing:\n",
        "- JUPYTER_NOTEBOOK (containing the notebook files)\n",
        "- JUPYTER_RESULTS (containing any result files)"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 31,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "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> <th>permId</th> <td>20160721002157457-271</td> </tr>\n",
           "    <tr> <th>properties</th> <td>{'DESCRIPTION': 'ave, some!', 'NAME': 'my_delightful_analysis'}</td> </tr>\n",
           "    <tr> <th>tags</th> <td>[]</td> </tr>\n",
           "  </tbody>\n",
           "</table>\n",
           "        "
          ],
    
           "<pybis.pybis.DataSet at 0x7efe60802d68>"
    
         "execution_count": 31,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "ds = o.get_dataset('20160721002157457-271')\n",
        "ds"
    
       "execution_count": 4,
    
       "metadata": {
        "collapsed": false
       },
    
       "outputs": [
        {
         "data": {
          "text/plain": [
           "'Dataset registration successful'"
          ]
         },
         "execution_count": 4,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
    
       "source": [
        "o.new_analysis(\n",
    
        "    name='my new data analysis', \n",
        "    description='some meaningful description',\n",
    
        "    sample = s,\n",
        "    notebook_files=['pybis demo.ipynb'],\n",
    
        "    result_files=['PLATE1_A01_06_GFP.jpg'],\n",
        "    parents = [ds]\n",
    
        ")"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "*TODO*: attach analysis to an experiment, not to a sample (usually there are a lot of datasets and samples, but only a few analyses per experiment)"
       ]
      }
     ],
     "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.5.1"
      }
     },
     "nbformat": 4,
     "nbformat_minor": 0
    }