CPANTS: Kwalitative website and its tools

90
CPANTS Kwalitative website and its tools Kenichi Ishigaki (charsbar) @YAPC::EU 2012 August 22, 2012

description

CPANTS talk at YAPC::EU 2012

Transcript of CPANTS: Kwalitative website and its tools

Page 1: CPANTS: Kwalitative website and its tools

CPANTS

Kwalitative website and its tools

Kenichi Ishigaki (charsbar)

@YAPC::EU 2012 August 22, 2012

Page 2: CPANTS: Kwalitative website and its tools

Kenichi Ishigaki (charsbar)

From Shibuya.pm, Tokyo, Japan.

Page 3: CPANTS: Kwalitative website and its tools

Freelancer

- Perl programmer - Writer/Translator

Page 4: CPANTS: Kwalitative website and its tools

Around 40 CPAN distributions

Page 5: CPANTS: Kwalitative website and its tools

DBD::SQLite

Page 6: CPANTS: Kwalitative website and its tools

Acme::CPANAuthors

Page 7: CPANTS: Kwalitative website and its tools

We have been enjoying the

CPANTS game since 2005.

Page 8: CPANTS: Kwalitative website and its tools

輝け!全日本最強 CPAN Author 決定選手権

by Koichi Taniguchi

http://blog.livedoor.jp/nipotan/archives/16108466.html

Page 9: CPANTS: Kwalitative website and its tools

He picked up Japanese authors

by eye.

Page 10: CPANTS: Kwalitative website and its tools

Our names are easy to find.

Page 11: CPANTS: Kwalitative website and its tools

There were not so many authors.

- Total: ~4000

- Japanese: ~50

Page 12: CPANTS: Kwalitative website and its tools

YAPC::Asia increased the number of

Japanese authors.

Page 13: CPANTS: Kwalitative website and its tools

YAPC::Asia / Japanese authors

2006 (Mar) 98 2007 (Apr) 154 2008 (May) 191 2009 (Sep) 228 2010 (Oct) 255 2011 (Oct) 270

Page 14: CPANTS: Kwalitative website and its tools

Needed something to pick

up Japanese authors more

easily.

Page 15: CPANTS: Kwalitative website and its tools

That's why I created a list of Japanese authors

and a script to maintain it.

Page 16: CPANTS: Kwalitative website and its tools

I've been reporting the

Japanese top 10 authors since

2008.

Page 17: CPANTS: Kwalitative website and its tools

I've been adding something new

every year.

Page 18: CPANTS: Kwalitative website and its tools

2008: sum of the kwalitee scores

per author

Page 19: CPANTS: Kwalitative website and its tools

2009: authors who released

most in the year

Page 20: CPANTS: Kwalitative website and its tools

2010: authors/ population ratio

Page 21: CPANTS: Kwalitative website and its tools

2011: launched a website (finally)

acme.cpanauthors.org

Page 22: CPANTS: Kwalitative website and its tools
Page 23: CPANTS: Kwalitative website and its tools

It had one big problem.

Page 24: CPANTS: Kwalitative website and its tools

No data.

Page 25: CPANTS: Kwalitative website and its tools

The official CPANTS site had

been down for some time.

Page 26: CPANTS: Kwalitative website and its tools

I needed to set up mine.

Page 27: CPANTS: Kwalitative website and its tools

I created a private repository and put everything

into it.

Page 28: CPANTS: Kwalitative website and its tools

Merged recent commits from

domm's repository.

Page 29: CPANTS: Kwalitative website and its tools

Added a few columns.

Page 30: CPANTS: Kwalitative website and its tools

Tweaked Catalyst/DBIC

stuff.

Page 31: CPANTS: Kwalitative website and its tools

It worked.

Page 32: CPANTS: Kwalitative website and its tools

Warnings were left.

Page 33: CPANTS: Kwalitative website and its tools

I needed to find some tuits to remove them.

Page 34: CPANTS: Kwalitative website and its tools

Perl QA Hackathon

Page 35: CPANTS: Kwalitative website and its tools
Page 36: CPANTS: Kwalitative website and its tools

Warnings were removed.

Page 37: CPANTS: Kwalitative website and its tools

Ported some of the changes I did locally to daxim's

repository.

