<commit_before>import os
import stat
import tmd.pwscf.config
from tmd.queue.queue_util import global_config

def write_queuefile(config):
    machine = config["machine"]

    gconf = global_config()

    if machine == "__local__":
        if gconf['allow_local']:
            _write_queuefile_local(config)
        else:
            raise ValueError("Local operation disallowed in global_config.yaml")
    elif machine == "ls5":
        _write_queuefile_ls5(config)
    else:
        raise ValueError("Unrecognized config['machine'] value")

def write_launcherfiles(config):
    machine = config["machine"]

    gconf = global_config()

    if machine == "__local__":
        if gconf['allow_local']:
            #TODO?
            raise ValueError("launcher not implemented for local operation")
        else:
            raise ValueError("Local operation disallowed in global_config.yaml")
    elif machine == "ls5":
        _write_launcherfiles_ls5(config)
    else:
        raise ValueError("Unrecognized config['machine'] value")

def get_qf_path(config):
    qf_name = "run_{}".format(config["calc"])
    qf_path = os.path.join(config["base_path"], config["prefix"], "wannier", qf_name)

    return qf_path

def _ls_format_duration(hours, minutes):
    hstr = str(hours)
    if minutes < 10:
        mstr = "0{}".format(str(minutes))
    else:
        mstr = str(minutes)

    return "{}:{}:00".format(hstr, mstr)

def _write_queuefile_ls5(config):
    duration = _ls_format_duration(config["hours"], config["minutes"])
    prefix = config["prefix"]

    qf = ["#!/bin/bash"]
    if config["calc"] == "wan_setup":
        qf.append("#SBATCH -p {}".format(config["queue"]))
        qf.append("#SBATCH -J {}".format(prefix))
        #qf.append("#SBATCH -o {}.out".format(prefix))
        qf.append("#SBATCH -e {}.err".format(prefix))
        qf.append("#SBATCH -t {}".format(duration))
        qf.append("#SBATCH -N {}".format(str(config["nodes"])))
        qf.append("#SBATCH -n {}".format(str(config["cores"])))
        qf.append("#SBATCH -A {}".format(config["project"]))
        qf.append("")
        qf.append("export OMP_NUM_THREADS=1")
        qf.append("ibrun tacc_affinity pw.x -input {}.scf.in > scf.out".format(prefix))
        qf.append("cd ..")
        qf.append("cp -r wannier/* bands")
        qf.append("cd bands")
        qf.append("ibrun tacc_affinity pw.x -input {}.bands.in > bands.out".format(prefix))
        qf.append("ibrun tacc_affinity bands.x -input {}.bands_post.in > bands_post.out".format(prefix))
        if config["wannier"]:
            qf.append("cd ../wannier")
            qf.append("ibrun tacc_affinity pw.x -input {}.nscf.in > nscf.out".format(prefix))
            qf.append("wannier90.x -pp {}".format(prefix))
            qf.append("ibrun tacc_affinity pw2wannier90.x -input {}.pw2wan.in > pw2wan.out".format(prefix))
    elif config["calc"] == "wan_run":
        qf.append("wannier90.x {}".format(prefix))
    else:
        raise ValueError("unrecognized config['calc'] ('wan_setup' and 'wan_run' supported)")

    qf_path = get_qf_path(config)

    with open(qf_path, 'w') as fp:
        qf_str = "\n".join(qf)
        fp.write(qf_str)

    os.chmod(qf_path, stat.S_IRWXU)

def _write_launcherfiles_ls5(config):<commit_msg>fix queuefile for running w90 in proper directory<commit_after>import os
import stat
import tmd.pwscf.config
from tmd.queue.queue_util import global_config

def write_queuefile(config):
    machine = config["machine"]

    gconf = global_config()

    if machine == "__local__":
        if gconf['allow_local']:
            _write_queuefile_local(config)
        else:
            raise ValueError("Local operation disallowed in global_config.yaml")
    elif machine == "ls5":
        _write_queuefile_ls5(config)
    else:
        raise ValueError("Unrecognized config['machine'] value")

def write_launcherfiles(config):
    machine = config["machine"]

    gconf = global_config()

    if machine == "__local__":
        if gconf['allow_local']:
            #TODO?
            raise ValueError("launcher not implemented for local operation")
        else:
            raise ValueError("Local operation disallowed in global_config.yaml")
    elif machine == "ls5":
        _write_launcherfiles_ls5(config)
    else:
        raise ValueError("Unrecognized config['machine'] value")

def get_qf_path(config):
    qf_name = "run_{}".format(config["calc"])
    qf_path = os.path.join(config["base_path"], config["prefix"], "wannier", qf_name)

    return qf_path

def _ls_format_duration(hours, minutes):
    hstr = str(hours)
    if minutes < 10:
        mstr = "0{}".format(str(minutes))
    else:
        mstr = str(minutes)

    return "{}:{}:00".format(hstr, mstr)

def _write_queuefile_ls5(config):
    duration = _ls_format_duration(config["hours"], config["minutes"])
    prefix = config["prefix"]

    qf = ["#!/bin/bash"]
    if config["calc"] == "wan_setup":
        qf.append("#SBATCH -p {}".format(config["queue"]))
        qf.append("#SBATCH -J {}".format(prefix))
        #qf.append("#SBATCH -o {}.out".format(prefix))
        qf.append("#SBATCH -e {}.err".format(prefix))
        qf.append("#SBATCH -t {}".format(duration))
        qf.append("#SBATCH -N {}".format(str(config["nodes"])))
        qf.append("#SBATCH -n {}".format(str(config["cores"])))
        qf.append("#SBATCH -A {}".format(config["project"]))
        qf.append("")
        qf.append("export OMP_NUM_THREADS=1")
        qf.append("ibrun tacc_affinity pw.x -input {}.scf.in > scf.out".format(prefix))
        qf.append("cd ..")
        qf.append("cp -r wannier/* bands")
        qf.append("cd bands")
        qf.append("ibrun tacc_affinity pw.x -input {}.bands.in > bands.out".format(prefix))
        qf.append("ibrun tacc_affinity bands.x -input {}.bands_post.in > bands_post.out".format(prefix))
        if config["wannier"]:
            qf.append("cd ../wannier")
            qf.append("ibrun tacc_affinity pw.x -input {}.nscf.in > nscf.out".format(prefix))
            qf.append("wannier90.x -pp {}".format(prefix))
            qf.append("ibrun tacc_affinity pw2wannier90.x -input {}.pw2wan.in > pw2wan.out".format(prefix))
    elif config["calc"] == "wan_run":
        wan_dir = os.path.join(config["base_path"], config["prefix"], "wannier")
        qf.append("cd {}; wannier90.x {}".format(wan_dir, prefix))
    else:
        raise ValueError("unrecognized config['calc'] ('wan_setup' and 'wan_run' supported)")

    qf_path = get_qf_path(config)

    with open(qf_path, 'w') as fp:
        qf_str = "\n".join(qf)
        fp.write(qf_str)

    os.chmod(qf_path, stat.S_IRWXU)

def _write_launcherfiles_ls5(config):
{'fraction_non_alphanumeric': 0.16024584020386748, 'fraction_numerical': 0.006595712786688653, 'mean_word_length': 3.0485436893203883, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3674204', 'n_tokens_mistral': 2313, 'n_tokens_neox': 2250, 'n_words': 432}