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

Revision: 114950
Author:   rfaulk
Date:     2012-04-18 00:15:24 +0000 (Wed, 18 Apr 2012)
Log Message:
-----------
modified to allow optional "user", "comment", and "api_uri" args
added new experiment template definitions

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-04-17 23:23:26 UTC (rev 114949)
+++ trunk/tools/wsor/message_templates/run_postings_and_metrics.py      
2012-04-18 00:15:24 UTC (rev 114950)
@@ -37,51 +37,94 @@
                         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, 78 : False, 79 
: False, 81 : False, 82 : False, 87 : True, 88 : True, 
-                        89 : True, 90 : True, 91 : True, 92 : True, 93 : True, 
94 : True, 95 : True, 96 : True, 97 : True, 98 : True
-                        }    
+                        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}
     # Run postings and metrics
     
-    generator = 'editcount'
-        
-    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'
-    metrics_cmd = 'cat ./output/postings_%(file_name)s.tsv | ./metrics -h 
db1047 --header --outfilename metrics_%(file_name)s_%(fname_generator)s.tsv 
%(generator)s'
+ 
+    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:   
-        
-        name, start_ts, end_ts, comment = get_experiment(key)
-        template_name = 'z' + str(key)
-        
+                        
         if template_indices[key]:
             
+            template_name = 'z' + str(key)
             logging.info('Generating postings for %s' % template_name)
-            # filename_part = start_ts[4:8] + '_' + end_ts[4:8] + '_' + 
template_name
-            filename_part = 'test_' + start_ts[4:8] + '_' + end_ts[4:8] + '_' 
+ template_name
+            
+            name, start_ts, end_ts, comment, user, api_uri  = 
get_experiment(key)         
 
-            os.system(postings_cmd % {'start_time' : start_ts, 'end_time' : 
end_ts, 'template' : template_name, 'file_name' : filename_part, 'rev_comment' 
: comment})
-            # os.system(metrics_cmd % {'file_name' : filename_part, 
'file_name' : filename_part, 'generator' : generator, 'fname_generator' : 
generator})
+            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, 
+                                      'file_name' : filename_part}
+                
+                # Optionally add the user, comment, or api args
+                if comment != None:
+                    cmd += ' --comment="%s"' % comment
+                if user != None:
+                    cmd += ' --user_name="%s"' % user
+                if api_uri != None:
+                    cmd +=  ' -a %s' % api_uri
+
+            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 %s' % template_name)
+            logging.info('Skipping postings for z%s ' % str(key))
             
     return 0
 
+
 """
     Returns the experiment name and start and end timestamps corresponding to 
the key 
 """
 def get_experiment(index):
     
+    user = None
+    comment = None
+    api_uri = None
+    
     if index >= 60 and index <= 77:
         test_handle = 'Huggle_3'
         start_ts = '20111018000000'
         end_ts = '20111119000000'
         comment = '\(\[\[WP:HG\|HG\]\]\)'
 
+    elif index >= 4 and index <= 5:
+        test_handle = 'Welcome_PT'
+        start_ts = '20120201000000'
+        end_ts = '20120312000000'
+        api_uri = 'http://pt.wikipedia.org/w/api.php'
+    
     elif index >= 1 and index <= 3:
         test_handle = 'Huggle_1_Portuguese'
         start_ts = '20111027000000'
         end_ts = '20111128000000'
-        comment = '\(\[\[WP:HG\|HG\]\]\)'
+        comment = '\(\[\[WP:H\|Huggle\]\]\)'
 
     elif (index >= 84 and index <= 86) or (index >= 99 and index <= 106):
         test_handle = 'Huggle_Short_1_and_2'
@@ -107,9 +150,23 @@
         end_ts = '20111217000000'
         comment = 'BOT'
 
-    logging.info('Processing %(test_handle)s from %(start_ts)s to %(end_ts)s 
on comment "%(comment)s" ...' % {'test_handle' : test_handle, 'start_ts' : 
start_ts, 'end_ts' : end_ts, 'comment' : comment})
+    elif index >= 117 and index <= 128:
+        test_handle = 'CorenSearchBot'
+        start_ts = '20120112000000'
+        end_ts = '20120226000000'
+        user = 'CorenSearchBot'
+        comment = '.*'
+        
+    elif index >= 131 and index <= 142:
+        test_handle = 'ImageTaggingBot'
+        start_ts = '20111221000000'
+        end_ts = '20120221000000'
+        user = 'ImageTaggingBot'
+        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
+    return test_handle, start_ts, end_ts, comment, user, api_uri
     
 """
     Call main, exit when execution is complete


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

Reply via email to