https://www.mediawiki.org/wiki/Special:Code/MediaWiki/115128

Revision: 115128
Author:   rfaulk
Date:     2012-05-03 14:50:39 +0000 (Thu, 03 May 2012)
Log Message:
-----------
added 28bot to experiments, enabled specification of revision file in postings 
command call

Modified Paths:
--------------
    trunk/tools/wsor/message_templates/run_postings_and_metrics.py

Modified: trunk/tools/wsor/message_templates/run_postings_and_metrics.py
===================================================================
--- trunk/tools/wsor/message_templates/run_postings_and_metrics.py      
2012-05-03 14:48:35 UTC (rev 115127)
+++ trunk/tools/wsor/message_templates/run_postings_and_metrics.py      
2012-05-03 14:50:39 UTC (rev 115128)
@@ -22,7 +22,7 @@
     Define script usage
 """
 class Usage(Exception):
-    
+
     def __init__(self, msg):
         self.msg = msg
 
@@ -32,53 +32,57 @@
 def main(args):
 
     # Set flags for template indices to process 
+    """
+
+    """
     template_indices = {1 : False, 2 : False, 3 : False,
                         60 : False, 61 : False, 62 : False, 63 : False, 64 : 
False, 65 : False, 66 : False, 67 : False, 68 : False, 69 : False,
                         70 : False, 71 : False, 72 : False, 73 : False, 74 : 
False, 75 : False, 76 : False, 77 : False,
-                        84 : False, 85 : False, 86 : False, 99 : False, 100 : 
False, 101 : False, 102 : False, 103 : False, 104 : False, 
-                        105 : False, 106 : False, 107 : False, 108 : False, 
109 : False, 110 : False, 111 : False, 112 : False,  113 : False, 
-                        114 : False, 115 : False, 116 : False, 87 : False, 88 
: False, 
+                        84 : False, 85 : False, 86 : False, 99 : False, 100 : 
False, 101 : False, 102 : False, 103 : False, 104 : False,
+                        105 : False, 106 : False, 107 : False, 108 : False, 
109 : False, 110 : False, 111 : False, 112 : False,  113 : False,
+                        114 : False, 115 : False, 116 : False, 87 : False, 88 
: False,
                         89 : False, 90 : False, 91 : False, 92 : False, 93 : 
False, 94 : False, 95 : False, 96 : False, 97 : False, 98 : False,
                         78 : False, 79 : False, 81 : False, 82 : False,
                         131 : False, 132 : False, 133 : False, 134 : False, 
135 : False, 136 : False, 137 : False, 138 : False, 139 : False, 140 : False, 
141 : False, 142 : False, # ImageTaggingBot
                         117 : False, 118 : False, 119 : False, 120 : False, 
121 : False, 122 : False, 123 : False, 124 : False, 125 : False, 126 : False, 
127 : False, 128 : False, # CorenSearchBot
                         78 : False, 79 : False, 81 : False, 82 : False, # 
TWINKLE
-                        4 : True, 5 : True  # Welcome templates - chico
-                        }       
-#    template_indices = {78 : True}
+                        4 : True, 5 : True,  # Welcome templates - chico
+                        143 : False, 144 : False, 145 : False, 146 : False  # 
28 bot
+    }
+    #    template_indices = {78 : True}
     # Run postings and metrics
-    
- 
+
+
     generator = 'editcounts'
     postings = True
-    
+
     # postings_cmd = './postings -h db1047 --start=%(start_time)s 
--end=%(end_time)s --comment="%(rev_comment)s" --message="{{%(template)s}}" 
--outfilename postings_%(file_name)s.tsv'
     postings_cmd = './postings -h db42 --start=%(start_time)s 
--end=%(end_time)s --message="{{%(template)s}}" --outfilename 
postings_%(file_name)s.tsv'
-    
+
     # metrics_cmd = 'cat ./output/postings_%(file_name)s.tsv | ./metrics -h 
db1047 --header --outfilename metrics_%(file_name)s_%(fname_generator)s.tsv 
%(generator)s'
     metrics_cmd = 'cat ./output/postings_%(file_name)s.tsv | ./metrics -h db42 
--header --outfilename metrics_%(file_name)s_%(fname_generator)s.tsv 
%(generator)s'
-    
-    for key in template_indices:   
-                        
+
+    for key in template_indices:
+
         if template_indices[key]:
-            
+
             template_name = 'z' + str(key)
             logging.info('Generating postings for %s' % template_name)
-            
-            name, start_ts, end_ts, comment, user, api_uri  = 
get_experiment(key)         
 
+            name, start_ts, end_ts, comment, user, api_uri, use_rev_file  = 
get_experiment(key)
+
             if key >= 60 and key <= 116:
                 filename_part = start_ts[4:8] + '_' + end_ts[4:8] + '_' + 
template_name
             else:
                 filename_part = template_name
-                        
+
             # filename_part = 'pt_' + template_name
             # filename_part = 'test_' + start_ts[4:8] + '_' + end_ts[4:8] + 
'_' + template_name
-            
+
             if postings:
-                cmd = postings_cmd % {'start_time' : start_ts, 'end_time' : 
end_ts, 'template' : template_name, 
+                cmd = postings_cmd % {'start_time' : start_ts, 'end_time' : 
end_ts, 'template' : template_name,
                                       'file_name' : filename_part}
-                
+
                 # Optionally add the user, comment, or api args
                 if comment != None:
                     cmd += ' --comment="%s"' % comment
@@ -86,16 +90,18 @@
                     cmd += ' --user_name="%s"' % user
                 if api_uri != None:
                     cmd +=  ' -a %s' % api_uri
+                if use_rev_file != None:
+                    cmd += ' --use_in_file %s' % use_rev_file
 
             else:
                 cmd = metrics_cmd % {'file_name' : filename_part, 'generator' 
: generator, 'fname_generator' : generator}
-            
+
             logging.info('Issuing command: %s' % cmd)
             os.system(cmd)
 
         else:
             logging.info('Skipping postings for z%s ' % str(key))
-            
+
     return 0
 
 
@@ -103,11 +109,12 @@
     Returns the experiment name and start and end timestamps corresponding to 
the key 
 """
 def get_experiment(index):
