3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
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
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.
21 package Bio::EnsEMBL::Hive::Scripts::InitPipeline;
31 my ($file_or_module, $tweaks) = @_;
33 my $pipeconfig_package_name = load_file_or_module( $file_or_module );
35 my $pipeconfig_object = $pipeconfig_package_name->new();
36 die
"PipeConfig $pipeconfig_package_name not created\n" unless $pipeconfig_object;
37 die
"PipeConfig $pipeconfig_package_name is not a Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf\n" unless $pipeconfig_object->isa(
'Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf');
39 print
"> Parsing the command-line options.\n\n";
40 $pipeconfig_object->process_options( 1 );
42 # Restore the password in the URL so that pipelines that need
43 # pipeline_url() don't see _EHIVE_HIDDEN_PASS
44 if ($pipeconfig_object->pipeline_url =~ /\$\{_EHIVE_HIDDEN_PASS\}/) {
45 my $real_password = $ENV{_EHIVE_HIDDEN_PASS};
46 $pipeconfig_object->root()->{
'pipeline_url'} =~ s/\$\{_EHIVE_HIDDEN_PASS\}/$real_password/;
47 $pipeconfig_object->root()->{
'pipeline_url'} =~ s/
'//g;
50 print "> Running the creation commands.\n\n";
51 $pipeconfig_object->run_pipeline_create_commands();
53 my $pipeline = Bio::EnsEMBL::Hive::HivePipeline->new(
54 -url => $pipeconfig_object->pipeline_url(),
55 -no_sql_schema_version_check => !$pipeconfig_object->is_analysis_topup );
57 my $hive_dba = $pipeline->hive_dba()
58 or die "HivePipeline could not be created for ".$pipeconfig_object->pipeline_url();
59 $hive_dba->dbc->requires_write_access();
61 print "> Parsing the PipeConfig file and adding objects (this may take a while).\n\n";
62 $pipeconfig_object->add_objects_from_config( $pipeline );
64 if($tweaks and @$tweaks) {
65 print "> Applying tweaks.\n\n";
66 my ($need_write, $msg_list_ref, $json) = $pipeline->apply_tweaks( $tweaks );
67 $pipeconfig_object->print_debug(join("", @$msg_list_ref), "\n");
70 $pipeline->test_connections();
72 print "> Storing the pipeline in the database.\n\n";
73 $pipeline->save_collections();
75 print "Pipeline successfully stored at ", $pipeconfig_object->pipeline_url, " !\n\n";
77 print $pipeconfig_object->useful_commands_legend();
79 $hive_dba->dbc->disconnect_if_idle; # This is necessary because the current lack of global DBC caching may leave this DBC connected and prevent deletion of the DB in pgsql mode
81 return $hive_dba->dbc->url;