From ad2dcdf8f489ee85603cb53d479a54951b2f5c38 Mon Sep 17 00:00:00 2001 From: David Wang Date: Sun, 27 Oct 2024 12:02:51 -0400 Subject: [PATCH 1/6] Adding stress test script --- .gitignore | 1 + clients/job11/autograde-Makefile | 3 ++ clients/job11/autograde.tar | Bin 0 -> 10240 bytes clients/job11/maxsubarray.py | 11 +++++ dump.rdb | Bin 0 -> 10068 bytes pyvenv.cfg | 8 ++++ stressTest.py | 76 +++++++++++++++++++++++++++++++ worker.py | 4 +- 8 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 clients/job11/autograde-Makefile create mode 100644 clients/job11/autograde.tar create mode 100644 clients/job11/maxsubarray.py create mode 100644 dump.rdb create mode 100644 pyvenv.cfg create mode 100644 stressTest.py diff --git a/.gitignore b/.gitignore index 14ed0260..f3856b55 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ pip-selfcheck.json # Backup files *.bak + diff --git a/clients/job11/autograde-Makefile b/clients/job11/autograde-Makefile new file mode 100644 index 00000000..a76f4cf1 --- /dev/null +++ b/clients/job11/autograde-Makefile @@ -0,0 +1,3 @@ +all: + tar xvf autograde.tar + (cd random; ./driver.sh) diff --git a/clients/job11/autograde.tar b/clients/job11/autograde.tar new file mode 100644 index 0000000000000000000000000000000000000000..4bd4c9fa578c1c281750997055b316148391d3b2 GIT binary patch literal 10240 zcmeIwO-sWt7zgm2`zd0quz|R|3&IY9S6}ezWVCBX2X2K_y~w`1Nouid)>{wazn854 zr+t$Bp1N#T)Y};u^Wy%xG={|0wkwx9-iORzL};y~mRfN|xDeV1Ld}?m>UzI5ubHEi z6xnu@?Yi`M^^dLB$MIiJTs!~5ZQe_F(NtsnpD^Ix=5M78^Vib${u#TY5$X=X5%aB{^JD!zDdjGQ%bNb17La zn^o<~X3jnq?7`LfOSz?D!LFz{r{9STiR>pTB&wh2km!D5LSp)f4M`eY?4EU-=XK_a zIeYRu`Yn7<-^9PwKK9I#a#htdoUc7{300Izz s00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_0D)nFPkFAEEdT%j literal 0 HcmV?d00001 diff --git a/clients/job11/maxsubarray.py b/clients/job11/maxsubarray.py new file mode 100644 index 00000000..82af12ed --- /dev/null +++ b/clients/job11/maxsubarray.py @@ -0,0 +1,11 @@ +def maxsubarray(nums): + n = len(nums) + if n == 1: + return nums[0] + lookup = [0] * n + lookup[0] = nums[0] + res = nums[0] + for i in range(1, n): + lookup[i] = max(lookup[i-1]+nums[i], nums[i]) + res = max(res, lookup[i]) + return res \ No newline at end of file diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000000000000000000000000000000000000..a346be38ff5cf370ae93b21b0bd5063d39dc62cc GIT binary patch literal 10068 zcmds73v?URnZ9>MPg}Mnzn#SK=;7E=EWbzys9`&@<+q(Ue#BuRct)DBHL)}!W=3|* z(pGu!h@-p}NSaU-5>g)R((Z1d^uX4MdGxS7J*D)(?gFRRZO;i%c6p_23)^PzNO>7T z9ALM*XXD)HSee)T?)QK9`~QFXTKpaT_4N%6ADLyI6BN%lFY8yNnm@!y^|$euSzK4DQ=aa39p*vJP}C7G}eXutOH z5lQ9O#`qYY+@D;!Ir+6@f*j)~lZldBwJ*J&xt_H;R^8;?Y&vFz-y6lBAG zDLBTz2;zKXa(8MZ=Fe>s~ za(luk^QtWHW;_LuAjTuf5JfW$hI6POxT53}czgm5TPWv~aL_}xi)efjjQhR>7;mJ( zfUy9z)hI?|Y7&!;It9%gw1sFD!ie}WFf$vOg8W2xP>RV4A7%qeoyse!$4C9Lv{#D8 z!mO%Mo!z9w0<0{vlXcw4gq_Z(S&@_ZiP~T!R?Bm-;fCQ5Wz!2{tvY&}JqS3eIesI^ zLPQA}3xvuy%Vda3tU`AABx~S3J?t1iLO)A}90?Nw7Ni>jE0KGMtW{Z=?gKdp2#n1b z3-F07DW=-n;y(oeWWOnX?X1-^ORNRMh)@li)MUt#XqeS~4e6G_hT&PuH;R%8vnZ*; z$mC#OcQWzqkg7(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T{y<^gYEBm9)LVH1wg5?fE`Sz`sv#DNn9!3 zOVbQa?xZGG6hmdzE#$2+L5@!l_$7fQ_jcU~_S~_GxsMT{%~UP);n|p*U|(dGX5{`gZD3Dh7g8XXEWi=Y~5%j;{ib{fTA2Hd;Q2Uo#8! zyP13)eqDr<90#GOIBx(6Cg1sk?$;fU$MaqQ&JDqznY$$^+8pA8V=Yr<)oTzeCA!(s z)8JiL%sH?31G?el`yk)>Ln0xGb>D@2^U`OQ{st_rw78!j*ik8N)#omTyF}iuL!cez z8SCzIY^==HPY!7>K{UTi@&$KK(Ahft(v^8H^_*vb=ncp0ePD3Sqn;%jZv#H}AE^)i z4g7`*xo-oz+fT#`8vLQRG4D5Z+z0yY@AsTq`Xt!p$_34iTKkQ3zN?YACl+-`Mt)EZ z4+(0hfX&K$r|t)j(QO3B1j(<1IQI9bf~sTd}l&lHiH>QF`&RYg)X{0FWHF z3)UBR6Qz3S=|Hfg(raQT^Phcm0NX!Y>mTIer307!u1C#A8b!m>g8Zo9PV0nD^wNsCS(7Y tAm+t!mtdx*q2#k_6?Cy)@oJmlbhh?Jme%6@VoidxfsrH6*|~p|{tF1_C?fy> literal 0 HcmV?d00001 diff --git a/pyvenv.cfg b/pyvenv.cfg new file mode 100644 index 00000000..ef8e71aa --- /dev/null +++ b/pyvenv.cfg @@ -0,0 +1,8 @@ +home = /opt/homebrew/opt/python@3.10/bin +implementation = CPython +version_info = 3.10.13.final.0 +virtualenv = 20.25.0 +include-system-site-packages = false +base-prefix = /opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10 +base-exec-prefix = /opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10 +base-executable = /opt/homebrew/opt/python@3.10/bin/python3.10 diff --git a/stressTest.py b/stressTest.py new file mode 100644 index 00000000..2edd4352 --- /dev/null +++ b/stressTest.py @@ -0,0 +1,76 @@ +import argparse +import subprocess +import time +import os +import sys +from config import Config + +def run_stress_test(num_submissions, submission_delay, autograder_image, output_file, tango_port, tango_path, job_name, job_path): + with open(output_file, 'a') as f: + f.write(f"Stress testing with {num_submissions} submissions\n") + for i in range(1, num_submissions + 1): + command = [ + 'python3', os.path.join(tango_path, 'clients/tango-cli.py'), + '-P', str(tango_port), + '-k', 'test', + '-l', job_name, + '--runJob', job_path, + '--image', autograder_image + ] + subprocess.run(command, stdout = f, stderr = f) + f.write(f"Submission {i} submitted \n") + + if submission_delay > 0: + time.sleep(submission_delay) + + sys.exit() + +def get_metrics(output_file): + if Config.LOGFILE == None: + print("Make sure logs are recorded in a log file") + + job_times = [] + with open(Config.LOGFILE, 'r') as f: + for line in f: + if "finished after " in line: + start = line.find("finished after ") + len("finished after ") + seconds = int(line[start:].split()[0]) + job_times.append(seconds) + + with open(output_file, 'a') as f: + if len(job_times) == 0: + print("No jobs have been completed") + else: + avg = sum(job_times)/len(job_times) + f.write(f"Average job time is {avg} seconds \n") + + sys.exit() + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Stress test script for Tango") + parser.add_argument('--num_submissions', type=int, default=10, help="Number of submissions") + parser.add_argument('--submission_delay', type=float, default=1.0, help="Delay between submissions") + parser.add_argument('--autograder_image', type=str, required=True, help="Autograder image") + parser.add_argument('--output_file', type=str, default='stress_test.out', help="Output file") + parser.add_argument('--tango_port', type=int, default=4567, help="Tango server port") + parser.add_argument('--tango_path', type=str, required=True, help="Path to Tango") + parser.add_argument('--job_name', type=str, required=True, help="Name of the job") + parser.add_argument('--job_path', type=str, required=True, help="Path to the job") + parser.add_argument('--get_metrics', type=bool, default = False, help= "Set to true to get metrics, does not create new jobs") + + args = parser.parse_args() + + if args.get_metrics: + get_metrics(args.output_file) + else: + run_stress_test( + args.num_submissions, + args.submission_delay, + args.autograder_image, + args.output_file, + args.tango_port, + args.tango_path, + args.job_name, + args.job_path + ) \ No newline at end of file diff --git a/worker.py b/worker.py index 204b1bb0..9f94e301 100644 --- a/worker.py +++ b/worker.py @@ -159,6 +159,7 @@ def run(self): """run - Step a job through its execution sequence""" try: # Hash of return codes for each step + start_time = time.time() ret = {} ret["waitvm"] = None ret["copyin"] = None @@ -319,7 +320,8 @@ def run(self): # Job termination. Notice that Tango considers # things like runjob timeouts and makefile errors to be # normal termination and doesn't reschedule the job. - self.log.info("Success: job %s:%d finished" % (self.job.name, self.job.id)) + elapsed_secs = time.time() - start_time + self.log.info("Success: job %s:%d finished after %d seconds" % (self.job.name, self.job.id, elapsed_secs)) # Move the job from the live queue to the dead queue # with an explanatory message From aee3f6a81ed0777404b16a0853f5be405b9bf464 Mon Sep 17 00:00:00 2001 From: David Wang Date: Sun, 27 Oct 2024 14:01:47 -0400 Subject: [PATCH 2/6] removing extraneous files --- clients/job11/autograde-Makefile | 3 --- clients/job11/autograde.tar | Bin 10240 -> 0 bytes clients/job11/maxsubarray.py | 11 ----------- dump.rdb | Bin 10068 -> 0 bytes pyvenv.cfg | 8 -------- 5 files changed, 22 deletions(-) delete mode 100644 clients/job11/autograde-Makefile delete mode 100644 clients/job11/autograde.tar delete mode 100644 clients/job11/maxsubarray.py delete mode 100644 dump.rdb delete mode 100644 pyvenv.cfg diff --git a/clients/job11/autograde-Makefile b/clients/job11/autograde-Makefile deleted file mode 100644 index a76f4cf1..00000000 --- a/clients/job11/autograde-Makefile +++ /dev/null @@ -1,3 +0,0 @@ -all: - tar xvf autograde.tar - (cd random; ./driver.sh) diff --git a/clients/job11/autograde.tar b/clients/job11/autograde.tar deleted file mode 100644 index 4bd4c9fa578c1c281750997055b316148391d3b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10240 zcmeIwO-sWt7zgm2`zd0quz|R|3&IY9S6}ezWVCBX2X2K_y~w`1Nouid)>{wazn854 zr+t$Bp1N#T)Y};u^Wy%xG={|0wkwx9-iORzL};y~mRfN|xDeV1Ld}?m>UzI5ubHEi z6xnu@?Yi`M^^dLB$MIiJTs!~5ZQe_F(NtsnpD^Ix=5M78^Vib${u#TY5$X=X5%aB{^JD!zDdjGQ%bNb17La zn^o<~X3jnq?7`LfOSz?D!LFz{r{9STiR>pTB&wh2km!D5LSp)f4M`eY?4EU-=XK_a zIeYRu`Yn7<-^9PwKK9I#a#htdoUc7{300Izz s00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_0D)nFPkFAEEdT%j diff --git a/clients/job11/maxsubarray.py b/clients/job11/maxsubarray.py deleted file mode 100644 index 82af12ed..00000000 --- a/clients/job11/maxsubarray.py +++ /dev/null @@ -1,11 +0,0 @@ -def maxsubarray(nums): - n = len(nums) - if n == 1: - return nums[0] - lookup = [0] * n - lookup[0] = nums[0] - res = nums[0] - for i in range(1, n): - lookup[i] = max(lookup[i-1]+nums[i], nums[i]) - res = max(res, lookup[i]) - return res \ No newline at end of file diff --git a/dump.rdb b/dump.rdb deleted file mode 100644 index a346be38ff5cf370ae93b21b0bd5063d39dc62cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10068 zcmds73v?URnZ9>MPg}Mnzn#SK=;7E=EWbzys9`&@<+q(Ue#BuRct)DBHL)}!W=3|* z(pGu!h@-p}NSaU-5>g)R((Z1d^uX4MdGxS7J*D)(?gFRRZO;i%c6p_23)^PzNO>7T z9ALM*XXD)HSee)T?)QK9`~QFXTKpaT_4N%6ADLyI6BN%lFY8yNnm@!y^|$euSzK4DQ=aa39p*vJP}C7G}eXutOH z5lQ9O#`qYY+@D;!Ir+6@f*j)~lZldBwJ*J&xt_H;R^8;?Y&vFz-y6lBAG zDLBTz2;zKXa(8MZ=Fe>s~ za(luk^QtWHW;_LuAjTuf5JfW$hI6POxT53}czgm5TPWv~aL_}xi)efjjQhR>7;mJ( zfUy9z)hI?|Y7&!;It9%gw1sFD!ie}WFf$vOg8W2xP>RV4A7%qeoyse!$4C9Lv{#D8 z!mO%Mo!z9w0<0{vlXcw4gq_Z(S&@_ZiP~T!R?Bm-;fCQ5Wz!2{tvY&}JqS3eIesI^ zLPQA}3xvuy%Vda3tU`AABx~S3J?t1iLO)A}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m2wCV3&?ye=%_IP+5Ns@ z(JHuG=7aWQpy$*NfVKL1aQNF4=)(ciyyb2%=^nx&w8*~X=ykOVsRe*zb^^t|1RP3T z%ez2&{8=0dDMdrkX5-@LuX|T{y<^gYEBm9)LVH1wg5?fE`Sz`sv#DNn9!3 zOVbQa?xZGG6hmdzE#$2+L5@!l_$7fQ_jcU~_S~_GxsMT{%~UP);n|p*U|(dGX5{`gZD3Dh7g8XXEWi=Y~5%j;{ib{fTA2Hd;Q2Uo#8! zyP13)eqDr<90#GOIBx(6Cg1sk?$;fU$MaqQ&JDqznY$$^+8pA8V=Yr<)oTzeCA!(s z)8JiL%sH?31G?el`yk)>Ln0xGb>D@2^U`OQ{st_rw78!j*ik8N)#omTyF}iuL!cez z8SCzIY^==HPY!7>K{UTi@&$KK(Ahft(v^8H^_*vb=ncp0ePD3Sqn;%jZv#H}AE^)i z4g7`*xo-oz+fT#`8vLQRG4D5Z+z0yY@AsTq`Xt!p$_34iTKkQ3zN?YACl+-`Mt)EZ z4+(0hfX&K$r|t)j(QO3B1j(<1IQI9bf~sTd}l&lHiH>QF`&RYg)X{0FWHF z3)UBR6Qz3S=|Hfg(raQT^Phcm0NX!Y>mTIer307!u1C#A8b!m>g8Zo9PV0nD^wNsCS(7Y tAm+t!mtdx*q2#k_6?Cy)@oJmlbhh?Jme%6@VoidxfsrH6*|~p|{tF1_C?fy> diff --git a/pyvenv.cfg b/pyvenv.cfg deleted file mode 100644 index ef8e71aa..00000000 --- a/pyvenv.cfg +++ /dev/null @@ -1,8 +0,0 @@ -home = /opt/homebrew/opt/python@3.10/bin -implementation = CPython -version_info = 3.10.13.final.0 -virtualenv = 20.25.0 -include-system-site-packages = false -base-prefix = /opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10 -base-exec-prefix = /opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10 -base-executable = /opt/homebrew/opt/python@3.10/bin/python3.10 From b186419fe2d5ad7947fae05ee87470cd0228ef50 Mon Sep 17 00:00:00 2001 From: David Wang Date: Sun, 27 Oct 2024 14:01:47 -0400 Subject: [PATCH 3/6] removing extraneous files --- .gitignore | 3 +- stressTest.py | 86 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 60 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index f3856b55..20e2bbd1 100644 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,4 @@ pip-selfcheck.json .vscode # Backup files -*.bak - +*.bak \ No newline at end of file diff --git a/stressTest.py b/stressTest.py index 2edd4352..eb42ad39 100644 --- a/stressTest.py +++ b/stressTest.py @@ -5,59 +5,91 @@ import sys from config import Config -def run_stress_test(num_submissions, submission_delay, autograder_image, output_file, tango_port, tango_path, job_name, job_path): - with open(output_file, 'a') as f: + +def run_stress_test( + num_submissions, + submission_delay, + autograder_image, + output_file, + tango_port, + tango_path, + job_name, + job_path, +): + with open(output_file, "a") as f: f.write(f"Stress testing with {num_submissions} submissions\n") for i in range(1, num_submissions + 1): command = [ - 'python3', os.path.join(tango_path, 'clients/tango-cli.py'), - '-P', str(tango_port), - '-k', 'test', - '-l', job_name, - '--runJob', job_path, - '--image', autograder_image + "python3", + os.path.join(tango_path, "clients/tango-cli.py"), + "-P", + str(tango_port), + "-k", + "test", + "-l", + job_name, + "--runJob", + job_path, + "--image", + autograder_image, ] - subprocess.run(command, stdout = f, stderr = f) - f.write(f"Submission {i} submitted \n") + subprocess.run(command, stdout=f, stderr=f) + f.write(f"Submission {i} submitted \n") if submission_delay > 0: time.sleep(submission_delay) - + sys.exit() + def get_metrics(output_file): if Config.LOGFILE == None: print("Make sure logs are recorded in a log file") job_times = [] - with open(Config.LOGFILE, 'r') as f: + with open(Config.LOGFILE, "r") as f: for line in f: if "finished after " in line: start = line.find("finished after ") + len("finished after ") seconds = int(line[start:].split()[0]) job_times.append(seconds) - - with open(output_file, 'a') as f: + + with open(output_file, "a") as f: if len(job_times) == 0: print("No jobs have been completed") else: - avg = sum(job_times)/len(job_times) + avg = sum(job_times) / len(job_times) f.write(f"Average job time is {avg} seconds \n") - + sys.exit() if __name__ == "__main__": parser = argparse.ArgumentParser(description="Stress test script for Tango") - parser.add_argument('--num_submissions', type=int, default=10, help="Number of submissions") - parser.add_argument('--submission_delay', type=float, default=1.0, help="Delay between submissions") - parser.add_argument('--autograder_image', type=str, required=True, help="Autograder image") - parser.add_argument('--output_file', type=str, default='stress_test.out', help="Output file") - parser.add_argument('--tango_port', type=int, default=4567, help="Tango server port") - parser.add_argument('--tango_path', type=str, required=True, help="Path to Tango") - parser.add_argument('--job_name', type=str, required=True, help="Name of the job") - parser.add_argument('--job_path', type=str, required=True, help="Path to the job") - parser.add_argument('--get_metrics', type=bool, default = False, help= "Set to true to get metrics, does not create new jobs") + parser.add_argument( + "--num_submissions", type=int, default=10, help="Number of submissions" + ) + parser.add_argument( + "--submission_delay", type=float, default=1.0, help="Delay between submissions" + ) + parser.add_argument( + "--autograder_image", type=str, required=True, help="Autograder image" + ) + parser.add_argument( + "--output_file", type=str, default="stress_test.out", help="Output file" + ) + parser.add_argument( + "--tango_port", type=int, default=4567, help="Tango server port" + ) + parser.add_argument("--tango_path", type=str, required=True, help="Path to Tango") + parser.add_argument("--job_name", type=str, required=True, help="Name of the job") + parser.add_argument("--job_path", type=str, required=True, help="Path to the job") + parser.add_argument( + "--get_metrics", + type=bool, + default=False, + help="Set to true to get metrics, does not create new jobs", + ) args = parser.parse_args() @@ -72,5 +104,5 @@ def get_metrics(output_file): args.tango_port, args.tango_path, args.job_name, - args.job_path - ) \ No newline at end of file + args.job_path, + ) From c4c686891935ad3950401ecd3de4049aaf57fc17 Mon Sep 17 00:00:00 2001 From: David Wang Date: Sun, 27 Oct 2024 14:08:18 -0400 Subject: [PATCH 4/6] fixing linter --- worker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/worker.py b/worker.py index 9f94e301..b5c96e5b 100644 --- a/worker.py +++ b/worker.py @@ -321,7 +321,10 @@ def run(self): # things like runjob timeouts and makefile errors to be # normal termination and doesn't reschedule the job. elapsed_secs = time.time() - start_time - self.log.info("Success: job %s:%d finished after %d seconds" % (self.job.name, self.job.id, elapsed_secs)) + self.log.info( + "Success: job %s:%d finished after %d seconds" + % (self.job.name, self.job.id, elapsed_secs) + ) # Move the job from the live queue to the dead queue # with an explanatory message From 5132168d081f993dde115534e7e4cb97d614305c Mon Sep 17 00:00:00 2001 From: David Wang Date: Sun, 27 Oct 2024 14:25:03 -0400 Subject: [PATCH 5/6] fixing coderabbit --- .gitignore | 2 +- stressTest.py | 28 ++++++++++++++++++++-------- worker.py | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 20e2bbd1..14ed0260 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,4 @@ pip-selfcheck.json .vscode # Backup files -*.bak \ No newline at end of file +*.bak diff --git a/stressTest.py b/stressTest.py index eb42ad39..b21789c3 100644 --- a/stressTest.py +++ b/stressTest.py @@ -19,9 +19,16 @@ def run_stress_test( with open(output_file, "a") as f: f.write(f"Stress testing with {num_submissions} submissions\n") for i in range(1, num_submissions + 1): + tango_cli = os.path.join(tango_path, "clients/tango-cli.py") + if not os.path.isfile(tango_cli): + raise ValueError(f"Tango CLI not found at: {tango_cli}") + if not os.path.exists(job_path): + raise ValueError(f"Job path does not exist: {job_path}") + if not isinstance(tango_port, int) or not (1024 <= tango_port <= 65535): + raise ValueError("Invalid port number") command = [ "python3", - os.path.join(tango_path, "clients/tango-cli.py"), + tango_cli, "-P", str(tango_port), "-k", @@ -33,18 +40,22 @@ def run_stress_test( "--image", autograder_image, ] - subprocess.run(command, stdout=f, stderr=f) - f.write(f"Submission {i} submitted \n") - + try: + subprocess.run(command, stdout=f, stderr=f) + f.write(f"Submission {i} submitted \n") + except subprocess.CalledProcessError as e: + f.write(f"Error running submission {i}: {e}\n") + continue if submission_delay > 0: time.sleep(submission_delay) - sys.exit() + sys.exit(0) def get_metrics(output_file): - if Config.LOGFILE == None: + if Config.LOGFILE is None: print("Make sure logs are recorded in a log file") + sys.exit(0) job_times = [] with open(Config.LOGFILE, "r") as f: @@ -59,9 +70,10 @@ def get_metrics(output_file): print("No jobs have been completed") else: avg = sum(job_times) / len(job_times) - f.write(f"Average job time is {avg} seconds \n") + f.write(f"Total jobs completed: {len(job_times)} \n") + f.write(f"Average job time: {avg} seconds \n") - sys.exit() + sys.exit(0) if __name__ == "__main__": diff --git a/worker.py b/worker.py index b5c96e5b..d00756c0 100644 --- a/worker.py +++ b/worker.py @@ -376,4 +376,4 @@ def run(self): if self.preVM and not vm: vm = self.job.vm = self.preVM if vm: - self.detachVM(return_vm=False, replace_vm=True) + self.detachVM(return_vm=False, replace_vm=True) \ No newline at end of file From 6fb153d22f563675fde755268008c8d7130072e9 Mon Sep 17 00:00:00 2001 From: David Wang Date: Sun, 3 Nov 2024 12:33:06 -0500 Subject: [PATCH 6/6] Fixing linting issues --- worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker.py b/worker.py index d00756c0..b5c96e5b 100644 --- a/worker.py +++ b/worker.py @@ -376,4 +376,4 @@ def run(self): if self.preVM and not vm: vm = self.job.vm = self.preVM if vm: - self.detachVM(return_vm=False, replace_vm=True) \ No newline at end of file + self.detachVM(return_vm=False, replace_vm=True)