Building on the Globus Python SDK

Similar documents
Introducing the New Globus CLI (alpha)

Leveraging the Globus Platform in your Web Applications. GlobusWorld April 26, 2018 Greg Nawrocki

f5-icontrol-rest Documentation

Building the Modern Research Data Portal using the Globus Platform. Rachana Ananthakrishnan GlobusWorld 2017

Intro. Scheme Basics. scm> 5 5. scm>

Leveraging the Globus Platform in your Web Applications

tapi Documentation Release 0.1 Jimmy John

9 R1 Get another piece of paper. We re going to have fun keeping track of (inaudible). Um How much time do you have? Are you getting tired?

FRONT USER GUIDE Getting Started with Front

Building the Modern Research Data Portal. Developer Tutorial

Introduction to SciTokens

Administrivia. Remote Procedure Calls. Reminder about last time. Building up to today

Going to cover; - Why we have SPIR-V - Brief history of SPIR-V - Some of the core required features we wanted - How OpenCL will use SPIR-V - How

IoT in 2016: a serious overview of IoT today and a technical preview of HoneyVNC. By Yonathan Klijnsma

bottle-rest Release 0.5.0

Hi, I m SMS SMS BOOTCAMP. Everything you need to know to get started with SMS marketing.

Intro to Algorithms. Professor Kevin Gold

Rapid Software Testing Guide to Making Good Bug Reports

Mr G s Java Jive. #11: Formatting Numbers

sanction Documentation

These are notes for the third lecture; if statements and loops.

THANKS FOR READING. - Marco Behler, Author. Copyright 2015 Marco Behler GmbH. All Rights Reserved.

Module 6. Campaign Layering

1: Introduction to Object (1)

CTI-TC Weekly Working Sessions

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

Rancher Part 4: Using the Catalog Example with GlusterFS

CSC 2515 Introduction to Machine Learning Assignment 2

MyGeotab Python SDK Documentation

STAUNING Credit Application Internet Sales Process with /Voic Templates to Non-Responsive Prospects 2018 Edition

Application Authorization with SET ROLE. Aurynn Shaw, Command Prompt, Inc. PGCon 2010

Quick housekeeping Last Two Homeworks Extra Credit for demoing project prototypes Reminder about Project Deadlines/specifics Class on April 12th Resul

If Statements, For Loops, Functions

Part II Composition of Functions

Our legacy archival system resides in an Access Database lovingly named The Beast. Having the data in a database provides the opportunity and ability

CTI-TC Interoperability Subcommittee

flask-jwt-simple Documentation

CS193X: Web Programming Fundamentals

Arbori Starter Manual Eugene Perkov

CS2304: Python for Java Programmers. CS2304: Advanced Function Topics

SSEA Newbies Handout 09 Summer 2012 August 17 th, 2012 Assignment 4: Bouncing Ball and Bizz Bazz Buzz

EMPOWER2018 Quick Base + Workato Workjam

CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise

Kuratowski Notes , Fall 2005, Prof. Peter Shor Revised Fall 2007

Introducing the. new & improved. Think. Formerly. Intelligent Business Automation.

CSE : Python Programming

Incoherent Rant about Code

1 GSW Bridging and Switching

TABLE OF CONTENTS. Fish Data Submission FAQs and Trouble-shooting Guide January 2013

Friday, 11 April 14. Advanced methods for creating decorators Graham Dumpleton PyCon US - April 2014

The Complete Nonprofit Website Toolkit Defining Your Content and Navigation Strategy June 2013

How to Add a Favicon in Ruby on Rails Apps

Persistence & State. SWE 432, Fall 2016 Design and Implementation of Software for the Web

Gearthonic Documentation

Biocomputing II Coursework guidance

GitHub-Flask Documentation

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Stanko Tadić

Rocking with Racket. Marc Burns Beatlight Inc

THEBES: THE GRID MIDDLEWARE PROJECT Project Overview, Status Report and Roadmap

It was a dark and stormy night. Seriously. There was a rain storm in Wisconsin, and the line noise dialing into the Unix machines was bad enough to

CS1 Lecture 3 Jan. 22, 2018

HTML version of slides:

EPISODE 23: HOW TO GET STARTED WITH MAILCHIMP

A computer program is a set of instructions that causes a computer to perform some kind of action. It isn t the physical parts of a computer like the

Blackfin Online Learning & Development

Integrating with ClearPass HTTP APIs

