a_simple_example_of_submitting_an_htcondor_job.md 5.71 KB
Newer Older
Adam Caprez's avatar
Adam Caprez committed
1
2
3
4
5
6
7
+++
title = "A simple example of submitting an HTCondor job"
description = "A simple example of submitting an HTCondor job."
+++

This page describes a complete example of submitting an HTCondor job.

8
1.  SSH to Crane
Adam Caprez's avatar
Adam Caprez committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167

    {{% panel theme="info" header="ssh command" %}}
    [apple@localhost]ssh apple@crane.unl.edu
    {{% /panel %}}

    {{% panel theme="info" header="output" %}}
    [apple@login.crane~]$
    {{% /panel %}}

2.  Write a simple python program in a file "hello.py" that we wish to
    run using HTCondor

    {{% panel theme="info" header="edit a python code named 'hello.py'" %}}
    [apple@login.crane ~]$ vim hello.py
    {{% /panel %}}

    Then in the edit window, please input the code below:

    {{% panel theme="info" header="hello.py" %}}
    #!/usr/bin/env python
    import sys
    import time
    i=1
    while i<=6:
            print i
            i+=1
            time.sleep(1)
    print 2**8
    print "hello world received argument = " +sys.argv[1]
    {{% /panel %}}

    This program will print 1 through 6 on stdout, then print the number
    256, and finally print  `hello world received argument = <Command
    Line Argument Sent to the hello.py>`

     

3.  Write an HTCondor submit script named "hello.submit"

    {{% panel theme="info" header="hello.submit" %}}
    Universe        = vanilla
    Executable      = hello.py
    Output          = OUTPUT/hello.out.$(Cluster).$(Process).txt
    Error           = OUTPUT/hello.error.$(Cluster).$(Process).txt
    Log             = OUTPUT/hello.log.$(Cluster).$(Process).txt
    notification = Never
    Arguments = $(Process)
    PeriodicRelease = ((JobStatus==5) && (CurentTime - EnteredCurrentStatus) > 30)
    OnExitRemove = (ExitStatus == 0)
    Queue 4
    {{% /panel %}}

4.  Create an OUTPUT directory to receive all output files that
    generated by your job (OUTPUT folder is used in the submit script
    above )

    {{% panel theme="info" header="create output directory" %}}
    [apple@login.crane ~]$ mkdir OUTPUT
    {{% /panel %}}

5.  Submit your job

    {{% panel theme="info" header="condor_submit" %}}
    [apple@login.crane ~]$ condor_submit hello.submit
    {{% /panel %}}

    {{% panel theme="info" header="Output of submit" %}}
    Submitting job(s)

    ....
    4 job(s) submitted to cluster 1013054.
    {{% /panel %}}

6.  Check status of `condor_q`

    {{% panel theme="info" header="condor_q" %}}
    [apple@login.crane ~]$ condor_q
    {{% /panel %}}

    {{% panel theme="info" header="Output of `condor_q`" %}}
    -- Schedd: login.crane.hcc.unl.edu : <129.93.227.113:9619?...
     ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD
    720587.0   logan          12/15 10:48  33+14:41:17 H  0   0.0  continuous.cron 20
    720588.0   logan          12/15 10:48 200+02:40:08 H  0   0.0  checkprogress.cron
    1012864.0   jthiltge        2/15 16:48   0+00:00:00 H  0   0.0  test.sh
    1013054.0   jennyshao       4/3  17:58   0+00:00:00 R  0   0.0  hello.py 0
    1013054.1   jennyshao       4/3  17:58   0+00:00:00 R  0   0.0  hello.py 1
    1013054.2   jennyshao       4/3  17:58   0+00:00:00 I  0   0.0  hello.py 2
    1013054.3   jennyshao       4/3  17:58   0+00:00:00 I  0   0.0  hello.py 3
    7 jobs; 0 completed, 0 removed, 0 idle, 4 running, 3 held, 0 suspended
    {{% /panel %}}

    Listed below are the three status of the jobs as observed in the
    above output

    | Symbol | Representation   |
    |--------|------------------|
    | H      | Held             |
    | R      | Running          |
    | I      | Idle and waiting |


7.  Explanation of the `$(Cluster)` and `$(Process)` in HTCondor script

    `$(Cluster)` and `$(Process)` are variables that are available in the
    variable name space in the HTCondor  script. `$(Cluster)` means the
    prefix of your job ID and `$(Process)` varies from `0` through number of
    jobs called with `Queue - 1`. If your job is a single job, then
    `$(Cluster) =` `<job ID>` else, your job ID is combined with `$(Cluster)` and
    `$(Process)`.

    In this example, `$(Cluster)`="1013054" and `$(Process)` varies from "0"
    to "3" for the above HTCondor script.
    In majority of the cases one will use these variables for modifying
    the behavior of each individual task of the HTCondor submission, for
    example one may vary the input/output file/parameters for the run
    program. In this example we are simply passing the `$(Process)` as
    arguments as `sys.argv[1]` in `hello.py`.
    The lines of interest for this discussion from file the HTCondor
    script "hello.submit" are listed below in the code section :

    {{% panel theme="info" header="for `$(Process)`" %}}
    Output= hello.out.$(Cluster).$(Process).txt
    Arguments = $(Process)
    Queue 4
    {{% /panel %}}

    The line of interest for this discussion from file "hello.py" is
    listed in the code section below:

    {{% panel theme="info" header="for `$(Process)`" %}}
    print "hello world received argument = " +sys.argv[1]
    {{% /panel %}}

8.  Viewing the results of your job

    After your job is completed you may use Linux "cat" or "vim" command
    to view the job output.

    For example in the file `hello.out.1013054.2.txt`, "1013054" means
    `$(Cluster)`, and "2" means `$(Process)` the output looks like.

    **example of one output file "hello.out.1013054.2.txt"**
    {{% panel theme="info" header="example of one output file `hello.out.1013054.2.txt`" %}}
    1
    2
    3
    4
    5
    6
    256
    hello world received argument = 2
    {{% /panel %}}

9.  Please see the link below for one more example:

    http://research.cs.wisc.edu/htcondor/tutorials/intl-grid-school-3/submit_first.html

Next: [Using Distributed Environment Modules on OSG]({{< relref "using_distributed_environment_modules_on_osg" >}})