Utilities
DataToolkitCore.SystemPath
— TypeSystemPath
A string, but one that explicitly refers to a path on the system.
DataToolkitCore.FilePath
— TypeFilePath <: SystemPath
Crude stand in for a file path type, which is strangely absent from Base.
This allows for load/write method dispatch, and the distinguishing of file content (as a String
) from file paths.
See also: DirPath
.
Examples
julia> string(FilePath("some/path"))
"some/path"
DataToolkitCore.DirPath
— TypeDirPath <: SystemPath
Signifies that a given string is in fact a path to a directory.
This allows for load/write method dispatch, and the distinguishing of file content (as a String) from file paths.
See also: FilePath
.
Examples
julia> string(DirPath("some/path"))
"some/path"
DataToolkitCore.@log_do
— Macro@log_do category message [expr]
Return the result of expr
, logging message
with category
if appropriate to do so.
DataToolkitCore.@getparam
— Macro@getparam container."parameter"::Type default=nothing
Get the parameter "parameter"
from container
(a DataCollection
, DataSet
, or DataTransformer
), ensuring that it is of type Type
. If it is not, an InvalidParameterType
error is thrown.
DataToolkitCore.atomic_write
— Functionatomic_write(f::Function, dest::AbstractString; temp::AbstractString = dest * "_XXXX.part")
Atomically write to dest
with f
, via temp
.
Calls the function f
that writes to temp
, with temp
given as an IO
handle or a String
depending on as
. Upon completion, temp
is renamed to dest
.
The file dest
is not touched until the write is complete, and if the write to dest
is interrupted or fails for any reason, no data is written to temp
.
It is impossible to gauntree truly atomic writes on hardware without power loss protection (PLP), even with copy-on-write (CoW) filesystems. This function makes a best effort, calling fdatasync
before renaming a file. In most situations this will be sufficient, but it is not a guarantee.