Skip to content

Commit f38eaaa

Browse files
authored
Feature/258 implemented initial cli UI (#259)
* #258: Added initial SCS CLI * Added exasol.ai.text to pylint ignored modules Module exasol.ai.text is compiled via Cython, released as binary. So probably pylint cannot verify types there.
1 parent bcd0ce3 commit f38eaaa

File tree

15 files changed

+523
-1
lines changed

15 files changed

+523
-1
lines changed

doc/changes/unreleased.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
This release marks most of the NC's dependencies in file `pyproject.toml` as _optional_. Please see updated installation instructions in the NC User Guide.
66

7+
## Features
8+
9+
* #258: Added initial SCS CLI
10+
711
## Refactorings
812

913
* #253: Made dependencies optional in file `pyproject.toml`
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sys
2+
from pathlib import Path
3+
4+
import click
5+
6+
from exasol.nb_connector.cli.groups import cli
7+
from exasol.nb_connector.cli.options import SCS_OPTIONS
8+
from exasol.nb_connector.cli.param_wrappers import add_params
9+
10+
11+
@cli.command()
12+
@add_params(SCS_OPTIONS)
13+
@click.option(
14+
"--connect/--no-connect",
15+
is_flag=True,
16+
help="""Verify if connecting to the configured Exasol database instance
17+
succeeds.""",
18+
)
19+
def check(scs_file: Path, connect: bool):
20+
"""
21+
Check the configuration currently saved to the Secure Configuration
22+
Storage and verify if it contains all required parameters.
23+
24+
Optionally also verify if a connection to the configured Exasol database
25+
instance is successful.
26+
"""
27+
pass
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from pathlib import Path
2+
3+
from exasol.nb_connector.cli.groups import cli
4+
from exasol.nb_connector.cli.options import (
5+
DOCKER_DB_OPTIONS,
6+
ONPREM_OPTIONS,
7+
SAAS_OPTIONS,
8+
)
9+
from exasol.nb_connector.cli.param_wrappers import add_params
10+
11+
12+
@cli.group()
13+
def configure():
14+
"""
15+
Add configuration options to the Secure Configuration Storage.
16+
"""
17+
pass
18+
19+
20+
@configure.command("onprem")
21+
@add_params(ONPREM_OPTIONS)
22+
def configure_onprem(scs_file: Path, **kwargs):
23+
"""
24+
Configure connection to an Exasol on-premise instance.
25+
"""
26+
pass
27+
28+
29+
@configure.command("saas")
30+
@add_params(SAAS_OPTIONS)
31+
def configure_saas(scs_file: Path, **kwargs):
32+
"""
33+
Configure connection to an Exasol SaaS instance.
34+
35+
Configuring one of the parameters --saas-database-id and
36+
--saas-database-name is sufficient.
37+
"""
38+
pass
39+
40+
41+
@configure.command("docker-db")
42+
@add_params(DOCKER_DB_OPTIONS)
43+
def configure_docker_db(scs_file: Path, **kwargs):
44+
"""
45+
Configure connection to an Exasol Docker instance.
46+
"""
47+
pass
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pathlib import Path
2+
3+
from exasol.nb_connector.cli.groups import cli
4+
from exasol.nb_connector.cli.options import SCS_OPTIONS
5+
from exasol.nb_connector.cli.param_wrappers import add_params
6+
7+
8+
@cli.command()
9+
@add_params(SCS_OPTIONS)
10+
def show(scs_file: Path):
11+
"""
12+
Show the configuration currently saved to the Secure Configuration
13+
Storage.
14+
"""
15+
pass

exasol/nb_connector/cli/groups.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import click
2+
3+
4+
@click.group()
5+
def cli():
6+
"""
7+
Manage application configuration data in the Secure Configuration
8+
Storage (SCS).
9+
10+
You can set environment variables SCS_FILE and SCS_MASTER_PASSWORD
11+
specifying the file containing the SCS and the master password for
12+
accessing and encrypting the file, respectively.
13+
14+
Otherwise the scs commands will require the SCS file to be passed as
15+
positional argument and the master password to be typed interactively.
16+
"""
17+
pass

exasol/nb_connector/cli/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import exasol.nb_connector.cli.commands.check
2+
import exasol.nb_connector.cli.commands.configure
3+
import exasol.nb_connector.cli.commands.show
4+
from exasol.nb_connector.cli.groups import cli
5+
6+
7+
def main():
8+
cli()
9+
10+
11+
if __name__ == "__main__":
12+
main()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from exasol.nb_connector.cli.options.bucketfs import BUCKETFS_OPTIONS
2+
from exasol.nb_connector.cli.options.common import (
3+
COMMON_OPTIONS,
4+
SAVE_OPTIONS,
5+
SCS_OPTIONS,
6+
)
7+
from exasol.nb_connector.cli.options.docker_db import EXTRA_DOCKER_DB_OPTIONS
8+
from exasol.nb_connector.cli.options.onprem import ONPREM_DB_OPTIONS
9+
from exasol.nb_connector.cli.options.saas import EXTRA_SAAS_OPTIONS
10+
from exasol.nb_connector.cli.options.ssl import SSL_OPTIONS
11+
12+
13+
def _wrap(options):
14+
return SCS_OPTIONS + SAVE_OPTIONS + options + COMMON_OPTIONS
15+
16+
17+
DOCKER_DB_OPTIONS = _wrap(EXTRA_DOCKER_DB_OPTIONS)
18+
19+
SAAS_OPTIONS = _wrap(EXTRA_SAAS_OPTIONS + SSL_OPTIONS)
20+
21+
ONPREM_OPTIONS = _wrap(ONPREM_DB_OPTIONS + BUCKETFS_OPTIONS + SSL_OPTIONS)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from exasol.nb_connector.ai_lab_config import AILabConfig as CKey
2+
from exasol.nb_connector.cli.param_wrappers import (
3+
ScsOption,
4+
ScsSecretOption,
5+
)
6+
7+
BUCKETFS_OPTIONS = [
8+
ScsOption(
9+
"--bucketfs-host",
10+
metavar="HOST",
11+
type=str,
12+
default="localhost",
13+
help="BucketFS host name",
14+
scs_key=CKey.bfs_host_name,
15+
),
16+
ScsOption(
17+
"--bucketfs-host-internal",
18+
metavar="HOST",
19+
type=str,
20+
help="BucketFS internal host name [reads default from --bucketfs-host]",
21+
scs_key=CKey.bfs_internal_host_name,
22+
get_default_from="bucketfs_host",
23+
),
24+
ScsOption(
25+
"--bucketfs-port",
26+
metavar="PORT",
27+
type=int,
28+
default=2580,
29+
help="BucketFS port",
30+
scs_key=CKey.bfs_port,
31+
),
32+
ScsOption(
33+
"--bucketfs-port-internal",
34+
metavar="PORT",
35+
type=int,
36+
help="BucketFS internal port [reads default from --bucketfs-port]",
37+
scs_key=CKey.bfs_internal_port,
38+
get_default_from="bucketfs_port",
39+
),
40+
ScsOption(
41+
"--bucketfs-user",
42+
metavar="USERNAME",
43+
type=str,
44+
# should we add "w" as default here?
45+
help="BucketFS user name",
46+
scs_key=CKey.bfs_user,
47+
),
48+
ScsSecretOption(
49+
"--bucketfs-password",
50+
envvar="SCS_BUCKETFS_PASSWORD",
51+
prompt="BucketFS write password",
52+
scs_key=CKey.bfs_password,
53+
),
54+
ScsOption(
55+
"--bucketfs-name",
56+
metavar="BFS_SERVICE",
57+
type=str,
58+
default="bfsdefault",
59+
help="BucketFS service name",
60+
scs_key=CKey.bfs_service,
61+
),
62+
ScsOption(
63+
"--bucket",
64+
metavar="BUCKET",
65+
type=str,
66+
default="default",
67+
help="BucketFS bucket name",
68+
scs_key=CKey.bfs_bucket,
69+
),
70+
ScsOption(
71+
"--bucketfs-use-encryption/--no-bucketfs-use-encryption",
72+
type=bool,
73+
default=True,
74+
help="Whether to encrypt communication with the BucketFS or not",
75+
scs_key=CKey.bfs_encryption,
76+
),
77+
]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from pathlib import Path
2+
3+
import click
4+
5+
from exasol.nb_connector.cli.param_wrappers import (
6+
ScsArgument,
7+
ScsOption,
8+
)
9+
10+
SCS_OPTIONS = [
11+
ScsArgument(
12+
"scs_file",
13+
metavar="SCS_FILE",
14+
type=Path,
15+
required=True,
16+
envvar="SCS_FILE",
17+
),
18+
]
19+
20+
SAVE_OPTIONS = [
21+
ScsOption(
22+
"--overwrite-backend/--no-overwrite-backend",
23+
is_flag=True,
24+
help="Whether to overwrite a different backend in the SCS.",
25+
)
26+
]
27+
28+
COMMON_OPTIONS = [
29+
ScsOption(
30+
"--db-schema",
31+
metavar="DB_SCHEMA",
32+
type=str,
33+
help="Database schema for installing UDFs of Exasol extensions",
34+
)
35+
]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import click
2+
3+
from exasol.nb_connector.ai_lab_config import Accelerator
4+
from exasol.nb_connector.ai_lab_config import AILabConfig as CKey
5+
from exasol.nb_connector.cli.param_wrappers import ScsOption
6+
7+
EXTRA_DOCKER_DB_OPTIONS = [
8+
ScsOption(
9+
"--db-mem-size",
10+
type=int,
11+
metavar="GiB",
12+
default=2,
13+
help="Database memory size (GiB)",
14+
scs_key=CKey.mem_size,
15+
),
16+
ScsOption(
17+
"--db-disk-size",
18+
metavar="GiB",
19+
type=int,
20+
default=2,
21+
help="Database disk size (GiB)",
22+
scs_key=CKey.disk_size,
23+
),
24+
ScsOption(
25+
"--accelerator",
26+
type=click.Choice(Accelerator, case_sensitive=False),
27+
default="none",
28+
help="Hardware acceleration",
29+
scs_key=CKey.accelerator,
30+
),
31+
]

0 commit comments

Comments
 (0)