Skip to content

Commit

Permalink
"Stuck Run" functionality dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcam committed Jan 27, 2025
1 parent 01a2eeb commit 8dbb862
Show file tree
Hide file tree
Showing 14 changed files with 6 additions and 264 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ LIST OF CHANGES
- npg::model_run_status -
current_run_statuses, latest_current_run_status,
active_runs_over_last_30_days, epoch
- Deleted 'Stuck Runs' button from the admin top-level menu,
the associated template and the view and model methods.

release 102.1.0 (2025-01-16)
- Fixed perlbrew installation by installing libdevel-patchperl-perl in
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ data/templates/run_lane_list_tag.tt2
data/templates/run_lane_read.tt2
data/templates/run_lane_update_tags.tt2
data/templates/run_list.tt2
data/templates/run_list_stuck_runs.tt2
data/templates/run_read.tt2
data/templates/run_status_create.tt2
data/templates/run_status_table.tt2
Expand Down Expand Up @@ -548,7 +547,6 @@ t/data/rendered/run.html-POST
t/data/rendered/run.html;add
t/data/rendered/run/1.html;update_tags
t/data/rendered/run/1.html;update_tags-no-tags
t/data/rendered/run/list_stuck_runs.html
t/data/rendered/run/runs_on_instrument.html
t/data/rendered/run_annotation_add_ajax.html
t/data/rendered/run_lane/1;update_tags
Expand Down
3 changes: 0 additions & 3 deletions data/templates/actions.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@
<ul class="inline">
<li><a class="npg_menu" href="[% SCRIPT_NAME %]/run/">Runs</a></li>
<li><a class="npg_menu" href="[% SCRIPT_NAME %]/instrument/">Instruments</a></li>
[%- IF requestor.is_member_of('loaders') || requestor.is_member_of('annotators') %]
<li><a class="npg_menu" href="[% SCRIPT_NAME %]/run/stuck_runs">Stuck Runs</a></li>
[% END -%]
[%- IF requestor.is_member_of('engineers') || requestor.is_member_of('admin') %]
<li><a class="npg_menu" href="[% SCRIPT_NAME %]/administration/">Admin</a></li>
[% END -%]
Expand Down
23 changes: 0 additions & 23 deletions data/templates/run_list_stuck_runs.tt2

This file was deleted.

12 changes: 0 additions & 12 deletions lib/npg/model/run.pm
Original file line number Diff line number Diff line change
Expand Up @@ -896,14 +896,6 @@ sub has_analysis_in_progress {
return 0;
}

sub potentially_stuck_runs {
my ( $self ) = @_;
if ( ! $self->{potentially_stuck_runs} ) {
$self->{potentially_stuck_runs} = $self->runs()->[0]->current_run_status()->potentially_stuck_runs();
}
return $self->{potentially_stuck_runs};
}

