Skip to content

Commit

Permalink
Manager system monitor, persist to file, tests, misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Rogerson committed Sep 15, 2023
1 parent 664c10a commit aedc94d
Show file tree
Hide file tree
Showing 26 changed files with 1,553 additions and 278 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/manager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Manager validation

on:
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies with Poetry
run: |
poetry install --no-interaction
working-directory: manager

- name: Run pytest
run: make test
working-directory: manager
2 changes: 1 addition & 1 deletion .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
curl -f http://localhost/service/ethereum-reader/status
curl -f http://localhost/service/manager/status
curl -f http://localhost/service/boyar/status
curl -f http://localhost/service/manager/status
- name: Cleanup container
if: always()
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ config.json
node_modules/
__pycache__/
ignore
uv.sh
uv.sh

.env
log.txt
160 changes: 160 additions & 0 deletions manager/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
26 changes: 26 additions & 0 deletions manager/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[FORMAT]
max-line-length=160


[MESSAGES CONTROL]
disable=
invalid-name,
ungrouped-imports,
logging-fstring-interpolation,
import-outside-toplevel,
too-few-public-methods,
raise-missing-from,
fixme,
too-many-instance-attributes,
missing-module-docstring,
consider-using-f-string

[SIMILARITIES]
ignore-imports=yes
ignore-signatures=yes
ignore-comments=yes
min-similarity-lines=5
min-public-methods=1

[MASTER]
init-hook='import sys; sys.path.append("./src")'
13 changes: 13 additions & 0 deletions manager/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"njpwerner.autodocstring",
"ms-python.pylint",
"ms-python.flake8",
"ms-python.mypy-type-checker",
"ms-python.black-formatter",
"ms-python.isort",
]
}
56 changes: 56 additions & 0 deletions manager/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"editor.detectIndentation": true,
"editor.formatOnSave": true,
"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 160,
"python.analysis.typeCheckingMode": "off", // Disable Pylance typechecking since we are using MyPy
"python.languageServer": "Pylance",
"python.analysis.autoSearchPaths": true,
// Pylint
"pylint.args": [
"--rcfile",
"${workspaceFolder}/.pylintrc"
],
"pylint.path": [
".venv/bin/pylint"
],
// Black
"black-formatter.args": [
"--config=pyproject.toml"
],
// MyPy
"mypy-type-checker.args": [
"--config-file=setup.cfg",
// https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules
"--namespace-packages",
"--explicit-package-bases"
],
"python.analysis.extraPaths": [
"src",
".venv/lib/python3.9/site-packages"
],
// Flake8
"flake8.args": [
"--config=setup.cfg"
],
// iSort
"isort.args": [
"-sp ./setup.cfg"
],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.defaultFormatter": "ms-python.black-formatter",
"isort.args": [
"--profile",
"black"
],
},
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"-s"
],
"explorer.compactFolders": false
}
22 changes: 22 additions & 0 deletions manager/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-include .makerc
export

install:
poetry install

shell:
poetry shell

typecheck:
poetry run mypy src --config-file=setup.cfg --namespace-packages --explicit-package-bases

format:
poetry run black --config=pyproject.toml src
poetry run isort -sp=setup.cfg src

lint:
poetry run pylint --rcfile ./.pylintrc src
poetry run flake8 --config=setup.cfg src

test:
poetry run pytest -s
11 changes: 8 additions & 3 deletions manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
WIP

## What's this?

Python manager for Orbs v3 node validator

## what it does
### What does it do?

- updates the deployment folder upon new releases
- update itself
- ensure cron is up
- ensure docker is up
- ensures recovery is up TBD
- exposes status

## TODO:
status json
## Developing

1. `make install` will install dependencies
2. `make shell` will activate virtual environment
3. `make test` runs unit tests
Loading

0 comments on commit aedc94d

Please sign in to comment.