{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": true, "pycharm": { "name": "#%% md\n" } }, "source": [ "## Setup and Quick Start\n", "To use panda-client API in notebook, you need to set it up first.\n", "\n", "#### Setup Jupyter interface" ] }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [ "from pandaclient import panda_jupyter\n", "panda_jupyter.setup()" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "markdown", "source": [ "#### Import panda-client API" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [ "from pandaclient import panda_api\n", "c = panda_api.get_api()" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "markdown", "source": [ "At this stage all end-user python APIs are available in the notebook. Try a toy example," ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [ "from pandaclient import panda_gui\n", "x = panda_gui.show_task(23518002)" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "markdown", "source": [ "which will load data from PanDA, convert them to a pandas dataframe, and show some plots\n", "after some delay.\n", "\n", "#### Get an OIDC ID token\n", "You need to get an OIDC ID token unless you use X509 authentication with grid middleware.\n", "The following method triggers the device code authentication flow and gives\n", "a PanDA IAM URL to redirect to your identity provider." ], "metadata": { "collapsed": false, "pycharm": { "name": "#%% md\n" } } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [ "c.hello()" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "markdown", "source": [ "If you already have a token you will immediately see an OK message.\n", "Otherwise, you will see something like\n", "```html\n", "INFO : Please go to https://panda-iam-doma.cern.ch/device?user_code=EEPGDH and sign in. Waiting until authentication is completed\n", "INFO : Ready to get ID token?\n", "[y/n]\n", "```\n", "Note that you need to get a token to the URL before entering **y** in the prompt.\n", "\n", "Once you go to the URL using your web browser, such as Chrome, FireFox, etc,\n", "you will be asked to sign in with your own ID provider.\n", "\n", "\n", "\n", "Then you will be navigated to a federated IAM platform, CILogon, to choose your own\n", "identity provider.\n", "\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", "\n", "When you successfully sign in you need to approve the virtual organization to retrieve\n", "your profile, such as name and email address, from your identity provider.\n", "\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", "\n", "You approved it and see a succeeded message in your browser, and now you can\n", "enter **y** in the notebook prompt to get a token.\n", "```html\n", "[y/n]\n", " y\n", "INFO : All set\n", "OK\n", "```\n", "Generally you don't have to repeat the procedure once you get a token since it is automatically renewed.\n", "\n", "----\n", "\n", "Download [notebook](https://raw.githubusercontent.com/PanDAWMS/panda-docs/main/docs/source/client/notebooks/jupyter_setup.ipynb)" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%% md\n" } } } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }