splight-cli 5.3.1__tar.gz → 5.3.2__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.
- {splight_cli-5.3.1 → splight_cli-5.3.2}/PKG-INFO +1 -1
- {splight_cli-5.3.1 → splight_cli-5.3.2}/pyproject.toml +2 -2
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/cli.py +26 -26
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/__init__.py +0 -23
- splight_cli-5.3.2/splight_cli/config/__init__.py +134 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/constants.py +0 -5
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/__init__.py +0 -6
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/__init__.py +0 -6
- splight_cli-5.3.2/splight_cli/workspace/__init__.py +73 -0
- splight_cli-5.3.1/splight_cli/config/__init__.py +0 -94
- splight_cli-5.3.1/splight_cli/context/__init__.py +0 -32
- splight_cli-5.3.1/splight_cli/context/workspace.py +0 -138
- splight_cli-5.3.1/splight_cli/settings.py +0 -34
- splight_cli-5.3.1/splight_cli/workspace/__init__.py +0 -96
- {splight_cli-5.3.1 → splight_cli-5.3.2}/README.md +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/component.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/exceptions.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/loaders.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/templates/.splightignore +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/templates/Initialization +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/templates/README.md +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/templates/auto_readme.md +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/templates/main.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/templates/spec.json +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/templates/tests.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/tests/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/tests/test_component_manager.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/utils.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/alert/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/asset/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/attribute/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/component/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/datalake/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/file/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/manager/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/manager/exceptions.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/manager/manager.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/manager/tests/test_datalake_manager.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/manager/tests/test_resource_manager.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/secret/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/component/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/component/component_builder.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/component/exceptions.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/component/hub_manager.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/component/resources/Dockerfile +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/component/resources/installer.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/component/tests/test_hub_manager.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/exceptions.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/server/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/server/exceptions.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/server/server_builder.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/hub/server/server_manager.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/tests/test_component/Initialization +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/tests/test_component/README.md +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/tests/test_component/main.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/tests/test_component/spec.json +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/tests/test_component/tests.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/utils/__init__.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/utils/input.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/utils/json.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/utils/loader.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/utils/pprint.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/utils/template.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/utils/yaml.py +0 -0
- {splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "splight-cli"
|
|
3
|
-
version = "5.3.
|
|
3
|
+
version = "5.3.2"
|
|
4
4
|
description = "Splight Command Line Interface"
|
|
5
5
|
authors = ["Splight Dev <dev@splight-ae.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -33,7 +33,7 @@ pre-commit = "3.2.2"
|
|
|
33
33
|
pytest = "^7.4.3"
|
|
34
34
|
coverage = "^7.3.2"
|
|
35
35
|
mock = "^5.1.0"
|
|
36
|
-
ruff = "^0.
|
|
36
|
+
ruff = "^0.8"
|
|
37
37
|
|
|
38
38
|
[tool.poetry.scripts]
|
|
39
39
|
splight = "splight_cli.cli:app"
|
|
@@ -2,26 +2,25 @@ from typing import Optional
|
|
|
2
2
|
|
|
3
3
|
import typer
|
|
4
4
|
from rich.console import Console
|
|
5
|
+
from splight_lib.settings import workspace_settings
|
|
5
6
|
|
|
6
7
|
from splight_cli.component import component_app
|
|
7
8
|
from splight_cli.config import config_app
|
|
8
|
-
from splight_cli.constants import error_style
|
|
9
|
-
from splight_cli.context import Context
|
|
10
|
-
from splight_cli.context.workspace import ConfigurationError
|
|
11
9
|
from splight_cli.engine import engine_app
|
|
12
10
|
from splight_cli.hub import hub_app
|
|
13
11
|
from splight_cli.version import __version__
|
|
14
12
|
from splight_cli.workspace import workspace_app
|
|
15
13
|
|
|
16
14
|
console = Console()
|
|
15
|
+
|
|
17
16
|
app = typer.Typer(
|
|
18
17
|
name="Splight Command Line",
|
|
19
18
|
add_completion=True,
|
|
20
19
|
rich_markup_mode="rich",
|
|
21
|
-
invoke_without_command=True,
|
|
22
20
|
pretty_exceptions_enable=False,
|
|
23
21
|
)
|
|
24
22
|
|
|
23
|
+
|
|
25
24
|
app.add_typer(config_app, name="configure")
|
|
26
25
|
app.add_typer(component_app, name="component")
|
|
27
26
|
app.add_typer(engine_app, name="engine")
|
|
@@ -29,33 +28,34 @@ app.add_typer(hub_app, name="hub")
|
|
|
29
28
|
app.add_typer(workspace_app, name="workspace")
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
def
|
|
33
|
-
if
|
|
34
|
-
print(
|
|
35
|
-
|
|
31
|
+
def ensure_settings(ctx: typer.Context):
|
|
32
|
+
if not workspace_settings.configured:
|
|
33
|
+
console.print(
|
|
34
|
+
"Please run `splight configure` or set the corresponding environment variables.",
|
|
35
|
+
style="red",
|
|
36
|
+
)
|
|
37
|
+
raise typer.Exit(code=1)
|
|
36
38
|
|
|
37
39
|
|
|
38
|
-
@app.callback()
|
|
40
|
+
@app.callback(invoke_without_command=True)
|
|
39
41
|
def main(
|
|
40
42
|
ctx: typer.Context,
|
|
41
43
|
version: Optional[bool] = typer.Option(
|
|
42
|
-
None, "--version", "-v",
|
|
44
|
+
None, "--version", "-v", is_eager=True
|
|
43
45
|
),
|
|
44
46
|
) -> None:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
raise typer.Exit(code=1)
|
|
60
|
-
if ctx.invoked_subcommand is None:
|
|
47
|
+
if version:
|
|
48
|
+
console.print(__version__)
|
|
49
|
+
raise typer.Exit()
|
|
50
|
+
|
|
51
|
+
command = ctx.invoked_subcommand
|
|
52
|
+
|
|
53
|
+
if command and command not in [
|
|
54
|
+
"workspace",
|
|
55
|
+
"configure",
|
|
56
|
+
]:
|
|
57
|
+
# Forward the check to every sub command
|
|
58
|
+
ensure_settings(ctx)
|
|
59
|
+
|
|
60
|
+
if command is None:
|
|
61
61
|
ctx.get_help()
|
|
@@ -7,7 +7,6 @@ from rich.console import Console
|
|
|
7
7
|
|
|
8
8
|
from splight_cli.component.component import ComponentManager
|
|
9
9
|
from splight_cli.constants import error_style, success_style
|
|
10
|
-
from splight_cli.context import check_credentials
|
|
11
10
|
|
|
12
11
|
component_app = typer.Typer(
|
|
13
12
|
name="Splight Component",
|
|
@@ -20,11 +19,6 @@ logger = logging.getLogger()
|
|
|
20
19
|
console = Console()
|
|
21
20
|
|
|
22
21
|
|
|
23
|
-
@component_app.callback(invoke_without_command=True)
|
|
24
|
-
def callback(ctx: typer.Context):
|
|
25
|
-
check_credentials(ctx)
|
|
26
|
-
|
|
27
|
-
|
|
28
22
|
@component_app.command()
|
|
29
23
|
def create(
|
|
30
24
|
ctx: typer.Context,
|
|
@@ -110,20 +104,3 @@ def test(
|
|
|
110
104
|
logger.exception(e)
|
|
111
105
|
console.print(f"Error testing component: {str(e)}", style=error_style)
|
|
112
106
|
raise typer.Exit(code=1)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
@component_app.command()
|
|
116
|
-
def create_local_db(
|
|
117
|
-
ctx: typer.Context,
|
|
118
|
-
path: str = typer.Argument(..., help="Path to component source code"),
|
|
119
|
-
) -> None:
|
|
120
|
-
try:
|
|
121
|
-
manager = ComponentManager()
|
|
122
|
-
console.print("Creating local component db...", style=success_style)
|
|
123
|
-
manager.create_local_db(path=path)
|
|
124
|
-
except Exception as e:
|
|
125
|
-
logger.exception(e)
|
|
126
|
-
console.print(
|
|
127
|
-
f"Error creating local component db: {str(e)}", style=error_style
|
|
128
|
-
)
|
|
129
|
-
raise typer.Exit(code=1)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from splight_lib.config import (
|
|
5
|
+
SplightConfigError,
|
|
6
|
+
SplightConfigManager,
|
|
7
|
+
Workspace,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
config_app = typer.Typer(
|
|
11
|
+
name="Splight CLI Configure",
|
|
12
|
+
add_completion=True,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@config_app.callback(invoke_without_command=True)
|
|
17
|
+
def config(ctx: typer.Context):
|
|
18
|
+
if ctx.invoked_subcommand:
|
|
19
|
+
return
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
manager = SplightConfigManager()
|
|
23
|
+
|
|
24
|
+
typer.echo(
|
|
25
|
+
typer.style(
|
|
26
|
+
"Interactive configuration for Splight CLI:",
|
|
27
|
+
fg="cyan",
|
|
28
|
+
bold=True,
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
current_workspace = manager.get(manager.current)
|
|
32
|
+
typer.echo(
|
|
33
|
+
typer.style(f"Current Workspace: {manager.current}", fg="yellow")
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Prompt for inputs
|
|
37
|
+
access_id = typer.prompt(
|
|
38
|
+
"SPLIGHT_ACCESS_ID",
|
|
39
|
+
default=current_workspace.SPLIGHT_ACCESS_ID or "",
|
|
40
|
+
show_default=True,
|
|
41
|
+
)
|
|
42
|
+
secret_key = typer.prompt(
|
|
43
|
+
"SPLIGHT_SECRET_KEY",
|
|
44
|
+
default=current_workspace.SPLIGHT_SECRET_KEY or "",
|
|
45
|
+
show_default=False,
|
|
46
|
+
)
|
|
47
|
+
api_host = typer.prompt(
|
|
48
|
+
"SPLIGHT_PLATFORM_API_HOST",
|
|
49
|
+
default=current_workspace.SPLIGHT_PLATFORM_API_HOST,
|
|
50
|
+
show_default=True,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# Update workspace
|
|
54
|
+
updated_workspace = Workspace(
|
|
55
|
+
SPLIGHT_ACCESS_ID=access_id,
|
|
56
|
+
SPLIGHT_SECRET_KEY=secret_key,
|
|
57
|
+
SPLIGHT_PLATFORM_API_HOST=api_host,
|
|
58
|
+
)
|
|
59
|
+
manager.update(manager.current, updated_workspace)
|
|
60
|
+
|
|
61
|
+
typer.echo(
|
|
62
|
+
typer.style("Configuration saved successfully.", fg="green")
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
except SplightConfigError as e:
|
|
66
|
+
typer.echo(
|
|
67
|
+
typer.style(f"Error configuring Splight CLI: {str(e)}", fg="red")
|
|
68
|
+
)
|
|
69
|
+
sys.exit(1)
|
|
70
|
+
except Exception as e:
|
|
71
|
+
typer.echo(typer.style(f"Unexpected error: {str(e)}", fg="red"))
|
|
72
|
+
sys.exit(1)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@config_app.command(name="get")
|
|
76
|
+
def get_variable(
|
|
77
|
+
ctx: typer.Context,
|
|
78
|
+
var_name: str = typer.Argument(..., help="The variable name to retrieve."),
|
|
79
|
+
):
|
|
80
|
+
try:
|
|
81
|
+
manager = SplightConfigManager()
|
|
82
|
+
current_workspace = manager.get(manager.current)
|
|
83
|
+
variable_name = var_name.upper()
|
|
84
|
+
|
|
85
|
+
if hasattr(current_workspace, variable_name):
|
|
86
|
+
value = getattr(current_workspace, variable_name)
|
|
87
|
+
typer.echo(typer.style(f"{variable_name}: {value}", fg="green"))
|
|
88
|
+
else:
|
|
89
|
+
typer.echo(
|
|
90
|
+
typer.style(
|
|
91
|
+
f"Variable '{variable_name}' does not exist in the workspace.",
|
|
92
|
+
fg="red",
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
except SplightConfigError as e:
|
|
97
|
+
typer.echo(
|
|
98
|
+
typer.style(f"Error retrieving variable: {str(e)}", fg="red")
|
|
99
|
+
)
|
|
100
|
+
sys.exit(1)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@config_app.command(name="set")
|
|
104
|
+
def set_variable(
|
|
105
|
+
ctx: typer.Context,
|
|
106
|
+
var_name: str = typer.Argument(..., help="The variable name to update."),
|
|
107
|
+
value: str = typer.Argument(..., help="The new value for the variable."),
|
|
108
|
+
):
|
|
109
|
+
try:
|
|
110
|
+
manager = SplightConfigManager()
|
|
111
|
+
current_workspace = manager.get(manager.current)
|
|
112
|
+
variable_name = var_name.upper()
|
|
113
|
+
|
|
114
|
+
if hasattr(current_workspace, variable_name):
|
|
115
|
+
setattr(current_workspace, variable_name, value)
|
|
116
|
+
manager.update(manager.current, current_workspace)
|
|
117
|
+
|
|
118
|
+
typer.echo(
|
|
119
|
+
typer.style(
|
|
120
|
+
f"Successfully updated '{variable_name}' to '{value}'.",
|
|
121
|
+
fg="green",
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
else:
|
|
125
|
+
typer.echo(
|
|
126
|
+
typer.style(
|
|
127
|
+
f"Variable '{variable_name}' does not exist in the workspace.",
|
|
128
|
+
fg="red",
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
except SplightConfigError as e:
|
|
133
|
+
typer.echo(typer.style(f"Error updating variable: {str(e)}", fg="red"))
|
|
134
|
+
sys.exit(1)
|
|
@@ -4,8 +4,6 @@ from pathlib import Path
|
|
|
4
4
|
from pydantic import AnyUrl
|
|
5
5
|
from rich.style import Style
|
|
6
6
|
|
|
7
|
-
from splight_cli.settings import SplightCLISettings
|
|
8
|
-
|
|
9
7
|
error_style = Style(color="red", bold=True)
|
|
10
8
|
success_style = Style(color="green")
|
|
11
9
|
warning_style = Style(color="yellow")
|
|
@@ -19,9 +17,6 @@ TEMPLATES_FOLDER = os.path.join(
|
|
|
19
17
|
COMPRESSION_TYPE = "7z"
|
|
20
18
|
DEFAULT_NAMESPACE = "NO_NAMESPACE"
|
|
21
19
|
DEFAULT_COMPONENT_ID = "DEMO"
|
|
22
|
-
DEFAULT_WORKSPACE_NAME = "default"
|
|
23
|
-
DEFAULT_WORKSPACE = SplightCLISettings().model_dump()
|
|
24
|
-
DEFAULT_WORKSPACES = {DEFAULT_WORKSPACE_NAME: DEFAULT_WORKSPACE}
|
|
25
20
|
|
|
26
21
|
CONFIG_FILE = os.path.join(SPLIGHT_PATH, "config")
|
|
27
22
|
PYTHON_COMPONENT_FILE = "main.py"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import typer
|
|
2
2
|
|
|
3
|
-
from splight_cli.context import check_credentials
|
|
4
3
|
from splight_cli.engine.alert import alert_app
|
|
5
4
|
from splight_cli.engine.asset import asset_app
|
|
6
5
|
from splight_cli.engine.attribute import attribute_app
|
|
@@ -23,8 +22,3 @@ engine_app.add_typer(component_app, name="component")
|
|
|
23
22
|
engine_app.add_typer(datalake_app, name="datalake")
|
|
24
23
|
engine_app.add_typer(file_app, name="file")
|
|
25
24
|
engine_app.add_typer(secret_app, name="secret")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@engine_app.callback(invoke_without_command=True)
|
|
29
|
-
def engine_callback(ctx: typer.Context):
|
|
30
|
-
check_credentials(ctx)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import typer
|
|
2
2
|
|
|
3
|
-
from splight_cli.context import check_credentials
|
|
4
3
|
from splight_cli.hub.component import component_app
|
|
5
4
|
from splight_cli.hub.server import server_app
|
|
6
5
|
|
|
@@ -13,8 +12,3 @@ hub_app = typer.Typer(
|
|
|
13
12
|
|
|
14
13
|
hub_app.add_typer(component_app, name="component")
|
|
15
14
|
hub_app.add_typer(server_app, name="server")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@hub_app.callback(invoke_without_command=True)
|
|
19
|
-
def hub_callback(ctx: typer.Context):
|
|
20
|
-
check_credentials(ctx)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from functools import wraps
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
from rich.table import Table
|
|
6
|
+
from splight_lib.config import SplightConfigManager
|
|
7
|
+
|
|
8
|
+
from splight_cli.constants import error_style, success_style
|
|
9
|
+
|
|
10
|
+
console = Console()
|
|
11
|
+
|
|
12
|
+
workspace_app = typer.Typer(
|
|
13
|
+
name="Splight CLI Workspace",
|
|
14
|
+
add_completion=True,
|
|
15
|
+
rich_markup_mode="rich",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def display_workspaces(workspaces: list[str], current: str) -> None:
|
|
20
|
+
table = Table("Workspaces", show_lines=False, show_edge=False)
|
|
21
|
+
for item in workspaces:
|
|
22
|
+
style = success_style if item == current else None
|
|
23
|
+
table.add_row(item, style=style)
|
|
24
|
+
console.print(table)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def error_handler(func):
|
|
28
|
+
@wraps(func)
|
|
29
|
+
def wrapper(*args, **kwargs):
|
|
30
|
+
try:
|
|
31
|
+
return func(*args, **kwargs)
|
|
32
|
+
except Exception as e:
|
|
33
|
+
console.print(str(e), style=error_style)
|
|
34
|
+
raise typer.Exit(code=1)
|
|
35
|
+
|
|
36
|
+
return wrapper
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@workspace_app.command()
|
|
40
|
+
@error_handler
|
|
41
|
+
def list() -> None:
|
|
42
|
+
config = SplightConfigManager()
|
|
43
|
+
display_workspaces(config.list(), config.current)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@workspace_app.command()
|
|
47
|
+
@error_handler
|
|
48
|
+
def create(
|
|
49
|
+
name: str = typer.Argument(..., help="The workspace's name"),
|
|
50
|
+
) -> None:
|
|
51
|
+
config = SplightConfigManager()
|
|
52
|
+
config.create(name)
|
|
53
|
+
display_workspaces(config.list(), config.current)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@workspace_app.command()
|
|
57
|
+
@error_handler
|
|
58
|
+
def delete(
|
|
59
|
+
name: str = typer.Argument(..., help="The workspace's name"),
|
|
60
|
+
) -> None:
|
|
61
|
+
config = SplightConfigManager()
|
|
62
|
+
config.delete(name)
|
|
63
|
+
console.print(f"Deleted workspace {name}", style=success_style)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@workspace_app.command()
|
|
67
|
+
@error_handler
|
|
68
|
+
def select(
|
|
69
|
+
name: str = typer.Argument(..., help="The workspace's name"),
|
|
70
|
+
) -> None:
|
|
71
|
+
config = SplightConfigManager()
|
|
72
|
+
config.set_current(name)
|
|
73
|
+
console.print(f"Current workspace: {name}", style=success_style)
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
import typer
|
|
5
|
-
|
|
6
|
-
from splight_cli.settings import CONFIG_VARS, SplightCLISettings
|
|
7
|
-
|
|
8
|
-
config_app = typer.Typer(
|
|
9
|
-
name="Splight CLI Configure",
|
|
10
|
-
add_completion=True,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@config_app.callback(invoke_without_command=True)
|
|
15
|
-
def config(
|
|
16
|
-
ctx: typer.Context,
|
|
17
|
-
from_json: str = typer.Option(
|
|
18
|
-
None, "--from-json", help="Configuration by json instaed of prompt"
|
|
19
|
-
),
|
|
20
|
-
):
|
|
21
|
-
if ctx.invoked_subcommand:
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
cli_context = ctx.obj
|
|
25
|
-
try:
|
|
26
|
-
if from_json:
|
|
27
|
-
from_json = json.loads(from_json)
|
|
28
|
-
new_settings = SplightCLISettings.model_validate(from_json)
|
|
29
|
-
else:
|
|
30
|
-
new_settings_data = {}
|
|
31
|
-
for config_var in CONFIG_VARS:
|
|
32
|
-
default = getattr(
|
|
33
|
-
cli_context.workspace.settings, config_var, None
|
|
34
|
-
)
|
|
35
|
-
value = typer.prompt(
|
|
36
|
-
typer.style(config_var, fg="yellow"),
|
|
37
|
-
type=str,
|
|
38
|
-
default=default,
|
|
39
|
-
show_default=True,
|
|
40
|
-
)
|
|
41
|
-
new_settings_data.update({config_var: value})
|
|
42
|
-
new_settings = SplightCLISettings.model_validate(new_settings_data)
|
|
43
|
-
cli_context.workspace.update_workspace(new_settings)
|
|
44
|
-
typer.echo("Configuration saved successfully", color="green")
|
|
45
|
-
except Exception as e:
|
|
46
|
-
typer.echo(f"Error configuring Splight CLI: {str(e)}", color="red")
|
|
47
|
-
sys.exit(1)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@config_app.command(name="get")
|
|
51
|
-
def get_variable(
|
|
52
|
-
ctx: typer.Context,
|
|
53
|
-
var_name: str = typer.Argument(..., help="The variable name to get value"),
|
|
54
|
-
):
|
|
55
|
-
"""Prints the value of the requested variable.
|
|
56
|
-
|
|
57
|
-
Parameters
|
|
58
|
-
----------
|
|
59
|
-
ctx: Context
|
|
60
|
-
The current context
|
|
61
|
-
var_name:
|
|
62
|
-
The variable name to get the value
|
|
63
|
-
"""
|
|
64
|
-
variable_name = var_name.upper()
|
|
65
|
-
settings = ctx.obj.workspace.settings
|
|
66
|
-
|
|
67
|
-
if hasattr(settings, variable_name):
|
|
68
|
-
value = getattr(settings, variable_name)
|
|
69
|
-
typer.echo(value)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@config_app.command(name="set")
|
|
73
|
-
def set_variable(
|
|
74
|
-
ctx: typer.Context,
|
|
75
|
-
var_name: str = typer.Argument(..., help="The variable name to update"),
|
|
76
|
-
value: str = typer.Argument(..., help="The new value"),
|
|
77
|
-
):
|
|
78
|
-
"""Sets a value of a variable in the current workspace.
|
|
79
|
-
|
|
80
|
-
Parameters
|
|
81
|
-
----------
|
|
82
|
-
ctx: Context
|
|
83
|
-
The current context
|
|
84
|
-
var_name: str
|
|
85
|
-
The variable's name to be updated
|
|
86
|
-
value: Any
|
|
87
|
-
The new value
|
|
88
|
-
"""
|
|
89
|
-
variable_name = var_name.upper()
|
|
90
|
-
settings = ctx.obj.workspace.settings
|
|
91
|
-
|
|
92
|
-
if hasattr(settings, variable_name):
|
|
93
|
-
setattr(settings, variable_name, value)
|
|
94
|
-
ctx.obj.workspace.update_workspace(settings)
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import typer
|
|
2
|
-
from rich.console import Console
|
|
3
|
-
|
|
4
|
-
from splight_cli.constants import error_style
|
|
5
|
-
from splight_cli.context.workspace import WorkspaceManager
|
|
6
|
-
|
|
7
|
-
console = Console()
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class Context:
|
|
11
|
-
def __init__(self, new_workspace: bool = False):
|
|
12
|
-
self.__workspace = WorkspaceManager(new_workspace=new_workspace)
|
|
13
|
-
|
|
14
|
-
@property
|
|
15
|
-
def workspace(self):
|
|
16
|
-
return self.__workspace
|
|
17
|
-
|
|
18
|
-
def __repr__(self):
|
|
19
|
-
return f"<Context {self.__workspace}>"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def check_credentials(ctx: typer.Context):
|
|
23
|
-
settings = ctx.obj.workspace.settings
|
|
24
|
-
|
|
25
|
-
access_id = settings.SPLIGHT_ACCESS_ID
|
|
26
|
-
secret_key = settings.SPLIGHT_SECRET_KEY
|
|
27
|
-
if not access_id or not secret_key:
|
|
28
|
-
console.print(
|
|
29
|
-
'Please set you Splight credentials with "splight configure"',
|
|
30
|
-
style=error_style,
|
|
31
|
-
)
|
|
32
|
-
raise typer.Exit(code=1)
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from typing import List
|
|
4
|
-
|
|
5
|
-
from splight_cli.constants import (
|
|
6
|
-
CONFIG_FILE,
|
|
7
|
-
DEFAULT_WORKSPACE,
|
|
8
|
-
DEFAULT_WORKSPACE_NAME,
|
|
9
|
-
DEFAULT_WORKSPACES,
|
|
10
|
-
)
|
|
11
|
-
from splight_cli.settings import SplightCLIConfig, SplightCLISettings
|
|
12
|
-
from splight_cli.utils.yaml import get_yaml_from_file, save_yaml_to_file
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class WorkspaceDeleteError(Exception):
|
|
16
|
-
def __init__(self, workspace: str):
|
|
17
|
-
self._msg = (
|
|
18
|
-
f"Workspace '{workspace}' is your active workspace\n\n"
|
|
19
|
-
"You cannot delete the currently active workspace"
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
def __str__(self) -> str:
|
|
23
|
-
return self._msg
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class NotExistingWorkspace(Exception):
|
|
27
|
-
def __init__(self, workspace: str):
|
|
28
|
-
self._msg = f"Workspace {workspace} does not exist in your environment"
|
|
29
|
-
|
|
30
|
-
def __str__(self) -> str:
|
|
31
|
-
return self._msg
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class ConfigurationError(Exception):
|
|
35
|
-
pass
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class WorkspaceManager:
|
|
39
|
-
def __init__(self, new_workspace: bool = False):
|
|
40
|
-
self.config_file = CONFIG_FILE
|
|
41
|
-
self._config = self.__load_config()
|
|
42
|
-
self._workspaces = self._config.workspaces
|
|
43
|
-
self._current_workspace = self._config.current_workspace
|
|
44
|
-
self._settings = self._workspaces[self._current_workspace]
|
|
45
|
-
if not self._settings.is_configured() and not new_workspace:
|
|
46
|
-
raise ConfigurationError(
|
|
47
|
-
(
|
|
48
|
-
"There is at least one variable missing. "
|
|
49
|
-
"Use command 'splight configure'"
|
|
50
|
-
)
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
def __load_config(self):
|
|
54
|
-
try:
|
|
55
|
-
if os.path.exists(self.config_file):
|
|
56
|
-
config = self._load_from_file(self.config_file)
|
|
57
|
-
else:
|
|
58
|
-
config = self._load_from_env()
|
|
59
|
-
except Exception as exc:
|
|
60
|
-
raise ConfigurationError(
|
|
61
|
-
"An error ocurred while loading configuration"
|
|
62
|
-
) from exc
|
|
63
|
-
return config
|
|
64
|
-
|
|
65
|
-
def _load_from_file(self, file_path: str) -> SplightCLIConfig:
|
|
66
|
-
config = get_yaml_from_file(file_path)
|
|
67
|
-
# Default values
|
|
68
|
-
config["workspaces"] = config.get("workspaces", DEFAULT_WORKSPACES)
|
|
69
|
-
workspace_name = config.get(
|
|
70
|
-
"current_workspace", DEFAULT_WORKSPACE_NAME
|
|
71
|
-
)
|
|
72
|
-
if workspace_name not in config["workspaces"]:
|
|
73
|
-
workspace_name = (
|
|
74
|
-
DEFAULT_WORKSPACE_NAME
|
|
75
|
-
if DEFAULT_WORKSPACE_NAME in config["workspaces"]
|
|
76
|
-
else list(config["workspaces"].keys())[0]
|
|
77
|
-
)
|
|
78
|
-
config["current_workspace"] = workspace_name
|
|
79
|
-
save_yaml_to_file(config, file_path)
|
|
80
|
-
config = SplightCLIConfig.model_validate(config)
|
|
81
|
-
return config
|
|
82
|
-
|
|
83
|
-
def _load_from_env(self) -> SplightCLIConfig:
|
|
84
|
-
config = SplightCLIConfig(
|
|
85
|
-
current_workspace=DEFAULT_WORKSPACE_NAME,
|
|
86
|
-
workspaces=DEFAULT_WORKSPACES,
|
|
87
|
-
)
|
|
88
|
-
path = Path(self.config_file)
|
|
89
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
90
|
-
path.touch()
|
|
91
|
-
save_yaml_to_file(config.model_dump(), self.config_file)
|
|
92
|
-
return config
|
|
93
|
-
|
|
94
|
-
@property
|
|
95
|
-
def settings(self) -> SplightCLISettings:
|
|
96
|
-
return self._settings
|
|
97
|
-
|
|
98
|
-
@property
|
|
99
|
-
def current_workspace(self) -> str:
|
|
100
|
-
return self._current_workspace
|
|
101
|
-
|
|
102
|
-
def update_workspace(self, new_settings: SplightCLISettings):
|
|
103
|
-
self._workspaces[self._current_workspace] = new_settings
|
|
104
|
-
save_yaml_to_file(self._config.model_dump(), self.config_file)
|
|
105
|
-
|
|
106
|
-
def select_workspace(self, workspace_name: str):
|
|
107
|
-
if workspace_name not in self._workspaces:
|
|
108
|
-
raise NotExistingWorkspace(workspace_name)
|
|
109
|
-
self._config.current_workspace = workspace_name
|
|
110
|
-
save_yaml_to_file(self._config.model_dump(), self.config_file)
|
|
111
|
-
|
|
112
|
-
def list_workspaces(self) -> List[str]:
|
|
113
|
-
return [
|
|
114
|
-
f"{key}*" if key == self._current_workspace else f"{key}"
|
|
115
|
-
for key in self._config.workspaces.keys()
|
|
116
|
-
]
|
|
117
|
-
|
|
118
|
-
def delete_workspace(self, workspace_name: str):
|
|
119
|
-
if workspace_name not in self._config.workspaces:
|
|
120
|
-
raise Exception("Not a valid namespace name")
|
|
121
|
-
|
|
122
|
-
if workspace_name == self._current_workspace:
|
|
123
|
-
raise WorkspaceDeleteError(workspace_name)
|
|
124
|
-
del self._config.workspaces[workspace_name]
|
|
125
|
-
save_yaml_to_file(self._config.model_dump(), self.config_file)
|
|
126
|
-
|
|
127
|
-
def create_workspace(self, workspace_name: str):
|
|
128
|
-
if workspace_name in self._config.workspaces:
|
|
129
|
-
raise Exception("Name already exists")
|
|
130
|
-
self._config.workspaces.update({workspace_name: DEFAULT_WORKSPACE})
|
|
131
|
-
self._config.current_workspace = workspace_name
|
|
132
|
-
self._current_workspace = workspace_name
|
|
133
|
-
save_yaml_to_file(self._config.model_dump(), self.config_file)
|
|
134
|
-
|
|
135
|
-
def list_workspace_contents(self, workspace_name: str):
|
|
136
|
-
if workspace_name not in self._config.workspaces:
|
|
137
|
-
raise NotExistingWorkspace(workspace_name)
|
|
138
|
-
return self._config.workspaces[workspace_name]
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
from typing import Dict
|
|
2
|
-
|
|
3
|
-
from pydantic import BaseModel, ConfigDict
|
|
4
|
-
from pydantic_settings import BaseSettings
|
|
5
|
-
|
|
6
|
-
from splight_cli.version import __version__
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class SplightCLISettings(BaseSettings):
|
|
10
|
-
SPLIGHT_ACCESS_ID: str | None = None
|
|
11
|
-
SPLIGHT_SECRET_KEY: str | None = None
|
|
12
|
-
SPLIGHT_PLATFORM_API_HOST: str = "https://api.splight-ai.com"
|
|
13
|
-
|
|
14
|
-
model_config: ConfigDict = ConfigDict(extra="ignore")
|
|
15
|
-
|
|
16
|
-
def is_configured(self) -> bool:
|
|
17
|
-
return (
|
|
18
|
-
False
|
|
19
|
-
if not self.SPLIGHT_ACCESS_ID or not self.SPLIGHT_SECRET_KEY
|
|
20
|
-
else True
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class SplightCLIConfig(BaseModel):
|
|
25
|
-
current_workspace: str = "default"
|
|
26
|
-
workspaces: Dict[str, SplightCLISettings]
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
ALL_CONFIG_VARS = set(SplightCLISettings.model_fields.keys())
|
|
30
|
-
CONFIG_VARS = [
|
|
31
|
-
"SPLIGHT_ACCESS_ID",
|
|
32
|
-
"SPLIGHT_SECRET_KEY",
|
|
33
|
-
]
|
|
34
|
-
SPLIGHT_CLI_VERSION = __version__
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import typer
|
|
2
|
-
from rich.console import Console
|
|
3
|
-
from rich.table import Table
|
|
4
|
-
|
|
5
|
-
from splight_cli.constants import error_style, success_style
|
|
6
|
-
|
|
7
|
-
workspace_app = typer.Typer(
|
|
8
|
-
name="Splight CLI Workspace",
|
|
9
|
-
add_completion=True,
|
|
10
|
-
rich_markup_mode="rich",
|
|
11
|
-
)
|
|
12
|
-
console = Console()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@workspace_app.command()
|
|
16
|
-
def list(ctx: typer.Context) -> None:
|
|
17
|
-
try:
|
|
18
|
-
results = ctx.obj.workspace.list_workspaces()
|
|
19
|
-
table = Table("WORKSPACES", show_lines=False, show_edge=False)
|
|
20
|
-
_ = [
|
|
21
|
-
table.add_row(item, style=success_style if "*" in item else None)
|
|
22
|
-
for item in results
|
|
23
|
-
]
|
|
24
|
-
console.print(table)
|
|
25
|
-
except Exception as e:
|
|
26
|
-
console.print(
|
|
27
|
-
f"Error configuring Splight Hub: {str(e)}", style=error_style
|
|
28
|
-
)
|
|
29
|
-
raise typer.Exit(code=1)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@workspace_app.command()
|
|
33
|
-
def create(
|
|
34
|
-
ctx: typer.Context,
|
|
35
|
-
name: str = typer.Argument(..., help="The workspace's name"),
|
|
36
|
-
) -> None:
|
|
37
|
-
try:
|
|
38
|
-
ctx.obj.workspace.create_workspace(name)
|
|
39
|
-
results = ctx.obj.workspace.list_workspaces()
|
|
40
|
-
table = Table("WORKSPACES", show_lines=False, show_edge=False)
|
|
41
|
-
_ = [
|
|
42
|
-
table.add_row(item, style=success_style if "*" in item else None)
|
|
43
|
-
for item in results
|
|
44
|
-
]
|
|
45
|
-
console.print(table)
|
|
46
|
-
except Exception as e:
|
|
47
|
-
console.print(
|
|
48
|
-
f"Error configuring Splight Hub: {str(e)}", style=error_style
|
|
49
|
-
)
|
|
50
|
-
raise typer.Exit(code=1)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@workspace_app.command()
|
|
54
|
-
def show(
|
|
55
|
-
ctx: typer.Context,
|
|
56
|
-
name: str = typer.Argument(..., help="The workspace name"),
|
|
57
|
-
) -> None:
|
|
58
|
-
try:
|
|
59
|
-
results = ctx.obj.workspace.list_workspace_contents(name)
|
|
60
|
-
table = Table("WORKSPACE CONTENTS", show_lines=True, show_edge=True)
|
|
61
|
-
for item in results:
|
|
62
|
-
table.add_row(item[0].lower(), item[1])
|
|
63
|
-
console.print(table)
|
|
64
|
-
except Exception as e:
|
|
65
|
-
console.print(
|
|
66
|
-
f"Error showing workspace contents: {str(e)}", style=error_style
|
|
67
|
-
)
|
|
68
|
-
raise typer.Exit(code=1)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
@workspace_app.command()
|
|
72
|
-
def delete(
|
|
73
|
-
ctx: typer.Context,
|
|
74
|
-
name: str = typer.Argument(..., help="The workspace's name"),
|
|
75
|
-
) -> None:
|
|
76
|
-
try:
|
|
77
|
-
ctx.obj.workspace.delete_workspace(name)
|
|
78
|
-
console.print(f"Deleted workspace {name}", style=success_style)
|
|
79
|
-
except Exception as e:
|
|
80
|
-
console.print(e, style=error_style)
|
|
81
|
-
raise typer.Exit(code=1)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
@workspace_app.command()
|
|
85
|
-
def select(
|
|
86
|
-
ctx: typer.Context,
|
|
87
|
-
name: str = typer.Argument(..., help="The workspace's name"),
|
|
88
|
-
) -> None:
|
|
89
|
-
try:
|
|
90
|
-
ctx.obj.workspace.select_workspace(name)
|
|
91
|
-
console.print(f"Current workspace: {name}", style=success_style)
|
|
92
|
-
except Exception as e:
|
|
93
|
-
console.print(
|
|
94
|
-
f"Error configuring Splight Hub: {str(e)}", style=error_style
|
|
95
|
-
)
|
|
96
|
-
raise typer.Exit(code=1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/component/tests/test_component_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/manager/tests/test_datalake_manager.py
RENAMED
|
File without changes
|
{splight_cli-5.3.1 → splight_cli-5.3.2}/splight_cli/engine/manager/tests/test_resource_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|