Skip to content

Commit 011e574

Browse files
committed
Clean up a few measurement references
1 parent 6b4bcd2 commit 011e574

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

api/handlers/modalityhandler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from ..web import base
22
from .. import config
33
from ..auth import require_login, require_admin
4-
from ..dao import containerstorage, APINotFoundException, APIValidationException
4+
from ..dao import containerstorage
5+
from ..web.errors import APINotFoundException, APIValidationException
56
#from ..validators import validate_data
67

78
log = config.log

api/jobs/queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def enqueue_job(job_map, origin, perm_check_uid=None):
229229
cr = create_containerreference_from_filereference(inputs[x])
230230

231231
# Whitelist file fields passed to gear to those that are scientific-relevant
232-
whitelisted_keys = ['info', 'tags', 'measurements', 'mimetype', 'type', 'modality', 'size']
232+
whitelisted_keys = ['info', 'tags', 'classification', 'mimetype', 'type', 'modality', 'size']
233233
obj_projection = { key: obj[key] for key in whitelisted_keys }
234234

235235
config_['inputs'][x] = {

api/jobs/rules.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fnmatch
22
import re
3+
import itertools
34

45
from .. import config
56
from ..types import Origin
@@ -33,15 +34,15 @@
3334
# 'value': '*.dcm'
3435
# },
3536
# {
36-
# 'type': 'file.measurements', # Match any of the file's measurements
37+
# 'type': 'file.classification', # Match any of the file's classification
3738
# 'value': 'diffusion'
3839
# },
3940
# {
4041
# 'type': 'container.has-type', # Match the container having any file (including this one) with this type
4142
# 'value': 'bvec'
4243
# },
4344
# {
44-
# 'type': 'container.has-measurement', # Match the container having any file (including this one) with this measurement
45+
# 'type': 'container.has-classification', # Match the container having any file (including this one) with this classification
4546
# 'value': 'functional'
4647
# }
4748
# ]
@@ -86,10 +87,11 @@ def match(value):
8687
elif match_type == 'file.name':
8788
return match(file_['name'])
8889

89-
# Match any of the file's measurements
90-
elif match_type == 'file.measurements':
90+
# Match any of the file's classification
91+
elif match_type == 'file.classification':
9192
if match_param:
92-
return any(match(value) for value in file_.get('measurements', []))
93+
classification_values = list(itertools.chain.from_iterable(file_.get('classification', {}).itervalues()))
94+
return any(match(value) for value in classification_values)
9395
else:
9496
return False
9597

@@ -102,11 +104,12 @@ def match(value):
102104

103105
return False
104106

105-
# Match the container having any file (including this one) with this measurement
106-
elif match_type == 'container.has-measurement':
107+
# Match the container having any file (including this one) with this classification
108+
elif match_type == 'container.has-classification':
107109
if match_param:
108110
for c_file in container['files']:
109-
if any(match(value) for value in c_file.get('measurements', [])):
111+
classification_values = list(itertools.chain.from_iterable(c_file.get('classification', {}).itervalues()))
112+
if any(match(value) for value in classification_values):
110113
return True
111114

112115
return False

api/placer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def finalize(self):
512512

513513
# OPPORTUNITY: packfile endpoint could be extended someday to take additional metadata.
514514
'modality': None,
515-
'measurements': [],
515+
'classification': {},
516516
'tags': [],
517517
'info': {},
518518

api/upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def process_upload(request, strategy, container_type=None, id_=None, origin=None
129129

130130
'type': None,
131131
'modality': None,
132-
'measurements': [],
132+
'classification': {},
133133
'tags': [],
134134
'info': {}
135135
}

raml/schemas/definitions/rule.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"enum": [
1212
"file.type",
1313
"file.name",
14-
"file.measurements",
14+
"file.classification",
1515
"container.has-type",
16-
"container.has-measurement"
16+
"container.has-classification"
1717
]
1818
},
1919
"value": { "type": "string" },

0 commit comments

Comments
 (0)