Skip to content
This repository was archived by the owner on Jan 26, 2025. It is now read-only.

Commit e0b0782

Browse files
authored
Merge pull request #8 from insight-platform/update-readme
Updating README and watch first sleep interval
2 parents 8d23d21 + 27dc7bb commit e0b0782

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ The configuration file supports variable interpolation. You can use a path to an
7070
For more information, refer to the [OmegaConf documentation](https://omegaconf.readthedocs.io/en/2.3_branch/usage.html#variable-interpolation).
7171

7272

73+
## Usage
74+
75+
You can find the watchdog service image on:
76+
* for x86: [GitHub Packages](https://github.com/insight-platform/PipelineWatchdog/pkgs/container/pipeline-watchdog-x86)
77+
* for arm64: [GitHub Packages](https://github.com/insight-platform/PipelineWatchdog/pkgs/container/pipeline-watchdog-arm64)
78+
79+
Configuration of a docker service might be as follows
80+
```yaml
81+
pipeline-watchdog:
82+
image: ghcr.io/insight-platform/pipeline-watchdog-<arh_name>:main
83+
restart: unless-stopped
84+
network_mode: host
85+
volumes:
86+
- /var/run/docker.sock:/var/run/docker.sock
87+
- ./config.yml:/app/config.yml
88+
environment:
89+
- LOGLEVEL=INFO
90+
- CONFIG_FILE_PATH=/app/config.yml
91+
```
92+
93+
7394
## Sample
7495
7596
The sample demonstrates how to start the watchdog service with an example pipeline to watch the buffer and restart the SDK client based on configuration and buffer state.

src/pipeline_watchdog/run.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def process_action(
8989

9090

9191
async def watch_queue(docker_client: DockerClient, buffer: str, config: QueueConfig):
92-
await asyncio.sleep(config.cooldown)
92+
await asyncio.sleep(config.polling_interval)
9393

9494
while True:
9595
content = await get_metrics(buffer)
@@ -108,7 +108,7 @@ async def watch_queue(docker_client: DockerClient, buffer: str, config: QueueCon
108108

109109

110110
async def watch_egress(docker_client: DockerClient, buffer: str, config: FlowConfig):
111-
await asyncio.sleep(config.cooldown)
111+
await asyncio.sleep(config.polling_interval)
112112

113113
while True:
114114
content = await get_metrics(buffer)
@@ -128,7 +128,7 @@ async def watch_egress(docker_client: DockerClient, buffer: str, config: FlowCon
128128

129129

130130
async def watch_ingress(docker_client: DockerClient, buffer: str, config: FlowConfig):
131-
await asyncio.sleep(config.cooldown)
131+
await asyncio.sleep(config.polling_interval)
132132

133133
while True:
134134
content = await get_metrics(buffer)

tests/test_run.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,10 @@ async def test_watch_queue(
291291
await watch_queue(docker_client, watch_config.buffer, watch_config.queue)
292292
except asyncio.CancelledError:
293293
sleep_mock.assert_has_awaits(
294-
[call(watch_config.queue.cooldown), call(watch_config.queue.cooldown)]
294+
[
295+
call(watch_config.queue.polling_interval),
296+
call(watch_config.queue.cooldown),
297+
]
295298
)
296299
pass
297300

@@ -324,7 +327,7 @@ async def test_watch_queue_empty(
324327
except asyncio.CancelledError:
325328
sleep_mock.assert_has_awaits(
326329
[
327-
call(watch_config.queue.cooldown),
330+
call(watch_config.queue.polling_interval),
328331
call(watch_config.queue.polling_interval),
329332
]
330333
)
@@ -359,7 +362,10 @@ async def test_watch_egress(
359362
await watch_egress(docker_client, watch_config.buffer, watch_config.egress)
360363
except asyncio.CancelledError:
361364
sleep_mock.assert_has_awaits(
362-
[call(watch_config.egress.cooldown), call(watch_config.egress.cooldown)]
365+
[
366+
call(watch_config.egress.polling_interval),
367+
call(watch_config.egress.cooldown),
368+
]
363369
)
364370
pass
365371

@@ -395,7 +401,7 @@ async def test_watch_egress_message_just_sent(
395401
except asyncio.CancelledError:
396402
sleep_mock.assert_has_awaits(
397403
[
398-
call(watch_config.egress.cooldown),
404+
call(watch_config.egress.polling_interval),
399405
call(watch_config.egress.polling_interval),
400406
]
401407
)
@@ -433,7 +439,7 @@ async def test_watch_ingress(
433439
except asyncio.CancelledError:
434440
sleep_mock.assert_has_awaits(
435441
[
436-
call(watch_config.ingress.cooldown),
442+
call(watch_config.ingress.polling_interval),
437443
call(watch_config.ingress.cooldown),
438444
]
439445
)
@@ -475,7 +481,7 @@ async def test_watch_ingress_message_just_received(
475481
except asyncio.CancelledError:
476482
sleep_mock.assert_has_awaits(
477483
[
478-
call(watch_config.ingress.cooldown),
484+
call(watch_config.ingress.polling_interval),
479485
call(watch_config.ingress.polling_interval),
480486
]
481487
)

0 commit comments

Comments
 (0)