diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/stylesheets/framework/emojis.scss | 2 | ||||
-rw-r--r-- | app/assets/stylesheets/framework/files.scss | 2 | ||||
-rw-r--r-- | app/assets/stylesheets/framework/variables.scss | 1 | ||||
-rw-r--r-- | app/models/bulk_imports/batch_tracker.rb | 2 | ||||
-rw-r--r-- | app/models/bulk_imports/tracker.rb | 5 | ||||
-rw-r--r-- | app/services/ml/model_versions/update_model_version_service.rb | 27 | ||||
-rw-r--r-- | app/workers/bulk_imports/finish_batched_pipeline_worker.rb | 36 |
7 files changed, 54 insertions, 21 deletions
diff --git a/app/assets/stylesheets/framework/emojis.scss b/app/assets/stylesheets/framework/emojis.scss index d3986f31d52..92cb509148f 100644 --- a/app/assets/stylesheets/framework/emojis.scss +++ b/app/assets/stylesheets/framework/emojis.scss @@ -27,7 +27,7 @@ gl-emoji { .emoji-picker-category-header { @include gl-sticky; - background-color: $white-transparent; + background: linear-gradient(to bottom, $white 50%, transparent 100%); } .emoji-picker-emoji { diff --git a/app/assets/stylesheets/framework/files.scss b/app/assets/stylesheets/framework/files.scss index eb627b036fe..c99e985e18c 100644 --- a/app/assets/stylesheets/framework/files.scss +++ b/app/assets/stylesheets/framework/files.scss @@ -603,6 +603,6 @@ span.idiff { right: 0; top: -$gradient-size; height: $gradient-size; - background: linear-gradient(to top, $white, transparentize($white, 1)); + background: linear-gradient(to top, $white, transparent); } } diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index ab8547c3fef..3770a9b68a0 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -182,7 +182,6 @@ $t-gray-a-24: rgba($gray-950, 0.24) !default; $white: #fff !default; $white-normal: $gray-50 !default; $white-dark: darken($gray-50, 2) !default; -$white-transparent: rgba($white, 0.8) !default; $black: #000 !default; $black-transparent: $t-gray-a-24 !default; diff --git a/app/models/bulk_imports/batch_tracker.rb b/app/models/bulk_imports/batch_tracker.rb index eb7fe9f9913..8561dfacb6e 100644 --- a/app/models/bulk_imports/batch_tracker.rb +++ b/app/models/bulk_imports/batch_tracker.rb @@ -8,6 +8,8 @@ module BulkImports validates :batch_number, presence: true, uniqueness: { scope: :tracker_id } + scope :by_last_updated, -> { order(updated_at: :desc) } + state_machine :status, initial: :created do state :created, value: 0 state :started, value: 1 diff --git a/app/models/bulk_imports/tracker.rb b/app/models/bulk_imports/tracker.rb index b06583c8e06..b5092591019 100644 --- a/app/models/bulk_imports/tracker.rb +++ b/app/models/bulk_imports/tracker.rb @@ -24,7 +24,6 @@ class BulkImports::Tracker < ApplicationRecord delegate :file_extraction_pipeline?, :abort_on_failure?, to: :pipeline_class DEFAULT_PAGE_SIZE = 500 - STALE_AFTER = 4.hours scope :next_pipeline_trackers_for, -> (entity_id) { entity_scope = where(bulk_import_entity_id: entity_id) @@ -88,8 +87,4 @@ class BulkImports::Tracker < ApplicationRecord transition [:created, :started] => :timeout end end - - def stale? - created_at < STALE_AFTER.ago - end end diff --git a/app/services/ml/model_versions/update_model_version_service.rb b/app/services/ml/model_versions/update_model_version_service.rb new file mode 100644 index 00000000000..a0de87792f8 --- /dev/null +++ b/app/services/ml/model_versions/update_model_version_service.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Ml + module ModelVersions + class UpdateModelVersionService + def initialize(project, name, version, description) + @project = project + @name = name + @version = version + @description = description + end + + def execute + model_version = Ml::ModelVersion + .by_project_id_name_and_version(@project.id, @name, @version) + + return ServiceResponse.error(message: 'Model not found') unless model_version.present? + + result = model_version.update(description: @description) + + return ServiceResponse.error(message: 'Model update failed') unless result + + ServiceResponse.success(payload: model_version) + end + end + end +end diff --git a/app/workers/bulk_imports/finish_batched_pipeline_worker.rb b/app/workers/bulk_imports/finish_batched_pipeline_worker.rb index 73ae2188ac4..980cdb98f32 100644 --- a/app/workers/bulk_imports/finish_batched_pipeline_worker.rb +++ b/app/workers/bulk_imports/finish_batched_pipeline_worker.rb @@ -6,6 +6,7 @@ module BulkImports include ExceptionBacktrace REQUEUE_DELAY = 5.seconds + STALE_AFTER = 4.hours idempotent! deduplicate :until_executing @@ -18,24 +19,21 @@ module BulkImports @tracker = Tracker.find(pipeline_tracker_id) @context = ::BulkImports::Pipeline::Context.new(tracker) - return unless tracker.batched? - return unless tracker.started? + return unless tracker.batched? && tracker.started? + + @sorted_batches = tracker.batches.by_last_updated + return fail_stale_tracker_and_batches if most_recent_batch_stale? + return re_enqueue if import_in_progress? - if tracker.stale? - logger.error(log_attributes(message: 'Tracker stale. Failing batches and tracker')) - tracker.batches.map(&:fail_op!) - tracker.fail_op! - else - tracker.pipeline_class.new(@context).on_finish - logger.info(log_attributes(message: 'Tracker finished')) - tracker.finish! - end + tracker.pipeline_class.new(@context).on_finish + logger.info(log_attributes(message: 'Tracker finished')) + tracker.finish! end private - attr_reader :tracker + attr_reader :tracker, :sorted_batches def re_enqueue with_context(bulk_import_entity_id: tracker.entity.id) do @@ -44,7 +42,19 @@ module BulkImports end def import_in_progress? - tracker.batches.any? { |b| b.started? || b.created? } + sorted_batches.any? { |b| b.started? || b.created? } + end + + def most_recent_batch_stale? + return false unless sorted_batches.any? + + sorted_batches.first.updated_at < STALE_AFTER.ago + end + + def fail_stale_tracker_and_batches + logger.error(log_attributes(message: 'Batch stale. Failing batches and tracker')) + sorted_batches.map(&:fail_op!) + tracker.fail_op! end def logger |