ensembl-hive  2.8.1
StandaloneJob.pm
Go to the documentation of this file.
1 =head1 LICENSE
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 =cut
19 
20 
21 package Bio::EnsEMBL::Hive::Scripts::StandaloneJob;
22 
23 use strict;
24 use warnings;
25 
31 use Bio::EnsEMBL::Hive::Utils ('load_file_or_module', 'destringify');
34 
35 
36 sub standaloneJob {
37  my ($module_or_file, $input_id, $flags, $flow_into, $language) = @_;
38 
39  # Tell the Valley not to bother about the other meadows.
40  $Bio::EnsEMBL::Hive::Valley::_loaded_meadow_drivers = ['Bio::EnsEMBL::Hive::Meadow::LOCAL'],
41 
43 
44  # Worker control parameters:
45  #-job_limit => $job_limit,
46  #-life_span => $life_span,
47  -no_cleanup => $flags->{no_cleanup},
48  -no_write => $flags->{no_write},
49  #-worker_log_dir => $worker_log_dir,
50  #-hive_log_dir => $hive_log_dir,
51  #-retry_throwing_jobs => $retry_throwing_jobs,
52  #-can_respecialize => $can_respecialize,
53 
54  # Other parameters:
55  -debug => $flags->{debug},
56  );
57 
58  # NOTE: `load_file_or_module` already checks that (Perl) modules can be compiled
59  my $runnable_module = $language ? $module_or_file : load_file_or_module( $module_or_file );
60 
61  my $hive_pipeline = Bio::EnsEMBL::Hive::HivePipeline->new();
62 
63  my ($dummy_analysis) = $hive_pipeline->add_new_or_update( 'Analysis', # NB: add_new_or_update returns a list
64  'logic_name' => 'Standalone_Dummy_Analysis', # looks nicer when printing out DFRs
65  'module' => $runnable_module,
66  'language' => $language,
67  );
68 
69  my $role = Bio::EnsEMBL::Hive::Role->new(
70  'worker' => $worker,
71  'analysis' => $dummy_analysis,
72  );
73  $worker->current_role( $role );
74 
76  'hive_pipeline' => $hive_pipeline,
77  'analysis' => $dummy_analysis,
78  'input_id' => $input_id,
79  );
80 
81  $worker->compile_runnable;
82  my $runnable_object = $worker->runnable_object;
83  $job->load_parameters( $runnable_object );
84 
85 
86  if($flow_into) {
87  Bio::EnsEMBL::Hive::Utils::PCL::parse_flow_into($hive_pipeline, $dummy_analysis, destringify($flow_into) );
88  }
89 
90  $runnable_object->input_job($job);
91  $runnable_object->life_cycle();
92 
93  $runnable_object->cleanup_worker_temp_directory() unless $flags->{no_cleanup};
94 
95  return !$job->died_somewhere()
96 }
97 
98 
99 1;
Bio::EnsEMBL::Hive::Utils
Definition: Collection.pm:4
Bio::EnsEMBL::Hive::GuestProcess
Definition: GuestProcess.pm:105
Bio::EnsEMBL::Hive::Utils::PCL::parse_flow_into
public parse_flow_into()
Bio::EnsEMBL::Hive::Role
Definition: Role.pm:9
Bio::EnsEMBL::Hive::HivePipeline::new
public new()
Bio::EnsEMBL::Hive::Storable::new
public Bio::EnsEMBL::Hive::Storable new()
debug
public debug()
Bio::EnsEMBL::Hive::HivePipeline
Definition: HivePipeline.pm:13
Bio::EnsEMBL::Hive::Utils::PCL
Definition: PCL.pm:12
Bio::EnsEMBL::Hive::Queen
Definition: Queen.pm:47
Bio::EnsEMBL::Hive::Queen::create_new_worker
public Bio::EnsEMBL::Hive::Worker create_new_worker()
Bio::EnsEMBL::Hive::AnalysisJob
Definition: AnalysisJob.pm:13
Bio::EnsEMBL::Hive::Valley
Definition: Valley.pm:16
Bio::EnsEMBL::Hive::Meadow::LOCAL
Definition: LOCAL.pm:13