Skip to content

Commit

Permalink
Merge pull request #280 from flask-dashboard/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
bogdanp05 committed Nov 29, 2019
2 parents 1a9633e + c0d3604 commit 7bc7296
Show file tree
Hide file tree
Showing 105 changed files with 2,369 additions and 657 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,12 @@ If you run into trouble migrating from version 1.X.X to version 2.0.0, this site
![Screenshot 4](/docs/img/ss4.png)
![Screenshot 5](/docs/img/ss5.png)

## Development
If you like our project, and willing to contribute, you can get started by cloning it and then running the following command:

. ./config/install.sh

For more information, check [this page](https://flask-monitoringdashboard.readthedocs.io/en/latest/developing.html).

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
21 changes: 21 additions & 0 deletions config/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/psf/black
rev: 19.3b0
hooks:
- id: black
args: [-S, --line-length=100]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: flake8
args: ['--max-line-length=100', '--ignore=F401, W503']
- repo: local
hooks:
- id: version_increase
name: version_increase
description: Increase version in constants.json
entry: env/bin/python config/increase_version.py
language: python
files: ^$
args: ['patch']
always_run: true
64 changes: 64 additions & 0 deletions config/increase_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python
"""
Run this script to increase the version defined in flask_monitoringdashboard/constants.py
The script can use the arguments 'major', 'minor', or 'patch' to increase the corresponding
version. If no argument is specified, the 'patch' version is increased
"""
import argparse
import json
import sys
import requests
import os
import subprocess

HERE = os.path.dirname(os.path.realpath(__file__))
FILE = os.path.abspath(os.path.join(HERE, '..', 'flask_monitoringdashboard', 'constants.json'))


def main(argv=None):
parser = argparse.ArgumentParser()
parser.add_argument("type", nargs="?", default="patch")
args = parser.parse_args(argv)

options = ['major', 'minor', 'patch']
if args.type not in options:
print('Incorrect argument type: {}. Options are: {}'.format(args.type, ', '.join(options)))
return 1

branch = (
subprocess.Popen("git rev-parse --abbrev-ref HEAD", shell=True, stdout=subprocess.PIPE)
.stdout.read()
.decode('utf-8')
.replace('\n', '')
)

if branch != 'development':
print('Only increasing version on development, not on branch "{}"'.format(branch))
return 0

index = options.index(args.type)

# read current data
with open(FILE, 'r', encoding='UTF-8') as json_file:
constants = json.load(json_file)

# retrieve latest version
response = requests.get('https://pypi.org/pypi/Flask-MonitoringDashboard/json')
pypi_json = response.json()
version = pypi_json['info']['version'].split('.')

version[index] = int(version[index]) + 1
for i in range(index + 1, len(version)): # set version after updated version to 0
version[i] = 0
constants['version'] = '.'.join(str(v) for v in version)
print('Increased {} version to {}'.format(args.type, constants['version']))

# write new version
with open(FILE, 'w', encoding='UTF-8') as json_file:
json.dump(constants, json_file, indent=4, separators=(',', ': '))

return 0


if __name__ == '__main__':
sys.exit(main())
9 changes: 9 additions & 0 deletions config/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Run from the root directory with ./config/install.sh
# Note that pre-commit is not in the requirements.txt, as we don't want this to ship with the package.

python -m venv env
source env/bin/activate
pip install -r requirements-dev.txt
cd config || exit
pre-commit install
cd ..
9 changes: 9 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
This project adheres to `Semantic Versioning <http://semver.org/>`_.
Please note that the changes before version 1.10.0 have not been documented.

v3.0.6
----------
Changed

- Removed profiler feature from monitoring level 2
- Added outlier detection feature to monitoring level 3
- Configurable profiler sampling period, with 5 ms default
- Implemented an in-memory cache for performance improvements

v3.0.0
----------
Changed
Expand Down
39 changes: 26 additions & 13 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config
import datetime

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
Expand All @@ -15,6 +16,7 @@
import os
import sys
import json

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../flask-monitoringdashboard'))

Expand Down Expand Up @@ -88,9 +90,7 @@
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
'github_fork': 'flask-dashboard/Flask-MonitoringDashboard'
}
html_theme_options = {'github_fork': 'flask-dashboard/Flask-MonitoringDashboard'}

html_sidebars = {'**': ['globaltoc.html', 'searchbox.html', 'sourcelink.html']}

Expand Down Expand Up @@ -122,15 +122,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
'pointsize': '11pt',

# Additional stuff for the LaTeX preamble.
#
'preamble': '',

# Latex figure (float) alignment
#
'figure_align': 'htbp',
Expand All @@ -140,8 +137,13 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Flask-MonitoringDashboard.tex', 'Flask-MonitoringDashboard Documentation',
author, 'manual'),
(
master_doc,
'Flask-MonitoringDashboard.tex',
'Flask-MonitoringDashboard Documentation',
author,
'manual',
)
]


Expand All @@ -150,8 +152,13 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'flask-monitoringdashboard', 'Flask-MonitoringDashboard Documentation',
[author], 1)
(
master_doc,
'flask-monitoringdashboard',
'Flask-MonitoringDashboard Documentation',
[author],
1,
)
]


Expand All @@ -161,9 +168,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Flask-MonitoringDashboard', 'Flask-MonitoringDashboard Documentation',
author, 'Flask-MonitoringDashboard', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
'Flask-MonitoringDashboard',
'Flask-MonitoringDashboard Documentation',
author,
'Flask-MonitoringDashboard',
'One line description of project.',
'Miscellaneous',
)
]


Expand Down
20 changes: 19 additions & 1 deletion docs/developing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ this page shows FMD from the point of view of the developer. We explain the
architecture of the project, take a look at the main components, and then
present some useful tools that we use during development.

Getting started
----------------
In order to get started with the environment of the FMD, run the following script

.. code-block:: bash
. ./config/install.sh
Note the '. ' before the script. This will activate your virtual environment. This script is
responsible for setting up the project, and installing the following pre-commit hooks:

- `Black`_: for automatic formatting the code. Note that we use a width-length of 100 characters.
- `Flake8`_: for checking style error.
- Auto increase the Python version. This can either be a major, minor, or patch version increase. For more info, see
the Versions-section below.

Architecture
--------------

Expand Down Expand Up @@ -161,4 +177,6 @@ The following tools are used for helping the development of the Dashboard:
.. _`Semantic-versioning`: https://semver.org/
.. _`SQLAlchemy`: https://www.sqlalchemy.org/
.. _Sphinx: www.sphinx-doc.org
.. _ReadTheDocs: http://flask-monitoringdashboard.readthedocs.io
.. _ReadTheDocs: http://flask-monitoringdashboard.readthedocs.io
.. _Black: https://github.com/psf/black
.. _Flake8: https://pypi.org/project/flake8

0 comments on commit 7bc7296

Please sign in to comment.