<commit_before>require 'timeout'

# This class represents a Marathon Deployment information.
# It is returned by asynchronious deployment calls.
class Marathon::DeploymentInfo < Marathon::Base

  RECHECK_INTERVAL = 3

  # Create a new deployment info object.
  # ++hash++: Hash returned by API, including 'deploymentId' and 'version'
  def initialize(hash)
    super(hash, %w[deploymentId version])
    raise Marathon::Error::ArgumentError, 'version must not be nil' unless version
  end

  # Wait for a deployment to finish.
  # ++timeout++: Timeout in seconds.
  def wait(timeout = 60)
    Timeout::timeout(timeout) do
      deployments = nil
      while deployments.nil? or deployments.select{|e| e.id == deploymentId}.size > 0 do
        sleep(RECHECK_INTERVAL) unless deployments.nil?
        deployments = Marathon::Deployment.list
      end
    end
  end

  def to_s
    if deploymentId
      "Marathon::DeploymentInfo { :version => #{version} :deploymentId => #{deploymentId} }"
    else
      "Marathon::DeploymentInfo { :version => #{version} }"
    end
  end

end
<commit_msg>Wait before looking for deployments the first time, as they don't show up immidiately.<commit_after>require 'timeout'

# This class represents a Marathon Deployment information.
# It is returned by asynchronious deployment calls.
class Marathon::DeploymentInfo < Marathon::Base

  RECHECK_INTERVAL = 3

  # Create a new deployment info object.
  # ++hash++: Hash returned by API, including 'deploymentId' and 'version'
  def initialize(hash)
    super(hash, %w[deploymentId version])
    raise Marathon::Error::ArgumentError, 'version must not be nil' unless version
  end

  # Wait for a deployment to finish.
  # ++timeout++: Timeout in seconds.
  def wait(timeout = 60)
    Timeout::timeout(timeout) do
      deployments = nil
      while deployments.nil? or deployments.select{|e| e.id == deploymentId}.size > 0 do
        sleep(RECHECK_INTERVAL)
        deployments = Marathon::Deployment.list
      end
    end
  end

  def to_s
    if deploymentId
      "Marathon::DeploymentInfo { :version => #{version} :deploymentId => #{deploymentId} }"
    else
      "Marathon::DeploymentInfo { :version => #{version} }"
    end
  end

end

{'fraction_non_alphanumeric': 0.09941520467836257, 'fraction_numerical': 0.003598740440845704, 'mean_word_length': 3.6527196652719667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '7296840', 'n_tokens_mistral': 664, 'n_tokens_neox': 630, 'n_words': 211}