<commit_before># coding: utf-8
# Copyright (c) Henniggroup.
# Distributed under the terms of the MIT License.

from __future__ import division, print_function, unicode_literals, \
    absolute_import

"""
The instrument module:
defines the inputset and the job

"""

import sys
import os, shutil
import subprocess
import logging

from pymatgen.io.vasp.inputs import Incar, Poscar, Potcar, Kpoints
from pymatgen.io.vasp.sets import DictVaspInputSet

from custodian.custodian import Job, ErrorHandler

from monty.json import MontyDecoder

from fireworks.user_objects.queue_adapters.common_adapter import CommonAdapter

from mpinterfaces.data_processor import MPINTVasprun

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(levelname)s:%(name)s:%(message)s')
sh = logging.StreamHandler(stream=sys.stdout)
sh.setFormatter(formatter)
logger.addHandler(sh)


class MPINTVaspInputSet(DictVaspInputSet):
    """
    defines the set of input required for a vasp job i.e
    create INCAR, POSCAR, POTCAR & KPOINTS files
    """

    def __init__(self, name, incar, poscar, potcar, kpoints,
                 qadapter=None, script_name='submit_script',
                 vis_logger=None, reuse_path=None, **kwargs):
        """
        default INCAR from config_dict

        """
        self.name = name
        self.incar = Incar.from_dict(incar.as_dict())
        self.poscar = Poscar.from_dict(poscar.as_dict())
        self.potcar = Potcar.from_dict(potcar.as_dict())
        if not type(kpoints) == str:
           self.kpoints = Kpoints.from_dict(kpoints.as_dict())
        else:
           self.kpoints = kpoints
        self.reuse_path = reuse_path # complete reuse paths
        self.extra = kwargs
        if qadapter is not None:
            self.qadapter = qadapter.from_dict(qadapter.to_dict())
        else:
            self.qadapter = None
        self.script_name = script_name
        config_dict = {}
        config_dict['INCAR'] = self.incar.as_dict()
        config_dict['POSCAR'] = self.poscar.as_dict()
        # caution the key and the value are not always the same
        config_dict['POTCAR'] = self.potcar.as_dict()
        # dict(zip(self.potcar.as_dict()['symbols'],
        # self.potcar.as_dict()['symbols']))
        config_dict['KPOINTS'] = self.kpoints.as_dict()
        # self.user_incar_settings = self.incar.as_dict()
        DictVaspInputSet.__init__(self, name, config_dict,
                                  ediff_per_atom=False, **kwargs)
        if vis_logger:
            self.logger = vis_logger
        else:
            self.logger = logger

    def write_input(self, job_dir, make_dir_if_not_present=True,
                    write_cif=False):
        """
        the input files are written to the job_dir
        process(if needed) and write the input files in each directory
        structures read from the poscar files in the directory
        """
        d = job_dir
        if make_dir_if_not_present and not os.path.exists(d):
            os.makedirs(d)
        self.logger.info('writing inputset to : ' + d)
        self.incar.write_file(os.path.join(d, 'INCAR'))
        self.kpoints.write_file(os.path.join(d, 'KPOINTS'))<commit_msg>further updates to instrument to handle extensions in calibrate<commit_after># coding: utf-8
# Copyright (c) Henniggroup.
# Distributed under the terms of the MIT License.

from __future__ import division, print_function, unicode_literals, \
    absolute_import

"""
The instrument module:
defines the inputset and the job

"""

import sys
import os, shutil
import subprocess
import logging

from pymatgen.io.vasp.inputs import Incar, Poscar, Potcar, Kpoints
from pymatgen.io.vasp.sets import DictVaspInputSet

from custodian.custodian import Job, ErrorHandler

from monty.json import MontyDecoder

from fireworks.user_objects.queue_adapters.common_adapter import CommonAdapter

from mpinterfaces.data_processor import MPINTVasprun

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(levelname)s:%(name)s:%(message)s')
sh = logging.StreamHandler(stream=sys.stdout)
sh.setFormatter(formatter)
logger.addHandler(sh)


class MPINTVaspInputSet(DictVaspInputSet):
    """
    defines the set of input required for a vasp job i.e
    create INCAR, POSCAR, POTCAR & KPOINTS files
    """

    def __init__(self, name, incar, poscar, potcar, kpoints,
                 qadapter=None, script_name='submit_script',
                 vis_logger=None, reuse_path=None, **kwargs):
        """
        default INCAR from config_dict

        """
        self.name = name
        self.incar = Incar.from_dict(incar.as_dict())
        self.poscar = Poscar.from_dict(poscar.as_dict())
        self.potcar = Potcar.from_dict(potcar.as_dict())
        if not type(kpoints) == str:
           self.kpoints = Kpoints.from_dict(kpoints.as_dict())
        else:
           self.kpoints = kpoints
        self.reuse_path = reuse_path # complete reuse paths
        self.extra = kwargs
        if qadapter is not None:
            self.qadapter = qadapter.from_dict(qadapter.to_dict())
        else:
            self.qadapter = None
        self.script_name = script_name
        config_dict = {}
        config_dict['INCAR'] = self.incar.as_dict()
        config_dict['POSCAR'] = self.poscar.as_dict()
        # caution the key and the value are not always the same
        config_dict['POTCAR'] = self.potcar.as_dict()
        # dict(zip(self.potcar.as_dict()['symbols'],
        # self.potcar.as_dict()['symbols']))
        if not type(kpoints) == str:
            config_dict['KPOINTS'] = self.kpoints.as_dict()
        else:
            config_dict['KPOINTS'] = self.kpoints        
        # self.user_incar_settings = self.incar.as_dict()
        DictVaspInputSet.__init__(self, name, config_dict,
                                  ediff_per_atom=False, **kwargs)
        if vis_logger:
            self.logger = vis_logger
        else:
            self.logger = logger

    def write_input(self, job_dir, make_dir_if_not_present=True,
                    write_cif=False):
        """
        the input files are written to the job_dir
        process(if needed) and write the input files in each directory
        structures read from the poscar files in the directory
        """
        d = job_dir
        if make_dir_if_not_present and not os.path.exists(d):
            os.makedirs(d)
        self.logger.info('writing inputset to : ' + d)
        self.incar.write_file(os.path.join(d, 'INCAR'))
        self.kpoints.write_file(os.path.join(d, 'KPOINTS'))
{'fraction_non_alphanumeric': 0.09814283557300317, 'fraction_numerical': 0.00030197795560924054, 'mean_word_length': 2.7529745042492917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6407435', 'n_tokens_mistral': 2080, 'n_tokens_neox': 2038, 'n_words': 476}