Skip to content
Snippets Groups Projects
Commit 102cc96f authored by Leo Gordon's avatar Leo Gordon
Browse files

API change: Scheduler::schedule_workers_resync_if_necessary() and...

API change: Scheduler::schedule_workers_resync_if_necessary() and Scheduler::schedule_workers() now take an obligatory $list_of_analyses
parent 09e3c9b8
Branches release/76
No related tags found
No related merge requests found
......@@ -585,10 +585,10 @@ sub reset_jobs_for_analysis_id {
=cut
sub balance_semaphores {
my ($self, $only_analyses) = @_;
my ($self, $list_of_analyses) = @_;
my $analysis_filter = $only_analyses
? "funnel.analysis_id IN (".join(',', map { $_->dbID } @$only_analyses).") AND"
my $analysis_filter = $list_of_analyses
? "funnel.analysis_id IN (".join(',', map { $_->dbID } @$list_of_analyses).") AND"
: '';
my $find_sql = qq{
......
......@@ -45,10 +45,7 @@ use Bio::EnsEMBL::Hive::Limiter;
sub schedule_workers_resync_if_necessary {
my ($queen, $valley, $filter_analysis) = @_;
my $list_of_analyses = $filter_analysis ? [ $filter_analysis ] : $queen->db->get_AnalysisAdaptor->fetch_all();
# $queen->db->get_AnalysisAdaptor->fetch_by_logic_name( $analyses_pattern )
my ($queen, $valley, $list_of_analyses) = @_;
my $submit_capacity = $valley->config_get('SubmitWorkersMax');
my $default_meadow_type = $valley->get_default_meadow()->type;
......@@ -60,7 +57,7 @@ sub schedule_workers_resync_if_necessary {
my $analysis_id2rc_name = { map { $_ => $rc_id2name->{ $analysis_id2rc_id->{ $_ }} } keys %$analysis_id2rc_id };
my ($workers_to_submit_by_meadow_type_rc_name, $total_extra_workers_required, $log_buffer)
= schedule_workers($queen, $submit_capacity, $default_meadow_type, $filter_analysis && [$filter_analysis], $meadow_capacity_limiter_hashed_by_type, $analysis_id2rc_name);
= schedule_workers($queen, $submit_capacity, $default_meadow_type, $list_of_analyses, $meadow_capacity_limiter_hashed_by_type, $analysis_id2rc_name);
print $log_buffer;
unless( $total_extra_workers_required ) {
......@@ -92,7 +89,7 @@ sub schedule_workers_resync_if_necessary {
}
($workers_to_submit_by_meadow_type_rc_name, $total_extra_workers_required, $log_buffer)
= schedule_workers($queen, $submit_capacity, $default_meadow_type, $filter_analysis && [$filter_analysis], $meadow_capacity_limiter_hashed_by_type, $analysis_id2rc_name);
= schedule_workers($queen, $submit_capacity, $default_meadow_type, $list_of_analyses, $meadow_capacity_limiter_hashed_by_type, $analysis_id2rc_name);
print $log_buffer;
}
......@@ -133,22 +130,20 @@ sub suggest_analysis_to_specialize_a_worker {
my $worker_rc_id = $worker->resource_class_id;
my $worker_meadow_type = $worker->meadow_type;
my @only_analyses = grep { !$worker_rc_id or $worker_rc_id==$_->resource_class_id}
my @list_of_analyses = grep { !$worker_rc_id or $worker_rc_id==$_->resource_class_id}
grep { !$worker_meadow_type or !$_->meadow_type or ($worker_meadow_type eq $_->meadow_type) }
# if any other attributes of the worker are specifically constrained in the analysis (such as meadow_name),
# the corresponding checks should be added here
@{ $queen->db->get_AnalysisAdaptor->fetch_all_by_pattern( $analyses_pattern ) };
return schedule_workers( $queen, 1, $worker_meadow_type, \@only_analyses );
return schedule_workers( $queen, 1, $worker_meadow_type, \@list_of_analyses );
}
sub schedule_workers {
my ($queen, $submit_capacity, $default_meadow_type, $only_analyses, $meadow_capacity_limiter_hashed_by_type, $analysis_id2rc_name) = @_;
$only_analyses ||= $queen->db->get_AnalysisAdaptor->fetch_all(); # make sure we have something to choose from
my ($queen, $submit_capacity, $default_meadow_type, $list_of_analyses, $meadow_capacity_limiter_hashed_by_type, $analysis_id2rc_name) = @_;
my @stats_sorted_by_suitability = @{ Bio::EnsEMBL::Hive::Scheduler::sort_stats_by_suitability( $only_analyses ) };
my @stats_sorted_by_suitability = @{ Bio::EnsEMBL::Hive::Scheduler::sort_stats_by_suitability( $list_of_analyses ) };
unless(@stats_sorted_by_suitability) {
return $analysis_id2rc_name ? ({}, 0, "Scheduler could not find any suitable analyses to start with\n") : undef; # FIXME: returns data in different format in "suggest analysis" mode
......
......@@ -271,7 +271,7 @@ sub main {
}
$self->{'dba'}->get_RoleAdaptor->print_active_role_counts;
Bio::EnsEMBL::Hive::Scheduler::schedule_workers_resync_if_necessary($queen, $valley, $analysis); # show what would be submitted, but do not actually submit
Bio::EnsEMBL::Hive::Scheduler::schedule_workers_resync_if_necessary($queen, $valley, $list_of_analyses); # show what would be submitted, but do not actually submit
$queen->get_remaining_jobs_show_hive_progress( $analysis ) if ($analysis);
$queen->get_remaining_jobs_show_hive_progress();
......@@ -325,6 +325,7 @@ sub generate_worker_cmd {
return $worker_cmd;
}
sub run_autonomously {
my ($self, $max_loops, $keep_alive, $queen, $valley, $list_of_analyses, $run_analysis, $run_job_id, $force) = @_;
......@@ -356,7 +357,7 @@ sub run_autonomously {
$self->{'dba'}->get_RoleAdaptor->print_active_role_counts;
my $workers_to_submit_by_meadow_type_rc_name
= Bio::EnsEMBL::Hive::Scheduler::schedule_workers_resync_if_necessary($queen, $valley, $run_analysis);
= Bio::EnsEMBL::Hive::Scheduler::schedule_workers_resync_if_necessary($queen, $valley, $list_of_analyses);
if( keys %$workers_to_submit_by_meadow_type_rc_name ) {
......
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