Skip to content

Commit

Permalink
Merge pull request #175 from marcelldls/live-log-follow
Browse files Browse the repository at this point in the history
Live log follow
  • Loading branch information
gilesknap authored Nov 5, 2024
2 parents e34309d + 8a179fb commit 376fa43
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 67 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
// Enable break on exception when debugging tests (see: tests/conftest.py)
"PYTEST_RAISE": "1",
},
},
{
"name": "Debug Monitor",
"type": "debugpy",
"request": "launch",
"module": "edge_containers_cli",
"args": [
"monitor"
],
"console": "integratedTerminal",
"env": {
"EC_CLI_BACKEND": "DEMO",
},
}
]
}
27 changes: 19 additions & 8 deletions src/edge_containers_cli/cmds/demo_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@

import time
from datetime import datetime
from random import randrange, seed

import polars

from edge_containers_cli.cmds.commands import CommandError, Commands, ServicesDataFrame
from edge_containers_cli.definitions import ECContext
from edge_containers_cli.globals import TIME_FORMAT

DELAY = 0.0
DELAY = 2.0
NUM_SERVICES = 8
seed(237)


def process_t(time_string) -> str:
Expand All @@ -22,13 +25,12 @@ def process_t(time_string) -> str:


sample_data = {
"name": ["demo-ea-01", "demo-ea-02", "demo-ea-03"], # type: ignore
"version": ["2024.10.1", "2024.10.1b", "2024.10.1"],
"ready": [True, True, False],
"name": [f"demo-ea-0{cnt}" for cnt in range(NUM_SERVICES)],
"version": ["1.0." + str(25 - cnt) for cnt in range(NUM_SERVICES)],
"ready": [True] * NUM_SERVICES,
"deployed": [
process_t("2024-10-22T11:23:10Z"),
process_t("2024-10-28T14:53:55Z"),
process_t("2024-10-22T12:51:50Z"),
process_t(f"2024-10-22T11:23:0{randrange(1,9, )}Z")
for cnt in range(NUM_SERVICES)
],
}
sample_ServicesDataFrame = ServicesDataFrame(polars.from_dict(sample_data))
Expand Down Expand Up @@ -69,6 +71,11 @@ def __init__(
self._target_valid = False
self._stateDF = sample_ServicesDataFrame

self.lorem_min = 10
self.lorem_max = 50
self.lorem_step = 5
self.lorem_count = self.lorem_min

@demo_message
def logs(self, service_name, prev):
self._logs(service_name, prev)
Expand Down Expand Up @@ -116,7 +123,11 @@ def _stop(self, service_name, commit=False):

def _get_logs(self, service_name, prev) -> str:
self._check_service(service_name)
logs_list = ["Lorem ipsum dolor sit amet"] * 25
if self.lorem_count < self.lorem_max:
self.lorem_count += self.lorem_step
else:
self.lorem_count = self.lorem_min
logs_list = ["Lorem ipsum dolor sit amet"] * self.lorem_count
return "\n".join(logs_list)

def _get_services(self, running_only) -> ServicesDataFrame:
Expand Down
Loading

0 comments on commit 376fa43

Please sign in to comment.