Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce index_files function not restricted to JLSO #29

Merged
merged 4 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Checkpoints"
uuid = "b4a3413d-e481-5afc-88ff-bdfbd6a50dce"
authors = "Invenia Technical Computing Corporation"
version = "0.3.9"
version = "0.3.10"

[deps]
AWSS3 = "1c724243-ef5b-51ab-93f4-b0a88ac62a95"
Expand Down
2 changes: 1 addition & 1 deletion src/Checkpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using OrderedCollections
export checkpoint, with_checkpoint_tags # creating stuff
export enabled_checkpoints
# indexing stuff
export IndexEntry, index_checkpoint_files
export IndexEntry, index_checkpoint_files, index_files
export checkpoint_name, checkpoint_path, prefixes, tags

const LOGGER = getlogger(@__MODULE__)
Expand Down
14 changes: 14 additions & 0 deletions src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,17 @@ function index_checkpoint_files(dir::AbstractPath)
end

index_checkpoint_files(dir) = index_checkpoint_files(Path(dir))

"""
index_files(dir)

Constructs a index for all the files located within `dir`.
Same as [`index_checkpoint_files`] except not restricted to files created by Checkpoints.jl.
"""
function index_files(dir::AbstractPath)
map(Iterators.filter(isfile, walkpath(dir))) do path
return IndexEntry(path)
end
end

index_files(dir) = index_files(Path(dir))
13 changes: 13 additions & 0 deletions test/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
end
end

@testset "files not saved by Checkpoints.jl" begin
mktempdir(SystemPath) do path
Checkpoints.config("TestPkg.bar", path)
TestPkg.bar([1,2,3])
other_file = joinpath(path, "date=2021-01-01", "other_file.txt")
mkpath(dirname(other_file))
write(other_file, 1)
index = index_files(path)
@test length(index) == 2
@test other_file == only(checkpoint_path(entry) for entry in index if entry.date == "2021-01-01")
end
end

@testset "clashing tags" begin
mktempdir() do path
Checkpoints.config("TestPkg.bar", path)
Expand Down