Skip to content

Commit 540968c

Browse files
authored
Merge pull request #5 from GabrielSalla/organize-files
Move main file to src
2 parents d3138d9 + d31a604 commit 540968c

File tree

93 files changed

+439
-432
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+439
-432
lines changed

.coveragerc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
[report]
2+
omit =
3+
src/_monitors/*
4+
src/_monitors_load/*
5+
src/tmp/*
6+
src/main.py
7+
src/utils/log.py
28
exclude_lines =
39
pragma: no cover
410
if TYPE_CHECKING:

.github/workflows/ci.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
steps:
1616
- name: Checkout Repository
1717
uses: actions/checkout@v4
18-
- name: Install Docker
19-
run: sudo apt install docker docker-compose
18+
# - name: Install Docker
19+
# run: sudo apt install docker-compose
2020
- name: Build image
2121
run: make build-dev
2222
- name: Save Docker image
@@ -34,8 +34,8 @@ jobs:
3434
steps:
3535
- name: Checkout Repository
3636
uses: actions/checkout@v4
37-
- name: Install Docker
38-
run: sudo apt install docker docker-compose
37+
# - name: Install Docker
38+
# run: sudo apt install docker-compose
3939
- name: Download Docker image
4040
uses: actions/download-artifact@v4
4141
with:
@@ -53,8 +53,8 @@ jobs:
5353
steps:
5454
- name: Checkout Repository
5555
uses: actions/checkout@v4
56-
- name: Install Docker
57-
run: sudo apt install docker docker-compose
56+
# - name: Install Docker
57+
# run: sudo apt install docker-compose
5858
- name: Download Docker image
5959
uses: actions/download-artifact@v4
6060
with:
@@ -72,8 +72,8 @@ jobs:
7272
steps:
7373
- name: Checkout Repository
7474
uses: actions/checkout@v4
75-
- name: Install Docker
76-
run: sudo apt install docker docker-compose
75+
# - name: Install Docker
76+
# run: sudo apt install docker-compose
7777
- name: Download Docker image
7878
uses: actions/download-artifact@v4
7979
with:

Makefile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
build-dev:
2-
docker-compose -f docker-compose-dev.yaml build sentinela-dev
2+
docker compose -f docker-compose-dev.yaml build sentinela-dev
33

44
pull-dev:
5-
docker-compose -f docker-compose-dev.yaml pull postgres motoserver
5+
docker compose -f docker-compose-dev.yaml pull postgres motoserver
66

77
migrate-dev:
8-
docker-compose -f docker-compose-dev.yaml run --rm --service-ports sentinela-dev alembic upgrade head
8+
docker compose -f docker-compose-dev.yaml run --rm --service-ports sentinela-dev alembic upgrade head
99

1010
run-dev:
11-
docker-compose -f docker-compose-dev.yaml up sentinela-dev
11+
docker compose -f docker-compose-dev.yaml up sentinela-dev
1212

1313
run-shell-dev:
14-
docker-compose -f docker-compose-dev.yaml run --rm --service-ports sentinela-dev /bin/sh
14+
docker compose -f docker-compose-dev.yaml run --rm --service-ports sentinela-dev /bin/sh
1515

1616
test-dev:
17-
docker-compose -f docker-compose-dev.yaml run --rm sentinela-dev pytest
17+
docker compose -f docker-compose-dev.yaml run --rm sentinela-dev pytest
1818

1919
down-dev:
20-
docker-compose -f docker-compose-dev.yaml down
20+
docker compose -f docker-compose-dev.yaml down
2121

2222
build-local:
23-
docker-compose -f docker-compose-local.yaml build sentinela-local
23+
docker compose -f docker-compose-local.yaml build sentinela-local
2424

2525
migrate-local:
26-
docker-compose -f docker-compose-local.yaml run --rm --service-ports sentinela-local alembic upgrade head
26+
docker compose -f docker-compose-local.yaml run --rm --service-ports sentinela-local alembic upgrade head
2727

2828
run-local:
29-
docker-compose -f docker-compose-local.yaml up sentinela-local
29+
docker compose -f docker-compose-local.yaml up sentinela-local
3030

3131
down-local:
32-
docker-compose -f docker-compose-local.yaml down
32+
docker compose -f docker-compose-local.yaml down
3333

3434
linter:
35-
docker-compose -f docker-compose-dev.yaml run --rm --no-deps sentinela-dev flake8 src/ tests/ monitor_utils/ internal_monitors/ sample_monitors/ tools/ __main__.py
35+
docker compose -f docker-compose-dev.yaml run --rm --no-deps sentinela-dev flake8 src/ tests/ internal_monitors/ sample_monitors/ tools/
3636

3737
mypy:
38-
docker-compose -f docker-compose-dev.yaml run --rm --no-deps sentinela-dev mypy --install-types --non-interactive src/ tests/ monitor_utils/ internal_monitors/ sample_monitors/ tools/ __main__.py
38+
docker compose -f docker-compose-dev.yaml run --rm --no-deps sentinela-dev mypy --install-types --non-interactive src/ tests/ internal_monitors/ sample_monitors/ tools/

configs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Flag to enable the sample monitors
22
load_sample_monitors: true
3-
# Path relative to the main file where the sample monitors are stored
3+
# Path relative to the project root, where the sample monitors are stored
44
sample_monitors_path: sample_monitors
5-
# Path relative to the main file where the internal monitors are stored
5+
# Path relative to the project root, where the internal monitors are stored
66
internal_monitors_path: internal_monitors
77
# Schedule to reload monitors from the database
88
monitors_load_schedule: "*/5 * * * *"

