← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/kill-rpsd into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/kill-rpsd into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #898648 in Launchpad itself: "cronscripts/rosetta-pofile-stats-daily.py is unnecessary"
  https://bugs.launchpad.net/launchpad/+bug/898648

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/kill-rpsd/+merge/114300

cronscripts/rosetta-pofile-stats-daily.py is unnecessary, has not been run for quite a while, interferes with FDT if it does want to get run, and has been replaced by a job. Delete it, with prejudice.
-- 
https://code.launchpad.net/~stevenk/launchpad/kill-rpsd/+merge/114300
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/kill-rpsd into lp:launchpad.
=== removed file 'cronscripts/rosetta-pofile-stats-daily.py'
--- cronscripts/rosetta-pofile-stats-daily.py	2012-01-01 03:14:54 +0000
+++ cronscripts/rosetta-pofile-stats-daily.py	1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
-#!/usr/bin/python -S
-#
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-# pylint: disable-msg=W0403
-
-"""Refresh and verify cached statistics for recently touched POFiles."""
-
-import _pythonpath
-
-from lp.services.scripts.base import LaunchpadCronScript
-from lp.translations.scripts.verify_pofile_stats import (
-    VerifyRecentPOFileStatsProcess,
-    )
-
-
-class VerifyRecentPOFileStats(LaunchpadCronScript):
-    """Go through recently touched `POFile`s and update their statistics."""
-
-    def main(self):
-        verifier = VerifyRecentPOFileStatsProcess(self.txn, self.logger)
-        verifier.run()
-
-
-if __name__ == '__main__':
-    script = VerifyRecentPOFileStats(name="pofile-stats-daily",
-                                     dbuser='pofilestats_daily')
-    script.lock_and_run()

=== modified file 'lib/lp/translations/doc/pofile-verify-stats.txt'
--- lib/lp/translations/doc/pofile-verify-stats.txt	2011-12-29 05:29:36 +0000
+++ lib/lp/translations/doc/pofile-verify-stats.txt	2012-07-10 23:37:53 +0000
@@ -119,75 +119,6 @@
     <BLANKLINE>
     See the log file for detailed information.
 
-Verify recently touched POFiles runs
-------------------------------------
-
-A separate script is used to verify statistics on POFiles that have
-been modified in the last week (or whatever number of days is configured
-in rosetta_pofile_stats.days_considered_recent parameter).
-
-    >>> from lp.translations.scripts.verify_pofile_stats import (
-    ...     VerifyRecentPOFileStatsProcess)
-    >>> from datetime import datetime, timedelta
-    >>> import pytz
-    >>> from zope.security.proxy import removeSecurityProxy
-
-In default configuration, we are looking for files modified in the last
-7 days.
-
-    >>> from lp.services.config import config
-    >>> pofile_age = int(
-    ...     config.rosetta_pofile_stats.days_considered_recent)
-    >>> pofile_age
-    7
-
-We add two POFiles with incorrect statistics, with one of them last
-modified 8 days ago, and another recently modified.
-
-    >>> now = datetime.now(pytz.UTC)
-    >>> more_than_a_week_ago = now - timedelta(pofile_age + 1)
-    >>> pofile_recent = removeSecurityProxy(factory.makePOFile('sr'))
-    >>> pofile_recent.rosettacount = 9
-    >>> pofile_old = removeSecurityProxy(factory.makePOFile('sr'))
-    >>> pofile_old.date_changed = more_than_a_week_ago
-    >>> pofile_old.rosettacount = 9
-
-A run of `VerifyRecentPOFileStatsProcess` script fixes only the POFile
-which was modified in the last week.
-
-    >>> verifier = VerifyRecentPOFileStatsProcess(transaction, logger)
-    >>> verifier.run()
-    INFO Verifying stats of POFiles updated in the last 7 days.
-    INFO Verifying a total of 1 POFiles.
-    INFO POFile ...:
-    cached stats were (0, 0, 9, 0), recomputed as (0, 0, 0, 0)
-    INFO Done.
-
-We can see that stats have been updated in the recently touched POFile,
-but not in the older one.
-
-    >>> pofile_recent.rosettacount
-    0
-    >>> pofile_old.rosettacount
-    9
-
-
-An actual script run also works, though it finds no errors since they were
-all fixed already.
-
-    >>> transaction.commit() # Ensure other process can see latest changes
-
-    >>> from lp.testing.script import run_script
-    >>> (returncode, out, err) = run_script(
-    ...     'cronscripts/rosetta-pofile-stats-daily.py')
-    >>> print returncode
-    0
-    >>> print err
-    INFO    Creating lockfile: /var/lock/launchpad-pofile-stats-daily.lock
-    INFO    Verifying stats of POFiles updated in the last ... days.
-    INFO    Verifying a total of 1 POFiles.
-    INFO    Done.
-
 Cron job
 --------
 

