Merge lp:~vila/udd/analyze-log-imports into lp:udd

Proposed by Vincent Ladeuil
Status: Merged
Merged at revision: 512
Proposed branch: lp:~vila/udd/analyze-log-imports
Merge into: lp:udd
Prerequisite: lp:~vila/udd/analyze_log
Diff against target: 53 lines (+29/-1)
1 file modified
analyze_log.py (+29/-1)
To merge this branch: bzr merge lp:~vila/udd/analyze-log-imports
Reviewer Review Type Date Requested Status
John A Meinel Needs Information
Review via email: mp+74057@code.launchpad.net

Commit message

Parse and report successful imports while parsing the importer log files.

Description of the change

Based on https://code.launchpad.net/~vila/udd/analyze_log/+merge/74056, this patch parses and reports the successful imports found in the log file.

This diverges a slight bit from the initial purpose of the
analyze_log.py purpose. If more divergences appear, it may be
nice to switch to a more general approach
s/report_times(/report('times', or report('imports', / and allow
some command-line or config parameter to decide which parts
should reported but I don't it need for now.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/05/2011 10:08 AM, Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging lp:~vila/udd/analyze-log-imports into lp:udd with lp:~vila/udd/analyze_log as a prerequisite.
>
> Requested reviews:
> Ubuntu Distributed Development Developers (udd)
>
> For more details, see:
> https://code.launchpad.net/~vila/udd/analyze-log-imports/+merge/74057
>
> Based on https://code.launchpad.net/~vila/udd/analyze_log/+merge/74056, this patch parses and reports the successful imports found in the log file.
>
> This diverges a slight bit from the initial purpose of the
> analyze_log.py purpose. If more divergences appear, it may be
> nice to switch to a more general approach
> s/report_times(/report('times', or report('imports', / and allow
> some command-line or config parameter to decide which parts
> should reported but I don't it need for now.
>
>

I'm not sure I understand what you mean by "diverges from the initial
purpose". Could you clarify a bit?

Would you want to add some test case to the matching logic? (They should
be fairly easy to write as unit tests.)

+ # Cough, not really times... cough

^- what are they then? The comment doesn't really add any clarity.

 review: needsinfo

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5l1f4ACgkQJdeBCYSNAAOyFwCfUAnmHFltJWBpDzhRoUXaMflc
yUcAoLS9QEy3P7+OskmNR5j0wILXFNMq
=mUIq
-----END PGP SIGNATURE-----

review: Needs Information
Revision history for this message
Vincent Ladeuil (vila) wrote :

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 09/05/2011 10:08 AM, Vincent Ladeuil wrote:
> > Vincent Ladeuil has proposed merging lp:~vila/udd/analyze-log-imports into
> lp:udd with lp:~vila/udd/analyze_log as a prerequisite.
> >
> > Requested reviews:
> > Ubuntu Distributed Development Developers (udd)
> >
> > For more details, see:
> > https://code.launchpad.net/~vila/udd/analyze-log-imports/+merge/74057
> >
> > Based on https://code.launchpad.net/~vila/udd/analyze_log/+merge/74056, this
> patch parses and reports the successful imports found in the log file.
> >
> > This diverges a slight bit from the initial purpose of the
> > analyze_log.py purpose. If more divergences appear, it may be
> > nice to switch to a more general approach
> > s/report_times(/report('times', or report('imports', / and allow
> > some command-line or config parameter to decide which parts
> > should reported but I don't it need for now.
> >
> >
>
> I'm not sure I understand what you mean by "diverges from the initial
> purpose". Could you clarify a bit?

The initial purpose was to report import times (report_*times*), it now also reports imports and imports != times.

>
> Would you want to add some test case to the matching logic? (They should
> be fairly easy to write as unit tests.)

That's one exception to TDD to me: I don't think automated tests add value here because I have real data to play with, both from the past and more importantly, live data from the running importer. So it's already easy enough to catch errors and fix them.

Regressions doesn't really matter either as we don't want to maintain compatibility with old logs anyway, if these logs needs to be analysed, it's far easier to just retrieve the old version of analyze_log.py.

>
> + # Cough, not really times... cough
>
> ^- what are they then? The comment doesn't really add any clarity.

48 + # Cough, not really times... cough
49 + for distro, release, version in self.versions:
50 + out.write('Imported: %-10s %-12s %s\n' % (distro, release, version))

It displays the distro, the release and the version that was imported, those aren't times.

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/06/2011 10:50 AM, Vincent Ladeuil wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 09/05/2011 10:08 AM, Vincent Ladeuil wrote:
>>> Vincent Ladeuil has proposed merging lp:~vila/udd/analyze-log-imports into
>> lp:udd with lp:~vila/udd/analyze_log as a prerequisite.
>>>
>>> Requested reviews:
>>> Ubuntu Distributed Development Developers (udd)
>>>
>>> For more details, see:
>>> https://code.launchpad.net/~vila/udd/analyze-log-imports/+merge/74057
>>>
>>> Based on https://code.launchpad.net/~vila/udd/analyze_log/+merge/74056, this
>> patch parses and reports the successful imports found in the log file.
>>>
>>> This diverges a slight bit from the initial purpose of the
>>> analyze_log.py purpose. If more divergences appear, it may be
>>> nice to switch to a more general approach
>>> s/report_times(/report('times', or report('imports', / and allow
>>> some command-line or config parameter to decide which parts
>>> should reported but I don't it need for now.
>>>
>>>
>>
>> I'm not sure I understand what you mean by "diverges from the initial
>> purpose". Could you clarify a bit?
>
> The initial purpose was to report import times (report_*times*), it now also reports imports and imports != times.
>
>>
>> Would you want to add some test case to the matching logic? (They should
>> be fairly easy to write as unit tests.)
>
> That's one exception to TDD to me: I don't think automated tests add value here because I have real data to play with, both from the past and more importantly, live data from the running importer. So it's already easy enough to catch errors and fix them.
>

You don't know if you are missing things running against the live
importer. (AFAIK.)

> Regressions doesn't really matter either as we don't want to maintain compatibility with old logs anyway, if these logs needs to be analysed, it's far easier to just retrieve the old version of analyze_log.py.
>
>>
>> + # Cough, not really times... cough
>>
>> ^- what are they then? The comment doesn't really add any clarity.
>
> 48 + # Cough, not really times... cough
> 49 + for distro, release, version in self.versions:
> 50 + out.write('Imported: %-10s %-12s %s\n' % (distro, release, version))
>
> It displays the distro, the release and the version that was imported, those aren't times.
>

The comment still doesn't add value, IMO.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5l8AwACgkQJdeBCYSNAANAFgCdGZUPNy6LWYtuNyAhNHUg71SK
8OgAoNWSCGS6mZXt88nkJ7LcRqszJElU
=KGAm
-----END PGP SIGNATURE-----

Revision history for this message
Vincent Ladeuil (vila) wrote :

>>>>> John Arbash Meinel <email address hidden> writes:

<snip/>

    >> That's one exception to TDD to me: I don't think automated tests
    >> add value here because I have real data to play with, both from
    >> the past and more importantly, live data from the running
    >> importer. So it's already easy enough to catch errors and fix
    >> them.
    >>

    > You don't know if you are missing things running against the live
    > importer. (AFAIK.)

Just try it then, you'll know more ;)

I've tested this script for several days on the live importer and also
on some older logs while changing it. It makes a real difference in the
feedback compared to tail -F.

This script is meant to help and the added feature is far from life
critical (even for me who took the time to write it). There are
certainly other areas that need more testing, I'd prefer to focus on
them.

    >>
    >> It displays the distro, the release and the version that was imported, those aren't times.
    >>

    > The comment still doesn't add value, IMO.

I put it there as a reminder that the method is not name doesn't
represent the job done and explained so in more words in the cover
letter.

I'll gladly update this comment if you have a better way to express
that.

Revision history for this message
Martin Pool (mbp) wrote :

Perhaps rather than futzing with the comment it's easier to just change it to something like 'report_metrics' now.

If you're not going to do that I would make the comment something like

 # Although this is called report_times, we're abusing it slightly to report non-time but similarly structured data.

If this is not run automatically (is it?) you should add something about it to readme.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Comment fixed as proposed.

> If this is not run automatically (is it?) you should add something about it to readme.

No, it's not, it is mainly meant as helping us get a better feeling of what's is going no (or was going on for that matter). I intend to refine it as the needs arise, feel free to tweak to your hearth content.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'analyze_log.py'
2--- analyze_log.py 2011-09-05 08:08:23 +0000
3+++ analyze_log.py 2011-09-05 08:08:23 +0000
4@@ -244,6 +244,27 @@
5 def __init__(self, name):
6 super(PackageParser, self).__init__(name)
7 self.tb = None
8+ self.versions = []
9+
10+ # Match the full list of imports
11+ _imported_re = re.compile('Imported \[(.*)\] ')
12+ # Match one import
13+ _package_imported_re = re.compile('PackageToImport\([^)]+\)')
14+
15+ def see_success(self, success):
16+ if success == 'Nothing new ':
17+ # .. here, move along
18+ return
19+
20+ imports = self._imported_re.match(success)
21+ if imports is None:
22+ return
23+
24+ for imp in self._package_imported_re.findall(imports.groups()[0]):
25+ # Get the interesting bits out of:
26+ # 'PackageToImport(mrbayes, 3.1.2-2, ubuntu, oneiric, release, )'
27+ _, version, distro, release, _, _ = imp.split(',')
28+ self.versions.append((distro, release, version))
29
30 def see(self, log, state, stamp, args):
31 if state in ('trying', 'starting'):
32@@ -251,7 +272,7 @@
33 elif state in ('locked', 'finished'):
34 self.ends(stamp)
35 elif state == 'success':
36- # There is something to grab in args there, distro, pocket, etc
37+ self.see_success(args[0])
38 self.ends(stamp)
39 else:
40 assert state == 'failed'
41@@ -260,6 +281,13 @@
42 # traceback
43 self.parse_traceback(log)
44
45+ def report_times(self, out, epoch=None, apocalypse=None):
46+ super(PackageParser, self).report_times(out, epoch=epoch,
47+ apocalypse=apocalypse)
48+ # Cough, not really times... cough
49+ for distro, release, version in self.versions:
50+ out.write('Imported: %-10s %-12s %s\n' % (distro, release, version))
51+
52
53 class Log(object):
54

Subscribers

People subscribed via source and target branches