-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Document python module * Update changelog * CI update; also test against pre-release
- Loading branch information
Showing
12 changed files
with
103 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Configuration | ||
|
||
This section provides and overview of dso settings and how to apply them. | ||
|
||
## pyproject.toml | ||
|
||
Project-specific dso settings can be set in the `pyproject.toml` file at the root of each project in the | ||
`[tool.dso]` section: | ||
|
||
```toml | ||
[tool.dso] | ||
# whether to compile relative paths declared with `!path` into absolute paths or relative paths (relative to each stage). | ||
# default is `true` | ||
use_relative_path = true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Installation | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# API reference | ||
|
||
```{eval-rst} | ||
.. automodule:: dso | ||
:members: | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Usage | ||
|
||
## Installation | ||
|
||
The DSO Python API is part of the DSO CLI package. See [installation](cli_installation.md) for more details. | ||
|
||
## Typical usage | ||
|
||
The purpose of the Python API is to provide covenient access to stage parameters from Python scripts or notebooks. | ||
Using {func}`~dso.read_params` the `params.yaml` file of the specified stage is compiled and loaded | ||
into a dictionary. The path must be specified relative to the project root -- this ensures that the correct stage is | ||
found irrespective of the current working directory, as long as it the project root or any subdirectory thereof. | ||
Only parameters that are declared as `params`, `dep`, or `output` in dvc.yaml are loaded to | ||
ensure that one does not forget to keep the `dvc.yaml` updated. | ||
|
||
```python | ||
from dso import read_params | ||
|
||
params = read_params("subfolder/my_stage") | ||
``` | ||
|
||
By default, DSO compiles paths in configuration files to paths relative to each stage (see [configuration](cli_configuration.md#pyprojecttoml)). | ||
From Python, you can use {func}`~dso.stage_here` to resolve paths | ||
relative to the current stage independent of your current working directory, e.g. | ||
|
||
```python | ||
import pandas as pd | ||
from dso import stage_here | ||
|
||
pd.read_csv(stage_here(params["samplesheet"])) | ||
``` | ||
|
||
This works, because `read_params` has stored the path of the current stage in a configuration object that persists in | ||
the current Python session. `stage_here` can use this information to resolve relative paths. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from ._metadata import __version__ # noqa | ||
from .api import here, read_params, set_stage, stage_here | ||
from .api import here, read_params, set_stage, stage_here, CONFIG | ||
|
||
__all__ = ["read_params", "here", "stage_here", "set_stage"] | ||
__all__ = ["read_params", "here", "stage_here", "set_stage", "CONFIG"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters