ensembl-hive  2.7.0
PeekJob.pm
Go to the documentation of this file.
1 #!/usr/bin/env perl
2 
3 # See the NOTICE file distributed with this work for additional information
4 # regarding copyright ownership.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 
18 package Bio::EnsEMBL::Hive::Scripts::PeekJob;
19 
20 use strict;
21 use warnings;
22 use Data::Dumper;
23 
24 sub peek {
25  my ($pipeline, $job_id) = @_;
26 
27  my $hive_dba = $pipeline->hive_dba;
28  die "Hive's DBAdaptor is not a defined Bio::EnsEMBL::Hive::DBSQL::DBAdaptor\n" unless $hive_dba and $hive_dba->isa('Bio::EnsEMBL::Hive::DBSQL::DBAdaptor');
29 
30  # fetch job and populate params
31  my $job_adaptor = $hive_dba->get_AnalysisJobAdaptor;
32  my $job = $job_adaptor->fetch_by_dbID( $job_id );
33  die "Cannot find job with id $job_id\n" unless $job;
34  $job->load_parameters;
35  my $analysis_id = $job->analysis_id;
36  my $logic_name = $job->analysis->logic_name;
37 
38  my $label = "[ Analysis $logic_name ($analysis_id) Job $job_id ]";
39  return _stringify_params($job->{'_unsubstituted_param_hash'}, $label);
40 }
41 
42 sub _stringify_params {
43  my ($params, $label) = @_;
44 
45  local $Data::Dumper::Sortkeys = 1;
46  local $Data::Dumper::Deepcopy = 1;
47  local $Data::Dumper::Indent = 1;
48 
49  return Data::Dumper->Dump( [ $params ], [ qq(*unsubstituted_param_hash $label) ] );
50 }
51 
52 1;