Skip to content

Commit

Permalink
📝 write-the mkdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wytamma committed Mar 21, 2024
1 parent 287cf35 commit 0f6cceb
Show file tree
Hide file tree
Showing 16 changed files with 273 additions and 3 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

name: mkdocs
on:
push:
branches:
- master
- main
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: actions/cache@v2
with:
key: ${{ github.ref }}
path: .cache
- run: pip install "mkdocstrings==0.22.0" "mkdocstrings-python==1.3.*" "mkdocs-material"
- run: mkdocs gh-deploy --force
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# snk-cli

The dynamic CLI from [snk](https://snk.wytamma.com/).
109 changes: 109 additions & 0 deletions docs/env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
title: Environments
---

# The CLI env command

The `env` subcommand in the `workflow` tool allows you to access and manage the conda environments used within the workflow. This guide provides an overview of the available options and commands for working with workflow environments.

## Options

- `--help`, `-h`: Show the help message and exit.

## Commands

The `env` subcommand provides several commands to manage the workflows conda environments.

### `list`

List the environments in the workflow.

```bash
workflow env list [OPTIONS]
```

### `activate`

Activate a workflow conda environment.

```bash
workflow env activate [OPTIONS] ENV_NAME
```

- `ENV_NAME`: Name of the environment to activate.

This command activates the specified conda environment within the workflow.

### `create`

This command creates all the conda environments specified in the `envs` dir.

A Snakemake workflow that uses a lot of conda envs can take a long time to install as each env is created sequentially. Running `workflow env create` will create all the conda envs in parallel (up to `--workers` at a time, defaults to number of cores).

```bash
workflow env create [OPTIONS] [NAME]
```

Individual conda envs can be create with `workflow env create ENV_NAME`.


### `remove`

Delete all conda environments.

```bash
workflow env remove [OPTIONS]
```

This command deletes all the conda environments in the workflow.

### `run`

The `env run` command in the `workflow` tool allows you to run a command within one of the workflow environments.

#### Arguments

- `cmd`: The command to run in the environment. This argument is required.

#### Options

- `--env`, `-e`: The name of the environment in which to run the command.
- `--help`, `-h`: Show the help message and exit.

#### Usage

To run a command in one of the workflow environments, use the following command format:

```bash
workflow env run --env ENV_NAME CMD...
```

- `CMD...`: The command and its arguments to execute within the specified environment.

Make sure to replace `ENV_NAME` with the actual name of the desired environment, and `CMD...` with the command you want to run.

#### Example

Here's an example command that demonstrates the usage of `workflow env run`:

```bash
workflow env run -e my_environment "python script.py --input input_file.txt --output output_file.txt"
```

This command runs the `python script.py --input input_file.txt --output output_file.txt` command within the `my_environment` environment in the workflow. Adjust the command and environment name according to your specific use case.


- `ENV_NAME`: Name of the environment in which to run the command.
- `COMMAND [ARGS]...`: The command and its arguments to execute within the specified environment.

This command runs the provided command within the specified conda environment in the workflow.

### `show`

Show the environments config file contents.

```bash
workflow env show [OPTIONS]
```

This command displays the contents of the environments configuration file used in the workflow.
19 changes: 19 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Home
---
# snk-cli

The dynamic CLI from [snk](https://snk.wytamma.com/).

# The Dynamically Generated Snk CLI

The primary feature of Snk is dynamic CLI generation. Many aspects of this CLI can be configure though the [Snk config file](/snk_config_file/).

The CLI provides several commands for interacting with the workflow including

- config - Access the workflow configuration.
- [env](/CLI/env/) - Access the workflow conda environments.
- [script](/CLI/script/) - Access the workflow scripts.
- info - Display information about the workflow.
- profile - Access the workflow profiles.
- run - Run the Snakemake workflow.
2 changes: 2 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
::: src.snk_cli.cli

4 changes: 4 additions & 0 deletions docs/reference/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
::: src.snk_cli.config.config

::: src.snk_cli.config.utils

2 changes: 2 additions & 0 deletions docs/reference/dynamic_typer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
::: src.snk_cli.dynamic_typer

4 changes: 4 additions & 0 deletions docs/reference/options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
::: src.snk_cli.options.option

::: src.snk_cli.options.utils

12 changes: 12 additions & 0 deletions docs/reference/subcommands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::: src.snk_cli.subcommands.run

::: src.snk_cli.subcommands.config

::: src.snk_cli.subcommands.env

::: src.snk_cli.subcommands.profile

::: src.snk_cli.subcommands.utils

::: src.snk_cli.subcommands.script

2 changes: 2 additions & 0 deletions docs/reference/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
::: src.snk_cli.testing

2 changes: 2 additions & 0 deletions docs/reference/utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
::: src.snk_cli.utils

2 changes: 2 additions & 0 deletions docs/reference/validate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
::: src.snk_cli.validate

2 changes: 2 additions & 0 deletions docs/reference/workflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
::: src.snk_cli.workflow

41 changes: 41 additions & 0 deletions docs/script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Scripts
---

# Script Commands

The `script` commands allow you to interact with the workflow scripts. Scripts must be located in the `scripts` directory of the workflow.

## List

The list command will list all scripts in the workflow.

```bash
snk script list
```

## Show

The show command will display the contents of a script.

```bash
snk script show hello.py
```

## Run

The run command will run a script.

```bash
snk script run hello.py
```

!!! note
The executor used to run the script is determined by the suffix of the script file. For example, a script named `hello.py` will be run using the `python` executor.

Use the `--env` option to specify the environment to run the script in.

```bash
snk script run --env python hello.py
```

44 changes: 44 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

site_name: snk_cli
# repo_url: https://github.com/wytamma/write-the

theme:
name: "material"
# homepage: https://write-the.wytamma.com
# logo: assets/logo.png
# favicon: images/favicon.png
palette:
- scheme: default
toggle:
icon: material/brightness-7
name: Switch to dark mode
- scheme: slate
toggle:
icon: material/brightness-4
name: Switch to light mode
features:
- toc.follow
- content.action.edit

extra:
social:
- icon: fontawesome/solid/robot
link: https://github.com/Wytamma/write-the
name: Generated with write-the

plugins:
- search
- mkdocstrings:
handlers:
python:
options:
docstring_style: "google"

markdown_extensions:
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
6 changes: 3 additions & 3 deletions src/snk_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ def __init__(self, workflow_dir_path: Path = None, *, pipeline_dir_path: Path =
)
else:
self.snk_config = snk_config
if self.snk_config.version:
self.version = self.snk_config.version
else:
if self.workflow.version:
self.version = self.workflow.version
else:
self.version = self.snk_config.version
self.options = build_dynamic_cli_options(self.snakemake_config, self.snk_config)
self.snakefile = self._find_snakefile()
self.conda_prefix_dir = self.workflow.conda_prefix_dir
Expand Down

0 comments on commit 0f6cceb

Please sign in to comment.