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
=== modified file 'analyze_log.py'
--- analyze_log.py 2011-09-05 08:08:23 +0000
+++ analyze_log.py 2011-09-05 08:08:23 +0000
@@ -244,6 +244,27 @@
244 def __init__(self, name):244 def __init__(self, name):
245 super(PackageParser, self).__init__(name)245 super(PackageParser, self).__init__(name)
246 self.tb = None246 self.tb = None
247 self.versions = []
248
249 # Match the full list of imports
250 _imported_re = re.compile('Imported \[(.*)\] ')
251 # Match one import
252 _package_imported_re = re.compile('PackageToImport\([^)]+\)')
253
254 def see_success(self, success):
255 if success == 'Nothing new ':
256 # .. here, move along
257 return
258
259 imports = self._imported_re.match(success)
260 if imports is None:
261 return
262
263 for imp in self._package_imported_re.findall(imports.groups()[0]):
264 # Get the interesting bits out of:
265 # 'PackageToImport(mrbayes, 3.1.2-2, ubuntu, oneiric, release, )'
266 _, version, distro, release, _, _ = imp.split(',')
267 self.versions.append((distro, release, version))
247268
248 def see(self, log, state, stamp, args):269 def see(self, log, state, stamp, args):
249 if state in ('trying', 'starting'):270 if state in ('trying', 'starting'):
@@ -251,7 +272,7 @@
251 elif state in ('locked', 'finished'):272 elif state in ('locked', 'finished'):
252 self.ends(stamp)273 self.ends(stamp)
253 elif state == 'success':274 elif state == 'success':
254 # There is something to grab in args there, distro, pocket, etc275 self.see_success(args[0])
255 self.ends(stamp)276 self.ends(stamp)
256 else:277 else:
257 assert state == 'failed'278 assert state == 'failed'
@@ -260,6 +281,13 @@
260 # traceback281 # traceback
261 self.parse_traceback(log)282 self.parse_traceback(log)
262283
284 def report_times(self, out, epoch=None, apocalypse=None):
285 super(PackageParser, self).report_times(out, epoch=epoch,
286 apocalypse=apocalypse)
287 # Cough, not really times... cough
288 for distro, release, version in self.versions:
289 out.write('Imported: %-10s %-12s %s\n' % (distro, release, version))
290
263291
264class Log(object):292class Log(object):
265293

Subscribers

People subscribed via source and target branches