A New Model for Image Distribution

RavenDB & document stores

CTI-TC Weekly Working Sessions

Building a Django Twilio Programmable Chat Application

CS 112 Project Assignment: Visual Password

moth Documentation Release Charles Thomas

nacelle Documentation

Federated AAI and the World of Tomorrow. Rion Dooley

Introduction to Domain Testing

PHP & MySQL For Dummies, 4th Edition PDF

Leaving the State: Sessionless (Stateless) Authentication in D8 with Whole Foods Market. BADCamp 2017

Penguin/Panda SEO Interview with Eric Lanchares

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

Computational Steering

Archan. Release 2.0.1

SAMPLE CHAPTER SECOND EDITION. Don Jones Jeffery Hicks Richard Siddaway MANNING

CPS122 Lecture: Course Intro; Introduction to Object-Orientation

Security. SWE 432, Fall 2017 Design and Implementation of Software for the Web

WEBINARS FOR PROFIT. Contents

Cache Coherence Tutorial

Seminar report Google App Engine Submitted in partial fulfillment of the requirement for the award of degree Of CSE

Who am I? I m a python developer who has been working on OpenStack since I currently work for Aptira, who do OpenStack, SDN, and orchestration

Web Hosting. Important features to consider

AJAX Programming Overview. Introduction. Overview

Citrix Connectivity Help. Table of Contents

Amber Weyland: [to cameraman] Just hold it there so we can see Mollie.

Security and Privacy. SWE 432, Fall 2016 Design and Implementation of Software for the Web

Chapter01.fm Page 1 Monday, August 23, :52 PM. Part I of Change. The Mechanics. of Change

Building up to today. Remote Procedure Calls. Reminder about last time. Threads - impl

THREE CORNERSTONES OF A SUCCESSFUL REAL ESTATE BUSINESS

What is version control? (discuss) Who has used version control? Favorite VCS? Uses of version control (read)

Binary, Hexadecimal and Octal number system

Hello everyone. My name is Kundan Singh and today I will describe a project we did at Avaya Labs.

Transcription:

Building on the Globus Python SDK Stephen Rosen April 11, 2017

SDK Overview The Globus SDK is a client-side library which provides language bindings for entities and methods available via web APIs.

SDK Overview The Globus SDK is a client-side library which provides language bindings for entities and methods available via web APIs. In principle, an SDK could be built for any language. Today, we only support Python. (Hence references to the Python SDK ) Everything in this presentation would apply to SDKs for other languages. They only have to maintain the same basic design.

How is the SDK Organized

How is the SDK Organized Making API resources native parts of a language requires some way of modeling those resources in that language.

How is the SDK Organized Making API resources native parts of a language requires some way of modeling those resources in that language. The SDK tries to maintain a very simple, class-based model for interacting with the service. Specifically:

How is the SDK Organized Making API resources native parts of a language requires some way of modeling those resources in that language. The SDK tries to maintain a very simple, class-based model for interacting with the service. Specifically: An adapter class for each API. e.g. TransferClient

How is the SDK Organized Making API resources native parts of a language requires some way of modeling those resources in that language. The SDK tries to maintain a very simple, class-based model for interacting with the service. Specifically: An adapter class for each API. e.g. TransferClient Authorization objects which handle API authorization, e.g. RefreshTokenAuthorizer

How is the SDK Organized Making API resources native parts of a language requires some way of modeling those resources in that language. The SDK tries to maintain a very simple, class-based model for interacting with the service. Specifically: An adapter class for each API. e.g. TransferClient Authorization objects which handle API authorization, e.g. RefreshTokenAuthorizer API Responses as GlobusResponse objects

How is the SDK Organized Making API resources native parts of a language requires some way of modeling those resources in that language. The SDK tries to maintain a very simple, class-based model for interacting with the service. Specifically: An adapter class for each API. e.g. TransferClient Authorization objects which handle API authorization, e.g. RefreshTokenAuthorizer API Responses as GlobusResponse objects Always allow access to verbatim API response data, usually as Python dicts

How is the SDK Organized Making API resources native parts of a language requires some way of modeling those resources in that language. The SDK tries to maintain a very simple, class-based model for interacting with the service. Specifically: An adapter class for each API. e.g. TransferClient Authorization objects which handle API authorization, e.g. RefreshTokenAuthorizer API Responses as GlobusResponse objects Always allow access to verbatim API response data, usually as Python dicts Contain the HTTP interface without concealing it i.e. throw Python Exceptions, but attach http status to them, etc