sub teams {
my $self = shift;
return map {$TEAMS{$_}} (sort {$a <=> $b} keys %TEAMS);
Expand Down Expand Up @@ -1149,10 +1141,6 @@ npg::model::run
=head2 num_reads - calculate number of reads of this run based on multplex_run and paired read or not
=head2 potentially_stuck_runs
return runs which are potentially stuck due to the length of time at their current run status - see method in model::run_status
=head2 run_status_dict
provides a short cut method to the run status dict object providing the description for the current run status
Expand Down
94 changes: 1 addition & 93 deletions lib/npg/model/run_status.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ use strict;
use warnings;
use English qw(-no_match_vars);
use Carp;
use Date::Parse;
use DateTime;
use Readonly;

use npg::model::event;
use npg::model::run_status_dict;
Expand All @@ -15,19 +12,6 @@ use base qw(npg::model);

our $VERSION = '0';

Readonly::Hash our %DAYS_PER_STATUS => (
'run complete' => 1,
'run mirrored' => 1,
'analysis pending' => 1,
'analysis in progress' => 2,
'secondary analysis in progress' => 3,
'analysis complete' => 1,
'archival pending' => 1,
'analysis in progress' => 1,
'analysis complete' => 1,
'archival in progress' => 2,
);

__PACKAGE__->mk_accessors(fields());
__PACKAGE__->has_a([qw(run user run_status_dict)]);

Expand Down Expand Up @@ -77,7 +61,7 @@ sub create {

my $desc = $self->run_status_dict->description();

my $msg = qq($desc for run @{[$self->run->name()]}\nhttp://sfweb.internal.sanger.ac.uk:9000/perl/npg/run/@{[$self->run->name()]}\n$history\n\n$contents_of_lanes);
my $msg = qq($desc for run @{[$self->run->name()]}\nhttp://sfweb.internal.sanger.ac.uk:12443/perl/npg/run/@{[$self->run->name()]}\n$history\n\n$contents_of_lanes);
my $event = npg::model::event->new({
run => $self->run(),
status_description => $desc,
Expand Down Expand Up @@ -113,57 +97,6 @@ sub create {
return 1;
}

sub potentially_stuck_runs {
my ( $self ) = @_;
my $return = {};

my $rows = $self->_runs_at_requested_statuses();

my $dtnow = $self->_datetime_now();

foreach my $row ( @{ $rows } ) {
my ( $id_run, $date, $status, $priority ) = @{ $row };
my ( $year, $month, $day ) = $date =~ /(\d{4})-(\d{2})-(\d{2})/xms;
my $dt = DateTime->new(
year => $year, month => $month, day => $day, time_zone => 'UTC',
);
my $days = $dtnow->delta_days($dt)->in_units( q{days} );
if ( $days >= $DAYS_PER_STATUS{$status} ) {
push @{ $return->{$status} }, { id_run => $id_run, days => $days, priority => $priority };
}
}

return $return;
}

sub _runs_at_requested_statuses {
my ( $self ) = @_;

if ( ! $self->{_runs_at_requested_statuses} ) {
my @statuses_for_query = keys %DAYS_PER_STATUS;
my $query_string = q{'} . ( join q{','}, keys %DAYS_PER_STATUS ) . q{'};

my $query = qq{SELECT rs.id_run, rs.date, rsd.description, r.priority
FROM run_status rs, run_status_dict rsd, run r
WHERE rs.iscurrent = 1
AND rs.id_run_status_dict = rsd.id_run_status_dict
AND rs.id_run = r.id_run
AND rsd.description IN ($query_string)
ORDER BY rsd.id_run_status_dict, rs.id_run};

$self->{_runs_at_requested_statuses} = $self->util->dbh->selectall_arrayref( $query );
}
return $self->{_runs_at_requested_statuses};
}

sub _datetime_now {
my ( $self ) = @_;
if ( ! $self->{_datetime_now} ) {
$self->{_datetime_now} = DateTime->now( time_zone => 'UTC' );
}
return $self->{_datetime_now};
}

1;
__END__
Expand Down Expand Up @@ -204,29 +137,6 @@ npg::model::run_status
Sets all other run_status for this id_run to iscurrent=0
Sets this iscurrent=1 (whatever was set/unset in the object);
=head2 potentially_stuck_runs
returns a hashref, keyed on status, which contains all the runs that are over a certain time period within a current run status
i.e. run complete => 1 day
run mirrored => 1 day
analysis pending => 1 day
analysis in progress => 2 days
secondary analysis in progress => 3 days
analysis complete => 1 day
archival pending => 1 day
analysis in progress => 1 day
analysis complete => 1 day
You get back a hashref as follows
{
'run complete' => [ { id_run => 1234, days => 2 }, { id_run => 2341, days => 3 } ],
...
}
my $hPotentiallyStuckRuns = $oRunStatus->potentially_stuck_runs();
=head1 DIAGNOSTICS
=head1 CONFIGURATION AND ENVIRONMENT
Expand All @@ -251,8 +161,6 @@ You get back a hashref as follows
=item npg::model::run_status_dict
=item Date::Parse
=back
=head1 INCOMPATIBILITIES
Expand Down
13 changes: 0 additions & 13 deletions lib/npg/view/run.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ sub authorised {
return 1;
}

if ( $aspect eq q{list_stuck_runs} && ( $requestor->is_member_of( q{loaders} ) || $requestor->is_member_of( q{annotators} ) || $requestor->is_member_of( q{manual_qc} ) ) ) {
return 1;
}

return $self->SUPER::authorised();
}

Expand Down Expand Up @@ -355,11 +351,6 @@ sub update {
return $self->SUPER::update(@args);
}

sub list_stuck_runs {
my ( $self ) = @_;
return 1;
}

1;

__END__
Expand Down Expand Up @@ -397,10 +388,6 @@ npg::view::run - view handling for runs
=head2 update - handling for tile-layout updates
=head2 list_stuck_runs
handling for the stuck runs page
=head1 DIAGNOSTICS
=head1 CONFIGURATION AND ENVIRONMENT
Expand Down
4 changes: 1 addition & 3 deletions t/10-model-run.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ use_ok ('npg::model::annotation');
my $util = t::util->new({fixtures => 1});

subtest 'model object that is not linked to a run' => sub {
plan tests => 7;
plan tests => 6;

my $model = npg::model::run->new({util => $util});
isa_ok($model, 'npg::model::run');
my @fields = $model->fields();
is((scalar @fields), 13, '$model->fields() size');

isa_ok( $model->potentially_stuck_runs(), q{HASH}, q{potentially_stuck_runs} );

is($model->name(), 'UNKNOWN_0000', 'unknown name if no instrument name and no id_run');

is($model->attach_annotation('test annotation'), 1, '$model->attach_annotation() with annotation, but no $model->id_run()');
Expand Down
51 changes: 1 addition & 50 deletions t/10-model-run_status.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More tests => 15;
use Test::More tests => 10;
use Test::Exception;

use npg::model::run;
Expand All @@ -10,47 +10,6 @@ use_ok('npg::model::run_status');

my $util = t::util->new({ fixtures => 1,});

{
my $rs = npg::model::run_status->new({
util => $util,
});
isa_ok($rs, 'npg::model::run_status');
my $expected_data = [
[ '9948', '2010-01-01 10:10:30', 'run complete', 1 ],
[ '9949', '2010-01-01 10:10:33', 'run complete', 1 ],
[ '9950', '2010-01-01 10:10:34', 'run complete', 1 ],
[ '9951', '2010-01-01 10:10:34', 'run complete', 1 ],
[ '1', '2007-06-05 12:22:32', 'analysis complete', 1 ],
[ '95', '2007-06-05 12:22:32', 'analysis complete', 4 ],
[ '5', '2007-06-05 12:32:28', 'run mirrored', 1 ],
[ '11', '2007-06-05 12:31:44', 'run mirrored', 1 ],
[ '12', '2007-06-05 12:32:27', 'run mirrored', 1 ],
];

is_deeply( $rs->_runs_at_requested_statuses(), $expected_data, q{correct data from _runs_at_requested_statuses obtained} );

my $datetime = $rs->_datetime_now();
is( $datetime, $rs->_datetime_now(), q{_datetime_now is cached correctly} );

$datetime->set_day(28);
$datetime->set_month(2);
$datetime->set_year(2011);

$expected_data = {
'analysis complete' => [ { 'days' => 1364, 'id_run' => '1', priority => 1 },
{ 'days' => 1364, 'id_run' => '95', priority => 4 }, ],
'run complete' => [ { 'days' => 423, 'id_run' => '9948', priority => 1 },
{ 'days' => 423, 'id_run' => '9949', priority => 1 },
{ 'days' => 423, 'id_run' => '9950', priority => 1 },
{ 'days' => 423, 'id_run' => '9951', priority => 1 }, ],
'run mirrored' => [ { 'days' => 1364, 'id_run' => '5', priority => 1 },
{ 'days' => 1364, 'id_run' => '11', priority => 1 },
{ 'days' => 1364, 'id_run' => '12', priority => 1 }, ]
};

is_deeply( $rs->potentially_stuck_runs(), $expected_data, q{potentially_stuck_runs returns the expected data} );
}

{
my $rs = npg::model::run_status->new({
util => $util,
Expand Down Expand Up @@ -102,12 +61,4 @@ my $util = t::util->new({ fixtures => 1,});
'no croak on create for id_run_status_dict = 4 for id_run 1';
}

{
my $model = npg::model::run_status->new( {
util => $util,
} );
my $potentially_stuck_runs = $model->potentially_stuck_runs();
isa_ok( $potentially_stuck_runs, q{HASH}, q{$model->potentially_stuck_runs()} );
}

1;
15 changes: 1 addition & 14 deletions t/20-view-run.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More tests => 27;
use Test::More tests => 26;
use Test::Exception;
use Test::Deep;
use CGI;
Expand Down Expand Up @@ -54,19 +54,6 @@ my $util = t::util->new({fixtures => 1,});
is_deeply($view->staging_urls($name), $esa_urls, 'run on staging, esa urls');
}

{
my $view = npg::view::run->new({
util => $util,
action => q{list},
aspect => q{list_stuck_runs},
model => npg::model::run->new({
util => $util,
id_run => q(),
}),
});
ok($util->test_rendered($view->render(), 't/data/rendered/run/list_stuck_runs.html'), 'list_stuck_runs render is ok');
}

{
my $str = t::request->new({
PATH_INFO => '/run;add',
Expand Down
1 change: 0 additions & 1 deletion t/data/rendered/actions_admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
</div>
<li><a class="npg_menu" href="/cgi-perl/npg/run/">Runs</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/instrument/">Instruments</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/run/stuck_runs">Stuck Runs</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/administration/">Admin</a></li>
<li><a class="npg_menu_highlight" href="/cgi-perl/npg/run/;add">New Run</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/search/">Search</a></li>
Expand Down
1 change: 0 additions & 1 deletion t/data/rendered/actions_annotator.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
</div>
<li><a class="npg_menu" href="/cgi-perl/npg/run/">Runs</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/instrument/">Instruments</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/run/stuck_runs">Stuck Runs</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/search/">Search</a></li>


1 change: 0 additions & 1 deletion t/data/rendered/actions_loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<li><a class="npg_menu" href="/cgi-perl/npg/run/">Runs</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/instrument/">Instruments</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/run/stuck_runs">Stuck Runs</a></li>
<li><a class="npg_menu_highlight" href="/cgi-perl/npg/run/;add">New Run</a></li>
<li><a class="npg_menu" href="/cgi-perl/npg/search/">Search</a></li>

Loading

0 comments on commit 8dbb862

Please sign in to comment.