api.jl Documentation

The api.jl file serves as the primary interface for the DSO API. It provides functions for path management, parameter handling, and interaction with the DSO CLI for project lifecycle tasks like stage creation and reproduction.


Path Management

These functions help navigate the project structure and manage the active stage

DataScienceOperations.hereFunction

here(rel_path::Union{Nothing,AbstractString}=nothing)::AbstractString

Get project root as a path string.

Arguments

  • rel_path::Union{Nothing,AbstractString}: Relative path to be appended to the project root

Output

Absolute path to rel_path

Notes

If rel_path is provided, returns joinpath(project_root, rel_path).

Examples

here("path/to/file")
source
DataScienceOperations.stage_hereFunction
stage_here(rel_path::Union{Nothing,AbstractString}=nothing)::AbstractString

Get the absolute path to the current stage.

Arguments

  • rel_path::Union{Nothing,AbstractString}: A relative path

Output

Absolute path to the curent project stage.

Notes

The current stage is stored in CONFIG and can be set calling eitherset_stage or read_params. Throws an error if no stage has been set (use set_stage or read_params first). If rel_path is provided, appends it to the stage root.

Examples

stage_here("path/to/file")
source
DataScienceOperations.set_stageFunction
set_stage(; stage::Union{String,AbstractString})::Nothing

Set the stage_here field in CONFIG.

Arguments

  • stage::Union{String,AbstractString}: Path to stage, relative to the project root

Notes

stage is interpreted as a path relative to the project root. If the referenced stage directory does not exist, an ArgumentError is thrown.

Example

set_stage("path/to/stage")
source

Parameter Handling

Use these functions to load and parse configuration parameters for your DSO project.

DataScienceOperations.read_paramsFunction
read_params(stage_path::Union{AbstractString, Nothing}=nothing, return_dict::Bool=false)::Union{Dict, DsoParams, NULL}

Set stage and load parameters from params.yaml via dso-cli.

Arguments

-stage_path::Union{AbstractString, Nothing}: path to stage -return_dict::Bool: indicates if parameters should be returned as dict or as DsoParams object. -dso_available::Function: Low level function to check if dso is installed. Do not alter. This is for tetsing purposes only. -run_dso::Function: Low level function that passes commands to dso. Do not alter. This is for testing purposes only. -read_yaml::Function: Low level function to read yaml files. Do not alter. This is for testing purposes only.

Output

Dso parameters. Either in dict format or as DsoParams object. The function will return null if DSO cli is not available.

Examples

params_dict = read_params("path/to/params.yaml", true)
params_obj = read_params("path/to/params.yaml", false)
same_params_obj = read_params("path/to/params.yaml")
source

DSO CLI Operations

These functions wrap common DSO CLI commands to manage the project lifecycle, including creating items and reproducing stages

DataScienceOperations.compile_configFunction
compile_config(dir::Union{AbstractString, Nothing})::Bool

This function runs the dso compile-config command and updates the params.yaml with info from other params.in.yaml and params.yaml.

Arguments

  • dir::Union{AbstractString, Nothing}: directory (including subdirectories and relevant parent files) to compile. By default compiles the current working directory.
  • dso_available::Function: Low level function to check if dso is installed. Do not alter. This is for tetsing purposes only.
  • run_dso::Function: Low level function that passes commands to dso. Do not alter. This is for testing purposes only.

Output

true: dso compile-config ran sucessfully false: else

Examples

compile_config()
compile_config("/path/to/dso/item")
source
DataScienceOperations.createFunction
create(item; dir::Union{AbstractString, Nothing}=nothing, name::Union{String, Nothing}=nothing, description::Union{String, Nothing}=nothing, template::Union{String, Nothing}=nothing)::Bool

Create a new project, folder or stage in a given directory.

Arguments

  • item::String: item to create (project, folder, stage)
  • dir::Union{AbstractString, Nothing}: path to directory in which project shall be initialised
  • name::Union{String, Nothing}: project name: e.g. singlecelllung_atlas. Can't be empty
  • description::Union{String, Nothing}: description short project description. Can't be empty
  • template::Union{String, Nothing}: Template for the stage (quartojl, quartopy, quarto_r).
  • dso_available::Function: Low level function to check if dso is installed. Do not alter. This is for tetsing purposes only.
  • run_dso::Function: Low level function that passes commands to dso. Do not alter. This is for testing purposes only.

Output

true: dso create ran sucessfully false: else

Examples

create("project", name = "single_cell_lung_atlas", description = "This project is awesome!")
create("folder", name = "single_cell_lung_atlas", description = "This folder comprises awesome analyses!")
create("project", name = "single_cell_lung_atlas", description = "This stage solves all your problems!")
source
DataScienceOperations.reproFunction
repro(;stage_dir::Union{AbstractString, Nothing}=nothing, single_stage::Bool=false)::Bool

This function reproduces a stage specified by stage_dir. If single_stage is set to TRUE, it reproduces the stage without its dependencies. Otherwise, it reproduces the current stage along with all its dependency stages. By default, the current stage will be reproduced.

Arguments

  • stage_dir::Union{String, Nothing}: The path to a stage. Defaults to the current stage (Nothing).
  • single_stage::Bool: flag indicating whether to reproduce only the current stage (true) or the current stage with all dependencies (false). Defaults to false
  • dso_available::Function: Low level function to check if dso is installed. Do not alter. This is for tetsing purposes only.
  • run_dso::Function: Low level function that passes commands to dso. Do not alter. This is for testing purposes only.

Output

true: dso repro ran sucessfully false: else

Examples

repro()
repro(stage_dir = "/path/to/dso/stage")
repro(stage_dir = "/path/to/dso/stage", single_stage = true)
source

Session information

Get the full information about the current session for reproducibility reasons.


Error Handling & Dependencies

All CLI-dependent functions (read_params, compile_config, create, repro) perform a check via dso_cli_available() before execution. If an external process fails, these functions capture the stderr content and throw a descriptive Julia error.