Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the dag scripts #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]: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 <filename>

# updates to the local repo
git commit

# update on the server
git push
57 changes: 35 additions & 22 deletions condor/dagman/build_dag.py
Original file line number Diff line number Diff line change
@@ -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} /data/condor_builds/users/blaufuss/umd_computing_examples/condor/dagman/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)
28 changes: 14 additions & 14 deletions condor/dagman/submit.sub
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@
# /data/i3store0/ OR /data/i3scratch0/
################################################################

## Jobs requiring more than 1GB of memory or 1CPU can add:
#request_cpus = <num_cpus>
#request_memory = 5
#<mem_in_MB> (default 1GB in umd, 2GB in wisc)
#request_disk = <disk_in_KB>

# 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
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).$(Cluster).out
error = $(basedir)$(Jobname).$(Cluster).err
should_transfer_files = YES
output = $(logfile)
error = $(logfile)

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 = $(logfile)

## 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
getenv = true
universe = vanilla

# Submit !
Arguments = $(command)
queue

64 changes: 64 additions & 0 deletions condor/dagman/test_script.py
Original file line number Diff line number Diff line change
@@ -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)

22 changes: 22 additions & 0 deletions condor/dagman/test_single.sub
Original file line number Diff line number Diff line change
@@ -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