Skip to content

Commit c5a388b

Browse files
authored
Merge pull request #114 from neuroscout/example_ridge
FIX: Fetch utils, and sorting of uploads
2 parents dc65808 + 94636af commit c5a388b

22 files changed

+399
-674
lines changed

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build:
77

88
python:
99
install:
10-
- requirements: requirements.txt
10+
- requirements: docs/requirements.txt
1111
- method: pip
1212
path: .
1313

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"python.linting.flake8Enabled": true,
3+
"python.linting.enabled": true
4+
}

docs/requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pytest>=4.2.0
2+
betamax>=0.8.1
3+
betamax_serializers>=0.2.0
4+
tqdm>=4.30.0
5+
altair>=4.0.0
6+
vega>=2.6.0
7+
pyjwt~=1.7.1
8+
requests>=2.21
9+
sphinx-rtd-theme

pyns/api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,12 @@ def _authorize(self, email=None, password=None):
137137
self._api_token = rv['access_token']
138138

139139
iat = datetime.utcfromtimestamp(
140-
jwt.decode(self._api_token, verify=False)['iat'])
140+
jwt.decode(self._api_token, verify=False,
141+
options={'verify_signature': False})['iat'])
141142
adj = iat - datetime.now()
142143
self._api_token_exp = datetime.utcfromtimestamp(
143-
jwt.decode(self._api_token, verify=False)['exp']) - adj
144+
jwt.decode(self._api_token, verify=False,
145+
options={'verify_signature': False})['exp']) - adj
144146

145147
def _check_expiry(self):
146148
if self._api_token is not None:

pyns/endpoints/analysis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,11 @@ def get_uploads(self, id, select='latest', **kwargs):
529529
uploads = self.get(id=id, sub_route='upload')
530530

531531
# Sort by date
532+
# Strip off seconds if they are there
533+
for u in uploads:
534+
if u['uploaded_at'].count(':') > 1:
535+
u['uploaded_at'] = u['uploaded_at'][:-3]
536+
532537
uploads = sorted(uploads, key=lambda x: datetime.datetime.strptime(
533538
x['uploaded_at'], '%Y-%m-%dT%H:%M'),
534539
reverse=(select == 'latest'))