-    
+
     user = None
     comment = None
     api_uri = None
-    
+    use_rev_file = None
+
     if index >= 60 and index <= 77:
         test_handle = 'Huggle_3'
         start_ts = '20111018000000'
@@ -119,7 +126,8 @@
         start_ts = '20120201000000'
         end_ts = '20120312000000'
         api_uri = 'http://pt.wikipedia.org/w/api.php'
-    
+        use_rev_file = '/home/rfaulk/pt_welcome_users.tsv'
+
     elif index >= 1 and index <= 3:
         test_handle = 'Huggle_1_Portuguese'
         start_ts = '20111027000000'
@@ -131,13 +139,13 @@
         start_ts = '20111108000000'
         end_ts = '20111202000000'
         comment = '\(\[\[WP:HG\|HG\]\]\)'
-        
+
     elif index >= 107 and index <= 116:
         test_handle = 'Huggle_Short_2'
         start_ts = '20111122000000'
         end_ts = '20111222000000'
         comment = '\(\[\[WP:HG\|HG\]\]\)'
-        
+
     elif (index >= 78 and index <= 79) or (index >= 81 and index <= 82):
         test_handle = 'Twinkle_1'
         start_ts = '20111109000000'
@@ -156,21 +164,28 @@
         end_ts = '20120226000000'
         user = 'CorenSearchBot'
         comment = '.*'
-        
+
     elif index >= 131 and index <= 142:
         test_handle = 'ImageTaggingBot'
         start_ts = '20111221000000'
         end_ts = '20120221000000'
         user = 'ImageTaggingBot'
         comment = '.*'
-                
+
+    elif index >= 143 and index <= 146:
+        test_handle = '28Bot'
+        start_ts = '20120119000000'
+        end_ts = '20120501000000'
+        user = '28bot'
+        comment = '.*'
+
     logging.info('Processing %(test_handle)s from %(start_ts)s to %(end_ts)s 
on comment "%(comment)s" for user "%(user)s" ...' % {'test_handle' : 
test_handle, 'start_ts' : start_ts, 'end_ts' : end_ts, 'comment' : comment, 
'user' : user})
-   
-    return test_handle, start_ts, end_ts, comment, user, api_uri
-    
+
+    return test_handle, start_ts, end_ts, comment, user, api_uri, use_rev_file
+
 """
     Call main, exit when execution is complete
 
-""" 
+"""
 if __name__ == "__main__":
     main([])
\ No newline at end of file


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to