def _get_mapping(self, dst): from dallinger.config import initialize_experiment_package initialize_experiment_package(dst) from dallinger.experiment import load exp_class = load() extra_files = getattr(exp_class, "extra_files", None) if extra_files is None: try: from dallinger_experiment.experiment import extra_files except ImportError: try: from dallinger_experiment.dallinger_experiment import extra_files except ImportError: pass if extra_files is not None: for src, filename in extra_files(): filename = filename.lstrip("/") if os.path.isdir(src): for dirpath, dirnames, filenames in os.walk(src, topdown=True): for fn in filenames: dst_fileparts = [dst, filename] + dirnames + [fn] dst_filepath = os.path.join(*dst_fileparts) yield ( os.path.join(dirpath, fn), dst_filepath, ) else: dst_filepath = os.path.join(dst, filename) yield (src, dst_filepath)
def register_extra_parameters(self): initialize_experiment_package(os.getcwd()) extra_parameters = None # Import and instantiate the experiment class if available # This will run any experiment specific parameter registrations from dallinger.experiment import load try: exp_klass = load() except ImportError: exp_klass = None exp_params = getattr(exp_klass, "extra_parameters", None) if exp_params is not None and not self._experiment_params_loaded: exp_params() self._experiment_params_loaded = True try: from dallinger_experiment.experiment import extra_parameters except ImportError: try: from dallinger_experiment.dallinger_experiment import extra_parameters except ImportError: try: from dallinger_experiment import extra_parameters except ImportError: pass if extra_parameters is not None and not self._module_params_loaded: extra_parameters() self._module_params_loaded = True
def _loaded_experiment(args): from dallinger import experiment klass = experiment.load() return klass(args)
from .utils import nocache config = get_config() if not config.ready: config.load() # Initialize the Dallinger database. session = db.session # Connect to the Redis queue for notifications. q = Queue(connection=conn) app = Flask('Experiment_Server') Experiment = experiment.load() """Load the experiment's extra routes, if any.""" try: from dallinger_experiment import extra_routes except ImportError: pass else: app.register_blueprint(extra_routes) """Basic routes.""" @app.route('/') def index(): """Index route""" abort(404)