Commit b5ac4261 authored by Carla Cummins's avatar Carla Cummins Committed by ens-bwalts
Browse files

Address @muffato's comments for peekJob.pl

parent 2e20f67e
......@@ -19,9 +19,7 @@ package Bio::EnsEMBL::Hive::Scripts::PeekJob;
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
sub peek {
my ($pipeline, $job_id) = @_;
......@@ -32,10 +30,23 @@ sub peek {
# fetch job and populate params
my $job_adaptor = $hive_dba->get_AnalysisJobAdaptor;
my $job = $job_adaptor->fetch_by_dbID( $job_id );
die "Cannot find job with id $job_id\n" unless $job;
$job->load_parameters;
my $analysis_id = $job->analysis_id;
my $logic_name = $job->analysis->logic_name;
my $label = "[ Analysis $logic_name ($analysis_id) Job $job_id ]";
return _stringify_params($job->{'_unsubstituted_param_hash'}, $label);
}
sub _stringify_params {
my ($params, $label) = @_;
local $Data::Dumper::Sortkeys = 1;
local $Data::Dumper::Deepcopy = 1;
local $Data::Dumper::Indent = 1;
my $unsub_params = $job->{'_unsubstituted_param_hash'};
return Data::Dumper->Dump( [ $unsub_params ], [ qw(*unsubstituted_param_hash) ] );
return Data::Dumper->Dump( [ $params ], [ qq(*unsubstituted_param_hash $label) ] );
}
1;
#!/usr/bin/env perl
# Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
# Copyright [2016-2019] EMBL-European Bioinformatics Institute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
use strict;
use warnings;
......@@ -29,7 +13,6 @@ BEGIN {
use Getopt::Long qw(:config no_auto_abbrev);
use Pod::Usage;
use Bio::EnsEMBL::Hive::Version qw(report_versions);
use Bio::EnsEMBL::Hive::HivePipeline;
use Bio::EnsEMBL::Hive::Scripts::PeekJob;
use Bio::EnsEMBL::Hive::Utils::URL;
......@@ -40,10 +23,7 @@ main();
sub main {
my ($url, $reg_conf, $reg_type, $reg_alias, $nosqlvc, $job_id);
my ($help, $report_versions);
$|=1; # make STDOUT unbuffered (STDERR is unbuffered anyway)
my ($url, $reg_conf, $reg_type, $reg_alias, $nosqlvc, $job_id, $help);
GetOptions(
......@@ -59,7 +39,6 @@ sub main {
# Other commands
'h|help' => \$help,
'v|version|versions' => \$report_versions,
) or die "Error in command line arguments\n";
if (@ARGV) {
......@@ -70,11 +49,6 @@ sub main {
pod2usage({-exitvalue => 0, -verbose => 2});
}
if($report_versions) {
report_versions();
exit(0);
}
my $pipeline;
if($url or $reg_alias) {
......@@ -115,7 +89,7 @@ peekJob.pl is an eHive component script that allows us to peek into the paramete
=head1 USAGE EXAMPLES
# Check the params for job 123456
runWorker.pl -url mysql://username:secret@hostname:port/ehive_dbname -job_id 12345
peekJob.pl -url mysql://username:secret@hostname:port/ehive_dbname -job_id 12345
=head1 OPTIONS
......@@ -151,7 +125,9 @@ URL defining where database is located
=item --job_id <id>
run a specific Job defined by its database id
which Job (as defined by its database id) to peek at
=back
=head2 Other options:
......@@ -161,16 +137,12 @@ run a specific Job defined by its database id
print this help
=item --versions
report both eHive code version and eHive database schema version
=back
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2018] EMBL-European Bioinformatics Institute
Copyright [2016-2019] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
......
......@@ -20,12 +20,9 @@ use strict;
use warnings;
use Test::More;
use Data::Dumper;
use Test::JSON;
use JSON qw(decode_json);
use Capture::Tiny ':all';
use Bio::EnsEMBL::Hive::Utils::Test qw(init_pipeline runWorker beekeeper get_test_url_or_die run_sql_on_db peekJob);
use Bio::EnsEMBL::Hive::Utils::Test qw(init_pipeline get_test_url_or_die peekJob);
# eHive needs this to initialize the pipeline (and run db_cmd.pl)
......@@ -43,7 +40,7 @@ my $stdout = capture_stdout {
peekJob($pipeline_url, ["-job_id" => 1]);
};
$stdout =~ s/\s+//g;
my $exp_stdout = "%unsubstituted_param_hash=('column_names'=>['value'],'inputlist'=>'#expr([0..#job_count#-1])expr#','job_count'=>10);";
my $exp_stdout = "%unsubstituted_param_hash[Analysisgenerate_jobs(1)Job1]=('column_names'=>['value'],'inputlist'=>'#expr([0..#job_count#-1])expr#','job_count'=>10);";
is( $stdout, $exp_stdout, 'Correct params reported' );
done_testing();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment