Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana integration #81

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
2a4dce8
Add to_dict method to metrics.
Jul 1, 2022
dc2d84a
Add to_dict function to metrics.
Jul 1, 2022
b19e62b
Merge branch 'master' into configure_metrics_with_yaml
Jul 1, 2022
93cbbd2
Merge in master.
Jul 1, 2022
99a4777
Add comments to new methods.
Jul 1, 2022
ca9f260
Remove leftover TODO
Jul 1, 2022
54b80fe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2022
bebc01d
Add from_dict to metrics and corresponding tests.
Jul 6, 2022
b5572a2
Add from_dict to metrics and corresponding tests.
Jul 6, 2022
40405b4
Merge branch 'configure_metrics_with_yaml' of github.com:synthesized-…
Jul 6, 2022
7bb61c4
Remove redundant function.
Jul 6, 2022
7acb26c
Add metrics_from_yaml and metrics_yaml_dump and corresponding tests.
Jul 7, 2022
ad3ad89
Add missing yaml dependency.
Jul 7, 2022
207f816
Add types-pyyaml to test requirements.
Jul 7, 2022
87856b6
Add types-pyyaml to requirements for mypy purposes.
Jul 7, 2022
d9cfcc7
Add types-pyyaml to requirements for mypy purposes.
Jul 7, 2022
c62dab2
Corrected typing error.
Jul 7, 2022
123b824
Add pyyaml stubs to precommit mypy + ignore pandas
simonhkswan Jul 7, 2022
8ec27b9
Improve YAML related tests.
Jul 7, 2022
ce8d81c
Improve YAML related tests.
Jul 7, 2022
e15de0d
Add adapter classes for metrics.
Jul 11, 2022
b14bcd4
Add adapter classes for metrics.
Jul 11, 2022
633c785
Merge with master
Jul 14, 2022
9a2b4ea
Add plotting functions
Jul 15, 2022
7f7cf9a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2022
43507bf
Fixed metrics_usage tests.
Jul 15, 2022
da9b766
Fixed metrics_usage tests.
Jul 15, 2022
3304c86
Fixed metrics_usage tests.
Jul 15, 2022
d1c8422
Update pyproject.toml
simonhkswan Jul 15, 2022
31cb4cd
Update pyproject.toml
simonhkswan Jul 15, 2022
61256a5
Update pyproject.toml
Jul 15, 2022
f817d92
Merge branch 'plotting_metrics' of github.com:synthesized-io/insight …
Jul 15, 2022
6d04e7c
Update pyproject.toml
Jul 15, 2022
d9993aa
Remove pkg_resources dependency.
Jul 15, 2022
2da774b
Fix code smells.
Jul 15, 2022
8d64734
Rewrite continuous and discrete plotting functions.
Jul 18, 2022
5739615
Fix code smells.
Jul 18, 2022
0f04431
Add docstrings.
Jul 20, 2022
e93de90
Update pyproject.toml
Jul 21, 2022
a0b91ec
Add sqlalchemy schema
Jul 27, 2022
8a8cd45
Add the first tables to the database
Jul 27, 2022
a7e4978
Merge with main
Jul 28, 2022
a974a63
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 28, 2022
367860b
Update pyproject.toml
Jul 28, 2022
d8d8c86
Update requirements.txt
Jul 28, 2022
f3cbe69
Update package requirements
Jul 28, 2022
d6fae79
Merge branch 'database_addition' of github.com:synthesized-io/insight…
Jul 28, 2022
951bf64
Remove postgres-data
Jul 28, 2022
acdbccd
Update .gitignore
Jul 28, 2022
54261c6
Update pyproject.toml
Jul 28, 2022
e91b370
Update pyproject.toml
Jul 28, 2022
c4ad428
Merge remote-tracking branch 'origin' into database_addition
Jul 28, 2022
47181db
Update Dockerfile and requirements
Hebruwu Jul 28, 2022
48381c0
Make metrics write their results into the database.
Hebruwu Aug 3, 2022
4220e58
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 3, 2022
1c14aaf
Make the database fill in all of its fields.
Hebruwu Aug 3, 2022
cb10d1e
Make the database fill in all of its fields.
Hebruwu Aug 3, 2022
ffe1217
Extract tests from seperate folder
Hebruwu Aug 3, 2022
7171e32
fix circular import
Hebruwu Aug 3, 2022
ddc9cb4
Add metric tests to a seperate folder
Hebruwu Aug 3, 2022
f8aa808
Introduce a version constant
Hebruwu Aug 3, 2022
25813c2
Add tests for the databse.
Hebruwu Aug 4, 2022
63ff050
Make sure the database is cleaned after each run.
Hebruwu Aug 4, 2022
d5148fe
Add grafana integration.
Hebruwu Aug 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ env.bak/
venv.bak/
version.py
setup.cfg
postgres-data

# Spyder project settings
.spyderproject
Expand Down
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ repos:
hooks:
- id: mypy
files: src
additional_dependencies: [numpy>=1.21, types-PyYAML]
additional_dependencies:
- numpy>=1.21
- sqlalchemy[mypy]
args: [--install-types, --non-interactive]
# Note that using the --install-types is problematic if running in
# parallel as mutating the pre-commit env at runtime breaks cache.
Expand Down
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM python:3.8 as base
RUN apt-get update
RUN pip install -U pip setuptools wheel

FROM base as builder
WORKDIR /build
RUN pip install build setuptools_scm
COPY pyproject.toml README.md /build/
COPY .git /build/.git
COPY src /build/src
RUN python -m build -nw --outdir /dist

FROM base
WORKDIR /code
RUN apt-get install libpq-dev postgresql-client -y
COPY requirements.txt requirements.txt
RUN pip install -U pip wheel
RUN pip install -r requirements.txt
COPY alembic.ini /code/
COPY migrations /code/migrations
COPY scripts /code/scripts
COPY --from=builder /dist/*.whl /dist/
RUN pip install /dist/*.whl
CMD /bin/bash
105 changes: 105 additions & 0 deletions alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# A generic, single database configuration.

[alembic]
# path to migration scripts
script_location = migrations

# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
# for all available tokens
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s

# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
prepend_sys_path = .

# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the python-dateutil library that can be
# installed by adding `alembic[tz]` to the pip requirements
# string value is passed to dateutil.tz.gettz()
# leave blank for localtime
# timezone =

# max length of characters to apply to the
# "slug" field
# truncate_slug_length = 40

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false

# version location specification; This defaults
# to migrations/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "version_path_separator" below.
# version_locations = %(here)s/bar:%(here)s/bat:migrations/versions

# version path separator; As mentioned above, this is the character used to split
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
# Valid values for version_path_separator are:
#
# version_path_separator = :
# version_path_separator = ;
# version_path_separator = space
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.

# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8

sqlalchemy.url = postgresql+psycopg2://{POSTGRES_USER}:{POSTGRES_PASSWORD}@postgres:5432


[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples

# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME

# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
41 changes: 41 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
version: '3.7'
services:
eval:
build: .
depends_on:
- postgres
tty: true
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
postgres:
image: postgres:latest
restart: always
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
logging:
options:
max-size: 10m
max-file: "3"
ports:
- "5432:5432"
volumes:
- "./postgres-data:/var/lib/postgresql/data"
grafana:
image: grafana/grafana-oss
restart: always
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
logging:
options:
max-size: 10m
max-file: "3"
ports:
- "3000:3000"
volumes:
- "./grafana:/etc/grafana"
- "./grafana-data:/var/lib/grafana"
...
Loading