ensembl-hive  2.8.1
tweak_pipeline.pl
Go to the documentation of this file.
1 #!/usr/bin/env perl
2 
3 use strict;
4 use warnings;
5 use JSON qw(encode_json);
6 
7  # Finding out own path in order to reference own components (including own modules):
8 use Cwd ();
9 use File::Basename ();
10 BEGIN {
11  $ENV{'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( Cwd::realpath($0) ) );
12  unshift @INC, $ENV{'EHIVE_ROOT_DIR'}.'/modules';
13 }
14 
15 use Getopt::Long qw(:config pass_through no_auto_abbrev);
16 use Pod::Usage;
17 
19 use Bio::EnsEMBL::Hive::Utils ('load_file_or_module');
21 
23 
24 main();
25 
26 
27 sub main {
28 
29  my $self = {};
30  my $tweaks = [];
31 
32  GetOptions(
33  # connection parameters
34  'url=s' => \$self->{'url'},
35  'reg_conf|reg_file=s' => \$self->{'reg_conf'},
36  'reg_type=s' => \$self->{'reg_type'},
37  'reg_alias|reg_name=s' => \$self->{'reg_alias'},
38  'nosqlvc' => \$self->{'nosqlvc'}, # using "nosqlvc" instead of "sqlvc!" for consistency with scripts where it is a propagated option
39  'json' => \$self->{'json'},
40  'tweak|SET=s@' => \$tweaks,
41  'DELETE=s' => sub { my ($opt_name, $opt_value) = @_; push @$tweaks, $opt_value.'#'; },
42  'SHOW=s' => sub { my ($opt_name, $opt_value) = @_; push @$tweaks, $opt_value.'?'; },
43 
44  'h|help' => \$self->{'help'},
45  ) or die "\nERROR: in command line arguments\n";
46 
47  if (@ARGV) {
48  die "\nERROR: There are invalid arguments on the command-line: ". join(" ", @ARGV). "\n";
49  }
50 
51  if($self->{'help'}) {
52  pod2usage({-exitvalue => 0, -verbose => 2});
53  }
54 
55  my $pipeline;
56 
57  if($self->{'url'} or $self->{'reg_alias'}) {
59  -url => $self->{'url'},
60  -reg_conf => $self->{'reg_conf'},
61  -reg_type => $self->{'reg_type'},
62  -reg_alias => $self->{'reg_alias'},
63  -no_sql_schema_version_check => $self->{'nosqlvc'},
64  );
65 
66  } else {
67  die "\nERROR: Connection parameters (url or reg_conf+reg_alias) need to be specified\n";
68  }
69  if(@$tweaks) {
70  my ($need_write, $msg_list_ref, $response_structure) = $pipeline->apply_tweaks( $tweaks );
71 
72  $response_structure->{URL} = $self->{'url'};
73  my $json = JSON->new->allow_nonref;
74 
75  print $self->{'json'} ? $json->encode($response_structure) : join('', @$msg_list_ref);
76  if ($need_write) {
77  $pipeline->hive_dba()->dbc->requires_write_access();
78  $pipeline->save_collections();
79  }
80  }
81 
82 }
83 
84 
85 __DATA__
86 
87 =pod
88 
89 =head1 NAME
90 
91 tweak_pipeline.pl
92 
93 =head1 SYNOPSIS
94 
95  tweak_pipeline.pl [ -url mysql://user:pass@server:port/dbname | -reg_conf <reg_conf_file> -reg_alias <reg_alias> ] -tweak 'analysis[mafft%].analysis_capacity=undef'
96 
97 =head1 DESCRIPTION
98 
99 This is a script to "tweak" attributes or parameters of an existing eHive pipeline.
100 
101 =head1 OPTIONS
102 
103 =over
104 
105 =item --url <url>
106 
107 URL defining where eHive database is located
108 
109 =item --reg_conf <path>
110 
111 path to a Registry configuration file
112 
113 =item --reg_type <name>
114 
115 Registry type of the eHive DBAdaptor
116 
117 =item --reg_alias <name>
118 
119 species/alias name for the eHive DBAdaptor
120 
121 =item --nosqlvc
122 
123 "No SQL Version Check" - set if you want to force working with a database created by a potentially schema-incompatible API
124 
125 =item --tweak <string>
126 
127 An assignment command that performs one individual "tweak". You can "tweak" global/Analysis parameters, Analysis attributes and Resource Classes:
128 
129  -tweak 'pipeline.param[take_time]=20' # override a value of a pipeline-wide parameter; can also create a non-existent parameter
130  -tweak 'analysis[take_b_apart].param[base]=10' # override a value of an Analysis-wide parameter; can also create a non-existent parameter
131  -tweak 'analysis[add_together].analysis_capacity=undef' # override a value of an Analysis attribute
132  -tweak 'analysis[add_together].batch_size=15' # override a value of an Analysis_stats attribute
133  -tweak 'analysis[part_multiply].resource_class=urgent' # set the Resource Class of an Analysis (whether a Resource Class with this name existed or not)
134  -tweak 'resource_class[urgent].LSF=-q yesteryear' # update or create a new Resource Description
135 
136 If multiple "tweaks" are requested, they will be performed in the given order.
137 
138 =item --DELETE <selector>
139 
140 Shortcut to delete a parameter
141 
142 =item --SHOW <selector>
143 
144 Shortcut to show a parameter value
145 
146 =back
147 
148 =head1 LICENSE
149 
150  See the NOTICE file distributed with this work for additional information
151  regarding copyright ownership.
152 
153  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
154  You may obtain a copy of the License at
155 
156  http://www.apache.org/licenses/LICENSE-2.0
157 
158  Unless required by applicable law or agreed to in writing, software distributed under the License
159  is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
160  See the License for the specific language governing permissions and limitations under the License.
161 
162 =head1 CONTACT
163 
164 Please subscribe to the eHive mailing list: http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users to discuss eHive-related questions or to be notified of our updates
165 
166 =cut
Bio::EnsEMBL::Hive::Utils
Definition: Collection.pm:4
Bio::EnsEMBL::Hive::Utils::URL::hide_url_password
public Void hide_url_password()
Bio::EnsEMBL::Hive::Utils::URL
Definition: URL.pm:11
Bio::EnsEMBL::Hive::HivePipeline::new
public new()
main
public main()
Bio::EnsEMBL::Hive::HivePipeline
Definition: HivePipeline.pm:13
BEGIN
public BEGIN()