Page 38: CPANTS: Kwalitative website and its tools

Showed a new acme.cpanauthors.org

featuring CPANTS info.

Page 39: CPANTS: Kwalitative website and its tools
Page 40: CPANTS: Kwalitative website and its tools
Page 41: CPANTS: Kwalitative website and its tools
Page 42: CPANTS: Kwalitative website and its tools

Unfortunately, the porting took too much time.

Page 43: CPANTS: Kwalitative website and its tools

I didn't merge the changes back to my repository.

Page 44: CPANTS: Kwalitative website and its tools

OSDC.TW

Page 45: CPANTS: Kwalitative website and its tools

I finally merged the changes.

Page 46: CPANTS: Kwalitative website and its tools

Got several reports that CPANTS was

broken.

Page 47: CPANTS: Kwalitative website and its tools

What broke CPANTS was a small change.

Page 48: CPANTS: Kwalitative website and its tools

"modules" : [ { "file" : "lib/Path/Extended.pm", "in_basedir" : 0, "in_lib" : 1, "module" : "Path::Extended", "uses" : { "Sub::Install" : 1, "strict" : 1, "warnings" : 1 } } ]

Page 49: CPANTS: Kwalitative website and its tools

I don't think this change is bad.

Page 50: CPANTS: Kwalitative website and its tools

Module::CPANTS::ProcessCPAN shouldn't have died by this.

Page 51: CPANTS: Kwalitative website and its tools

It should have had tests.

Page 52: CPANTS: Kwalitative website and its tools

Is should have run faster.

Page 53: CPANTS: Kwalitative website and its tools

It should have been easier to fix

analysis.

Page 54: CPANTS: Kwalitative website and its tools

Enough issues for a summer.

Page 55: CPANTS: Kwalitative website and its tools

What should we do?

Page 56: CPANTS: Kwalitative website and its tools

- We need tests. - we need to find

test cases. - we need to do it

many times.

Page 57: CPANTS: Kwalitative website and its tools

Making it run faster is the first priority.

Page 58: CPANTS: Kwalitative website and its tools

I wrote a barebone script to store data in

parallel.

Page 59: CPANTS: Kwalitative website and its tools

JSON

create table if not exists analysis ( id integer primary key autoincrement, path text unique, distv text, author text, json text, duration integer );

Page 60: CPANTS: Kwalitative website and its tools

Raw SQL statements

Page 61: CPANTS: Kwalitative website and its tools

Parallel::ForkManager

Page 62: CPANTS: Kwalitative website and its tools

SQLite queue

Page 63: CPANTS: Kwalitative website and its tools

Beware a race condition

my ($id) = $dbh->selectrow_array(" SELECT id FROM queue WHERE status = 0 LIMIT = 1 "); $dbh->do(" UPDATE queue SET status = 1 WHERE id = ? ", undef, $id);

Page 64: CPANTS: Kwalitative website and its tools

sqlite_update_hook

my $id; my $dbh->sqlite_update_hook(sub { (undef, undef, undef, $id) = @_; });

Page 65: CPANTS: Kwalitative website and its tools

$dbh->do(" UPDATE queue SET status = 1, WHERE id IN ( SELECT id FROM queue WHERE status = 0 LIMIT 1 ) ");

Page 66: CPANTS: Kwalitative website and its tools

Archive::Any::Lite

Page 67: CPANTS: Kwalitative website and its tools

Archive::Any::Plugin::Bzip2

Page 68: CPANTS: Kwalitative website and its tools

WorePAN

- Bundling is bad - We need a specific version - Derived from OrePAN

Page 69: CPANTS: Kwalitative website and its tools

use WorePAN; my $worepan = WorePAN->new( root => 'path/to/a/directory/', files => [qw( I/IS/ISHIGAKI/WorePAN-0.01.tar.gz )], use_backpan => 1, no_network => 0, cleanup => 1, );

Page 70: CPANTS: Kwalitative website and its tools

use WorePAN; my $worepan = WorePAN->new( root => 'path/to/a/directory/', files => [qw( I/IS/ISHIGAKI/WorePAN-0.01.tar.gz )], local_mirror => '/home/ishigaki/minicpan/', no_network => 1, cleanup => 1, );

