Skip to content
Snippets Groups Projects
Commit ae156f97 authored by Emmanuelle Saillard's avatar Emmanuelle Saillard
Browse files

update generate command

parent 8616f17b
Branches tools
No related tags found
No related merge requests found
...@@ -136,43 +136,56 @@ def extract_all_todo_from_logdir(tool, logdir): ...@@ -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(level):
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)
here = os.getcwd() 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) os.chdir(dir)
print(f"Generate the codes (in {os.getcwd()}): ", end='') subprocess.run(f'PYTHONPATH=../ python3 main.py --generator_dir errors --level {level} --real_world_data ../output.csv', shell=True, check=True)
for generator in generators:
m = re.match("^.*?/([^/]*)Generator.py$", generator)
if m:
print(m.group(1), end=", ")
else: else:
print(generator, end=", ") raise Exception("Cannot find the generators. Please report that bug.")
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) 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) # cmd_build(): what to do when '-c build' is used (building the tool, discarding the cache)
######################## ########################
...@@ -1910,6 +1923,9 @@ parser.add_argument('-l', '--logs-dir', metavar='path', default="logs", type=pat ...@@ -1910,6 +1923,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, parser.add_argument('-g', '--gencodes', metavar='path', default="gencodes", type=pathlib.Path,
help='path to directory of source files (default: gencodes)') 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', 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") 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")
...@@ -1951,7 +1967,10 @@ if args.c == 'all': ...@@ -1951,7 +1967,10 @@ if args.c == 'all':
cmd_run(rootdir=rootdir, toolname=args.x, batchinfo=args.b) cmd_run(rootdir=rootdir, toolname=args.x, batchinfo=args.b)
cmd_html(rootdir, toolnames=arg_tools) cmd_html(rootdir, toolnames=arg_tools)
elif args.c == 'generate': elif args.c == 'generate':
cmd_gencodes() if args.level:
cmd_gencodes(level=args.level)
else:
cmd_gencodes(level=2)
elif args.c == 'build': elif args.c == 'build':
for t in arg_tools: for t in arg_tools:
cmd_build(rootdir=rootdir, toolname=t) cmd_build(rootdir=rootdir, toolname=t)
......
...@@ -7,6 +7,10 @@ docker run -v `pwd`:/MBB -it mbb:latest bash ...@@ -7,6 +7,10 @@ docker run -v `pwd`:/MBB -it mbb:latest bash
## Generate the codes ## Generate the codes
```
python3 MBB.py -c generate --level 2
```
Or
``` ```
cd /MBB cd /MBB
tar -xf real_world_data.csv.tar.gz 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