Skip to content
Snippets Groups Projects
pybis demo.ipynb 243 KiB
Newer Older
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Working with pybis"
   ]
  },
Swen Vermeul's avatar
Swen Vermeul committed
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "········\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'vermeul-190613105017193x7338CBACCD9B0721D96EA8D19C3C3965'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pybis import Openbis\n",
    "o = Openbis(url='https://openbis-tst.ethz.ch', verify_certificates=False)\n",
    "import getpass\n",
    "password = getpass.getpass()\n",
    "\n",
    "o.login('vermeul',password, save_token=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "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://openbis-tst.ethz.ch: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://openbis-tst.ethz.ch:443  http://127.0.0.1:8081"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "o.get_datastores()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## connect to openBIS\n",
    "(using stored session token ~/.pybis/localhost.token)"
   ]
  },
  {
   "cell_type": "code",
Swen Vermeul's avatar
Swen Vermeul committed
   "execution_count": 1,
Swen Vermeul's avatar
Swen Vermeul committed
   "metadata": {},
Swen Vermeul's avatar
Swen Vermeul committed
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'admin-190322224519031x6CD252246FDAD84555B20A030E8F60F8'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pybis import Openbis\n",
    "o = Openbis(url='https://localhost:8443', verify_certificates=False)\n",
    "o.token"
   ]
  },
Swen Vermeul's avatar
Swen Vermeul committed
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'admin-190322225222678x9B6C922E404DB51F1C50A1B9DDFF371B'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "o.login('admin', 'changeit', save_token=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"@type\": \"as.dto.common.search.SearchResult\", \"@id\": 1, \"objects\": [], \"totalCount\": 4}\n"
     ]
    },
    {
     "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>identifier</th>\n",
       "      <th>permId</th>\n",
       "      <th>experiment</th>\n",
       "      <th>sample_type</th>\n",
       "      <th>registrator</th>\n",
       "      <th>registrationDate</th>\n",
       "      <th>modifier</th>\n",
       "      <th>modificationDate</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "identifier    permId    experiment    sample_type    registrator    registrationDate    modifier    modificationDate\n",
       "------------  --------  ------------  -------------  -------------  ------------------  ----------  ------------------"
      ]
     },
Loading
Loading full blame...