<commit_before>module Houdini
  RequestError = Class.new(NameError)
  HostError = Class.new(NameError)

  HOST = 'v0.houdiniapi.com'

  class Base
    def self.request(params)

      puts "sending #{params.to_json} to houdini"
      validate_config

      url = File.join("https://", HOST, "tasks.json")
      uri = URI.parse(url)
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true
      response, body = http.post(uri.path, params.to_json)

      if response.code != "200"
        raise RequestError, "The request to houdini failed with code #{response.code}: #{body}"
      end

      [response, body]
    end

    private

    def self.validate_config
      raise HostError, "Houdini.app_host should specify http:// or https://" unless Houdini.app_host.match(/^https?\:\/\//)
    end
  end


end<commit_msg>fix validation<commit_after>module Houdini
  RequestError = Class.new(NameError)
  HostError = Class.new(NameError)

  HOST = 'v0.houdiniapi.com'

  class Base
    def self.request(params)

      puts "sending #{params.to_json} to houdini"
      validate_config

      url = File.join("https://", HOST, "tasks.json")
      uri = URI.parse(url)
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true
      response, body = http.post(uri.path, params.to_json)

      if response.code != "200"
        raise RequestError, "The request to houdini failed with code #{response.code}: #{body}"
      end

      [response, body]
    end

    private

    def self.validate_config
      #TODO: validate params in Houdini.setup
      raise HostError, "Houdini.app_url should specify http:// or https://" unless Houdini.app_url.match(/^https?\:\/\//)
    end
  end


end
{'fraction_non_alphanumeric': 0.12580456407255705, 'fraction_numerical': 0.004681100058513751, 'mean_word_length': 2.7012987012987013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '3263174', 'n_tokens_mistral': 582, 'n_tokens_neox': 559, 'n_words': 139}