Skip to content
Snippets Groups Projects
Commit c21655a1 authored by Nathaniel Kofalt's avatar Nathaniel Kofalt
Browse files

Merge pull request #265 from scitran/gear-config

Gear config
parents 1b732076 aec57e60
No related branches found
No related tags found
No related merge requests found
......@@ -49,14 +49,23 @@ Category = util.Enum('Category', {
Gear = namedtuple('gear', ['name', 'category', 'input'])
Gears = [
Gear('dicom_mr_classifier', Category.classifier, {'type': 'file', 'location': '/', 'uri': '/opt/flywheel-temp/dicom_mr_classifier-bali.3.0-rc.2.tar'}),
Gear('dcm_convert', Category.converter, {'type': 'file', 'location': '/', 'uri': '/opt/flywheel-temp/dcm_convert-bali.3.0-rc.2.tar' }),
Gear('qa-report-fmri', Category.qa, {'type': 'file', 'location': '/', 'uri': '/opt/flywheel-temp/qa-report-fmri-bali.3.0-rc.2.tar' })
]
def get_gears():
"""
Fetch the install-global gears from the database
"""
gear_doc = config.db.static.find_one({'_id': 'gears'})
gears_map = gear_doc['gear_list']
gears = []
for g in gears_map:
cat_string = g['category']
gears.append(Gear(g['name'], Category[cat_string], g['input']))
return gears
def get_gear_by_name(name):
for gear in Gears:
for gear in get_gears():
if gear.name == name:
return gear
raise Exception("Unknown gear " + name)
......
import fnmatch
import json
from . import jobs
from . import config
......@@ -34,27 +35,12 @@ MATCH_TYPES = [
'container.has-type'
]
# TODO: replace with default rules, which get persisted, maintained, upgraded, and reasoned intelligently
HARDCODED_RULES = [
{
'alg': 'dicom_mr_classifier',
'all': [
['file.type', 'dicom']
]
},
{
'alg': 'dcm_convert',
'all': [
['file.type', 'dicom']
]
},
{
'alg': 'qa-report-fmri',
'all': [
['file.type', 'nifti']
]
}
]
def get_base_rules():
"""
Fetch the install-global gear rules from the database
"""
rule_doc = config.db.static.find_one({'_id': 'rules'})
return rule_doc['rule_list']
def _log_file_key_error(file_, container, error):
log.warning('file ' + file_.get('name', '?') + ' in container ' + str(container.get('_id', '?')) + ' ' + error)
......@@ -137,7 +123,7 @@ def create_jobs(db, container, container_type, file_):
rules = get_rules_for_container(db, container)
# Add hardcoded rules that cannot be removed or changed
for hardcoded_rule in HARDCODED_RULES:
for hardcoded_rule in get_base_rules():
rules.append(hardcoded_rule)
for rule in rules:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment