Skip to content

Commit dd1755f

Browse files
authored
Merge pull request #64 from ScilifelabDataCentre/use-typer-recommended-cli-config-loc
(WIP) SQ-834: Use typer recommended cli config loc
2 parents e74f00d + a2beff0 commit dd1755f

35 files changed

+267
-389
lines changed

docs/cli/_auto_generated/auth.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ $ divbase-cli auth login [OPTIONS] EMAIL
4242

4343
* `--password TEXT`: [required]
4444
* `--divbase-url TEXT`: DivBase server URL to connect to. [default: http://localhost:8000/api]
45-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
4645
* `-f, --force`: Force login again even if already logged in
4746
* `--help`: Show this message and exit.
4847

@@ -72,5 +71,4 @@ $ divbase-cli auth whoami [OPTIONS]
7271

7372
**Options**:
7473

75-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
7674
* `--help`: Show this message and exit.

docs/cli/_auto_generated/config.md

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,13 @@ $ divbase-cli config [OPTIONS] COMMAND [ARGS]...
1616

1717
**Commands**:
1818

19-
* `create`: Create a user configuration file for...
2019
* `add`: Add a new project to your user...
21-
* `remove`: Remove a project from your user...
20+
* `rm`: Remove a project from your user...
2221
* `set-default`: Set your default project to use in all...
2322
* `show-default`: Print the currently set default project to...
2423
* `set-dload-dir`: Set the default download dir
2524
* `show`: Pretty print the contents of your current...
2625

27-
## `divbase-cli config create`
28-
29-
Create a user configuration file for divbase-cli.
30-
31-
**Usage**:
32-
33-
```console
34-
$ divbase-cli config create [OPTIONS]
35-
```
36-
37-
**Options**:
38-
39-
* `-c, --config PATH`: Where to store your config file locally on your pc. [default: /home/roryc/.config/divbase/config.yaml]
40-
* `--help`: Show this message and exit.
41-
4226
## `divbase-cli config add`
4327

4428
Add a new project to your user configuration file.
@@ -57,17 +41,16 @@ $ divbase-cli config add [OPTIONS] NAME
5741

5842
* `-u, --divbase-url TEXT`: DivBase API URL associated with this project. [default: http://localhost:8000/api]
5943
* `-d, --default`: Set this project as the default project in your config file.
60-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
6144
* `--help`: Show this message and exit.
6245

63-
## `divbase-cli config remove`
46+
## `divbase-cli config rm`
6447

6548
Remove a project from your user configuration file.
6649

6750
**Usage**:
6851

6952
```console
70-
$ divbase-cli config remove [OPTIONS] NAME
53+
$ divbase-cli config rm [OPTIONS] NAME
7154
```
7255

7356
**Arguments**:
@@ -76,7 +59,6 @@ $ divbase-cli config remove [OPTIONS] NAME
7659

7760
**Options**:
7861

79-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
8062
* `--help`: Show this message and exit.
8163

8264
## `divbase-cli config set-default`
@@ -95,7 +77,6 @@ $ divbase-cli config set-default [OPTIONS] NAME
9577

9678
**Options**:
9779

98-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
9980
* `--help`: Show this message and exit.
10081

10182
## `divbase-cli config show-default`
@@ -110,7 +91,6 @@ $ divbase-cli config show-default [OPTIONS]
11091

11192
**Options**:
11293

113-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
11494
* `--help`: Show this message and exit.
11595

11696
## `divbase-cli config set-dload-dir`
@@ -132,7 +112,6 @@ $ divbase-cli config set-dload-dir [OPTIONS] DOWNLOAD_DIR
132112

133113
**Options**:
134114

135-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
136115
* `--help`: Show this message and exit.
137116

138117
## `divbase-cli config show`
@@ -147,5 +126,4 @@ $ divbase-cli config show [OPTIONS]
147126

148127
**Options**:
149128

150-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
151129
* `--help`: Show this message and exit.

docs/cli/_auto_generated/dimensions.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ $ divbase-cli dimensions update [OPTIONS]
3232
**Options**:
3333

3434
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
35-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
3635
* `--help`: Show this message and exit.
3736

3837
## `divbase-cli dimensions show`
@@ -51,5 +50,4 @@ $ divbase-cli dimensions show [OPTIONS]
5150
* `--filename TEXT`: If set, will show only the entry for this VCF filename.
5251
* `--unique-scaffolds`: If set, will show all unique scaffold names found across all the VCF files in the project.
5352
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
54-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
5553
* `--help`: Show this message and exit.

docs/cli/_auto_generated/files.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ $ divbase-cli files ls [OPTIONS]
4444
* `-p, --prefix TEXT`: Optional prefix to filter the listed files by name (only list files starting with this prefix).
4545
* `-r, --include-results-files`: If set, will also show DivBase query results files which are hidden by default.
4646
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
47-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
4847
* `--help`: Show this message and exit.
4948

5049
## `divbase-cli files info`
@@ -67,7 +66,6 @@ $ divbase-cli files info [OPTIONS] FILE_NAME
6766

6867
* `--tsv`: If set, will print the output in .TSV format for easier programmatic parsing.
6968
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
70-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
7169
* `--help`: Show this message and exit.
7270

7371
## `divbase-cli files download`
@@ -105,7 +103,6 @@ You can also specify "." to download to the current directory.
105103
* `--disable-verify-checksums`: Turn off checksum verification which is on by default. Checksum verification means all downloaded files are verified against their MD5 checksums.It is recommended to leave checksum verification enabled unless you have a specific reason to disable it.
106104
* `--project-version TEXT`: User defined version of the project's at which to download the files. If not provided, downloads the latest version of all selected files.
107105
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
108-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
109106
* `--help`: Show this message and exit.
110107

111108
## `divbase-cli files stream`
@@ -133,7 +130,6 @@ $ divbase-cli files stream [OPTIONS] FILE_NAME
133130

134131
* `--version-id TEXT`: Specify this if you want to look at an older/specific version of the file. If not provided, the latest version of the file is used. To get a file's version ids, use the 'divbase-cli file info [FILE_NAME]' command.
135132
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
136-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
137133
* `--help`: Show this message and exit.
138134

139135
## `divbase-cli files upload`
@@ -161,7 +157,6 @@ $ divbase-cli files upload [OPTIONS] [FILES]...
161157
* `--file-list PATH`: Text file with list of files to upload.
162158
* `--disable-safe-mode`: Turn off safe mode which is on by default. Safe mode adds 2 extra bits of security by first calculating the MD5 checksum of each file that you're about to upload:(1) Checks if any of the files you're about to upload already exist (by comparing name and checksum) and if so stops the upload process.(2) Sends the file's checksum when the file is uploaded so the server can verify the upload was successful (by calculating and comparing the checksums).It is recommended to leave safe mode enabled unless you have a specific reason to disable it.
163159
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
164-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
165160
* `--help`: Show this message and exit.
166161

167162
## `divbase-cli files rm`
@@ -189,7 +184,6 @@ $ divbase-cli files rm [OPTIONS] [FILES]...
189184
* `--file-list PATH`: Text file with list of files to delete.
190185
* `--dry-run`: If set, will not actually delete the files, just print what would be deleted.
191186
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
192-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
193187
* `--help`: Show this message and exit.
194188

195189
## `divbase-cli files restore`
@@ -216,5 +210,4 @@ $ divbase-cli files restore [OPTIONS] [FILES]...
216210

217211
* `--file-list PATH`: Text file with list of files to restore.
218212
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
219-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
220213
* `--help`: Show this message and exit.

docs/cli/_auto_generated/query.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ $ divbase-cli query tsv [OPTIONS] FILTER
4949
* `--show-sample-results / --no-show-sample-results`: Print sample_ID and Filename results from the query. [default: no-show-sample-results]
5050
* `--metadata-tsv-name TEXT`: Name of the sample metadata TSV file in the project's data store on DivBase. [default: sample_metadata.tsv]
5151
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
52-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
5352
* `--help`: Show this message and exit.
5453

5554
## `divbase-cli query bcftools-pipe`
@@ -81,5 +80,4 @@ will be performed. E.g. 'Area:West of Ireland,Northern Portugal;Sex:F'
8180
* `--command TEXT`: String consisting of the bcftools command to run on the files returned by the tsv query. [required]
8281
* `--metadata-tsv-name TEXT`: Name of the sample metadata TSV file in the project's data store on DivBase. [default: sample_metadata.tsv]
8382
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
84-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
8583
* `--help`: Show this message and exit.

docs/cli/_auto_generated/task-history.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ $ divbase-cli task-history user [OPTIONS]
3232

3333
**Options**:
3434

35-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
3635
* `--limit INTEGER`: Maximum number of tasks to display in the terminal. Sorted by recency. [default: 10]
3736
* `--project TEXT`: Optional project name to filter the user's task history by project.
3837
* `--help`: Show this message and exit.
@@ -53,7 +52,6 @@ $ divbase-cli task-history id [OPTIONS] TASK_ID
5352

5453
**Options**:
5554

56-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
5755
* `--help`: Show this message and exit.
5856

5957
## `divbase-cli task-history project`
@@ -72,6 +70,5 @@ $ divbase-cli task-history project [OPTIONS] PROJECT
7270

7371
**Options**:
7472

75-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
7673
* `--limit INTEGER`: Maximum number of tasks to display in the terminal. Sorted by recency. [default: 10]
7774
* `--help`: Show this message and exit.

docs/cli/_auto_generated/version.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ $ divbase-cli version add [OPTIONS] NAME
3939

4040
* `--description TEXT`: Optional description of the version.
4141
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
42-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
4342
* `--help`: Show this message and exit.
4443

4544
## `divbase-cli version list`
@@ -59,8 +58,8 @@ $ divbase-cli version list [OPTIONS]
5958
**Options**:
6059

6160
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
62-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
6361
* `--include-deleted / --no-include-deleted`: Include soft-deleted versions in the listing. [default: no-include-deleted]
62+
* `--tsv`: If set, will print the output in .TSV format for easier programmatic parsing.
6463
* `--help`: Show this message and exit.
6564

6665
## `divbase-cli version info`
@@ -80,7 +79,6 @@ $ divbase-cli version info [OPTIONS] VERSION
8079
**Options**:
8180

8281
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
83-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
8482
* `--help`: Show this message and exit.
8583

8684
## `divbase-cli version delete`
@@ -102,5 +100,4 @@ $ divbase-cli version delete [OPTIONS] NAME
102100
**Options**:
103101

104102
* `--project TEXT`: Name of the DivBase project, if not provided uses the default in your DivBase config file
105-
* `-c, --config PATH`: Path to your user configuration file. If you didn't specify a custom path when you created it, you don't need to set this. [default: /home/roryc/.config/divbase/config.yaml]
106103
* `--help`: Show this message and exit.

docs/development/celery_task_implementation.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ The DivBase client uses the [Typer](https://typer.tiangolo.com/) library to buil
258258
- There needs to be a Typer app (on the form `query_app = typer.Typer()`) to which the CLI command functions needs to be connected. The app needs to be initiated with `app.add_typer(query_app, name="query")` in `./packages/divbase-cli/src/divbase_cli/divbase_cli.py`.
259259
- The typer app name is used as a decorator for the function, e.g. `@query_app.command("bcftools-pipe")`. The argument of the decorator will become the command for the CLI.
260260
- Pack the task arguments in the Pydantic request model (see Section 2.2), e.g. `request_data=BcftoolsQueryRequest()` for type validation.
261-
- The `resolve_project()` helper function is be used to fetch the data from the users local config and is needed for the established pattern to make the request. This helper function need that the CLI function args contain `project: str | None = PROJECT_NAME_OPTION,` and `config_file: Path = CONFIG_FILE_OPTION,`. See an existing CLI file for more details on the constants they are calling.
261+
- The `resolve_project()` helper function is be used to fetch the data from the users local config and is needed for the established pattern to make the request. This helper function need that the CLI function args contain `project: str | None = PROJECT_NAME_OPTION,`. See an existing CLI file for more details on the constants they are calling.
262262
- The main function call for all DivBase CLI->API interactions is `make_authenticated_request()`. If the user is logged in to the CLI, it sends the user's JSON Web Token as part of the request, which the API uses to validate the user's identity and project role/permissions.
263263
- The arguments `method="POST",divbase_base_url=project_config.divbase_url` should always be included as is.
264264
- `api_route` is the route URL defined in the corresponding endpoint (see Section 2.3).
@@ -281,7 +281,6 @@ def pipe_query(
281281
command: str = BCFTOOLS_ARGUMENT,
282282
metadata_tsv_name: str = METADATA_TSV_ARGUMENT,
283283
project: str | None = PROJECT_NAME_OPTION,
284-
config_file: Path = CONFIG_FILE_OPTION,
285284
) -> None:
286285
"""
287286
Submit a query to run on the DivBase API. A single, merged VCF file will be added to the project's storage bucket on success.

docs/user-guides/quick-start.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,7 @@ pipx install divbase-cli
3737

3838
If you do not have `pipx` installed, you can install it by following [the official instructions from pipx](https://pipx.pypa.io/stable/installation/). Refer to the [Installation Guide](installation.md) for more detailed instructions or other ways to install divbase-cli.
3939

40-
## Step 4: Configure the CLI
41-
42-
Set up your user configuration file:
43-
44-
```bash
45-
divbase-cli config create
46-
```
47-
48-
This creates a configuration file stored on your local device at: `~/.config/divbase/config.yaml`.
40+
## Step 4: Add your project(s) to your divbase-cli config
4941

5042
Add your project(s) to the configuration file:
5143

docs/user-guides/setup_divbase_cli.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,7 @@ This section covers how to configure divbase-cli to know which projects you're a
1010

1111
## 1. Create a user config file and add your project(s)
1212

13-
After installing `divbase-cli`, you can create a user config file as follows:
14-
15-
```bash
16-
divbase-cli config create
17-
```
18-
19-
To view the contents of your user config file, you can run:
20-
21-
```bash
22-
divbase-cli config show
23-
```
24-
25-
To add a project to the config file you can run:
13+
After installing `divbase-cli`, you can add a new project to your user config file by running:
2614

2715
```bash
2816
divbase-cli config add [PROJECT_NAME] # append `--default` to make it the default project
@@ -37,6 +25,12 @@ If you want to change your default project later, you can run the same command w
3725
divbase-cli config set-default [PROJECT_NAME] # This must be a project that is already in your config file
3826
```
3927

28+
To view the contents of your user config file, you can run:
29+
30+
```bash
31+
divbase-cli config show
32+
```
33+
4034
## 2. Logging into DivBase server
4135

4236
With the config setup you can now log into DivBase server via `divbase-cli`. This will keep you logged in for 1 week.

0 commit comments

Comments
 (0)