Example #1
0
def eskapade_run():
    """Run Eskapade.

    Top-level entry point for an Eskapade run started from the
    command line.  Arguments specified by the user are parsed and
    converted to settings in the configuration object.  Optionally, an
    interactive Python session is started when the run is finished.
    """
    from escore import process_manager, ConfigObject, DataStore
    from escore.core import execution
    from escore.core.run_utils import create_arg_parser

    # create parser for command-line arguments
    parser = create_arg_parser()
    user_args = parser.parse_args()

    # create config object for settings
    if not user_args.unpickle_config:
        # create new config
        settings = ConfigObject()
    else:
        # read previously persisted settings if pickled file is specified
        conf_path = user_args.config_files.pop(0)
        settings = ConfigObject.import_from_file(conf_path)
    del user_args.unpickle_config

    # set configuration macros
    settings.add_macros(user_args.config_files)

    # set user options
    settings.set_user_opts(user_args)

    try:
        # run Eskapade
        execution.eskapade_run(settings)
    except Exception as exc:
        logger.error('{exc}', exc=exc)
        raise

    # start interpreter if requested (--interactive on command line)
    if settings.get('interactive'):
        # set Pandas display options
        import pandas as pd
        pd.set_option('display.width', 120)
        pd.set_option('display.max_columns', 50)

        # make datastore and config available in interactive session
        ds = process_manager.service(DataStore)
        settings = process_manager.service(ConfigObject)

        # start interactive session
        from code import InteractiveConsole
        cons = InteractiveConsole(locals())
        cons.interact(
            "\nContinuing interactive session ... press Ctrl+d to exit.\n")
Example #2
0
    def eskapade_run(self,
                     macro,
                     return_status=definitions.StatusCode.Success):
        """Run Eskapade"""

        settings = process_manager.service(ConfigObject)
        settings['logLevel'] = LogLevel.DEBUG
        settings['macro'] = macro
        status = execution.eskapade_run(settings)
        self.assertTrue(status == return_status)