<commit_before>require 'chef/provider/lwrp_base'
require 'chef/provider/chef_node'
require 'openssl'

class Chef::Provider::Machine < Chef::Provider::LWRPBase

  use_inline_resources

  def whyrun_supported?
    true
  end

  action :create do
    node_json = node_provider.new_json
    node_json['normal']['provisioner_options'] = new_resource.provisioner_options
    machine = new_resource.provisioner.acquire_machine(self, node_json)
    begin
      machine.setup_convergence(self, new_resource)
      if new_resource.converge || (new_resource.converge.nil? && new_resource.updated_by_last_action?)
        machine.converge(self)
      end
    ensure
      machine.disconnect
    end
  end

  action :converge do
    node_json = node_provider.new_json
    node_json['normal']['provisioner_options'] = new_resource.provisioner_options
    machine = new_resource.provisioner.connect_to_machine(node_json)
    begin
      machine.converge(self)
    ensure
      machine.disconnect
    end
  end

  action :delete do
    # Grab the node json by asking the provider for it
    node_data = node_provider.current_json

    # Destroy the machine
    new_resource.provisioner.delete_machine(self, node_data)
  end

  attr_reader :node_provider

  def load_current_resource
    @node_provider = Chef::Provider::ChefNode.new(new_resource, nil)
    @node_provider.load_current_resource
  end
end
<commit_msg>Re-converge if converge has not yet succeeded<commit_after>require 'chef/provider/lwrp_base'
require 'chef/provider/chef_node'
require 'openssl'

class Chef::Provider::Machine < Chef::Provider::LWRPBase

  use_inline_resources

  def whyrun_supported?
    true
  end

  action :create do
    node_json = node_provider.new_json
    node_json['normal']['provisioner_options'] = new_resource.provisioner_options
    machine = new_resource.provisioner.acquire_machine(self, node_json)
    begin
      machine.setup_convergence(self, new_resource)
      # If we were asked to converge, or anything changed, or if a converge has never succeeded, converge.
      if new_resource.converge || (new_resource.converge.nil? && new_resource.updated_by_last_action?) ||
         !node['automatic'] || node['automatic'].size == 0
        machine.converge(self)
      end
    ensure
      machine.disconnect
    end
  end

  action :converge do
    node_json = node_provider.new_json
    node_json['normal']['provisioner_options'] = new_resource.provisioner_options
    machine = new_resource.provisioner.connect_to_machine(node_json)
    begin
      machine.converge(self)
    ensure
      machine.disconnect
    end
  end

  action :delete do
    # Grab the node json by asking the provider for it
    node_data = node_provider.current_json

    # Destroy the machine
    new_resource.provisioner.delete_machine(self, node_data)
  end

  attr_reader :node_provider

  def load_current_resource
    @node_provider = Chef::Provider::ChefNode.new(new_resource, nil)
    @node_provider.load_current_resource
  end
end

{'fraction_non_alphanumeric': 0.07869289763254418, 'fraction_numerical': 0.00033344448149383126, 'mean_word_length': 4.008347245409015, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7459287', 'n_tokens_mistral': 962, 'n_tokens_neox': 928, 'n_words': 192}