Why Does This Model Matter? Why am I even up here, in front of you, talking about these internal minutae of this library?

Why Does This Model Matter? Why am I even up here, in front of you, talking about these internal minutae of this library? This model is extensible, the objects are composable, and it is a viable basis for building tools against APIs of your own which authenticate with Globus Auth.

Why Does This Model Matter? Why am I even up here, in front of you, talking about these internal minutae of this library? This model is extensible, the objects are composable, and it is a viable basis for building tools against APIs of your own which authenticate with Globus Auth. All that s necessary to support a new API is a new Client class to act as an adapter.

Is This Going to Get Technical? I m Getting Woozy! Please take good care of yourselves and drink lots of water.

Is This Going to Get Technical? I m Getting Woozy!

Is This Going to Get Technical? I m Getting Woozy! I m going to get fairly technical in content here. You are not expected to be Python experts please just think about what kinds of usage we re enabling if you wish to dig in.

Is This Going to Get Technical? I m Getting Woozy! I m going to get fairly technical in content here. You are not expected to be Python experts please just think about what kinds of usage we re enabling if you wish to dig in. Even if you are comfortable with the content, the focus is not only on How we re doing things, but also on What we re trying to do. Id est, let s make programming with Globus (and maybe with your API too!) easy.

Is This Going to Get Technical? I m Getting Woozy! I m going to get fairly technical in content here. You are not expected to be Python experts please just think about what kinds of usage we re enabling if you wish to dig in. Even if you are comfortable with the content, the focus is not only on How we re doing things, but also on What we re trying to do. Id est, let s make programming with Globus (and maybe with your API too!) easy. Let s make interactive experimentation with these APIs a real possibility, and a source of joy.

The Simplest Possible Example

The Simplest Possible Example To start with, let s consider the simplest possible form of a search API. There is one, and only one, call available: GET / search?q= hello against the API at search.example.com.

The Simplest Possible Example To start with, let s consider the simplest possible form of a search API. There is one, and only one, call available: GET / search?q= hello against the API at search.example.com. What does the client for this API look like?

The Simplest Possible Example (cont.) GET /search?q = hello against search.example.com

The Simplest Possible Example (cont.) GET /search?q = hello against search.example.com from globus_sdk. base import BaseClient class SearchClient ( BaseClient ): def init (self, *args, ** kwargs ): super ( SearchClient, self ). init (self, " search ", *args, ** kwargs ) self. base_url = " https :// search. example.com " def search (self, q): return self.get ("/ search ", params ={"q": q})

The Simplest Possible Example (cont.) GET /search?q = hello against search.example.com from globus_sdk. base import BaseClient class SearchClient ( BaseClient ): def init (self, *args, ** kwargs ): super ( SearchClient, self ). init (self, " search ", *args, ** kwargs ) self. base_url = " https :// search. example.com " def search (self, q): return self.get ("/ search ", params ={"q": q}) And one could use it as in client = SearchClient () client. search (" hello ")

What About Authorization

What About Authorization Yeah...

What About Authorization Yeah... What about authorization?

What About Authorization Yeah... What about authorization? Well, out of the box your brand new client will support it just fine. Assuming you have some tokens from doing an authentication flow, then...

What About Authorization Yeah... What about authorization? Well, out of the box your brand new client will support it just fine. Assuming you have some tokens from doing an authentication flow, then... from globus_sdk import RefreshTokenAuthorizer # skip the details on the authorizer for now client = SearchClient ( authorizer=refreshtokenauthorizer (...) ) client. search (" hello, but authenticated ")

Authentication for your API Although authorizing access once a login flow is complete is pretty simple, getting that done requires a few steps. Specifically, you need

Authentication for your API Although authorizing access once a login flow is complete is pretty simple, getting that done requires a few steps. Specifically, you need your API registered in Globus as a Resource Server

Authentication for your API Although authorizing access once a login flow is complete is pretty simple, getting that done requires a few steps. Specifically, you need your API registered in Globus as a Resource Server at least one, possibly more than one, Scope for your Resource Server

Authentication for your API Although authorizing access once a login flow is complete is pretty simple, getting that done requires a few steps. Specifically, you need your API registered in Globus as a Resource Server at least one, possibly more than one, Scope for your Resource Server a client application a consumer of your API registered in Globus, with or without credentials

