<commit_before>require 'json'
require 'bellows/http'
require 'bellows/util'
require 'bellows/gerrit'
require 'bellows/smoke_stack'

module Bellows
  class Tasks < Thor

    desc "sync PROJECT", "Create tests & update refspecs for active reviews."
    method_options :test => :boolean
    def sync(project)
      if not ['nova', 'glance', 'keystone'].include?(project) then
        puts "ERROR: Please specify a valid project name."
        exit 1
      end
      test = options[:test]
      smoke_tests = Bellows::SmokeStack.get_smoke_tests(project)
      Bellows::Gerrit.reviews(project) do |review|
        owner = review['owner']['name']
        refspec = review['currentPatchSet']['ref']
        review_id = Bellows::Util.short_spec(refspec)
        smoke_test = smoke_tests[review_id]
        desc = owner + ": " +review['subject']
        if not smoke_test
          puts "Creating... " + desc
          Bellows::SmokeStack.create_smoke_test(project, desc, refspec, [1], [1, 2]) if not test
        else
          if smoke_test["#{project}_package_builder"]['branch'] != refspec then
            puts "Updating... " + desc
            puts "refspec: " + refspec<commit_msg>Don't hard code test suite ids and config template ids on create.<commit_after>require 'json'
require 'bellows/http'
require 'bellows/util'
require 'bellows/gerrit'
require 'bellows/smoke_stack'

module Bellows
  class Tasks < Thor

    desc "sync PROJECT", "Create tests & update refspecs for active reviews."
    method_options :test => :boolean
    def sync(project)
      if not ['nova', 'glance', 'keystone'].include?(project) then
        puts "ERROR: Please specify a valid project name."
        exit 1
      end
      test = options[:test]
      smoke_tests = Bellows::SmokeStack.get_smoke_tests(project)
      configs=Util.load_configs
      test_suite_ids = configs['test_suite_ids'].collect {|x| x.to_s }
      config_template_ids = configs['config_template_ids'].collect {|x| x.to_s }

      Bellows::Gerrit.reviews(project) do |review|
        owner = review['owner']['name']
        refspec = review['currentPatchSet']['ref']
        review_id = Bellows::Util.short_spec(refspec)
        smoke_test = smoke_tests[review_id]
        desc = owner + ": " +review['subject']
        if not smoke_test
          puts "Creating... " + desc
          Bellows::SmokeStack.create_smoke_test(project, desc, refspec, config_template_ids, test_suite_ids) if not test
        else
          if smoke_test["#{project}_package_builder"]['branch'] != refspec then
            puts "Updating... " + desc
            puts "refspec: " + refspec
{'fraction_non_alphanumeric': 0.11951126384116074, 'fraction_numerical': 0.0019091256204658267, 'mean_word_length': 3.0494590417310663, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '73136', 'n_tokens_mistral': 795, 'n_tokens_neox': 813, 'n_words': 200}