Due Monday, November 26, at the start of class.
Run a job (or many!) on CHTC using HTCondor. This is our gateway into tapping the full potential of CHTC via scripting.
This assignment is quite straightforward, but I will walk you through some of the set-up steps, just to be sure.
submit-368.chtc.wisc.edu. You can
sshto the machine from any other machine, including your own desktop or laptop. If you are not sure how to
sshto a remote machine, check out the Remote Logins section of my Notes for Beginners page.
condor_q. If those commands fail, contact me right away.
#!/usr/bin/env python """Homework for CS 368-4 (2012 Fall) Assigned on Day 09, 2012-11-19 Written by Tim Cartwright Submitted to CHTC by YOUR NAME """ import getpass import os import platform import socket import sys import time input_filename = None if len(sys.argv) > 1: input_filename = sys.argv print >> sys.stderr, __doc__ print 'Time :', time.strftime('%Y-%m-%d (%a) %H:%M:%S %Z') print 'Host :', getpass.getuser(), '@', socket.gethostname() uname = platform.uname() print "System :", uname, uname, uname print "Version :", platform.python_version() print "Program :", sys.executable print 'Script :', os.path.abspath(__file__) print if input_filename is None: print 'No input filename given, all done!' sys.exit(0) print 'Reading input file at', os.path.abspath(input_filename) input_file_object = open(input_filename, 'r') input_lines = input_file_object.readlines() print 'Found %d lines in the input file' % (len(input_lines)) input_file_object.close() output_file_object = open('homework-09-output.txt', 'w') print >> output_file_object, 'First line of input file:' print >> output_file_object, input_lines.rstrip('\n') output_file_object.close() print 'Wrote output file'
chmod 0755 homework_09.py
If you named the script something other than
homework_09.py, substitute your actual script file
name in command above instead.
And then, with a single command-line argument, which is the name of your input text file:
If you cannot run your script like this, neither can HTCondor! Fix any problems with the script and/or your command until this step works perfectly.
When you provide a command-line argument, be sure to check out the output file created by the script:
Here are some things to observe and/or watch out for.
007 (010.000.000) 11/13 06:26:43 Shadow exception!
The key phrase is the
Shadow exception! part. If you see this message in your log file, probably
repeated many times, remove your entire job cluster. Then, try running your script from the command-line again.
Does it really work? If so, check over your submit file very carefully for typos. When this error happened to
me (yes, I screwed up!), it was because I could not run my script from the command-line correctly.
Like writing code with Python itself, the more you play around with the basics of HTCondor and running jobs, the more you will learn and be ready for the next step(s). So, here are some things to try:
#!/usr/bin/env pythonline at the top of each script
chmodcommand (above) on your script file
submit-368.chtc.wisc.edu, because the environment on that machine is most similar to the environment on (most of) the execute machines. Once again, be absolutely sure that your compiled program works from the command line on
submit-368before actually submitting it.
Do the work yourself, consulting reasonable reference materials as needed; any reference material that gives you a complete or nearly complete solution to this problem or a similar one is not OK to use. Asking the instructors for help is OK, asking other students for help is not. All standard UW policies concerning student conduct (esp. UWS 14) and information technology apply to this course and assignment.
All homework assignments must be turned in by email! See the email page for more details about formatting, etc.
For this assignment, you must submit several files in order for your assignment to be complete:
All of these files should be from a single run of the script (you may choose which version to send me, with or without the input file).