<commit_before>require 'renv'
require 'fog'
require 'renv/data'
require 'renv/connection'

module Renv
  class Engine
    def initialize(connection:, name: nil, data: nil)
      @_name       = name
      @_connection = connection
      @_data       = data || Data.new
      @_loaded     = false
    end

    def get(key)
      _data[key]
    end

    def set(hash)
      hash.each_pair do |key, value|
        _data[key] = value
      end
      _save
    end

    def del(keys)
      keys.each { |key| _data.delete(key) }
      _save
    end

    def dump
      _data.dump
    end

    def load(payload)
      _data.load(payload)
      _save
    end

    private

    def _data
      return @_data if @_loaded
      s3file = @_connection.files.get(_path_current)
      payload = s3file ? s3file.body : ''
      @_loaded = true
      @_data.load(payload)
    end
<commit_msg>Adds comments<commit_after>require 'renv'
require 'fog'
require 'renv/data'
require 'renv/connection'

module Renv
  class Engine
    def initialize(connection:, name: nil, data: nil)
      @_name       = name
      @_connection = connection
      @_data       = data || Data.new
      @_loaded     = false
    end

    def get(key)
      _data[key]
    end

    # Sets one or more key-value pairs
    def set(hash)
      hash.each_pair do |key, value|
        _data[key] = value
      end
      _save
    end

    # Deletes one or more keys-value pairs
    def del(keys)
      keys.each { |key| _data.delete(key) }
      _save
    end

    def dump
      _data.dump
    end

    def load(payload)
      _data.load(payload)
      _save
    end

    private

    def _data
      return @_data if @_loaded
      s3file = @_connection.files.get(_path_current)
      payload = s3file ? s3file.body : ''
      @_loaded = true
      @_data.load(payload)
    end

{'fraction_non_alphanumeric': 0.08961748633879782, 'fraction_numerical': 0.003278688524590164, 'mean_word_length': 1.8971518987341771, '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': '3173150', 'n_tokens_mistral': 627, 'n_tokens_neox': 611, 'n_words': 163}