Ejemplo n.º 1
0
def main():
    argparse = ArgumentParser(
        description=
        'Upgrade ELOAD config to a format compatible with current automation')
    argparse.add_argument('--eload',
                          required=True,
                          type=int,
                          help='The ELOAD number for this submission')
    argparse.add_argument('--analysis_alias',
                          required=False,
                          type=str,
                          help='Analysis alias to use')
    argparse.add_argument(
        '--debug',
        action='store_true',
        default=False,
        help='Set the script to output logging information at debug level')

    args = argparse.parse_args()

    log_cfg.add_stdout_handler()
    if args.debug:
        log_cfg.set_log_level(logging.DEBUG)

    # Load the config_file from default location
    load_config()

    with Eload(args.eload) as eload:
        eload.upgrade_config_if_needed(args.analysis_alias)
Ejemplo n.º 2
0
 def setUp(self):
     config_file = os.path.join(self.resources_folder, 'submission_config.yml')
     load_config(config_file)
     # Need to set the directory so that the relative path set in the config file works from the top directory
     os.chdir(ROOT_DIR)
     self.eload = Eload(55)
     self.updated_config = EloadConfig(os.path.join(self.eload.eload_dir, 'updated_config.yml'))
     # Used to restore test config after each test
     self.original_cfg = deepcopy(self.eload.eload_cfg.content)
     self.original_updated_cfg = deepcopy(self.updated_config.content)
     self.updated_config.set('version', value=__version__)
    def test_create_log_file(self):
        # Creating a second eload object to test whether the logging file handler
        # has been created twice
        eload2 = Eload(self.eload.eload_num)

        self.eload.info("Testing the creation of logging file")

        assert os.path.exists(self.logfile_name)

        with open(self.logfile_name, "r") as test_logfile:
            k = [i for i in test_logfile.readlines() if "Testing the creation of logging file" in i]

            # Checking if the log message is written only once in the log file
            assert len(k) == 1
 def setUp(self):
     config_file = os.path.join(self.resources_folder, 'submission_config.yml')
     load_config(config_file)
     # Need to set the directory so that the relative path set in the config file works from the top directory
     os.chdir(ROOT_DIR)
     self.eload = Eload(55)
     self.original_config = EloadConfig(os.path.join(self.eload.eload_dir, 'original_config.yml'))
     self.updated_config = EloadConfig(os.path.join(self.eload.eload_dir, 'updated_config.yml'))
     # Setup the config
     self.eload.eload_cfg.content = deepcopy(self.original_config.content)
     self.original_updated_cfg = deepcopy(self.updated_config.content)
     self.updated_config.set('version', value=__version__)
     # Get the log file name
     self.logfile_name = os.path.join(self.eload.eload_dir, str(self.eload.eload) + "_submission.log")
    def test_context_manager(self):
        with Eload(55) as eload:
            assert eload.eload_cfg.query('submission',
                                         'assembly_accession') is None
            eload.eload_cfg.set('submission',
                                'assembly_accession',
                                value='GCA_00009999.9')
            assert eload.eload_cfg.query(
                'submission', 'assembly_accession') == 'GCA_00009999.9'

        # Config file gets written
        with open(eload.eload_cfg.config_file) as open_file:
            config_dict = yaml.safe_load(open_file)
            assert config_dict['submission'][
                'assembly_accession'] == 'GCA_00009999.9'