tecosaur / DataToolkit.jl

Reproducible, flexible, and convenient data management
https://tecosaur.github.io/DataToolkit.jl
90 stars 4 forks source link

Using DataToolkit inside a package #49

Open BatyLeo opened 3 months ago

BatyLeo commented 3 months ago

Hello, I would be interested in using DataToolkit directly inside a package in order to make loading datasets easier.

Following the tutorial, it works when creating an environment from scratch that is not a package, however it doesn't work when adding DataToolkit to a package environment. When restarting the REPL after the init command, it doesn't load automatically the data collection when using DataToolkit. I'm not sure if this is a bug or if I understood something wrong about this package usage?


To reproduce the issue:

(@v1.10) pkg> generate MyPackage
  Generating  project MyPackage:
    MyPackage/Project.toml
    MyPackage/src/MyPackage.jl

(@v1.10) pkg> activate MyPackage
  Activating project at `~/Documents/tuto/MyPackage`

(MyPackage) pkg> add DataToolkit

julia> using DataToolkit

(⋅) data> init
 Create Data.toml for current project? [Y/n]: y
 Name: tutorial
 Use checksums by default? [Y/n]: n
 ✓ Created new data collection 'tutorial' at /home/leo/Documents/tuto/MyPackage/Data.toml

(tutorial) data> 

After restarting the REPL:

(@v1.10) pkg> activate MyPackage
  Activating project at `~/Documents/tuto/MyPackage`

julia> using DataToolkit

(⋅) data> 
tecosaur commented 3 weeks ago

Hi Leo! Sorry for the late reply.

You'll want to call DataToolkit.init(@__MODULE__) inside the __init__ function of the package.

That should make the datasets availible, and you can check with data> stack list.

To make package usage easier in the future, the init function is likely going to be split off into the DataToolkitBase package in the next version BTW :slightly_smiling_face: