# Path: util/logger.py
# class _MyFormatter(logging.Formatter):
#     def format(self, record):
# def set_file_handler(path=None, prefix='', time_str=''):
# _LOGGING_METHOD = ['info', 'warning', 'error', 'critical',
#                    'warn', 'exception', 'debug']


import numpy as np
import init_path
import os
import glob
from util import logger
from . import species2species
            rank_info
        )

        # save the weights for the first species
        for i_species in self.species[::-1][:self.args.save_top_species]:
            np.save(
                os.path.join(
                    path, str(self.current_generation) + '_' +
                    str(i_species['SpcID'])
                ),
                {key: i_species[key] for key in KEY_LIST['species_data']}
            )

    def load(self, load_path):
        # the number of species, the number of generation
        load_path = os.path.abspath(os.path.join(self.base_path, load_path))
        species_list = glob.glob(load_path + '_*.npy')

        self.current_generation = os.path.basename(load_path).split('_')[0]
        rank_info = np.load(load_path + '_rank_info.npy').item()
        assert self.current_generation == rank_info['current_generation']
        self.num_total_species = rank_info['num_total_species']

        # load the species
        for i_species_path in species_list:
            i_species = np.load(i_species_path).item()
            self.add_species(i_species)
        num_species = len(self.species)
        logger.info('Load species bank with bank size: {}'.format(num_species))
        logger.info('Start with generation: {}'.format(self.current_generation))

# Path: util/logger.py
# class _MyFormatter(logging.Formatter):
#     def format(self, record):
# def set_file_handler(path=None, prefix='', time_str=''):
# _LOGGING_METHOD = ['info', 'warning', 'error', 'critical',
#                    'warn', 'exception', 'debug']


# Path: evolution/species_bank.py
import numpy as np
import init_path
import os
import glob
from util import logger
from . import species2species

            rank_info
        )

        # save the weights for the first species
        for i_species in self.species[::-1][:self.args.save_top_species]:
            np.save(
                os.path.join(
                    path, str(self.current_generation) + '_' +
                    str(i_species['SpcID'])
                ),
                {key: i_species[key] for key in KEY_LIST['species_data']}
            )

    def load(self, load_path):
        # the number of species, the number of generation
        load_path = os.path.abspath(os.path.join(self.base_path, load_path))
        species_list = glob.glob(load_path + '_*.npy')

        self.current_generation = os.path.basename(load_path).split('_')[0]
        rank_info = np.load(load_path + '_rank_info.npy').item()
        assert self.current_generation == rank_info['current_generation']
        self.num_total_species = rank_info['num_total_species']

        # load the species
        for i_species_path in species_list:
            i_species = np.load(i_species_path).item()
            self.add_species(i_species)
        num_species = len(self.species)
        logger.info('Load species bank with bank size: {}'.format(num_species))
        logger.info('Start with generation: {}'.format(self.current_generation))

        logger.info('{} Species existed'.format(self.num_total_species))