Authentication for your API Although authorizing access once a login flow is complete is pretty simple, getting that done requires a few steps. Specifically, you need your API registered in Globus as a Resource Server at least one, possibly more than one, Scope for your Resource Server a client application a consumer of your API registered in Globus, with or without credentials the user must complete a login flow, via your client application definition, authorizing it to access your API on his or her behalf

Authentication for your API Although authorizing access once a login flow is complete is pretty simple, getting that done requires a few steps. Specifically, you need your API registered in Globus as a Resource Server at least one, possibly more than one, Scope for your Resource Server a client application a consumer of your API registered in Globus, with or without credentials the user must complete a login flow, via your client application definition, authorizing it to access your API on his or her behalf A full discussion of all perhaps even of any of these is beyond the scope of this talk.

Customizing Error and Response Types If it s your API, you may very well have your own standards and conventions for error formats. If your API is similar enough to Globus APIs, maybe you can make do with the default error handler.

Customizing Error and Response Types If it s your API, you may very well have your own standards and conventions for error formats. If your API is similar enough to Globus APIs, maybe you can make do with the default error handler. You may want to do more sophisticated parsing of your errors. Maybe your errors always have a reason field, or a request id for logging, by way of example.

Customizing Error and Response Types If it s your API, you may very well have your own standards and conventions for error formats. If your API is similar enough to Globus APIs, maybe you can make do with the default error handler. You may want to do more sophisticated parsing of your errors. Maybe your errors always have a reason field, or a request id for logging, by way of example. The same basic principle may apply to response formats perhaps your Search API always sends back its results in an array named hits.

Custom Response Class from globus_sdk import GlobusHTTPResponse class SearchAPIResponse ( GlobusHTTPResponse ): """ Assume ( parsed ) JSON response data, handled by GlobusHTTPResponse "" def iter ( self ): """ Search responses are iterable -- iterate over search hits array """ return iter (self [" hits "])

Custom Response Class from globus_sdk import GlobusHTTPResponse class SearchAPIResponse ( GlobusHTTPResponse ): """ Assume ( parsed ) JSON response data, handled by GlobusHTTPResponse "" def iter ( self ): """ Search responses are iterable -- iterate over search hits array """ return iter (self [" hits "]) Well, that doesn t seem too hard. But it must be really tricky to get it plugged correctly into the SearchClient right?

Custom Response Class (cont.)...it must be really tricky to get it plugged correctly into the SearchClient right? Obviously, I wouldn t ask such a question unless it s really, really easy.

Custom Response Class (cont.)...it must be really tricky to get it plugged correctly into the SearchClient right? Obviously, I wouldn t ask such a question unless it s really, really easy. There are two ways: is this a default class for all responses from this API, via this client class? Or is this a specific response type for this method?

Custom Response Class (cont.)...it must be really tricky to get it plugged correctly into the SearchClient right? Obviously, I wouldn t ask such a question unless it s really, really easy. There are two ways: is this a default class for all responses from this API, via this client class? Or is this a specific response type for this method? Either class SearchClient ( BaseClient ): default_response_class = SearchAPIResponse... or def search (self, q): return self.get ("/ search ", params ={"q": q}, response_class = SearchAPIResponse ) depending on your needs.

Why would I customize responses?

Why would I customize responses? Start with the basics: class SearchAPIResponse ( GlobusHTTPResponse ): def iter ( self ): return iter (self [" hits "]) class SearchClient ( BaseClient ):... def search (self, q): return self.get ("/ search ", params ={"q": q}, response_class = SearchAPIResponse )

Why would I customize responses? Start with the basics: class SearchAPIResponse ( GlobusHTTPResponse ): def iter ( self ): return iter (self [" hits "]) class SearchClient ( BaseClient ):... def search (self, q): return self.get ("/ search ", params ={"q": q}, response_class = SearchAPIResponse ) Now we can iterate over the hits in a response: client = SearchClient () for hit in client. search (" hello "): # some helper which does pretty printing print_hit ( hit )

Continuing to Custom Error Classes Just as easily as you can set the response class for a client, you can give it a custom error class. This may merely serve to ensure that you have your own exception type, distinct from GlobusError, or it may do complex parsing.

