Skip to content

Commit

Permalink
Introduce index_files function not restricted to JLSO (#29)
Browse files Browse the repository at this point in the history
* Change `index_checkpoint_files` to not filter to JLSO

* Introduce `index_files` function not restricted to JLSO

* Update test/indexing.jl

* Update test/indexing.jl
  • Loading branch information
nickrobinson251 authored Jul 22, 2021
1 parent 9283756 commit 732fdf4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
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

2 comments on commit 732fdf4

@nickrobinson251
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/41320

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.10 -m "<description of version>" 732fdf4e1d7187fc2ac65e9c4d3e99e23ac01c55
git push origin v0.3.10

Please sign in to comment.