Skip to content
Snippets Groups Projects
Verified Commit 520c696b authored by Simon Schwitanski's avatar Simon Schwitanski :slight_smile:
Browse files

Merge branch 'tools'

parents 2e933471 ae156f97
No related branches found
No related tags found
No related merge requests found
......@@ -136,43 +136,56 @@ def extract_all_todo_from_logdir(tool, logdir):
########################
# cmd_gencodes(): what to do when '-c generate' is used (Generating the codes)
# cmd_gencodes(): what to do when '-c generate -lev <1|2|>' is used (Generating the codes)
########################
#### THIS IS OUTDATED
def cmd_gencodes():
if os.path.exists("/MBI/scripts/original_MBI_generators/CollArgGenerator.py"): # Docker run
print("Docker run")
generators = glob.glob("/MBI/scripts/original_MBI_generators/*Generator.py")
dir = "/MBI/gencodes"
elif os.path.exists("../../scripts/original_MBI_generators/CollArgGenerator.py"): # Local run, from logs dir
print("Local run, from tools' logs dir")
generators = glob.glob(f"{os.getcwd()}/../../scripts/original_MBI_generators/*Generator.py")
dir = "../../gencodes/"
elif os.path.exists("scripts/original_MBI_generators/CollArgGenerator.py"): # Local run, from main dir
print("Local run, from MBI main dir")
generators = glob.glob(f"{os.getcwd()}/scripts/original_MBI_generators/*Generator.py")
dir = "gencodes/"
else:
raise Exception("Cannot find the codes' original_MBI_generators. Please report that bug.")
subprocess.run(f"rm -rf {dir} ; mkdir {dir}", shell=True, check=True)
def cmd_gencodes(level):
here = os.getcwd()
if os.path.exists("/MBB/scripts/errors/"):
#level = 2
print(f"Generate level {level}")
subprocess.run(f'tar -xf real_world_data.csv.tar.gz', shell=True, check=True)
dir = "scripts/"
os.chdir(dir)
print(f"Generate the codes (in {os.getcwd()}): ", end='')
for generator in generators:
m = re.match("^.*?/([^/]*)Generator.py$", generator)
if m:
print(m.group(1), end=", ")
subprocess.run(f'PYTHONPATH=../ python3 main.py --generator_dir errors --level {level} --real_world_data ../output.csv', shell=True, check=True)
else:
print(generator, end=", ")
subprocess.run(f'../scripts/ensure_python3 {generator}', shell=True, check=True)
print("\nTest count: ", end='')
sys.stdout.flush()
subprocess.run("ls *.c|wc -l", shell=True, check=True)
subprocess.run("for n in *.c ; do cat -n $n > $n.txt ; done", shell=True, check=True)
raise Exception("Cannot find the generators. Please report that bug.")
os.chdir(here)
# if os.path.exists("/MBI/scripts/original_MBI_generators/CollArgGenerator.py"): # Docker run
# print("Docker run")
# generators = glob.glob("/MBI/scripts/original_MBI_generators/*Generator.py")
# dir = "/MBI/gencodes"
# elif os.path.exists("../../scripts/original_MBI_generators/CollArgGenerator.py"): # Local run, from logs dir
# print("Local run, from tools' logs dir")
# generators = glob.glob(f"{os.getcwd()}/../../scripts/original_MBI_generators/*Generator.py")
# dir = "../../gencodes/"
# elif os.path.exists("scripts/original_MBI_generators/CollArgGenerator.py"): # Local run, from main dir
# print("Local run, from MBI main dir")
# generators = glob.glob(f"{os.getcwd()}/scripts/original_MBI_generators/*Generator.py")
# dir = "gencodes/"
# else:
# raise Exception("Cannot find the codes' original_MBI_generators. Please report that bug.")
# subprocess.run(f"rm -rf {dir} ; mkdir {dir}", shell=True, check=True)
# here = os.getcwd()
# os.chdir(dir)
# print(f"Generate the codes (in {os.getcwd()}): ", end='')
# for generator in generators:
# m = re.match("^.*?/([^/]*)Generator.py$", generator)
# if m:
# print(m.group(1), end=", ")
# else:
# print(generator, end=", ")
# subprocess.run(f'../scripts/ensure_python3 {generator}', shell=True, check=True)
# print("\nTest count: ", end='')
# sys.stdout.flush()
# subprocess.run("ls *.c|wc -l", shell=True, check=True)
# subprocess.run("for n in *.c ; do cat -n $n > $n.txt ; done", shell=True, check=True)
# os.chdir(here)
########################
# cmd_build(): what to do when '-c build' is used (building the tool, discarding the cache)
########################
......@@ -1617,6 +1630,9 @@ parser.add_argument('-l', '--logs-dir', metavar='path', default="logs", type=pat
parser.add_argument('-g', '--gencodes', metavar='path', default="gencodes", type=pathlib.Path,
help='path to directory of source files (default: gencodes)')
parser.add_argument('-lev', '--level', metavar='int', default=2, type=int,
help='Generation level to generate codes (default: 2)')
parser.add_argument('-b', metavar='batch', default='1/1',
help="Limits the test executions to the batch #N out of M batches (Syntax: 'N/M'). To get 3 runners, use 1/3 2/3 3/3")
......@@ -1658,7 +1674,10 @@ if args.c == 'all':
cmd_run(rootdir=rootdir, toolname=args.x, batchinfo=args.b)
cmd_html(rootdir, toolnames=arg_tools)
elif args.c == 'generate':
cmd_gencodes()
if args.level:
cmd_gencodes(level=args.level)
else:
cmd_gencodes(level=2)
elif args.c == 'build':
for t in arg_tools:
cmd_build(rootdir=rootdir, toolname=t)
......
......@@ -7,6 +7,10 @@ docker run -v `pwd`:/MBB -it mbb:latest bash
## Generate the codes
```
python3 MBB.py -c generate --level 2
```
Or
```
cd /MBB
tar -xf real_world_data.csv.tar.gz
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment