toolforge-components-cli 0.0.4__py3-none-any.whl → 0.0.6__py3-none-any.whl
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.
- toolforge_components_cli/cli.py +92 -12
- {toolforge_components_cli-0.0.4.dist-info → toolforge_components_cli-0.0.6.dist-info}/METADATA +1 -1
- toolforge_components_cli-0.0.6.dist-info/RECORD +9 -0
- {toolforge_components_cli-0.0.4.dist-info → toolforge_components_cli-0.0.6.dist-info}/WHEEL +1 -1
- toolforge_components_cli-0.0.4.dist-info/RECORD +0 -9
- {toolforge_components_cli-0.0.4.dist-info → toolforge_components_cli-0.0.6.dist-info}/LICENSE +0 -0
- {toolforge_components_cli-0.0.4.dist-info → toolforge_components_cli-0.0.6.dist-info}/entry_points.txt +0 -0
toolforge_components_cli/cli.py
CHANGED
|
@@ -6,9 +6,12 @@ import logging
|
|
|
6
6
|
import os
|
|
7
7
|
import subprocess
|
|
8
8
|
import sys
|
|
9
|
+
from textwrap import indent
|
|
10
|
+
from typing import Any
|
|
9
11
|
|
|
10
12
|
import click
|
|
11
13
|
import yaml
|
|
14
|
+
from tabulate import tabulate
|
|
12
15
|
from toolforge_weld.errors import (
|
|
13
16
|
ToolforgeError,
|
|
14
17
|
ToolforgeUserError,
|
|
@@ -88,12 +91,34 @@ def _display_deployment(deployment_data: dict, as_json: bool, prefix: str = "")
|
|
|
88
91
|
else:
|
|
89
92
|
if prefix:
|
|
90
93
|
click.echo(prefix)
|
|
91
|
-
click.echo(
|
|
92
|
-
|
|
94
|
+
click.echo(
|
|
95
|
+
click.style("Deployment ID: ", bold=True) + deployment_data["deploy_id"]
|
|
96
|
+
)
|
|
97
|
+
click.echo(
|
|
98
|
+
click.style("Created: ", bold=True) + deployment_data["creation_time"]
|
|
99
|
+
)
|
|
100
|
+
click.echo(
|
|
101
|
+
click.style("Status: ", bold=True)
|
|
102
|
+
+ _format_status(deployment_data.get("status", "unknown"))
|
|
103
|
+
)
|
|
104
|
+
click.echo(
|
|
105
|
+
click.style("Long status: ", bold=True)
|
|
106
|
+
+ "\n"
|
|
107
|
+
+ indent(text=deployment_data.get("long_status", "unknown"), prefix=" ")
|
|
108
|
+
)
|
|
93
109
|
if deployment_data.get("builds"):
|
|
94
|
-
click.echo("\
|
|
110
|
+
click.echo("\n" + click.style("Builds:", bold=True))
|
|
95
111
|
for component, build in deployment_data["builds"].items():
|
|
96
|
-
click.echo(
|
|
112
|
+
click.echo(
|
|
113
|
+
f" {component}({_format_status(build['build_status'])}): {build['build_id']}"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
if deployment_data.get("runs"):
|
|
117
|
+
click.echo("\n" + click.style("Runs:", bold=True))
|
|
118
|
+
for component, run in deployment_data["runs"].items():
|
|
119
|
+
click.echo(
|
|
120
|
+
f" {component}({_format_status(run['run_status'])}): {run.get('run_long_status', '')}"
|
|
121
|
+
)
|
|
97
122
|
|
|
98
123
|
|
|
99
124
|
@click.version_option(prog_name="Toolforge Components CLI")
|
|
@@ -349,7 +374,50 @@ def deployment_create(ctx, as_json: bool) -> None:
|
|
|
349
374
|
if deployment_data.get("builds"):
|
|
350
375
|
click.echo("\nBuilds:")
|
|
351
376
|
for component, build in deployment_data["builds"].items():
|
|
352
|
-
click.echo(
|
|
377
|
+
click.echo(
|
|
378
|
+
f" {component}({_format_status(build['build_status'])}): {build['build_id']}"
|
|
379
|
+
)
|
|
380
|
+
if deployment_data.get("runs"):
|
|
381
|
+
click.echo("\nRuns:")
|
|
382
|
+
for component, run in deployment_data["runs"].items():
|
|
383
|
+
click.echo(
|
|
384
|
+
f" {component}({_format_status(run['run_status'])}): {run.get('run_long_status', '')}"
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def _format_headers(headers: list[str]) -> list[str]:
|
|
389
|
+
return [click.style(item, bold=True) for item in headers]
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def _format_builds(builds: dict[str, dict[str, Any]]) -> str:
|
|
393
|
+
builds_strings: list[str] = []
|
|
394
|
+
for component_name, build_info in builds.items():
|
|
395
|
+
builds_strings.append(
|
|
396
|
+
f"{component_name}({_format_status(build_info['build_status'])}): {build_info['build_id']}"
|
|
397
|
+
)
|
|
398
|
+
return "\n".join(builds_strings)
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
def _format_runs(runs: dict[str, dict[str, Any]]) -> str:
|
|
402
|
+
runs_strings: list[str] = []
|
|
403
|
+
for component_name, run_info in runs.items():
|
|
404
|
+
runs_strings.append(
|
|
405
|
+
f"{component_name}({_format_status(run_info['run_status'])}): {run_info.get('run_long_status', '')}"
|
|
406
|
+
)
|
|
407
|
+
return "\n".join(runs_strings)
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def _format_status(status: str) -> str:
|
|
411
|
+
fg_color = "yellow"
|
|
412
|
+
|
|
413
|
+
if status in ("running", "pending"):
|
|
414
|
+
fg_color = "yellow"
|
|
415
|
+
elif status == "failed":
|
|
416
|
+
fg_color = "red"
|
|
417
|
+
elif status == "successful":
|
|
418
|
+
fg_color = "green"
|
|
419
|
+
|
|
420
|
+
return click.style(status, fg=fg_color)
|
|
353
421
|
|
|
354
422
|
|
|
355
423
|
@deployment.command(name="list", help="List all deployments.")
|
|
@@ -371,13 +439,24 @@ def deployment_list(ctx, as_json: bool) -> None:
|
|
|
371
439
|
return
|
|
372
440
|
|
|
373
441
|
deployments = response.get("data", {}).get("deployments", [])
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
442
|
+
formatted_deployments = [
|
|
443
|
+
[
|
|
444
|
+
deployment["deploy_id"],
|
|
445
|
+
deployment["creation_time"],
|
|
446
|
+
_format_status(deployment.get("status", "unknown")),
|
|
447
|
+
_format_builds(deployment.get("builds", {})),
|
|
448
|
+
_format_runs(deployment.get("runs", {})),
|
|
449
|
+
]
|
|
450
|
+
for deployment in deployments
|
|
451
|
+
]
|
|
452
|
+
click.echo(
|
|
453
|
+
tabulate(
|
|
454
|
+
formatted_deployments,
|
|
455
|
+
headers=_format_headers(
|
|
456
|
+
["ID", "Creation time", "Status", "Builds", "Runs"]
|
|
457
|
+
),
|
|
458
|
+
)
|
|
459
|
+
)
|
|
381
460
|
|
|
382
461
|
|
|
383
462
|
@deployment.command(name="show", help="Show details of a specific deployment.")
|
|
@@ -430,6 +509,7 @@ def deployment_delete(
|
|
|
430
509
|
|
|
431
510
|
|
|
432
511
|
def main() -> int:
|
|
512
|
+
debug = False
|
|
433
513
|
try:
|
|
434
514
|
args = sys.argv[1:]
|
|
435
515
|
debug = "-d" in args or "--debug" in args
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
toolforge_components_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
toolforge_components_cli/cli.py,sha256=f0jdHP17CG2uIgc2316BDsE_6wGwMw--elVpX_dSRMY,16682
|
|
3
|
+
toolforge_components_cli/components.py,sha256=ISGD-ahjp6mndIgCxU6V98X0Xcb7abJuLjc_Rk4CjZU,3128
|
|
4
|
+
toolforge_components_cli/config.py,sha256=wT8-kciiOIYcjoB9EELjc2FQARooQSBQlZv3elvMH2k,730
|
|
5
|
+
toolforge_components_cli-0.0.6.dist-info/LICENSE,sha256=4cCtcomD2KVzNeUs8QZPGv_R1FQXPYzr0-2LSnK0hwQ,35121
|
|
6
|
+
toolforge_components_cli-0.0.6.dist-info/METADATA,sha256=1_h3wuKWG6awFJ5rUEhxwuC1QdzrlmRt30VkqdSjWOo,1523
|
|
7
|
+
toolforge_components_cli-0.0.6.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
8
|
+
toolforge_components_cli-0.0.6.dist-info/entry_points.txt,sha256=D1g7NaMicWBsSJmJXBVU9eUnVfg45d_o4Io7LQe-SWE,74
|
|
9
|
+
toolforge_components_cli-0.0.6.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
toolforge_components_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
toolforge_components_cli/cli.py,sha256=I1q8ulVDE3fw4lyR8toLLXGlv0EOXnU02lEFd6WW8so,14140
|
|
3
|
-
toolforge_components_cli/components.py,sha256=ISGD-ahjp6mndIgCxU6V98X0Xcb7abJuLjc_Rk4CjZU,3128
|
|
4
|
-
toolforge_components_cli/config.py,sha256=wT8-kciiOIYcjoB9EELjc2FQARooQSBQlZv3elvMH2k,730
|
|
5
|
-
toolforge_components_cli-0.0.4.dist-info/LICENSE,sha256=4cCtcomD2KVzNeUs8QZPGv_R1FQXPYzr0-2LSnK0hwQ,35121
|
|
6
|
-
toolforge_components_cli-0.0.4.dist-info/METADATA,sha256=_t41BTWVQPBh50-8aCYWLcKKFpCQg_gX40hp_0WAsPM,1523
|
|
7
|
-
toolforge_components_cli-0.0.4.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
8
|
-
toolforge_components_cli-0.0.4.dist-info/entry_points.txt,sha256=D1g7NaMicWBsSJmJXBVU9eUnVfg45d_o4Io7LQe-SWE,74
|
|
9
|
-
toolforge_components_cli-0.0.4.dist-info/RECORD,,
|
{toolforge_components_cli-0.0.4.dist-info → toolforge_components_cli-0.0.6.dist-info}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|