docker-compose-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ services:
3535
depends_on:
3636
- postgres
3737
- motoserver
38-
command: python3 . controller executor
38+
command: python3 src/main.py controller executor

docker-compose-local.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ services:
3030
- ./internal_monitors:/app/internal_monitors:Z
3131
depends_on:
3232
- postgres
33-
command: python3 . controller executor
33+
command: python3 src/main.py controller executor

docs/usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ The deployment should set the necessary environment variables for all the instan
6464
Controllers and executors can be started passing them as parameters.
6565
```shell
6666
# Controller
67-
python3 . controller
67+
python3 src/main.py controller
6868

6969
# Executor
70-
python3 . executor
70+
python3 src/main.py executor
7171
```

internal_monitors/active_notification_alert_solved/active_notification_alert_solved.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Any, TypedDict, cast
22

3+
from databases import query_application
4+
from models import Notification, NotificationStatus
35
from monitor_utils import (
46
AgeRule,
57
AlertOptions,
@@ -10,9 +12,6 @@
1012
read_file,
1113
)
1214

13-
from src.databases import query_application
14-
from src.models import Notification, NotificationStatus
15-
1615
monitor_options = MonitorOptions(
1716
update_cron="*/5 * * * *",
1817
search_cron="*/30 * * * *",

internal_monitors/monitor_long_time_queued/monitor_long_time_queued.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from typing import Any, TypedDict, cast
22

3+
from configs import configs
4+
from databases import query_application
5+
from models import Monitor
36
from monitor_utils import (
47
AlertOptions,
58
IssueOptions,
@@ -10,10 +13,6 @@
1013
read_file,
1114
)
1215

13-
from src.configs import configs
14-
from src.databases import query_application
15-
from src.models import Monitor
16-
1716
monitor_options = MonitorOptions(
1817
update_cron="* * * * *",
1918
search_cron="*/5 * * * *",

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ max-line-length = 100
5050
line-length = 100
5151

5252
[tool.mypy]
53+
mypy_path = "src"
5354
ignore_missing_imports = true
5455
warn_return_any = true
5556
check_untyped_defs = true
@@ -59,13 +60,14 @@ module = "tests.*"
5960
disable_error_code = ["arg-type", "empty-body", "misc", "list-item"]
6061

6162
[tool.isort]
62-
src_paths = ["src", "tests", "__main__.py"]
63+
src_paths = ["src", "tests"]
6364
skip = ["alembic", "tmp", "_monitors", "_monitors_load"]
6465
line_length = 100
6566
include_trailing_comma = true
6667
multi_line_output = 3
6768

6869
[tool.pytest.ini_options]
70+
pythonpath = "src"
6971
testpaths = "tests"
7072
addopts = "-rf --show-capture=all --color=yes --cov=src --cov-report=term-missing --cov-fail-under=100"
7173

0 commit comments

Comments
 (0)