GithubHelp home page GithubHelp logo

martelogan / tapioca-cbrain Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 8 KB

Simple Python wrapper for CBrain (https://portal.cbrain.mcgill.ca) implemented as a flavor of tapioca (https://tapioca-wrapper.readthedocs.io/)

License: MIT License

Makefile 16.45% Python 83.55%
cbrain cbrain-api client python

tapioca-cbrain's Introduction

Tapioca cbrain

Installation

Note: pending stable deployment on pypi, we recommend the following developer install.

git clone https://github.com/martelogan/tapioca-cbrain.git
cd tapioca-cbrain
python setup.py install

Ideally, it is advised to manage Python virtual environments via conda in order to safely segregate module dependencies. In this case, it is recommended to locallize pip installations during conda environment creation, to avoid dependency conflicts, by instantiating the environment with its own pip setup, ร  la conda create --name custom_venv_name pip then activating it (linux example: source activate custom_venv_name)

Getting Started

from tapioca_cbrain import Cbrain

# assuming credentials known in advance:
api = Cbrain(cbrain_api_token="<your_api_token_string>")

# get user profile details as response object
user_response_obj = api.users(id='<your_user_id>').get()

# print user profile dict
user_data = user_response_obj().data
print user_data

# post to create a new CBrain session, and store response (with credentials)
session_payload = {'login': '<your_username_string>', 'password': '<your_password_string>'}
session_response_obj = api.session(id='').post(data=session_payload)
session_data = session_response_obj().data

# credential print statements
print session_data['cbrain_api_token']
print session_data['user_id']

Jupyter Notebook

Through this simple (minimalist) wrapper, our workflow can readily take advantage of Jupyter Notebook.

For example, listing available endpoints by typing api. + pressing tab

>>> api.
api.bourreaux                    api.data_providers               api.data_providers_browse
api.data_providers_delete        api.data_providers_isalive       api.data_providers_register
...

Or typing api.users? + presssing enter to get

>>> api.users?
Docstring:
Automatic generated __doc__ from resource_mapping.
Resource: {id}/
Docs: https://portal.cbrain.mcgill.ca/swagger#!/Users
...

Disclaimer

Significant work remains to ensure complete api support, but this should suffice to get up & running.

A quick demo CLI gist demonstrates how we could automate session creation and apply this wrapper to easily expose our api to end-users.

Note also, for the sake of this project, a simple (presently unmaintained) swagger2tapioca utility gist was written to convert generic OpenAPI/Swagger v2.0(JSON) to tapioca resource_mapping.py files (ie. effectively automate tapioca wrapper creation)

tapioca-cbrain's People

Contributors

martelogan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.