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

DataToolkit.@d_strMacro
@d_str -> loaded data

Shorthand for loading a dataset in the default format, d"iris" is equivalent to read(dataset("iris")).

DataToolkit.@data_cmdMacro
@data_cmd -> Data REPL command result

Proxy for running the command in the Data REPL, e.g. data`config set demo 1` is equivalent to data> config set demo 1.

DataToolkitBase

DataToolkitBase.@importMacro
@import pkg1, pkg2...
@import pkg1 as name1, pkg2 as name2...
@import pkg: foo, bar...
@import pkg: foo as bar, bar as baz...

Fetch modules previously registered with @addpkg, and import them into the current namespace. This macro tries to largely mirror the syntax of using.

If a required package had to be loaded for the @import statement, a PkgRequiredRerunNeeded singleton will be returned.

Example

@import pkg
pkg.dothing(...)
# Alternative form
@import pkg: dothing
dothing(...)

Functions

DataToolkitBase

DataToolkitBase.datasetFunction
dataset([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.

DataToolkitBase.loadcollection!Function
loadcollection!(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

DataToolkitBase

Unexported Symbols

Modules

DataToolkitBase and DataToolkitCommon are available as Base and Common respectively.

Macros

DataToolkit

DataToolkit.@addpkgsMacro
@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.@import.

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 dependencies
DataToolkitBase.@addpkgMacro
@addpkg name::Symbol uuid::String

Register the package identified by name with UUID uuid. This package may now be used with @import $name.

All @addpkg statements should lie within a module's __init__ function.

Example

@addpkg CSV "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"

Functions

DataToolkit

DataToolkit.initFunction
init(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.addpkgsFunction
addpkgs(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

DataToolkitBase.getlayerFunction
getlayer(::Nothing)

Return the first DataCollection on the STACK.

getlayer(name::AbstractString)
getlayer(uuid::UUID)

Find the DataCollection in STACK with name/uuid.

Types

DataToolkitBase

DataToolkitBase.IdentifierType

A 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::SmallDict{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").