<commit_before>require 'aws/s3'

module Artifacts
  AWS_PARAMETERS = %w(AWS_ACCESS_KEY_ID AWS_S3_BUCKET AWS_SECRET_ACCESS_KEY)

  include AWS::S3

  def archive_artifacts
    if AWS_PARAMETERS.all? { |p| ENV[p] }
      puts "Establishing connection to S3"
      establish_s3_connection!

      if browserid_log && File.exists?(browserid_log)
        puts "Copying #{browserid_log} to S3"
        archive_log
        puts "OK"
      end
    end
  end

  def establish_s3_connection!
    AWS::S3::Base.establish_connection!(
      :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
      :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
    )
  end

  def archive_log
    S3Object.store("browserid-#{build_tag}.log", open(browserid_log), artifact_bucket)
  end

  def browserid_log
    ENV['BROWSERID_LOG']
  end

  def artifact_bucket
    ENV['AWS_S3_BUCKET']
  end

  def build_tag
    "#{Time.now.to_i}-#{ENV['DRIVER']}-#{RUBY_ENGINE}"
  end
end<commit_msg>Fix environment variable references.<commit_after>require 'aws/s3'

module Artifacts
  AWS_PARAMETERS = %w(ACCESS_KEY_ID AWS_S3_BUCKET SECRET_ACCESS_KEY)

  include AWS::S3

  def archive_artifacts
    if AWS_PARAMETERS.all? { |p| ENV[p] }
      puts "Establishing connection to S3"
      establish_s3_connection!

      if browserid_log && File.exists?(browserid_log)
        puts "Copying #{browserid_log} to S3"
        archive_log
        puts "OK"
      end
    end
  end

  def establish_s3_connection!
    AWS::S3::Base.establish_connection!(
      :access_key_id => ENV['ACCESS_KEY_ID'],
      :secret_access_key => ENV['SECRET_ACCESS_KEY']
    )
  end

  def archive_log
    S3Object.store("browserid-#{build_tag}.log", open(browserid_log), artifact_bucket)
  end

  def browserid_log
    ENV['BROWSERID_LOG']
  end

  def artifact_bucket
    ENV['AWS_S3_BUCKET']
  end

  def build_tag
    "#{Time.now.to_i}-#{ENV['DRIVER']}-#{RUBY_ENGINE}"
  end
end
{'fraction_non_alphanumeric': 0.10611604809200209, 'fraction_numerical': 0.010454783063251438, 'mean_word_length': 3.524822695035461, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1182647', 'n_tokens_mistral': 733, 'n_tokens_neox': 728, 'n_words': 128}