<commit_before>require 'simple_deploy/stack/deployment'
require 'simple_deploy/stack/execute'
require 'simple_deploy/stack/output_mapper'
require 'simple_deploy/stack/stack_attribute_formatter'
require 'simple_deploy/stack/stack_creator'
require 'simple_deploy/stack/stack_destroyer'
require 'simple_deploy/stack/stack_formatter'
require 'simple_deploy/stack/stack_lister'
require 'simple_deploy/stack/stack_reader'
require 'simple_deploy/stack/stack_updater'
require 'simple_deploy/stack/status'

module SimpleDeploy
  class Stack

    def initialize(args)
      @environment = args[:environment]
      @name = args[:name]

      @config = SimpleDeploy.config
      @logger = SimpleDeploy.logger

      @use_internal_ips = !!args[:internal]
      @entry = Entry.new :name => @name
    end

    def create(args)
      attributes = stack_attribute_formatter.updated_attributes args[:attributes]
      @template_file = args[:template]

      @entry.set_attributes attributes
      stack_creator.create

      @entry.save
    end

    def update(args)
      if !deployment.clear_for_deployment? && args[:force]
        deployment.clear_deployment_lock true

        Backoff.exp_periods do |p|
          sleep p
          break if deployment.clear_for_deployment?
        end
      end

      if deployment.clear_for_deployment?
        @logger.info "Updating #{@name}."
        attributes = stack_attribute_formatter.updated_attributes args[:attributes]
        @template_body = args[:template_body] || template

        @entry.set_attributes attributes
        stack_updater.update_stack_if_changes attributes, @template_body
        @logger.info "Update complete for #{@name}."

        @entry.save
        true
      else
        @logger.info "Not clear to update."
        false
      end
    end

    def in_progress_update(args)
      if args[:caller].kind_of? Stack::Deployment::Status
        @logger.info "Updating #{@name}."
        attributes = stack_attribute_formatter.updated_attributes args[:attributes]
        @template_body = args[:template_body] || template

        @entry.set_attributes attributes
        stack_updater.update_stack_if_changes attributes, @template_body
        @logger.info "Update complete for #{@name}."

        @entry.save
        true
      else
        false
      end
    end

    def deploy(force = false)
      deployment.execute force
    end<commit_msg>changed in_progress_update to use the last set template body<commit_after>require 'simple_deploy/stack/deployment'
require 'simple_deploy/stack/execute'
require 'simple_deploy/stack/output_mapper'
require 'simple_deploy/stack/stack_attribute_formatter'
require 'simple_deploy/stack/stack_creator'
require 'simple_deploy/stack/stack_destroyer'
require 'simple_deploy/stack/stack_formatter'
require 'simple_deploy/stack/stack_lister'
require 'simple_deploy/stack/stack_reader'
require 'simple_deploy/stack/stack_updater'
require 'simple_deploy/stack/status'

module SimpleDeploy
  class Stack

    def initialize(args)
      @environment = args[:environment]
      @name = args[:name]

      @config = SimpleDeploy.config
      @logger = SimpleDeploy.logger

      @use_internal_ips = !!args[:internal]
      @entry = Entry.new :name => @name
    end

    def create(args)
      attributes = stack_attribute_formatter.updated_attributes args[:attributes]
      @template_file = args[:template]

      @entry.set_attributes attributes
      stack_creator.create

      @entry.save
    end

    def update(args)
      if !deployment.clear_for_deployment? && args[:force]
        deployment.clear_deployment_lock true

        Backoff.exp_periods do |p|
          sleep p
          break if deployment.clear_for_deployment?
        end
      end

      if deployment.clear_for_deployment?
        @logger.info "Updating #{@name}."
        attributes = stack_attribute_formatter.updated_attributes args[:attributes]
        @template_body = args[:template_body] || template

        @entry.set_attributes attributes
        stack_updater.update_stack_if_changes attributes, @template_body
        @logger.info "Update complete for #{@name}."

        @entry.save
        true
      else
        @logger.info "Not clear to update."
        false
      end
    end

    def in_progress_update(args)
      if args[:caller].kind_of? Stack::Deployment::Status
        @logger.info "Updating #{@name}."
        attributes = stack_attribute_formatter.updated_attributes args[:attributes]

        @entry.set_attributes attributes
        stack_updater.update_stack_if_changes attributes, @template_body
        @logger.info "Update complete for #{@name}."

        @entry.save
        true
      else
        false
      end
    end

    def deploy(force = false)
      deployment.execute force
    end
{'fraction_non_alphanumeric': 0.08540405095009397, 'fraction_numerical': 0.0, 'mean_word_length': 3.1151202749140894, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4196820', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1335, 'n_words': 284}