pyns/fetch_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
try:
88
from bids.variables import SparseRunVariable, BIDSRunVariableCollection
99
from bids.variables.entities import RunInfo
10-
from bids.layout import BIDSLayout
10+
from bids.layout import BIDSLayout, BIDSLayoutIndexer
1111
except ImportError:
1212
SparseRunVariable = None
1313
BIDSRunVariableCollection = None
@@ -90,7 +90,7 @@ def fetch_predictors(predictor_names, dataset_name, return_type='df', rescale=Fa
9090
Scale(collection, predictor_names)
9191

9292
if resample:
93-
collection = collection.to_dense().resample('TR')
93+
collection = collection.to_dense('TR')
9494

9595
if return_type == 'df':
9696
collection = collection.to_df()
@@ -177,7 +177,7 @@ def install_dataset(dataset_dir, preproc_address, no_get=False):
177177
return preproc_dir
178178

179179

180-
def fetch_images(dataset_name, data_dir, no_get=False, datalad_jobs=-1,
180+
def fetch_images(dataset_name, data_dir, no_get=False, datalad_jobs='auto',
181181
preproc_address=None, **kwargs):
182182
""" Fetch preprocessed images from a Neuroscout dataset.
183183
Installs dataset using DataLad if not already installed.

tests/cassettes/analysis.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"http_interactions": [
33
{
4-
"recorded_at": "2022-07-26T00:02:45",
4+
"recorded_at": "2023-10-05T20:35:16",
55
"request": {
66
"body": {
77
"encoding": "utf-8",
@@ -15,7 +15,7 @@
1515
"gzip, deflate, br"
1616
],
1717
"Authorization": [
18-
"JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NTkzOTg1NTIsImlhdCI6MTY1ODc5Mzc1MiwibmJmIjoxNjU4NzkzNzUyLCJpZGVudGl0eSI6MX0.55A1Lj_YkR1rnvtVxXnDkHuyMbY8I5xRYvD38Rh9NXY"
18+
"JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2OTcxNDI5MDMsImlhdCI6MTY5NjUzODEwMywibmJmIjoxNjk2NTM4MTAzLCJpZGVudGl0eSI6MX0.hHABEu1rQp90CjzyOR4_lNzu9NFmGMYqo8tTE3tnlDA"
1919
],
2020
"Connection": [
2121
"keep-alive"
@@ -35,7 +35,7 @@
3535
},
3636
"response": {
3737
"body": {
38-
"base64_string": "H4sIAAAAAAAAA31Sy2rDMBC89zP2rIDj0rTxLTQNFJoeEh8KIRjFXhM1siT0CDXG/96V3ZT0kPrkHWlmZ3bVQWmRe6wK7iGDNEnTSfI4SWd5kmQJMKi45w59ISrI5lSiK60wXmgFmQpSMjhydxyOQT+5QyCO1OUJCai5dMig0RVKyDp4VSb4+LMJxN5N9wy24fCJJYE7sKJK4jcFwnPuTqQoRY3QM3jnDVJpWo/OF1xx2TrhqNXWo3HE7uBZK2+587EigWVomvYK6yBvTdTwUe8Nz9HSYITB+mLwI/pwBrE8wp6u5ZYrV2vb8Bh4UO5Zd1t79bJeXMtf0v1L+mNoOY4b+tieBidqcXs36tZU1LkodVDEShgYblGNCxwXZixWovxJBPALaBsTTtN58rCPoDjTw4DM20BLtGHIn97P6Mx57kMkLzeLVU4KLhwa4S/PaGwTHFq6gl+8MRKLoezvvgEbyNMlcQIAAA==",
38+
"base64_string": "H4sIAAAAAAAAA31Sy2rDMBC89zP2rIDtkEJ8C00DhaaHxIdCCEaR10SNJQs9Qo3xv3dlN6U9pD55R5rZmV31ICxyj1XJPeSQJdl8liazZFFkST4HBhX33KEvZQX5kkp0wkrjZash16FpGJy5O4/HIJSxijhNKy5IQM0bhwxUW2EDeQ8v2gQff3aB2If0yGAfTh8oCDyAlVUSvxQIL7i7kGIja4SBwRtXSKXpPDpfcs2bzklHrfYejSN2D0+t9pY7HysSWAelul9YD0VnooaPeq94jZZGIwy2N4Pv0YcziOIMR7pWWK5d3VrFY+BReWD9fe3N83b1W/6W7l/SH0PradwwxPY0OFnL+7vR96air6VogyZWwsBwi3pa4LQwY7GS4jsRwA/Q2pgwzZbJ4hhBeaWHAbm3gZZow5g/mz/SmfPch0he71abghRcOCnpb89oahMcWrqCn1yZBsuxHB6+AGVJPhBxAgAA",
3939
"encoding": "utf-8",
4040
"string": ""
4141
},
@@ -53,7 +53,7 @@
5353
"application/json"
5454
],
5555
"Date": [
56-
"Tue, 26 Jul 2022 00:02:45 GMT"
56+
"Thu, 05 Oct 2023 20:35:16 GMT"
5757
],
5858
"Server": [
5959
"nginx/1.21.6"

tests/cassettes/analysis_object.json

Lines changed: 15 additions & 15 deletions
Large diffs are not rendered by default.

tests/cassettes/auth.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"http_interactions": [
33
{
4-
"recorded_at": "2022-07-26T00:02:32",
4+
"recorded_at": "2023-10-05T20:35:03",
55
"request": {
66
"body": {
77
"encoding": "utf-8",
@@ -32,7 +32,7 @@
3232
},
3333
"response": {
3434
"body": {
35-
"base64_string": "H4sIAAAAAAAAAxWM0Q6CIAAA3/sMP8BJZavenDaDEpepg15cEktArWWZ0vr36PG2u/tYZ8Z41xXPm+Kttbb4iBxOPBELtMvBQex9VJUh+zPMNARYoJVtpJpvjSQ3U5wqHadXgFPYwaauLj5cRCkFccDcSDMQibcoG9RAeRuwzOZYK411Nprx/RTmr0tYO/xoGuLYruuBvSyoSsCj7Z/5QNpAbV9jVNIldIeE9sFsmVQrTKj1nfwA8qMS37wAAAA=",
35+
"base64_string": "H4sIAAAAAAAAAxWM0Q6CIAAA3/sMP6BpacveSEyhwFXotBdXxiaIWakraf179njb3X2Mc1Hwts27puI3Y2XwAZs8BSISeJtYe7HzcHkJij+jWCOLCuxOR0nxcJSkP4tY8aYQOQSSFtWqvHpoQVjmUBnrCPovMrzEpcY1ks2bympGGbEJA3oc309B0l8DZfLj2KTmtAzB2u+t5/7ump7UQ3Swc0V179JNHZDs0Sw75s+7m4LA+E5+szv14bwAAAA=",
3636
"encoding": "utf-8",
3737
"string": ""
3838
},
@@ -50,7 +50,7 @@
5050
"application/json"
5151
],
5252
"Date": [
53-
"Tue, 26 Jul 2022 00:02:32 GMT"
53+
"Thu, 05 Oct 2023 20:35:03 GMT"
5454
],
5555
"Server": [
5656
"nginx/1.21.6"

tests/cassettes/dataset.json

Lines changed: 17 additions & 17 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)