Page 71: CPANTS: Kwalitative website and its tools

use WorePAN; my $worepan = WorePAN->new( root => 'path/to/a/directory/', dists => { 'Catalyst-Runtime' => 5.9, 'DBIx-Class' => 0, }, cleanup => 1, );

Page 72: CPANTS: Kwalitative website and its tools

Bonus features

my $worepan = WorePAN->new( root => 'path/to/a/CPAN/mirror/', cleanup => 0, ); my $authors = $worepan->authors; my $modules = $worepan->modules; my $file = $worepan->files; my $dists = $worepan->latest_distributions;

Page 73: CPANTS: Kwalitative website and its tools

$worepan->add_files(qw{ /path/to/a/local/distribution-0.01.tar.gz }); $worepan->update_indices;

Page 74: CPANTS: Kwalitative website and its tools

Now we have enough tools.

Page 75: CPANTS: Kwalitative website and its tools

Processing time is significantly decreased.

Page 76: CPANTS: Kwalitative website and its tools

What's next?

Page 77: CPANTS: Kwalitative website and its tools

::Site refactoring

Page 78: CPANTS: Kwalitative website and its tools

I'm preparing the data now.

Page 79: CPANTS: Kwalitative website and its tools

Creating more databases/tables.

Page 80: CPANTS: Kwalitative website and its tools

Merging information from external sources.

- CPAN indices - CPAN uploads database

Page 81: CPANTS: Kwalitative website and its tools

Calculating scores on prerequisite

modules.

Page 82: CPANTS: Kwalitative website and its tools

It will be this year's something new in my annual

report.

Page 83: CPANTS: Kwalitative website and its tools

And then, I'll move on to fixing

the metrics.

Page 84: CPANTS: Kwalitative website and its tools

Some of them are badly broken.

"versions" : { "lib/Data/Phrasebook.pm" : "use vars qw($VERSION);¥n", "lib/Data/Phrasebook/Debug.pm" : "use vars qw($VERSION);¥n", "lib/Data/Phrasebook/Generic.pm" : "use vars qw($VERSION);¥n", "lib/Data/Phrasebook/Loader.pm" : "use vars qw($VERSION);¥n", "lib/Data/Phrasebook/Loader/Base.pm" : "use vars qw($VERSION);¥n", "lib/Data/Phrasebook/Loader/Text.pm" : "use vars qw($VERSION);¥n", "lib/Data/Phrasebook/Plain.pm" : "use vars qw($VERSION);¥n", "lib/Data/Phrasebook/SQL.pm" : "use vars qw($VERSION);¥n", "lib/Data/Phrasebook/SQL/Query.pm" : "use vars qw($VERSION);¥n" },

Page 85: CPANTS: Kwalitative website and its tools

Error is not a stash.

"error" : { "easily_repackageable" : "easily_repackageable_by_fedora", "easily_repackageable_by_fedora" : "fits_fedora_license", "metayml_conforms_spec_current" : [ "1.4", "Expected a map structure from data string or file. [Validation: 1.4]" ], "metayml_conforms_to_known_spec" : [ "1.0", "Expected a map structure from data string or file. [Validation: 1.0]" ], "no_pod_errors" : " home cpants tmp analyze 11442 8001be43fb65..." }

Page 86: CPANTS: Kwalitative website and its tools

Should have initialize/finalize phases.

Module::CPANTS::Kwalitee::Distros

doesn't clean up after mirrored Debian CPANTS file

https://rt.cpan.org/Ticket/Display.html?id=51514

Page 87: CPANTS: Kwalitative website and its tools

There are much more to do.

- JSON API for metacpan.org and so on. - Email Reporting like CPAN Testers - Evaluate new Kwalitee indicators - New metrics like portable filename - Blog about recent tendency - More comprehensive tests - Analysis per perl version/architecture - Cover Perl::Critic, CPAN::Critic::Module::Abstract - 35 RT tickets and several github isses

Page 88: CPANTS: Kwalitative website and its tools

Resources

github.com/charsbar/www-cpants github.com/charsbar/worepan

github.com/daxim/Module-CPANTS-Analyse

Page 89: CPANTS: Kwalitative website and its tools

Questions?

Page 90: CPANTS: Kwalitative website and its tools

Thank you