Skip to content

Commit

Permalink
Merge pull request #8 from insight-platform/update-readme
Browse files Browse the repository at this point in the history
Updating README and watch first sleep interval
  • Loading branch information
placccebo authored Aug 23, 2024
2 parents 8d23d21 + 27dc7bb commit e0b0782
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ The configuration file supports variable interpolation. You can use a path to an
For more information, refer to the [OmegaConf documentation](https://omegaconf.readthedocs.io/en/2.3_branch/usage.html#variable-interpolation).


## Usage

You can find the watchdog service image on:
* for x86: [GitHub Packages](https://github.com/insight-platform/PipelineWatchdog/pkgs/container/pipeline-watchdog-x86)
* for arm64: [GitHub Packages](https://github.com/insight-platform/PipelineWatchdog/pkgs/container/pipeline-watchdog-arm64)

Configuration of a docker service might be as follows
```yaml
pipeline-watchdog:
image: ghcr.io/insight-platform/pipeline-watchdog-<arh_name>:main
restart: unless-stopped
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./config.yml:/app/config.yml
environment:
- LOGLEVEL=INFO
- CONFIG_FILE_PATH=/app/config.yml
```
## Sample
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.
Expand Down
6 changes: 3 additions & 3 deletions src/pipeline_watchdog/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def process_action(


async def watch_queue(docker_client: DockerClient, buffer: str, config: QueueConfig):
await asyncio.sleep(config.cooldown)
await asyncio.sleep(config.polling_interval)

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


async def watch_egress(docker_client: DockerClient, buffer: str, config: FlowConfig):
await asyncio.sleep(config.cooldown)
await asyncio.sleep(config.polling_interval)

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


async def watch_ingress(docker_client: DockerClient, buffer: str, config: FlowConfig):
await asyncio.sleep(config.cooldown)
await asyncio.sleep(config.polling_interval)

while True:
content = await get_metrics(buffer)
Expand Down
18 changes: 12 additions & 6 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ async def test_watch_queue(
await watch_queue(docker_client, watch_config.buffer, watch_config.queue)
except asyncio.CancelledError:
sleep_mock.assert_has_awaits(
[call(watch_config.queue.cooldown), call(watch_config.queue.cooldown)]
[
call(watch_config.queue.polling_interval),
call(watch_config.queue.cooldown),
]
)
pass

Expand Down Expand Up @@ -324,7 +327,7 @@ async def test_watch_queue_empty(
except asyncio.CancelledError:
sleep_mock.assert_has_awaits(
[
call(watch_config.queue.cooldown),
call(watch_config.queue.polling_interval),
call(watch_config.queue.polling_interval),
]
)
Expand Down Expand Up @@ -359,7 +362,10 @@ async def test_watch_egress(
await watch_egress(docker_client, watch_config.buffer, watch_config.egress)
except asyncio.CancelledError:
sleep_mock.assert_has_awaits(
[call(watch_config.egress.cooldown), call(watch_config.egress.cooldown)]
[
call(watch_config.egress.polling_interval),
call(watch_config.egress.cooldown),
]
)
pass

Expand Down Expand Up @@ -395,7 +401,7 @@ async def test_watch_egress_message_just_sent(
except asyncio.CancelledError:
sleep_mock.assert_has_awaits(
[
call(watch_config.egress.cooldown),
call(watch_config.egress.polling_interval),
call(watch_config.egress.polling_interval),
]
)
Expand Down Expand Up @@ -433,7 +439,7 @@ async def test_watch_ingress(
except asyncio.CancelledError:
sleep_mock.assert_has_awaits(
[
call(watch_config.ingress.cooldown),
call(watch_config.ingress.polling_interval),
call(watch_config.ingress.cooldown),
]
)
Expand Down Expand Up @@ -475,7 +481,7 @@ async def test_watch_ingress_message_just_received(
except asyncio.CancelledError:
sleep_mock.assert_has_awaits(
[
call(watch_config.ingress.cooldown),
call(watch_config.ingress.polling_interval),
call(watch_config.ingress.polling_interval),
]
)
Expand Down

0 comments on commit e0b0782

Please sign in to comment.