From 7108275a31f2c82be66b3929b66db74df7ca42ce Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 10 Aug 2021 13:11:10 -0400 Subject: [PATCH 1/4] Add a new test script --- condor/dagman/build_dag.py | 2 +- condor/dagman/test_script.py | 64 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 condor/dagman/test_script.py diff --git a/condor/dagman/build_dag.py b/condor/dagman/build_dag.py index 93cda54..950096e 100755 --- a/condor/dagman/build_dag.py +++ b/condor/dagman/build_dag.py @@ -19,6 +19,6 @@ #spec_ind = -2.0 command = f'python {script} {twin} {spec_ind} {counter}' job_id = f'{jobbase}_{counter}' - print(f'JOB {job_id} /data/condor_builds/users/blaufuss/umd_computing_examples/condor/dagman/submit.sub') + print(f'JOB {job_id} {os.getcwd()}/submit.sub') print(f'VARS {job_id} JOBNAME="{job_id}" command="{command}"') counter += 1 diff --git a/condor/dagman/test_script.py b/condor/dagman/test_script.py new file mode 100644 index 0000000..fad9dd2 --- /dev/null +++ b/condor/dagman/test_script.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import os +import pickle +import argparse +import matplotlib +matplotlib.use('Agg') + +from matplotlib import pyplot as plt +import numpy as np +from scipy.stats import norm + +parser = argparse.ArgumentParser() +parser.add_argument("-o", "--outfile", type=str, required=True, + help = "Name of the output file (ending in .npy") +parser.add_argument("-p", "--plotfile", type=str, default=None, + help = "If given, create a histogram of the values and save it here.") +parser.add_argument("-n", "--nvalues", type=int, + default = 10000, + help = "The number of random values to create") +parser.add_argument("--gaussian", default=False, action="store_true", + help = "If given, produce values from a Gaussian instead of" + " from a uniform distribution") +args = parser.parse_args() + + +# Going to generate some basic test data +if args.gaussian: + my_random_values = norm.rvs(loc=0, scale=1, size=args.nvalues) +else: + my_random_values = np.random.uniform(low=-1, high=1, size=args.nvalues) + +# Save the files +np.save(args.outfile, my_random_values) + +# Are we making a plot? +if args.plotfile is not None: + fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8, 5)) + + ax.hist(my_random_values, + bins = np.linspace(-1, 1, 101), + histtype='step', + linewidth=3, + color='k', + label = "My values!") + + # Add a legend + ax.legend(loc='upper right', framealpha=1, fontsize=12) + + # Make it look nice + ax.grid(alpha=0.25) + ax.set_xlim(xmin=-1, xmax=1) + ax.set_xlabel("Random values", fontsize=16) + ax.set_ylabel("Number of values in each bin", fontsize=16) + + # Make the numbers on the axis larger + ax.tick_params(labelsize=12) + + # Move things around to fix any spacing issues + fig.tight_layout() + + # And save + plt.savefig(args.plotfile) + From e87174acedc4690a1def90116f589e5fa5cbb648 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 10 Aug 2021 13:14:05 -0400 Subject: [PATCH 2/4] Updates to the submit.sub file --- condor/dagman/submit.sub | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/condor/dagman/submit.sub b/condor/dagman/submit.sub index fdbbe94..861b2aa 100644 --- a/condor/dagman/submit.sub +++ b/condor/dagman/submit.sub @@ -13,23 +13,25 @@ # /data/i3store0/ OR /data/i3scratch0/ ################################################################ -## Jobs requiring more than 1GB of memory or 1CPU can add: -#request_cpus = -#request_memory = 5 -# (default 1GB in umd, 2GB in wisc) -#request_disk = - # Run the environment script from icetray before anything else -#executable = /data/condor_builds/users/blaufuss/combo/stable/build/env-shell.sh executable = /cvmfs/icecube.opensciencegrid.org/py3-v4.1.0/Ubuntu_18.04_x86_64/metaprojects/combo/V01-00-00/env-shell.sh +Arguments = "$(args)" + # Where the log, out, err files will live basedir = /data/condor_builds/users/blaufuss/umd_computing_examples/condor/dagman/ -output = $(basedir)$(Jobname).$(Cluster).out -error = $(basedir)$(Jobname).$(Cluster).err -should_transfer_files = YES +output = $(basedir)/$(Jobname).out +error = $(basedir)/$(Jobname).err + +should_transfer_files = NO # Only 1 log file for all jobs -log = /data/condor_builds/users/blaufuss/umd_computing_examples/condor/dagman/$(Jobname).log +# "log" holds the information about how Condor is assigning the job +log = $(logdir)/$(Jobname).log + +## Jobs requiring more than 1GB of memory or 1CPU can add: +request_cpus = 1 +request_memory = 2GB +request_disk = 1GB # Other condor stuff notification = never From a4be9437daa90c2a0b199efca9597678223d622d Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 10 Aug 2021 13:15:28 -0400 Subject: [PATCH 3/4] Add git commands to the README file --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 3eaa154..7fa19ba 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,22 @@ Some example setup files for using UMD computing. * Example HT condor job files This is new material + + +# Copy the code from github. This way assumes you have your public ssh key on github +git clone git@github.com:mjlarson/umd_computing_examples.git + +# List any changed or new files +git status + +# List where these files came from on github +git remote -v + +# Tell git that you plan to copy the updates of these files to the repository +git add + +# updates to the local repo +git commit + +# update on the server +git push From 3771ad32531e71e6daecd396ceda0a5a51ccf57b Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 10 Aug 2021 14:25:06 -0400 Subject: [PATCH 4/4] Working versions of the scripts --- condor/dagman/build_dag.py | 57 +++++++++++++++++++++-------------- condor/dagman/submit.sub | 10 +++--- condor/dagman/test_single.sub | 22 ++++++++++++++ 3 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 condor/dagman/test_single.sub diff --git a/condor/dagman/build_dag.py b/condor/dagman/build_dag.py index 950096e..2fc54aa 100755 --- a/condor/dagman/build_dag.py +++ b/condor/dagman/build_dag.py @@ -1,24 +1,37 @@ #!/usr/bin/env python -#Let's make a dag. -# ./build_dag.py > newdag.dag -# then hand it to condor -import numpy as np - -jobbase = 'stacked_sens_test' -script = '/data/condor_builds/users/blaufuss/umd_computing_examples/jupyter/stacked_sensitivity_refactor.py' - -counter = 0 - -time_windows = np.logspace(1,6,6) -spectra = np.linspace(-3.5,-1,11) - -for twin in time_windows: - for spec_ind in spectra: - #twin = 100 - #spec_ind = -2.0 - command = f'python {script} {twin} {spec_ind} {counter}' - job_id = f'{jobbase}_{counter}' - print(f'JOB {job_id} {os.getcwd()}/submit.sub') - print(f'VARS {job_id} JOBNAME="{job_id}" command="{command}"') - counter += 1 +# test_script.py [-h] -o OUTFILE [-p PLOTFILE] [-n NVALUES] [--gaussian] +# Want to run 100 files with 10000 values each with gaussian +# + 100 files with 10000 values each with uniform + +executable = "/data/condor_builds/users/mlarson/umd_workshop/umd_computing_examples/condor/dagman/test_script.py" +sub_name = "/data/condor_builds/users/mlarson/umd_workshop/umd_computing_examples/condor/dagman/submit.sub" +logdir = "/data/condor_builds/users/mlarson/umd_workshop/umd_computing_examples/condor/dagman/logs/" +outfile_dir = "/data/condor_builds/users/mlarson/umd_workshop/umd_computing_examples/condor/dagman/output/" + +dagman = "" + +for gaussian in [True, False]: + for i in range(100): + if gaussian: job_name = "gaussian_" + else: job_name = "uniform_" + + job_name += str(i) + dagman += f"JOB {job_name} {sub_name}\n" + dagman += f"VARS {job_name} " + dagman += f"executable=\"{executable}\" " + dagman += f"args=\"" + dagman += f" -o {outfile_dir}{job_name}.npy " + dagman += f" -p {outfile_dir}{job_name}.pdf " + dagman += f" -n 10000 " + if gaussian: + dagman += " --gaussian" + dagman += "\"" + + dagman += f" logfile=\"{logdir}{job_name}.log\"" + + dagman += "\n" + + +with open("my_dagman.dag", "w") as f: + f.write(dagman) diff --git a/condor/dagman/submit.sub b/condor/dagman/submit.sub index 861b2aa..dc0f003 100644 --- a/condor/dagman/submit.sub +++ b/condor/dagman/submit.sub @@ -14,19 +14,18 @@ ################################################################ # Run the environment script from icetray before anything else -executable = /cvmfs/icecube.opensciencegrid.org/py3-v4.1.0/Ubuntu_18.04_x86_64/metaprojects/combo/V01-00-00/env-shell.sh +executable = $(executable) Arguments = "$(args)" # Where the log, out, err files will live -basedir = /data/condor_builds/users/blaufuss/umd_computing_examples/condor/dagman/ -output = $(basedir)/$(Jobname).out -error = $(basedir)/$(Jobname).err +output = $(logfile) +error = $(logfile) should_transfer_files = NO # Only 1 log file for all jobs # "log" holds the information about how Condor is assigning the job -log = $(logdir)/$(Jobname).log +log = $(logfile) ## Jobs requiring more than 1GB of memory or 1CPU can add: request_cpus = 1 @@ -39,6 +38,5 @@ getenv = true universe = vanilla # Submit ! -Arguments = $(command) queue diff --git a/condor/dagman/test_single.sub b/condor/dagman/test_single.sub new file mode 100644 index 0000000..b6ef460 --- /dev/null +++ b/condor/dagman/test_single.sub @@ -0,0 +1,22 @@ +# Unix submit description file +# sleep.sub -- simple sleep job +universe = vanilla +getenv = True + +executable = test_script.py + +log = Busy.log +output = Busy.$(Process).out +error = Busy.$(Process).error + +should_transfer_files = Yes +when_to_transfer_output = ON_EXIT + +arguments = "-o test1.npy --gaussian" +queue + +arguments = "-o test2.npy --gaussian" +queue + +arguments = "-o test3.npy" +queue