divbase-cli 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- divbase_cli-0.1.0a1/.gitignore +46 -0
- divbase_cli-0.1.0a1/PKG-INFO +44 -0
- divbase_cli-0.1.0a1/README.md +19 -0
- divbase_cli-0.1.0a1/pyproject.toml +52 -0
- divbase_cli-0.1.0a1/src/divbase_cli/__init__.py +1 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_commands/__init__.py +4 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_commands/auth_cli.py +95 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_commands/dimensions_cli.py +472 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_commands/file_cli.py +632 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_commands/query_cli.py +300 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_commands/shared_args_options.py +23 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_commands/task_history_cli.py +125 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_commands/user_config_cli.py +145 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_commands/version_cli.py +214 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_config.py +71 -0
- divbase_cli-0.1.0a1/src/divbase_cli/cli_exceptions.py +166 -0
- divbase_cli-0.1.0a1/src/divbase_cli/config_resolver.py +86 -0
- divbase_cli-0.1.0a1/src/divbase_cli/display_task_history.py +197 -0
- divbase_cli-0.1.0a1/src/divbase_cli/divbase_cli.py +76 -0
- divbase_cli-0.1.0a1/src/divbase_cli/retries.py +34 -0
- divbase_cli-0.1.0a1/src/divbase_cli/services/__init__.py +0 -0
- divbase_cli-0.1.0a1/src/divbase_cli/services/announcements.py +46 -0
- divbase_cli-0.1.0a1/src/divbase_cli/services/pre_signed_urls.py +460 -0
- divbase_cli-0.1.0a1/src/divbase_cli/services/project_versions.py +103 -0
- divbase_cli-0.1.0a1/src/divbase_cli/services/s3_files.py +444 -0
- divbase_cli-0.1.0a1/src/divbase_cli/user_auth.py +380 -0
- divbase_cli-0.1.0a1/src/divbase_cli/user_config.py +177 -0
- divbase_cli-0.1.0a1/src/divbase_cli/utils.py +28 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# repo secrets
|
|
2
|
+
.env
|
|
3
|
+
.env*
|
|
4
|
+
|
|
5
|
+
# python stuff
|
|
6
|
+
.venv
|
|
7
|
+
.ruff_cache/
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.py[cod]
|
|
10
|
+
*$py.class
|
|
11
|
+
|
|
12
|
+
.vscode/
|
|
13
|
+
|
|
14
|
+
# project specific files
|
|
15
|
+
/sample_metadata.tsv
|
|
16
|
+
/sample_metadata_*.tsv
|
|
17
|
+
*.vcf
|
|
18
|
+
*.vcf.gz
|
|
19
|
+
*.vcf.gz.csi
|
|
20
|
+
*.vcf.gz.tbi
|
|
21
|
+
!tests/fixtures/*.vcf.gz
|
|
22
|
+
tests/fixtures/temp*
|
|
23
|
+
tests/fixtures/merged*
|
|
24
|
+
divbase_metadata_template*.tsv
|
|
25
|
+
|
|
26
|
+
# query job config files
|
|
27
|
+
bcftools_divbase_job_config.json
|
|
28
|
+
|
|
29
|
+
# benchmarking files
|
|
30
|
+
vcf_dimensions.tsv
|
|
31
|
+
mock*.tsv
|
|
32
|
+
task_records*.json
|
|
33
|
+
split_scaffold_files.txt
|
|
34
|
+
scripts/benchmarking/*.yaml
|
|
35
|
+
scripts/benchmarking/results
|
|
36
|
+
|
|
37
|
+
#MacOS artifacts
|
|
38
|
+
.DS_Store
|
|
39
|
+
|
|
40
|
+
# mkdocs build cache
|
|
41
|
+
.cache/
|
|
42
|
+
# mkdocs auto generated files
|
|
43
|
+
docs/cli/_auto_generated/*.md
|
|
44
|
+
|
|
45
|
+
# pypi
|
|
46
|
+
dist/
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: divbase-cli
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Command Line Interface for Divbase
|
|
5
|
+
Project-URL: Homepage, https://divbase.scilifelab-2-prod.sys.kth.se
|
|
6
|
+
Project-URL: Documentation, https://scilifelabdatacentre.github.io/divbase
|
|
7
|
+
Project-URL: Repository, https://github.com/ScilifelabDataCentre/divbase
|
|
8
|
+
Project-URL: Issues, https://github.com/ScilifelabDataCentre/divbase/issues
|
|
9
|
+
Author-email: SciLifeLab Data Centre <datacentre@scilifelab.se>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Requires-Dist: divbase-lib==0.1.0a1
|
|
22
|
+
Requires-Dist: keyring>=25.7.0
|
|
23
|
+
Requires-Dist: typer==0.24.1
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# divbase-cli
|
|
27
|
+
|
|
28
|
+
Command Line Interface for Divbase.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pipx install divbase-cli
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
divbase --help # can also run divbase-cli --help
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Development
|
|
43
|
+
|
|
44
|
+
This package is developed in the [DivBase repository](https://github.com/ScilifelabDataCentre/divbase) by Scilifelab Data Centre.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# divbase-cli
|
|
2
|
+
|
|
3
|
+
Command Line Interface for Divbase.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pipx install divbase-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
divbase --help # can also run divbase-cli --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Development
|
|
18
|
+
|
|
19
|
+
This package is developed in the [DivBase repository](https://github.com/ScilifelabDataCentre/divbase) by Scilifelab Data Centre.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "divbase-cli"
|
|
3
|
+
description = "Command Line Interface for Divbase"
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
license = "MIT"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "SciLifeLab Data Centre", email = "datacentre@scilifelab.se" },
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.12"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"typer==0.24.1",
|
|
12
|
+
"keyring>=25.7.0",
|
|
13
|
+
"divbase-lib==0.1.0a1",
|
|
14
|
+
]
|
|
15
|
+
dynamic = ["version"]
|
|
16
|
+
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://divbase.scilifelab-2-prod.sys.kth.se"
|
|
31
|
+
Documentation = "https://scilifelabdatacentre.github.io/divbase"
|
|
32
|
+
Repository = "https://github.com/ScilifelabDataCentre/divbase"
|
|
33
|
+
Issues = "https://github.com/ScilifelabDataCentre/divbase/issues"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
divbase-cli = "divbase_cli.divbase_cli:main"
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = ["hatchling >= 1.26"]
|
|
40
|
+
build-backend = "hatchling.build"
|
|
41
|
+
|
|
42
|
+
[tool.hatch.version]
|
|
43
|
+
path = "src/divbase_cli/__init__.py"
|
|
44
|
+
|
|
45
|
+
[tool.uv.sources]
|
|
46
|
+
divbase-lib = { workspace = true }
|
|
47
|
+
|
|
48
|
+
[tool.ruff]
|
|
49
|
+
extend = "../../ruff.toml"
|
|
50
|
+
|
|
51
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
|
52
|
+
"divbase_api" = { msg = "divbase-cli cannot use code from divbase-api. Move shared code to divbase-lib." }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0a1"
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CLI subcommand for managing user auth with DivBase server.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
from pydantic import SecretStr
|
|
10
|
+
from rich import print
|
|
11
|
+
|
|
12
|
+
from divbase_cli.cli_config import cli_settings
|
|
13
|
+
from divbase_cli.cli_exceptions import DivBaseAPIConnectionError, DivBaseAPIError
|
|
14
|
+
from divbase_cli.config_resolver import resolve_url_for_non_project_specific_commands
|
|
15
|
+
from divbase_cli.services.announcements import get_and_display_announcements
|
|
16
|
+
from divbase_cli.user_auth import (
|
|
17
|
+
check_existing_session,
|
|
18
|
+
login_to_divbase,
|
|
19
|
+
logout_of_divbase,
|
|
20
|
+
make_authenticated_request,
|
|
21
|
+
)
|
|
22
|
+
from divbase_cli.user_config import load_user_config
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
divbase_home_url = cli_settings.DIVBASE_API_URL.replace("/api", "")
|
|
27
|
+
|
|
28
|
+
auth_app = typer.Typer(
|
|
29
|
+
no_args_is_help=True,
|
|
30
|
+
help=f"Login/logout of DivBase server. To register, visit {divbase_home_url}.",
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@auth_app.command("login")
|
|
35
|
+
def login(
|
|
36
|
+
email: str,
|
|
37
|
+
divbase_url: str = typer.Option(cli_settings.DIVBASE_API_URL, help="DivBase server URL to connect to."),
|
|
38
|
+
force: bool = typer.Option(False, "--force", "-f", help="Force login again even if already logged in"),
|
|
39
|
+
):
|
|
40
|
+
"""
|
|
41
|
+
Log in to the DivBase server.
|
|
42
|
+
|
|
43
|
+
You'll be prompted for your password after running the command.
|
|
44
|
+
"""
|
|
45
|
+
password: str = typer.prompt("please enter your password", hide_input=True, confirmation_prompt=False)
|
|
46
|
+
secret_password = SecretStr(password)
|
|
47
|
+
del password # avoid user passwords showing up in error messages etc...
|
|
48
|
+
|
|
49
|
+
config = load_user_config()
|
|
50
|
+
|
|
51
|
+
if not force:
|
|
52
|
+
session_expires_at = check_existing_session(divbase_url=divbase_url, config=config)
|
|
53
|
+
if session_expires_at:
|
|
54
|
+
print(f"Already logged in to {divbase_url} with email: {config.logged_in_email}.")
|
|
55
|
+
print(f"Session expires: {datetime.fromtimestamp(session_expires_at)}")
|
|
56
|
+
|
|
57
|
+
if not typer.confirm("Do you want to login again? This will replace your current session."):
|
|
58
|
+
print("Login cancelled.")
|
|
59
|
+
return
|
|
60
|
+
|
|
61
|
+
login_to_divbase(email=email, password=secret_password, divbase_url=divbase_url)
|
|
62
|
+
|
|
63
|
+
try:
|
|
64
|
+
get_and_display_announcements(divbase_base_url=divbase_url)
|
|
65
|
+
except (DivBaseAPIError, DivBaseAPIConnectionError):
|
|
66
|
+
# lets not fail the login process if announcements are not working.
|
|
67
|
+
logger.info("Failed to get announcements after login. Error was: ", exc_info=True)
|
|
68
|
+
|
|
69
|
+
print(f"Logged in successfully as: {email}")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@auth_app.command("logout")
|
|
73
|
+
def logout():
|
|
74
|
+
"""
|
|
75
|
+
Log out of the DivBase server.
|
|
76
|
+
"""
|
|
77
|
+
logout_of_divbase()
|
|
78
|
+
print("Logged out successfully.")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@auth_app.command("whoami")
|
|
82
|
+
def whoami():
|
|
83
|
+
"""
|
|
84
|
+
Return information about the currently logged-in user.
|
|
85
|
+
"""
|
|
86
|
+
divbase_url = resolve_url_for_non_project_specific_commands()
|
|
87
|
+
|
|
88
|
+
request = make_authenticated_request(
|
|
89
|
+
method="GET",
|
|
90
|
+
divbase_base_url=divbase_url,
|
|
91
|
+
api_route="v1/auth/whoami",
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
current_user = request.json()
|
|
95
|
+
print(f"Currently logged in as: {current_user['email']} (Name: {current_user['name']})")
|