<commit_before>module PubSub
  class Subscriber
    def self.subscribe
      new.subscribe
    end

    def subscribe
      # Ensure our own topic has been created
      subscribe_to_service(PubSub.service_identifier)
      PubSub.config.subscriptions.keys.each do |service_identifier|
        subscribe_to_service(service_identifier)
      end
    end

    def subscribe_to_service(service_identifier)
      PubSub.logger.info("Subscribing to #{service_identifier}")
      sns.create_topic(name: service_identifier)
    end

    private

    def sns
      @sns ||= Aws::SNS::Client.new
    end
  end<commit_msg>fix pub_sub:subscribe to work<commit_after>module PubSub
  class Subscriber
    def self.subscribe
      new.subscribe
    end

    def subscribe
      # Ensure our own topic has been created
      PubSub.config.subscriptions.keys.each do |service_identifier|
        subscribe_to_service(service_identifier)
      end
    end

    def subscribe_to_service(service_identifier)
      topic = Aws::SNS::Topic.new(sns.create_topic(name: service_identifier).topic_arn)
      queue_data = Aws::SQS::Client.new.get_queue_attributes(queue_url: Queue.new.queue_url, attribute_names: ["QueueArn"])
      queue_arn = queue_data.attributes["QueueArn"]
      topic.subscribe(endpoint: queue_arn, protocol: 'sqs')
      PubSub.logger.info "Subscribed #{queue_arn} to #{topic.arn}"
    end

    private

    def sns
      @sns ||= Aws::SNS::Client.new
    end
  end
{'fraction_non_alphanumeric': 0.08407382091592618, 'fraction_numerical': 0.0, 'mean_word_length': 3.280701754385965, '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': '325603', 'n_tokens_mistral': 457, 'n_tokens_neox': 441, 'n_words': 93}