From da3dd75a1de5df970d688c30c9271a1503c8e940 Mon Sep 17 00:00:00 2001 From: tooyosi Date: Thu, 12 Dec 2024 13:51:23 +0000 Subject: [PATCH] rely on only pool_subject_set_id for fetching prediction context --- app/services/batch/prediction/create_job.rb | 5 +---- spec/fixtures/contexts.yml | 21 ------------------ .../batch/prediction/create_job_spec.rb | 22 +------------------ 3 files changed, 2 insertions(+), 46 deletions(-) diff --git a/app/services/batch/prediction/create_job.rb b/app/services/batch/prediction/create_job.rb index dba9fe5..920e5af 100644 --- a/app/services/batch/prediction/create_job.rb +++ b/app/services/batch/prediction/create_job.rb @@ -15,10 +15,7 @@ def initialize(prediction_job, bajor_client = Bajor::Client.new) def run begin subject_set_id = prediction_job.subject_set_id - context = Context - .where(active_subject_set_id: subject_set_id) - .or(Context.where(pool_subject_set_id: subject_set_id)) - .order(Arel.sql("CASE WHEN active_subject_set_id = #{subject_set_id} THEN 0 ELSE 1 END")) + context = Context.where(pool_subject_set_id: subject_set_id) workflow_name = context.first&.extractor_name diff --git a/spec/fixtures/contexts.yml b/spec/fixtures/contexts.yml index 5ec0fb5..dec7a2e 100644 --- a/spec/fixtures/contexts.yml +++ b/spec/fixtures/contexts.yml @@ -15,24 +15,3 @@ galaxy_zoo_euclid_active_learning_project: pool_subject_set_id: 67 module_name: 'galaxy_zoo' extractor_name: 'euclid' - - -third_workflow_context: - id: 3 - workflow_id: 143 - project_id: 41 - active_subject_set_id: 70 - pool_subject_set_id: 80 - module_name: 'galaxy_zoo' - extractor_name: 'third_workflow' - -fourth_workflow_context: - id: 4 - workflow_id: 153 - project_id: 42 - active_subject_set_id: 80 - pool_subject_set_id: 70 - module_name: 'galaxy_zoo' - extractor_name: 'fourth_workflow' - - diff --git a/spec/services/batch/prediction/create_job_spec.rb b/spec/services/batch/prediction/create_job_spec.rb index 9cf771b..ee1a330 100644 --- a/spec/services/batch/prediction/create_job_spec.rb +++ b/spec/services/batch/prediction/create_job_spec.rb @@ -12,7 +12,7 @@ PredictionJob.new( manifest_url: manifest_url, state: :pending, - subject_set_id: context.active_subject_set_id, + subject_set_id: context.pool_subject_set_id, probability_threshold: 0.5, randomisation_factor: 0.5 ) @@ -57,26 +57,6 @@ end end - describe 'with same active_subject_id and pool_subject_set_id' do - let(:context1){ contexts(:third_workflow_context) } - let(:context2){ contexts(:fourth_workflow_context) } - let(:prediction_job) do - PredictionJob.new( - manifest_url: manifest_url, - state: :pending, - subject_set_id: context2.pool_subject_set_id, - probability_threshold: 0.5, - randomisation_factor: 0.5 - ) - end - - it 'calls the bajor client service with workflow name from an active_subject_set_id' do - - described_class.new(prediction_job, bajor_client_double).run - expect(bajor_client_double).to have_received(:create_prediction_job).with(manifest_url, context1.extractor_name).once - end - end - it 'updates the state tracking info on the prediction job resource' do expect { prediction_create_job.run