Skip to content

Commit 48a72dc

Browse files
committed
fix: Making path simplification safer; Improving demo messaging
1 parent e2e10ec commit 48a72dc

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

dk-installer.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ def get_installer_version():
139139
return "N/A"
140140

141141

142+
def simplify_path(path: pathlib.Path) -> pathlib.Path:
143+
try:
144+
return path.relative_to(pathlib.Path().absolute())
145+
except ValueError:
146+
return path
147+
148+
142149
@contextlib.contextmanager
143150
def stream_iterator(proc: subprocess.Popen, stream_name: str, file_path: pathlib.Path, timeout: float = 1.0):
144151
comm_index, exc_attr = {
@@ -543,7 +550,7 @@ def _msg_unexpected_error(self, exception: Exception) -> None:
543550
CONSOLE.msg(f"Command '{exception.cmd}' failed with code {exception.ret_code}. See the output below.")
544551
CONSOLE.print_log(log_path)
545552

546-
msg_file_path = self.session_zip.relative_to(pathlib.Path().absolute())
553+
msg_file_path = simplify_path(self.session_zip)
547554
CONSOLE.space()
548555
CONSOLE.msg("For assistance, send the logs to open-source-support@datakitchen.io or reach out")
549556
CONSOLE.msg("to the #support channel on https://data-observability-slack.datakitchen.io/join.")
@@ -981,12 +988,7 @@ def _print_intro_text(self, args):
981988

982989
class ComposeActionMixin:
983990
def get_compose_file_path(self, args):
984-
compose_path = self.data_folder.joinpath(args.compose_file_name)
985-
try:
986-
compose_path = compose_path.relative_to(pathlib.Path().absolute())
987-
except ValueError:
988-
pass
989-
return compose_path
991+
return simplify_path(self.data_folder.joinpath(args.compose_file_name))
990992

991993
def get_status(self, args) -> dict[str, str]:
992994
compose_installs = self.run_cmd("docker", "compose", "ls", "--format=json", capture_json=True)
@@ -1619,6 +1621,9 @@ class ObsRunDemoAction(DemoContainerAction):
16191621

16201622
def execute(self, args):
16211623
CONSOLE.title("Run Observability demo")
1624+
CONSOLE.msg("This process may take 2~5 minutes depending on your system resources and network speed.")
1625+
CONSOLE.space()
1626+
16221627
try:
16231628
self.run_dk_demo_container("obs-run-demo")
16241629
except Exception:
@@ -2112,11 +2117,14 @@ def execute(self, args):
21122117
CONSOLE.msg("Running the TestGen demo requires the platform to be running.")
21132118
raise AbortAction
21142119

2115-
if args.obs_export:
2116-
if not (self.data_folder / DEMO_CONFIG_FILE).exists():
2117-
CONSOLE.msg("Observability demo configuration missing.")
2118-
raise AbortAction
2120+
if args.obs_export and not (self.data_folder / DEMO_CONFIG_FILE).exists():
2121+
CONSOLE.msg("Observability demo configuration missing.")
2122+
raise AbortAction
21192123

2124+
CONSOLE.msg("This process may take up to 3 minutes depending on your system resources and network speed.")
2125+
CONSOLE.space()
2126+
2127+
if args.obs_export:
21202128
self.run_dk_demo_container("tg-run-demo")
21212129

21222130
quick_start_command = [
@@ -2163,7 +2171,7 @@ def execute(self, args):
21632171
*command,
21642172
)
21652173

2166-
CONSOLE.msg("Completed creating demo!")
2174+
CONSOLE.title("Demo SUCCEEDED")
21672175

21682176

21692177
class TestgenDeleteDemoAction(DemoContainerAction, ComposeActionMixin):

0 commit comments

Comments
 (0)