<commit_before>require 'spec_helper'

describe 'a live system', :if => ENV['LIVE_CLUSTER_CONFIG'], :order => :defined do
  before(:all) do
    @adapter = OodCore::Job::Factory.build(
      YAML.load_file(ENV['LIVE_CLUSTER_CONFIG'])
    )

    @script_content = <<~HERESCRIPT
      #!/bin/bash
      #JOB_HEADERS_HERE
      sleep 100
      exit 0
    HERESCRIPT

    @script = OodCore::Job::Script.new(
      # generate a random job name
      # e.g. TEST_SYQECQXW
      job_name: 'TEST_' + (0...8).map { (65 + rand(26)).chr }.join,
      content: @script_content,
      # don't clutter the file system with output from tests
      output_path: '/dev/null',
      error_path: '/dev/null',
      submit_as_hold: true
    )

    # Confirm that live tests will be run, and let the use know the name in case manual cleanup is necessary
    puts "\nRunning tests on live system with job_name #{@script.job_name}\n"
  end

  after(:all) do
    # Mark the boundry between live test outcomes and those of non-live system tests
    puts "\nLive system tests complete. Continuing with other tests:\n"
  end
<commit_msg>make live test config loading more flexible<commit_after>require 'spec_helper'

describe 'a live system', :if => ENV['LIVE_CLUSTER_CONFIG'], :order => :defined do
  before(:all) do
    # load job config either from cluster config or from yaml in format { adapter:, ... }
    config = YAML.load_file(ENV['LIVE_CLUSTER_CONFIG'])
    @adapter = OodCore::Job::Factory.build(config.dig("v2", "job") || config)

    @script_content = <<~HERESCRIPT
      #!/bin/bash
      #JOB_HEADERS_HERE
      sleep 100
      exit 0
    HERESCRIPT

    @script = OodCore::Job::Script.new(
      # generate a random job name
      # e.g. TEST_SYQECQXW
      job_name: 'TEST_' + (0...8).map { (65 + rand(26)).chr }.join,
      content: @script_content,
      # don't clutter the file system with output from tests
      output_path: '/dev/null',
      error_path: '/dev/null',
      submit_as_hold: true
    )

    # Confirm that live tests will be run, and let the use know the name in case manual cleanup is necessary
    puts "\nRunning tests on live system with job_name #{@script.job_name}\n"
  end

  after(:all) do
    # Mark the boundry between live test outcomes and those of non-live system tests
    puts "\nLive system tests complete. Continuing with other tests:\n"
  end

{'fraction_non_alphanumeric': 0.11092366090257276, 'fraction_numerical': 0.008857022353437369, 'mean_word_length': 2.993265993265993, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3923639', 'n_tokens_mistral': 787, 'n_tokens_neox': 755, 'n_words': 246}