7
7
8
8
from luigi import six
9
9
10
- parser = argparse .ArgumentParser (
11
- "luigi-grep is used to search for workflows using the luigi scheduler's json api" )
12
- parser .add_argument (
13
- "--scheduler-host" , default = "localhost" , help = "hostname of the luigi scheduler" )
14
- parser .add_argument (
15
- "--scheduler-port" , default = "8082" , help = "port of the luigi scheduler" )
16
- parser .add_argument ("--prefix" , help = "prefix of a task query to search for" , default = None )
17
- parser .add_argument ("--status" , help = "search for jobs with the given status" , default = None )
18
-
19
10
20
11
class LuigiGrep (object ):
21
12
@@ -29,7 +20,7 @@ def graph_url(self):
29
20
30
21
def _fetch_json (self ):
31
22
"""Returns the json representation of the dep graph"""
32
- print "Fetching from url: " + self .graph_url
23
+ print ( "Fetching from url: " + self .graph_url )
33
24
resp = urllib2 .urlopen (self .graph_url ).read ()
34
25
return json .loads (resp )
35
26
@@ -61,7 +52,17 @@ def status_search(self, status):
61
52
if job_info ['status' ].lower () == status .lower ():
62
53
yield self ._build_results (jobs , job )
63
54
64
- if __name__ == '__main__' :
55
+
56
+ def main ():
57
+ parser = argparse .ArgumentParser (
58
+ "luigi-grep is used to search for workflows using the luigi scheduler's json api" )
59
+ parser .add_argument (
60
+ "--scheduler-host" , default = "localhost" , help = "hostname of the luigi scheduler" )
61
+ parser .add_argument (
62
+ "--scheduler-port" , default = "8082" , help = "port of the luigi scheduler" )
63
+ parser .add_argument ("--prefix" , help = "prefix of a task query to search for" , default = None )
64
+ parser .add_argument ("--status" , help = "search for jobs with the given status" , default = None )
65
+
65
66
args = parser .parse_args ()
66
67
grep = LuigiGrep (args .scheduler_host , args .scheduler_port )
67
68
@@ -77,3 +78,6 @@ def status_search(self, status):
77
78
print (" status={status}" .format (status = status ))
78
79
for job in jobs :
79
80
print (" {job}" .format (job = job ))
81
+
82
+ if __name__ == '__main__' :
83
+ main ()
0 commit comments