<commit_before>#!/usr/bin/env python

from __future__ import print_function
import sys
import json
import os
import subprocess
from simcity.util import expandfilename, copyglob, listdirs

if __name__ == '__main__':
    print("Input:")
    print(sys.argv)
    
    tmp_dir = sys.argv[1]
    in_dir = sys.argv[2]
    out_dir = sys.argv[3]
    
    with open(os.path.join(in_dir, 'input.json'), 'r') as f:
        params = json.load(f)
    
    print("Parameters:")
    print(params)
    
    try:
        model = params['model']
    except:
        model = 'tutorial'
    
    src = expandfilename(['~', 'bangalore-matsim'])
    
    indir = expandfilename([tmp_dir, 'input'])
    moddir = expandfilename([indir, model])
    outdir = expandfilename([tmp_dir, 'output', model])
    
    os.mkdir(indir)
    os.mkdir(moddir)
    # don't make output directory
    
    # Set up runtime directories
    copyglob([src, 'input', model, '*'], moddir)
    
    # Run simulation
    os.chdir(tmp_dir)
    subprocess.call([expandfilename([src, 'scripts', 'matsim-runner.sh']), model])
    
    # Copy output files to output directory
    copyglob(expandfilename([outdir, '*.(log|gz|png|txt)']), out_dir)
    
    itersdir = expandfilename([outdir, 'ITERS'])
    for d in listdirs(itersdir):
        iterglob = expandfilename([itersdir, d, '*'])
        copyglob(iterglob, out_dir, prefix="ITER_" + d + "_")
    
    print("Done")<commit_msg>Correctly use copyglob in matsim<commit_after>#!/usr/bin/env python

from __future__ import print_function
import sys
import json
import os
import subprocess
from simcity.util import expandfilename, copyglob, listdirs

if __name__ == '__main__':
    print("Input:")
    print(sys.argv)
    
    tmp_dir = sys.argv[1]
    in_dir = sys.argv[2]
    out_dir = sys.argv[3]
    
    with open(os.path.join(in_dir, 'input.json'), 'r') as f:
        params = json.load(f)
    
    print("Parameters:")
    print(params)
    
    try:
        model = params['model']
    except:
        model = 'tutorial'
    
    src = expandfilename(['~', 'bangalore-matsim'])
    
    indir = expandfilename([tmp_dir, 'input'])
    moddir = expandfilename([indir, model])
    outdir = expandfilename([tmp_dir, 'output', model])
    
    os.mkdir(indir)
    os.mkdir(moddir)
    # don't make output directory
    
    # Set up runtime directories
    copyglob([src, 'input', model, '*'], moddir)
    
    # Run simulation
    os.chdir(tmp_dir)
    subprocess.call([expandfilename([src, 'scripts', 'matsim-runner.sh']), model])
    
    # Copy output files to output directory
    for ftype in ('*.log', '*.gz', '*.png', '*.txt'):
        copyglob(expandfilename([outdir, ftype]), out_dir)
    
    itersdir = expandfilename([outdir, 'ITERS'])
    for d in listdirs(itersdir):
        iterglob = expandfilename([itersdir, d, '*'])
        copyglob(iterglob, out_dir, prefix="ITER_" + d + "_")
    
    print("Done")
{'fraction_non_alphanumeric': 0.14417808219178083, 'fraction_numerical': 0.002054794520547945, 'mean_word_length': 2.9741496598639454, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7210029', 'n_tokens_mistral': 1002, 'n_tokens_neox': 983, 'n_words': 220}