<commit_before>require 'yao/config'
require 'faraday'
require 'yao/plugins/default_client_generator'

module Yao
  Yao.config.param :endpoints, nil

  module Client
    class ClientSet
      def initialize
        @pool       = {}
        @admin_pool = {}
      end
      attr_reader :pool, :admin_pool

      %w(default compute network image metering volume orchestration identity).each do |type|
        define_method(type) do
          self.pool[type]
        end

        define_method("#{type}_admin") do
          self.admin_pool[type]
        end
      end

      def register_endpoints(endpoints, token: nil)
        endpoints.each_pair do |type, urls|
          # XXX: neutron just have v2.0 API and endpoint may not have version prefix
          if type == "network"
            urls = urls.map {|public_or_admin, url|
              path = URI.parse(url).path
              url = (path == '' || path == '/') ? File.join(url, "v2.0") : url
              [public_or_admin, url]
            }.to_h
          end

          force_public_url = Yao.config.endpoints[type.to_sym][:public] rescue nil
          force_admin_url = Yao.config.endpoints[type.to_sym][:admin] rescue nil<commit_msg>allways add v2.0 because endpoint may has some paths<commit_after>require 'yao/config'
require 'faraday'
require 'yao/plugins/default_client_generator'

module Yao
  Yao.config.param :endpoints, nil

  module Client
    class ClientSet
      def initialize
        @pool       = {}
        @admin_pool = {}
      end
      attr_reader :pool, :admin_pool

      %w(default compute network image metering volume orchestration identity).each do |type|
        define_method(type) do
          self.pool[type]
        end

        define_method("#{type}_admin") do
          self.admin_pool[type]
        end
      end

      def register_endpoints(endpoints, token: nil)
        endpoints.each_pair do |type, urls|
          # XXX: neutron just have v2.0 API and endpoint may not have version prefix
          if type == "network"
            urls = urls.map {|public_or_admin, url|
              url = File.join(url, "v2.0")
              [public_or_admin, url]
            }.to_h
          end

          force_public_url = Yao.config.endpoints[type.to_sym][:public] rescue nil
          force_admin_url = Yao.config.endpoints[type.to_sym][:admin] rescue nil
{'fraction_non_alphanumeric': 0.0939625850340136, 'fraction_numerical': 0.004251700680272109, 'mean_word_length': 2.1970108695652173, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5128710', 'n_tokens_mistral': 718, 'n_tokens_neox': 699, 'n_words': 182}