Sha256: 52a63149580aeb0249c48d5faf12facfa88474d9cb655a3310579807543f24e9

Contents?: true

Size: 885 Bytes

Versions: 1

Compression:

Stored size: 885 Bytes

Contents

module EasyML
  class RefreshDatasetJob < ApplicationJob
    def perform(id)
      begin
        dataset = EasyML::Dataset.find(id)
        puts "Refreshing dataset #{dataset.name}"
        puts "Needs refresh? #{dataset.needs_refresh?}"
        unless dataset.needs_refresh?
          dataset.update(workflow_status: :ready)
        end

        create_event(dataset, "started")

        puts "Prepare! #{dataset.name}"
        dataset.prepare
        if dataset.features.needs_fit.any?
          dataset.fit_features(async: true)
          puts "Computing features!"
        else
          dataset.actually_refresh
          puts "Done!"
        end
      rescue StandardError => e
        puts "Error #{e.message}"
        if Rails.env.test?
          raise e
        end
        dataset.update(workflow_status: :failed)
        handle_error(dataset, e)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
easy_ml-0.2.0.pre.rc52 app/jobs/easy_ml/refresh_dataset_job.rb