Skip to content

Commit

Permalink
Merge pull request #877 from mgcam/daemon_pickup_illumina_only
Browse files Browse the repository at this point in the history
Restricted pipeline daemons to deal with runs by a certain manufacturer.
  • Loading branch information
marcomoscasgr authored Feb 11, 2025
2 parents fec9f6b + fb42b41 commit 39c6bb6
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 24 deletions.
7 changes: 7 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
LIST OF CHANGES
---------------

- Changed pipeline daemons so that they pick up runs performed on the
instruments by a manufacturer with a name given by a new attribute -
instrument_name. By default this name is set to 'Illumina' so that
the daemons continue picking up Illumina-only runs even if other
runs are present in the run tracking database.
- Deleted redundant t::dbic_util::test_schema_wh method.

release 68.7.1 (2024-12-17)
- Fix perlbrew installation by installing libdevel-patchperl-perl in runner
- Changed/extended tests for npg_pipeline::function::autoqc to ensure that
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ t/data/cache/my_samplesheet_12376.csv
t/data/dbic_fixtures/000-Designation.yml
t/data/dbic_fixtures/000-EntityType.yml
t/data/dbic_fixtures/000-InstrumentStatusDict.yml
t/data/dbic_fixtures/000-Manufacturer.yml
t/data/dbic_fixtures/000-RunLaneStatusDict.yml
t/data/dbic_fixtures/000-RunStatusDict.yml
t/data/dbic_fixtures/000-Tag.yml
Expand Down
23 changes: 19 additions & 4 deletions lib/npg_pipeline/daemon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ with qw{
our $VERSION = '0';

Readonly::Scalar my $SLEEPY_TIME => 900;
Readonly::Scalar my $DEFAULT_INSTRUMENT_MANUFACTURER => 'Illumina';

has 'pipeline_script_name' => (
isa => q{Str},
Expand All @@ -30,12 +31,21 @@ has 'pipeline_script_name' => (
builder => 'build_pipeline_script_name',
);

has 'manufacturer_name' => (
isa => q{Str},
is => q{ro},
default => $DEFAULT_INSTRUMENT_MANUFACTURER,
documentation => 'Instrument manufacturer name, defaults to Illumina. ' .
'Runs on instruments by this manufacturer only will be ' .
'considered by this daemon.',
);

has 'dry_run' => (
isa => q{Bool},
is => q{ro},
required => 0,
default => 0,
documentation => 'dry run mode flag, false by default',
documentation => 'Dry run mode flag, false by default',
);

has 'seen' => (
Expand All @@ -58,6 +68,7 @@ sub _build_npg_tracking_schema {

sub runs_with_status {
my ($self, $status_name, $from_time) = @_;

if (!$status_name) {
$self->logcroak(q[Need status name]);
}
Expand All @@ -73,7 +84,8 @@ sub runs_with_status {
}

return
map { $_->run() }
grep { $_->instrument_format->manufacturer->name eq $self->manufacturer_name }
map { $_->run() }
$self->npg_tracking_schema()->resultset(q[RunStatus])->search(
$condition,
{prefetch=>q[run_status_dict], order_by => q[me.date],}
Expand Down Expand Up @@ -194,8 +206,8 @@ case of error.
=head2 runs_with_status
With one argument, which should be a valid run status description,
returns a list of DBIx::Class::Row objects from the Run result set,
which correspond to runs with the current status descriptiongiven
returns a list of C<DBIx::Class::Row> objects from the C<Run> result set,
which correspond to runs with the current status description given
by the argument.
# find runs with current status 'archival pending'
Expand All @@ -215,6 +227,9 @@ should be after the time given by the second argument.
In both cases a list of returned objects is sorted in the assending
run status timestamp order.
Only runs performed on the instruments by the manufacturer given by
the C<manufacturer_name> attribute are chosen.
If no run satisfies the conditions given by the argument(s), an
empty list is returned.
Expand Down
45 changes: 32 additions & 13 deletions t/50-npg_pipeline-daemon-analysis.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More tests => 12;
use Test::More tests => 8;
use Test::Exception;
use Cwd qw{ getcwd abs_path };
use File::Path qw{ make_path };
Expand Down Expand Up @@ -30,19 +30,38 @@ my $schema = t::dbic_util->new()->test_schema();
my $test_run = $schema->resultset(q[Run])->find(1234);
$test_run->update_run_status('analysis pending', 'pipeline',);

my %h = map { $_ => 1 } (1234, 4330, 4999, 5222);
my @statuses = ();
for my $r ($schema->resultset(q[Run])->search({})->all()) {
my $id = $r->id_run;
if ($h{$id}) {
cmp_ok ($r->current_run_status_description, 'eq',
'analysis pending', "test run $id is analysis pending");
} else {
push @statuses, $r->current_run_status_description;
subtest 'runs and statuses' => sub {
plan tests => 10;

my %h = map { $_ => 1 } (1234, 4330, 4999, 5222, 100000);
my @other_statuses = ();
for my $r ($schema->resultset(q[Run])->search({})->all()) {
my $id = $r->id_run;
if ($h{$id}) {
cmp_ok ($r->current_run_status_description, 'eq',
'analysis pending', "test run $id is analysis pending");
} else {
push @other_statuses, $r->current_run_status_description;
}
}
}
is (scalar(grep { $_ eq 'analysis pending' } @statuses), 0,
'other test runs are not analysis pending');
is (scalar(grep { $_ eq 'analysis pending' } @other_statuses), 0,
'other test runs are not analysis pending');

my $runner = npg_pipeline::daemon::analysis->new(npg_tracking_schema => $schema);
is ($runner->manufacturer_name, 'Illumina', 'default manufacturer name');
my @run_ids = sort { $a <=> $b } map { $_->id_run }
$runner->runs_with_status('analysis pending');
is (join(q[,], @run_ids), '1234,4330,4999,5222', 'correct Illumina runs IDs');

$runner = npg_pipeline::daemon::analysis->new(
manufacturer_name => 'Element Biosciences',
npg_tracking_schema => $schema
);
is ($runner->manufacturer_name, 'Element Biosciences',
'manufacturer name as set');
@run_ids = map { $_->id_run } $runner->runs_with_status('analysis pending');
ok ((@run_ids == 1) && ($run_ids[0] == 100000), 'One Element Biosciences run');
};

my $rf_path = '/some/path';

Expand Down
7 changes: 7 additions & 0 deletions t/data/dbic_fixtures/000-Manufacturer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- id_manufacturer: 20
name: Element Biosciences
- id_manufacturer: 10
name: Illumina
- id_manufacturer: 16
name: Roche/454
8 changes: 8 additions & 0 deletions t/data/dbic_fixtures/100-InstrumentFormat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@
default_columns: 4
days_between_washes: 28
runs_between_washes: 1
- id_instrument_format: 12
id_manufacturer: 20
model: AVITI23
iscurrent: 1
default_tiles: 0
default_columns: 0
days_between_washes: 30
runs_between_washes: 1
8 changes: 8 additions & 0 deletions t/data/dbic_fixtures/200-Instrument.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,12 @@
iscurrent: 1
ipaddr:
instrument_comp: HS1
- id_instrument: 70
name: AVITI2301
id_instrument_format: 12
external_name: ''
serial: ''
iscurrent: 1
ipaddr: ~
instrument_comp: ~

14 changes: 14 additions & 0 deletions t/data/dbic_fixtures/300-Run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,18 @@
id_run_pair: ~
is_paired: 0
priority: 3
team: A
- actual_cycle_count: 316
batch_id: ~
expected_cycle_count: 316
flowcell_id: ~
folder_name: 'elembio_run'
folder_path_glob: 't/data'
id_instrument: 70
id_instrument_format: 12
id_run: 100000
id_run_pair: ~
is_paired: 1
priority: 1
team: A

19 changes: 19 additions & 0 deletions t/data/dbic_fixtures/400-RunStatus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,22 @@
id_run_status_dict: 4
id_user: 7
iscurrent: 1
- id_run_status: 45
id_run: 100000
date: 2024-11-23 02:14:17
id_run_status_dict: 2
id_user: 7
iscurrent: 0
- id_run_status: 46
id_run: 100000
date: 2024-11-23 12:23:10
id_run_status_dict: 4
id_user: 7
iscurrent: 0
- id_run_status: 47
id_run: 100000
date: 2024-11-23 12:44:40
id_run_status_dict: 6
id_user: 7
iscurrent: 1

7 changes: 0 additions & 7 deletions t/dbic_util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ sub test_schema_mlwh {
);
}

sub test_schema_wh {
my ($self, $fixture_path) = @_;
return $self->create_test_db(
'npg_warehouse::Schema', $fixture_path
);
}

no Moose;
__PACKAGE__->meta->make_immutable();
1;
Expand Down

0 comments on commit 39c6bb6

Please sign in to comment.