Reference
This is the public API for DataToolkit. Some symbols have been exported for convenience, others need to be specifically imported or accessed with DataToolkit.<thing>.
Exported Symbols
Macros
DataToolkit.@d_str — Macro@d_str -> loaded dataShorthand for loading a dataset in the default format, d"iris" is equivalent to read(dataset("iris")).
DataToolkit.@data_cmd — Macro@data_cmd -> Data REPL command resultProxy for running the command in the Data REPL, e.g. data`config set demo 1` is equivalent to data> config set demo 1.
DataToolkit.@require — Macro@require Package
@require Package = "UUID"Functions
DataToolkit.dataset — Functiondataset([collection::DataCollection], identstr::AbstractString, [parameters::Dict{String, Any}])
dataset([collection::DataCollection], identstr::AbstractString, [parameters::Pair{String, Any}...])Return the data set identified by identstr, optionally specifying the collection the data set should be found in and any parameters that apply.
DataToolkitCore.loadcollection! — Functionloadcollection!(source::Union{<:AbstractString, <:IO}, mod::Module=Base.Main;
soft::Bool=false, index::Int=1)Load a data collection from source and add it to the data stack at index. source must be accepted by read(source, DataCollection).
mod should be set to the Module within which loadcollection! is being invoked. This is important when code is run by the collection. As such, it is usually appropriate to call:
loadcollection!(source, @__MODULE__; soft)When soft is set, should an data collection already exist with the same UUID, nothing will be done and nothing will be returned.
Types
Unexported Symbols
Modules
DataToolkitBase and DataToolkitCommon are available as Base and Common respectively.
Macros
DataToolkit
DataToolkit.@addpkgs — Macro@addpkgs pkgs...For each named package, register it with DataToolkitBase. Each package must be a dependency of the current module, recorded in its Project.toml.
This allows the packages to be used with DataToolkitBase.@require.
Instead of providing a list of packages, the symbol * can be provided to register all dependencies.
This must be run at runtime to take effect, so be sure to place it in the __init__ function of a package.
Examples
@addpkgs JSON3 CSV
@addpkgs * # Register all dependenciesDataToolkit.@addpkg — Macro@addpkg name::Symbol uuid::StringRegister the package identified by name with UUID uuid. This package may now be used with @require $name.
All @addpkg statements should lie within a module's __init__ function.
Example
@addpkg CSV "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"Functions
DataToolkit
DataToolkit.init — Functioninit(mod::Module=Main; force::Bool=false)Load the mod-local Data.toml if it exists. When mod is Main, every Data.toml on the load path is loaded, except for Data.tomls within packages' projects. Unless force is set, the data collection is soft-loaded.
A Data.d directory can be used in place of a Data.toml, in which case every toml file within it will be read. Mixing Data.d/*.toml and Data.toml is discouraged.
DataToolkit.plugins — Functionplugins()List the currently availible plugins, by name.
DataToolkit.addpkgs — Functionaddpkgs(mod::Module, pkgs::Vector{Symbol})For each package in pkgs, which are dependencies recorded in mod's Project.toml, register the package with DataToolkitBase.addpkg.
If pkgs consists of the single symbol :*, then all dependencies of mod will be registered.
This must be run at runtime to take effect, so be sure to place it in the __init__ function of a package.
DataToolkitBase
DataToolkitCore.getlayer — Functiongetlayer(::Nothing)Return the first DataCollection on the STACK.
getlayer(name::AbstractString)
getlayer(uuid::UUID)Find the DataCollection in STACK with name/uuid.
Types
DataToolkitCore.Identifier — TypeA description that can be used to uniquely identify a DataSet.
Four fields are used to describe the target DataSet:
collection, the name or UUID of the collection (optional).dataset, the name or UUID of the dataset.type, the type that should be loaded from the dataset.parameters, any extra parameters of the dataset that should match.
Constructors
Identifier(collection::Union{AbstractString, UUID, Nothing},
dataset::Union{AbstractString, UUID},
type::Union{QualifiedType, Nothing},
parameters::Dict{String, Any})Parsing
An Identifier can be represented as a string with the following form, with the optional components enclosed by square brackets:
[COLLECTION:]DATASET[::TYPE]Such forms can be parsed to an Identifier by simply calling the parse function, i.e. parse(Identifier, "mycollection:dataset").
Identifier(dataset::DataSet, collection::Union{Symbol, Nothing}=:name,
name::Symbol=something(collection, :name))Create an Identifier referring to dataset, specifying the collection dataset comes from as well (when collection is not nothing) as all of its parameters, but without any type information.
Should collection and name default to the symbol :name, which signals that the collection and dataset reference of the generated Identifier should use the names of the collection/dataset. If set to :uuid, the UUID is used instead. No other value symbols are supported.