Continuing to Custom Error Classes Just as easily as you can set the response class for a client, you can give it a custom error class. This may merely serve to ensure that you have your own exception type, distinct from GlobusError, or it may do complex parsing. Starting with from globus_sdk import GlobusAPIError class SearchAPIError ( GlobusAPIError ) """ No special methods or parsing on this specific error type """ it s easy enough to apply this class to a client class.

Continuing to Custom Error Classes Just as easily as you can set the response class for a client, you can give it a custom error class. This may merely serve to ensure that you have your own exception type, distinct from GlobusError, or it may do complex parsing. Starting with from globus_sdk import GlobusAPIError class SearchAPIError ( GlobusAPIError ) """ No special methods or parsing on this specific error type """ it s easy enough to apply this class to a client class. All that s needed is class SearchClient ( BaseClient ): error_class = SearchAPIError...

It s My API, Why Would I Do ANY of This?

It s My API, Why Would I Do ANY of This? Short answer? Auth is hard. Or, at the very least, messy.

It s My API, Why Would I Do ANY of This? As we ve started to build tools and products on top of the SDK over this past year, some things have become obvious pain points. The biggest, and most significant one to address is Authorization.

It s My API, Why Would I Do ANY of This? As we ve started to build tools and products on top of the SDK over this past year, some things have become obvious pain points. The biggest, and most significant one to address is Authorization. Reminder: Authentication is user logs in, and Authorization is credential gets sent to API

It s My API, Why Would I Do ANY of This? As we ve started to build tools and products on top of the SDK over this past year, some things have become obvious pain points. The biggest, and most significant one to address is Authorization. Reminder: Authentication is user logs in, and Authorization is credential gets sent to API We provide GlobusAuthorizer s which handle the messy authorization activities of tracking tokens, watching their expiration times, requesting renewed credentials, and generally making things just work.

It s My API, Why Would I Do ANY of This? As we ve started to build tools and products on top of the SDK over this past year, some things have become obvious pain points. The biggest, and most significant one to address is Authorization. Reminder: Authentication is user logs in, and Authorization is credential gets sent to API We provide GlobusAuthorizer s which handle the messy authorization activities of tracking tokens, watching their expiration times, requesting renewed credentials, and generally making things just work. You can re-invent these wheels if you want, but perhaps, if you do, maybe take a peek at our source... Like I said, Auth is hard.

Proof of Concept? No! We really are using this toolkit internally. Even as we work on the new Search API, we need client-side tools and scripts.

Proof of Concept? No! We really are using this toolkit internally. Even as we work on the new Search API, we need client-side tools and scripts. That SearchClient from before? Eerily similar to a SearchClient we really use.

Proof of Concept? No! We really are using this toolkit internally. Even as we work on the new Search API, we need client-side tools and scripts. That SearchClient from before? Eerily similar to a SearchClient we really use. When we first started sharing this library last year, it was just beginning to grow beyond being a toy, a prototype, a proof of concept. Today, we have enough confidence that we re building products on it. We d like you all to have the confidence in us to do the same.

I Already Use the SDK, and I Hate/Love It Some of you are already using the SDK to start building applications. There are probably many things more you want it to do, plenty of things you like about it lots, and a handful which you find unsatisfactory.

I Already Use the SDK, and I Hate/Love It Some of you are already using the SDK to start building applications. There are probably many things more you want it to do, plenty of things you like about it lots, and a handful which you find unsatisfactory. It can only be, maximally, as good as the feedback you give us. Tell us what you like. Tell us what you don t like.

I Already Use the SDK, and I Hate/Love It Some of you are already using the SDK to start building applications. There are probably many things more you want it to do, plenty of things you like about it lots, and a handful which you find unsatisfactory. It can only be, maximally, as good as the feedback you give us. Tell us what you like. Tell us what you don t like. Tell us the class names that you find annoying, the functions whose signatures are too big, the helpers which you think are missing, and tell us how it made one of your days just one is enough a little bit better. Say it on the listhost (developer-discuss@globus.org) and tell us in GitHub issues (https://github.com/globus/globus-sdk-python).

Final Notes I d like to say a special thanks to everyone, both in and out of Globus, who has made a commit, filed an issue, asked or answered a question, or voiced an opinion.

Final Notes I d like to say a special thanks to everyone, both in and out of Globus, who has made a commit, filed an issue, asked or answered a question, or voiced an opinion. Reminder: Give Us Your Feedback and Contributions Open GitHub issues and Pull Requests (https://github.com/globus/globus-sdk-python/issues) Join the discussion developer-discuss@globus.org