=== modified file 'lib/lp/translations/scripts/verify_pofile_stats.py'
--- lib/lp/translations/scripts/verify_pofile_stats.py	2012-06-29 08:40:05 +0000
+++ lib/lp/translations/scripts/verify_pofile_stats.py	2012-07-10 23:37:53 +0000
@@ -6,16 +6,13 @@
 """Verify (and refresh) `POFile`s' cached statistics."""
 
 __metaclass__ = type
-__all__ = ['VerifyPOFileStatsProcess']
-
-
-from datetime import (
-    datetime,
-    timedelta,
-    )
+__all__ = [
+    'VerifyPOFileStatsProcess',
+    ]
+
+
 import logging
 
-import pytz
 from zope.component import getUtility
 from zope.interface import implements
 
@@ -103,27 +100,6 @@
                 % (pofile.id, str(old_stats), str(new_stats)))
 
 
-class QuickVerifier(Verifier):
-    """`ITunableLoop` to verify statistics on POFiles touched recently."""
-
-    def __init__(self, transaction, logger, start_at_id=0):
-        super(QuickVerifier, self).__init__(transaction, logger, start_at_id)
-        days_considered_recent = int(
-            config.rosetta_pofile_stats.days_considered_recent)
-        cutoff_time = (
-            datetime.now(pytz.UTC) - timedelta(days_considered_recent))
-        self.touched_pofiles = self.pofileset.getPOFilesTouchedSince(
-            cutoff_time)
-        self.logger.info(
-            "Verifying a total of %d POFiles." % self.touched_pofiles.count())
-
-    def getPOFilesBatch(self, chunk_size):
-        """Return a batch of POFiles to work with."""
-        pofiles = self.touched_pofiles[
-            self.total_checked: self.total_checked + int(chunk_size)]
-        return pofiles
-
-
 class VerifyPOFileStatsProcess:
     """Recompute & verify `POFile` translation statistics."""
 
@@ -171,40 +147,3 @@
             self.transaction.commit()
 
         self.logger.info("Done.")
-
-
-class VerifyRecentPOFileStatsProcess:
-    """Recompute & verify `POFile` translation statistics."""
-
-    def __init__(self, transaction, logger=None):
-        self.transaction = transaction
-        self.logger = logger
-        if logger is None:
-            self.logger = logging.getLogger("pofile-stats-daily")
-
-    def run(self):
-        self.logger.info(
-            "Verifying stats of POFiles updated in the last %s days." % (
-                config.rosetta_pofile_stats.days_considered_recent))
-        loop = QuickVerifier(self.transaction, self.logger)
-        iteration_duration = (
-            config.rosetta_pofile_stats.looptuner_iteration_duration)
-        DBLoopTuner(loop, iteration_duration).run()
-
-        if loop.total_incorrect > 0 or loop.total_exceptions > 0:
-            # Not all statistics were correct, or there were failures while
-            # checking them.  Email the admins.
-            template = get_email_template(
-                'pofile-stats.txt', 'translations')
-            message = template % {
-                'exceptions': loop.total_exceptions,
-                'errors': loop.total_incorrect,
-                'total': loop.total_checked}
-            simple_sendmail(
-                from_addr=config.canonical.noreply_from_address,
-                to_addrs=[config.launchpad.errors_address],
-                subject="POFile statistics errors (daily)",
-                body=MailWrapper().format(message))
-            self.transaction.commit()
-
-        self.logger.info("Done.")


Follow ups