Skip to content

Commit

Permalink
db : also record step
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-cc committed Aug 13, 2020
1 parent 5d4bc46 commit 816a628
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gcvb/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def end_run(cursor,run):
WHERE id = ?""",[run])

@with_connection
def add_metric(cursor, run_id, test_id, name, value):
cursor.execute("INSERT INTO valid(metric,value,test_id) VALUES (?,?,?)",[name,value,test_id])
def add_metric(cursor, run_id, test_id, step, name, value):
cursor.execute("INSERT INTO valid(metric,value,test_id,task_step) VALUES (?,?,?,?)",[name,value,test_id, step])

@with_connection
def get_last_run(cursor):
Expand Down
2 changes: 2 additions & 0 deletions gcvb/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def write_script(tests, config, data_root, base_id, run_id, *, job_file="job.sh"
step = 0
for c,t in enumerate(test["Tasks"]):
step += 1
f.write("export GCVB_STEP_ID={!s}\n".format(step))
f.write("python3 -m gcvb db start_task {0} {1} 0\n".format(test["id_db"],step))
at_job_creation={}
fill_at_job_creation_task(at_job_creation, t, test["id"]+"_"+str(c), config)
Expand All @@ -109,6 +110,7 @@ def write_script(tests, config, data_root, base_id, run_id, *, job_file="job.sh"
f.write("python3 -m gcvb db end_task {0} {1} $?\n".format(test["id_db"],step))
for d,v in enumerate(t.get("Validations",[])):
step += 1
f.write("export GCVB_STEP_ID={!s}\n".format(step))
f.write("python3 -m gcvb db start_task {0} {1} 0\n".format(test["id_db"],step))
fill_at_job_creation_validation(at_job_creation, v, data_root, test["data"], config, valid)
f.write(format_launch_command(v["launch_command"],config,at_job_creation))
Expand Down
1 change: 1 addition & 0 deletions gcvb/jobrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def run(self):
env = dict(os.environ)
env["GCVB_RUN_ID"] = f"{self.run_id}"
env["GCVB_TEST_ID"] = f"{self.test_id_db}"
env["GCVB_STEP_ID"] = f"{self.step}"
self.return_code = subprocess.call(self.launch_command, shell=True, cwd=self.test_id, env=env)
def name(self):
return f"{self.test_id}_{self.num_process}x{self.num_threads}_{self.type}"
Expand Down
5 changes: 3 additions & 2 deletions gcvb/user_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

def add_metric(name, value):
db.set_db("../../../gcvb.db")
for env in ["GCVB_RUN_ID","GCVB_TEST_ID"]:
for env in ["GCVB_RUN_ID","GCVB_TEST_ID","GCVB_STEP_ID"]:
if env not in os.environ:
raise Exception("Environment variable {} is not defined.".format(env))
test_id=os.environ["GCVB_TEST_ID"] # string as in the yaml file.
run_id=os.environ["GCVB_RUN_ID"] # integer id
db.add_metric(run_id, test_id, name, value)
step_id=os.environ["GCVB_STEP_ID"]
db.add_metric(run_id, test_id, step_id, name, value)

def get_tests(run=None):
if not(run):
Expand Down

0 comments on commit 816a628

Please sign in to comment.