Skip to content

Commit e066b77

Browse files
authored
Merge pull request #50 from neuroscout/enh-user-pred
Add user predictors route
2 parents 4113b4d + 1c6c25a commit e066b77

File tree

4 files changed

+199
-116
lines changed

4 files changed

+199
-116
lines changed

pyns/models/analysis.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ def create_analysis(self, *, name, dataset_name, predictor_names,
200200
predictors = [p['id'] for p in self._client.predictors.get(
201201
run_id=run_id, name=predictor_names)]
202202

203+
# Get Predictor IDs
204+
predictors += [p['id'] for p in self._client.user.get_predictors(
205+
run_id=run_id, name=predictor_names)]
206+
203207
if len(predictors) != len(predictor_names):
204208
raise ValueError(
205209
"Not all named predictors could be found for the "

pyns/models/user.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
"""Provides the User class."""
22
from .base import Base
33

4+
45
class User(Base):
5-
_base_path_= 'user'
6-
_auto_methods_= ('get', 'post', 'put')
6+
_base_path_ = 'user'
7+
_auto_methods_ = ('get', 'post', 'put')
8+
9+
def get_predictors(self, **kwargs):
10+
""" Get NeuroVault uploads associated with this analysis
11+
:param str id: Analysis hash_id.
12+
:return: client response object
13+
"""
14+
return self.get(sub_route='predictors', **kwargs)

tests/cassettes/analysis_object.json

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"http_interactions": [
33
{
4-
"recorded_at": "2019-09-12T22:54:04",
4+
"recorded_at": "2019-09-13T22:27:35",
55
"request": {
66
"body": {
77
"encoding": "utf-8",
@@ -47,7 +47,7 @@
4747
"application/json"
4848
],
4949
"Date": [
50-
"Thu, 12 Sep 2019 22:54:04 GMT"
50+
"Fri, 13 Sep 2019 22:27:35 GMT"
5151
],
5252
"Server": [
5353
"nginx/1.15.6"
@@ -79,7 +79,7 @@
7979
}
8080
},
8181
{
82-
"recorded_at": "2019-09-12T22:54:04",
82+
"recorded_at": "2019-09-13T22:27:35",
8383
"request": {
8484
"body": {
8585
"encoding": "utf-8",
@@ -125,7 +125,7 @@
125125
"application/json"
126126
],
127127
"Date": [
128-
"Thu, 12 Sep 2019 22:54:04 GMT"
128+
"Fri, 13 Sep 2019 22:27:35 GMT"
129129
],
130130
"Server": [
131131
"nginx/1.15.6"
@@ -157,7 +157,7 @@
157157
}
158158
},
159159
{
160-
"recorded_at": "2019-09-12T22:54:04",
160+
"recorded_at": "2019-09-13T22:27:35",
161161
"request": {
162162
"body": {
163163
"encoding": "utf-8",
@@ -203,7 +203,7 @@
203203
"application/json"
204204
],
205205
"Date": [
206-
"Thu, 12 Sep 2019 22:54:04 GMT"
206+
"Fri, 13 Sep 2019 22:27:35 GMT"
207207
],
208208
"Server": [
209209
"nginx/1.15.6"
@@ -235,7 +235,78 @@
235235
}
236236
},
237237
{
238-
"recorded_at": "2019-09-12T22:54:04",
238+
"recorded_at": "2019-09-13T22:27:35",
239+
"request": {
240+
"body": {
241+
"encoding": "utf-8",
242+
"string": ""
243+
},
244+
"headers": {
245+
"Accept": [
246+
"*/*"
247+
],
248+
"Accept-Encoding": [
249+
"gzip, deflate"
250+
],
251+
"Authorization": [
252+
"JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1Njg5MzM2NDQsImlhdCI6MTU2ODMyODg0NCwibmJmIjoxNTY4MzI4ODQ0LCJpZGVudGl0eSI6MX0.2d1tXjaviiP005FWpIoYwoNHaGG9YM4B8Zf51AR6QlU"
253+
],
254+
"Connection": [
255+
"keep-alive"
256+
],
257+
"User-Agent": [
258+
"python-requests/2.21.0"
259+
]
260+
},
261+
"method": "GET",
262+
"uri": "https://neuroscout.org/api/user/predictors?run_id=126&name=brightness"
263+
},
264+
"response": {
265+
"body": {
266+
"encoding": null,
267+
"string": "[]\n"
268+
},
269+
"headers": {
270+
"Access-Control-Allow-Origin": [
271+
"*"
272+
],
273+
"Connection": [
274+
"keep-alive"
275+
],
276+
"Content-Length": [
277+
"3"
278+
],
279+
"Content-Type": [
280+
"application/json"
281+
],
282+
"Date": [
283+
"Fri, 13 Sep 2019 22:27:35 GMT"
284+
],
285+
"Server": [
286+
"nginx/1.15.6"
287+
],
288+
"Strict-Transport-Security": [
289+
"max-age=63072000; includeSubDomains; preload"
290+
],
291+
"X-Content-Type-Options": [
292+
"nosniff"
293+
],
294+
"X-Frame-Options": [
295+
"DENY"
296+
],
297+
"X-XSS-Protection": [
298+
"1; mode=block"
299+
]
300+
},
301+
"status": {
302+
"code": 200,
303+
"message": "OK"
304+
},
305+
"url": "https://neuroscout.org/api/user/predictors?run_id=126&name=brightness"
306+
}
307+
},
308+
{
309+
"recorded_at": "2019-09-13T22:27:35",
239310
"request": {
240311
"body": {
241312
"encoding": "utf-8",
@@ -269,7 +340,7 @@
269340
},
270341
"response": {
271342
"body": {
272-
"base64_string": "H4sIAAAAAAAAA3WSTW/CMAyG7/sZPpeJVmKD3qahSZvGDtDDJISq0JqRkSZV7HRCaP99DgU0Dtyi1x/vYzsHKOaQp/ejBCqPirEuFUMO2TCdDIaTQZoVWZaPIIFasSLkUteQS3aNVHndsnYWchuMSWCraHsMw2z61vxIjXHVDkXYKEOYQONqNJAf4NW2geNjEdbfWMlzCdkYVgkUinaxAXqj7cx1GuE3gQ/VoKjtnpG4VFaZPWkSgwVjS1J9gKfA7tlZ9opYFPZBDP8JS2n+jl30h3mwUjs703xG+7XXX1u2SAQrcSy8srRxvlFxwt7iRH2de4ETr86ZTnil/gbPGWDa7/KYGreiN/r24u2t4Vvl0fYH6Q/Qeqx1dQIGuAjOxwHS7DEbr6KoOzn0mckH20cfJEasOMTi6fzppZAOFNaN5vO36G2EfVeeqK4OdfcHot3RUU4CAAA=",
343+
"base64_string": "H4sIAAAAAAAAA3WSTWvCQBCG7/0Zc47FRNpqblJpKTSlaA4FkbBJxrp1sxt2ZwMi/e+dNUbqwdvyzsf7zMweIV9CGt8/RFBZFIR1IQhSSMbxbDSejeJJniRpAhHUgoRDKmQNKWfX6CorW5JGQ6q9UhHshNudwpBNXj8zrlGm2iMLW6EcRtCYGhWkR3jTrafwWPnyByt+riGZwiaCXLh9aIBWSZ2ZTiL8RvAhGmS1PRA6KoQW6uCkY4MVYeu4+ghzT+bZaLLCEStkPRv+E9bc/B274A9Lr7k2G2i+gn1p5feONDoHG3bMrdBua2wjwoS9xZn6OvcCx16dUR3zcv0NngFg0e/ylBq2Irfy9uL1reFbYVH3B+kP0FqsZXUGBrgIxoYB4uQpmW6CKDs+9MBkve6jjxxzJMiH4sVy/pJzB+fLRtLwLXobZt8XZ6qrQ939AdazcNhOAgAA",
273344
"encoding": null,
274345
"string": ""
275346
},
@@ -287,7 +358,7 @@
287358
"application/json"
288359
],
289360
"Date": [
290-
"Thu, 12 Sep 2019 22:54:04 GMT"
361+
"Fri, 13 Sep 2019 22:27:35 GMT"
291362
],
292363
"Server": [
293364
"nginx/1.15.6"

0 commit comments

Comments
 (0)