Commit d1a2884e authored by Sean Fitzgibbon's avatar Sean Fitzgibbon
Browse files

Fixed bug where BATCH might run SLIDE instead of APPLXFM

parent 221215a4
......@@ -19,13 +19,40 @@ import pandas as pd
from slider.slide_reg import register_slide_to_slide, apply_slide_xfm
from slider.chart_reg import register_chart_to_slide
REQUIRED_ARGS = {
'chart': ['chart', 'slide', 'slide_res'],
'slide': ['moving', 'moving_res', 'fixed', 'fixed_res'],
'applyxfm': ['moving', 'moving_res', 'fixed', 'fixed_res', 'moving_reg', 'fixed_reg', 'resampled-img'],
}
def looks_like(df):
col_names = list(df)
def has_required_args(ftype):
return all([arg in col_names for arg in REQUIRED_ARGS[ftype]])
if has_required_args('chart'):
print('Looks like a CHART csv')
return 'CHART'
elif has_required_args('applyxfm'):
print('Looks like an APPLYXFM csv')
return 'APPLYXFM'
elif has_required_args('slide') and not has_required_args('applyxfm'):
print('Looks like an SLIDE csv')
return 'SLIDE'
else:
raise RuntimeError('Unknown CSV column names')
def run_batch(csv):
# TODO: Add support for CHART and APPLYXFM csv
df = pd.read_csv(csv)
file_type = looks_like(df)
if all(item in list(df) for item in ['moving', 'moving_res', 'fixed', 'fixed_res']):
if file_type == 'SLIDE':
# csv is SLIDE
print('Batch slider_app.py SLIDE')
......@@ -33,7 +60,7 @@ def run_batch(csv):
for idx, row in df.iterrows():
register_slide_to_slide(**row)
elif all(item in list(df) for item in ['chart', 'slide', 'slide_res']):
elif file_type == 'CHART':
# csv is CHART
print('Batch slider_app.py CHART')
......@@ -41,13 +68,11 @@ def run_batch(csv):
for idx, row in df.iterrows():
register_chart_to_slide(**row)
elif all(item in list(df) for item in ['moving', 'moving_res', 'fixed', 'fixed_res', 'moving_reg', 'fixed_reg']):
elif file_type == 'APPLYXFM':
# csv is APPLYXFM
print('Batch slider_app.py APPLYXFM')
for idx, row in df.iterrows():
apply_slide_xfm(**row)
else:
raise RuntimeError('Unknown CSV column names')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment