Commit 250575ef authored by Médéric Boquien's avatar Médéric Boquien

Implement a simple verification of the list of modules to warn the user if...

Implement a simple verification of the list of modules to warn the user if some mandatory modules are missing.
parent 4cd225be
......@@ -4,7 +4,7 @@
# Author: Yannick Roehlly
import pkgutil
import collections
from collections import Iterable, OrderedDict
import multiprocessing as mp
from textwrap import wrap
......@@ -70,7 +70,7 @@ def evaluate_description(description):
if description.startswith('eval '):
results = eval(description[4:])
# If the evaluation lead to a single value, we put it in a list.
if not isinstance(results, collections.Iterable):
if not isinstance(results, Iterable):
results = [results]
elif description.startswith('range '):
start, stop, step = [float(item) for item
......@@ -219,6 +219,8 @@ class Configuration(object):
self.config['sed_creation_modules'].comments[module_name] = [
creation_modules.get_module(module_name, blank=True).comments]
# Configuration for the analysis method
self.config['analysis_configuration'] = {}
self.config.comments['analysis_configuration'] = ["", ""] + wrap(
......@@ -276,3 +278,39 @@ class Configuration(object):
return configuration
def check_modules(self):
"""Make a basic check to ensure that some required modules are present.
Otherwise we emit a warning so the user knows their list of modules is
suspicious. We do not emit an exception as they may be using an
unofficial module that is not in our list
modules = OrderedDict((('SFH', ['sfh2exp', 'sfhdelayed', 'sfhfromfile',
('SSP', ['bc03', 'm2005']),
('nebular', ['nebular']),
('dust attenuation', ['dustatt_calzleit',
('dust emission', ['casey2012', 'dale2014',
'dl2007', 'dl2014']),
('AGN', ['dale2014', 'fritz2006']),
('radio', ['radio']),
('redshift', ['redshifting'])))
comments = {'SFH': "ERROR! Choosing one SFH modules is mandatory.",
'SSP': "ERROR! Choosing one SSP is mandatory.",
'nebular': "WARNING! Choosing the nebular module is "
"recommended. Without it the Lyman continuum "
"is left untouched.",
'dust attenuation': "No dust attenuation module found.",
'dust emission': "No dust attenuation module found.",
'AGN': "No AGN module found.",
'radio': "No radio module found.",
'redshift': "ERROR! No redshifting module found"}
for module in modules:
if all([user_module not in modules[module] for user_module in
print("{} Options are: {}.".
format(comments[module], ', '.join(modules[module])))
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