<commit_before>--
-- Implements the functions to serialize the model and optimizer state, as well
-- as the performance history.
--

require "lfs"
require "torch"

local json = require "lunajson"
local serializer = lantern.make_class("serializer")

function serializer:remove_file_if_exists(fn)
	if not paths.filep(fn) then return end

	local success, err = os.remove(fn)
	if not success then
		self.logger:update(
			"/console/error",
			"Failed removing `" .. old .. "`: " .. err
		)
		os.exit(1)
	end
end

function serializer:rename_file_if_exists(old, new)
	if not paths.filep(old) then return end

	local success, err = os.rename(old, new)
	if not success then
		self.logger:update(
			"/console/error",
			"Failed renaming `" .. old .. "` to `" .. new .. "`: " .. err
		)
		os.exit(1)<commit_msg>Fixed formatting.<commit_after>--
-- Implements the functions to serialize the model and optimizer state,
-- as well as the performance history.
--

require "lfs"
require "torch"

local json = require "lunajson"
local serializer = lantern.make_class("serializer")

function serializer:remove_file_if_exists(fn)
	if not paths.filep(fn) then return end

	local success, err = os.remove(fn)
	if not success then
		self.logger:update(
			"/console/error",
			"Failed removing `" .. old .. "`: " .. err
		)
		os.exit(1)
	end
end

function serializer:rename_file_if_exists(old, new)
	if not paths.filep(old) then return end

	local success, err = os.rename(old, new)
	if not success then
		self.logger:update(
			"/console/error",
			"Failed renaming `" .. old .. "` to `" .. new .. "`: " .. err
		)
		os.exit(1)
{'fraction_non_alphanumeric': 0.13495024875621892, 'fraction_numerical': 0.0024875621890547263, 'mean_word_length': 3.457063711911357, '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': '4122171', 'n_tokens_mistral': 589, 'n_tokens_neox': 548, 'n_words': 160}