<commit_before>class VirtualMachineInstance < ActiveRecord::Base
  belongs_to :benchmark_execution
  validates :benchmark_execution, presence: true
  has_many :nominal_metric_observations
  has_many :ordered_metric_observations

  def complete_benchmark(continue, success = true)
    if success
      create_event!(:finished_running)
      if continue
        create_event!(:started_postprocessing)
      else
        Delayed::Job.enqueue(StartPostprocessingJob.new(benchmark_execution_id))
      end
    else
      create_event!(:failed_on_running)
      Delayed::Job.enqueue(ReleaseResourcesJob.new(benchmark_execution_id))
    end
  end

  def complete_postprocessing(success = true)
    if success
      create_event!(:finished_postprocessing)
    else<commit_msg>Fix missing dependent destroy behavior that prevented metric observations from deletion<commit_after>class VirtualMachineInstance < ActiveRecord::Base
  belongs_to :benchmark_execution
  validates :benchmark_execution, presence: true
  has_many :nominal_metric_observations, dependent: :destroy
  has_many :ordered_metric_observations, dependent: :destroy

  def complete_benchmark(continue, success = true)
    if success
      create_event!(:finished_running)
      if continue
        create_event!(:started_postprocessing)
      else
        Delayed::Job.enqueue(StartPostprocessingJob.new(benchmark_execution_id))
      end
    else
      create_event!(:failed_on_running)
      Delayed::Job.enqueue(ReleaseResourcesJob.new(benchmark_execution_id))
    end
  end

  def complete_postprocessing(success = true)
    if success
      create_event!(:finished_postprocessing)
    else
{'fraction_non_alphanumeric': 0.06537530266343826, 'fraction_numerical': 0.0, 'mean_word_length': 4.680412371134021, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1771832', 'n_tokens_mistral': 472, 'n_tokens_neox': 454, 'n_words': 89}