GithubHelp home page GithubHelp logo

pyns's Introduction

pyNS ๐ŸŒฒ

Python package codecov docs

pyNS is a python library to easily interact with the Neuroscout API.

pyNS enables advanced used cases not supported by the neuroscout.org web-based analysis builder, such as batch-creation of analyses, meta-analytic applications, as well as supporting the operations of the neuroscout-cli

Installation

Use pip to install it:

pip install pyns

Documentation ๐Ÿ“š

Full documentation can be found at readthedocs.

For API docs, check out the Swagger API UI.

For a tutorial see this jupyter notebook example.
You can also follow the Neuroscout Paper's analyses in this interactive jupyter book.

Testing

We use pytest for testing, and betamax to record HTTP requests used in tests.
To re-run tests locally set theUSER_TEST_EMAIL and USER_TEST_PWD environment variables with valid API credentials.

pyns's People

Contributors

adelavega avatar jsmentch avatar rbroc avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kan-k jsmentch rbroc

pyns's Issues

Decide if/how to handle flask/requests Client differences

One idea with this library is that it could also be used internally in neuroscout to test the API itself.
In fact, this library is so far based on the internal flask client wrapper I use in the neuroscout tests.

However, one difficulty is that the flask client (which is used to test in flask without testing the live URL), is slightly different from requests.

We need to decide if its worthwhile to design the library to deal with both clients. There may be a way to subclass the client over in the main neuroscout repo to deal with this, but push off the responsibility over there so that this library stays cleaner.

Use consistent method names that match API routes

Currently, we have ns.analyses.full() and ns.analyses.get_report(). Methods should probably all follow the same naming conventions, and ideally match the API (so, e.g., the first above should be ns.analyses.get_full().

requests slowing things down?

At least some routes in pyns are extremely slow compared to directly hitting the API (e.g., via the browser). It looks like the bottleneck is in requests, because just doing something like requests.get(https://neuroscout.org/api/analyses/Mzq74/full) is very slow on my machine (several seconds). Probably worth looking into.

In depth tutorials/notebooks

Let's add some jupyter notebooks or tutorials covering some use cases of pyNS.

One example is how to deal with categorical variables.

Add single sign on

The frontend supports SSO, but pyNS currenly only supports users created through our db.

Adding SSO directly from pyNS would be useful.

Add convenience function to fill/clear/push/pull

Currently it's a bit cumbersome:

paranoia = life.clone()
paranoia.dataset_id = 19
paranoia.runs = []
paranoia.predictors = []
paranoia.push()
paranoia.fill()

That could all be made into a little helper function in which you provide a dataset_id

Add exception handling for requests

Requests usually will just return an error code, instead of throw exception.

Instead, lets throw exceptions, and have the calls return the content.

Add _repr_ to objects

Currently, they are not terribly useful:
<pyns.models.analysis.Analysis at 0x7f163c718c50>

Add betamax support

Add betamax to cache requests in the tests. Also, think about whether the current "test user" is a good idea, or might be insecure.

pin altair/vegalite version

Analysis reports are generated for the following versions:
altair 4.0.0
vega-lite 2.6.0

Note that when upgrading to these versions, there's no need to call notebook renderer.

inconsistent name for RMS predictor

RMS is coded with name field = 'rms' for a bunch of datasets (SchematicNarrative, Sherlock, SherlockMerlin) and as 'rmse' for all others, which yields issues with pyNS-based queries.

Add OO Interface for Analysis creation

To make pyNS more user friendly, it would be useful if the library returns python objects that mirror the JSON response. These objects could have methods associated with them to save to the API directly.

For example

analysis = api.Analysis(name='new_analysis')
analysis.create()
print(analysis.hash_id)
    5xdj45
analysis.predictors = [124, 421, 246]
analysis.save()
analysis.compile()
print(analysis.status())
   PENDING
print(analysis.status())
   FINISHED

Add Travis-CI

It would be good to add Travis-CI support for CI testing.

Cache requests

We should consider caching requests in the client, as some routes can take a long time to retrieve. Since you're already using requests (which btw should be added to requirements), a super simple solution I see no downside to would be to add requests-cache.

Automatically re-authorize

Currently, once your api token is stale, protected calls will just fail, and you have to manually re-authorize.

It'd be nice if the API checks that the token is expired, and automatically re-authorizes when possible (i.e. the keys are in the os environment)

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.