Skip to content

Commit 7bc7296

Browse files
authored
Merge pull request #280 from flask-dashboard/development
Development
2 parents 1a9633e + c0d3604 commit 7bc7296

File tree

105 files changed

+2369
-657
lines changed

Some content is hidden

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

105 files changed

+2369
-657
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,12 @@ If you run into trouble migrating from version 1.X.X to version 2.0.0, this site
106106
![Screenshot 4](/docs/img/ss4.png)
107107
![Screenshot 5](/docs/img/ss5.png)
108108

109+
## Development
110+
If you like our project, and willing to contribute, you can get started by cloning it and then running the following command:
111+
112+
. ./config/install.sh
113+
114+
For more information, check [this page](https://flask-monitoringdashboard.readthedocs.io/en/latest/developing.html).
115+
109116
## License
110-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
117+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

config/.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 19.3b0
4+
hooks:
5+
- id: black
6+
args: [-S, --line-length=100]
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v2.3.0
9+
hooks:
10+
- id: flake8
11+
args: ['--max-line-length=100', '--ignore=F401, W503']
12+
- repo: local
13+
hooks:
14+
- id: version_increase
15+
name: version_increase
16+
description: Increase version in constants.json
17+
entry: env/bin/python config/increase_version.py
18+
language: python
19+
files: ^$
20+
args: ['patch']
21+
always_run: true

config/increase_version.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python
2+
"""
3+
Run this script to increase the version defined in flask_monitoringdashboard/constants.py
4+
The script can use the arguments 'major', 'minor', or 'patch' to increase the corresponding
5+
version. If no argument is specified, the 'patch' version is increased
6+
"""
7+
import argparse
8+
import json
9+
import sys
10+
import requests
11+
import os
12+
import subprocess
13+
14+
HERE = os.path.dirname(os.path.realpath(__file__))
15+
FILE = os.path.abspath(os.path.join(HERE, '..', 'flask_monitoringdashboard', 'constants.json'))
16+
17+
18+
def main(argv=None):
19+
parser = argparse.ArgumentParser()
20+
parser.add_argument("type", nargs="?", default="patch")
21+
args = parser.parse_args(argv)
22+
23+
options = ['major', 'minor', 'patch']
24+
if args.type not in options:
25+
print('Incorrect argument type: {}. Options are: {}'.format(args.type, ', '.join(options)))
26+
return 1
27+
28+
branch = (
29+
subprocess.Popen("git rev-parse --abbrev-ref HEAD", shell=True, stdout=subprocess.PIPE)
30+
.stdout.read()
31+
.decode('utf-8')
32+
.replace('\n', '')
33+
)
34+
35+
if branch != 'development':
36+
print('Only increasing version on development, not on branch "{}"'.format(branch))
37+
return 0
38+
39+
index = options.index(args.type)
40+
41+
# read current data
42+
with open(FILE, 'r', encoding='UTF-8') as json_file:
43+
constants = json.load(json_file)
44+
45+
# retrieve latest version
46+
response = requests.get('https://pypi.org/pypi/Flask-MonitoringDashboard/json')
47+
pypi_json = response.json()
48+
version = pypi_json['info']['version'].split('.')
49+
50+
version[index] = int(version[index]) + 1
51+
for i in range(index + 1, len(version)): # set version after updated version to 0
52+
version[i] = 0
53+
constants['version'] = '.'.join(str(v) for v in version)
54+
print('Increased {} version to {}'.format(args.type, constants['version']))
55+
56+
# write new version
57+
with open(FILE, 'w', encoding='UTF-8') as json_file:
58+
json.dump(constants, json_file, indent=4, separators=(',', ': '))
59+
60+
return 0
61+
62+
63+
if __name__ == '__main__':
64+
sys.exit(main())

config/install.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Run from the root directory with ./config/install.sh
2+
# Note that pre-commit is not in the requirements.txt, as we don't want this to ship with the package.
3+
4+
python -m venv env
5+
source env/bin/activate
6+
pip install -r requirements-dev.txt
7+
cd config || exit
8+
pre-commit install
9+
cd ..

docs/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
This project adheres to `Semantic Versioning <http://semver.org/>`_.
66
Please note that the changes before version 1.10.0 have not been documented.
77

8+
v3.0.6
9+
----------
10+
Changed
11+
12+
- Removed profiler feature from monitoring level 2
13+
- Added outlier detection feature to monitoring level 3
14+
- Configurable profiler sampling period, with 5 ms default
15+
- Implemented an in-memory cache for performance improvements
16+
817
v3.0.0
918
----------
1019
Changed

docs/conf.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# full list see the documentation:
77
# http://www.sphinx-doc.org/en/stable/config
88
import datetime
9+
910
# -- Path setup --------------------------------------------------------------
1011

1112
# If extensions (or modules to document with autodoc) are in another directory,
@@ -15,6 +16,7 @@
1516
import os
1617
import sys
1718
import json
19+
1820
sys.path.insert(0, os.path.abspath('..'))
1921
sys.path.insert(0, os.path.abspath('../flask-monitoringdashboard'))
2022

@@ -88,9 +90,7 @@
8890
# further. For a list of options available for each theme, see the
8991
# documentation.
9092
#
91-
html_theme_options = {
92-
'github_fork': 'flask-dashboard/Flask-MonitoringDashboard'
93-
}
93+
html_theme_options = {'github_fork': 'flask-dashboard/Flask-MonitoringDashboard'}
9494

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

@@ -122,15 +122,12 @@
122122
# The paper size ('letterpaper' or 'a4paper').
123123
#
124124
'papersize': 'letterpaper',
125-
126125
# The font size ('10pt', '11pt' or '12pt').
127126
#
128127
'pointsize': '11pt',
129-
130128
# Additional stuff for the LaTeX preamble.
131129
#
132130
'preamble': '',
133-
134131
# Latex figure (float) alignment
135132
#
136133
'figure_align': 'htbp',
@@ -140,8 +137,13 @@
140137
# (source start file, target name, title,
141138
# author, documentclass [howto, manual, or own class]).
142139
latex_documents = [
143-
(master_doc, 'Flask-MonitoringDashboard.tex', 'Flask-MonitoringDashboard Documentation',
144-
author, 'manual'),
140+
(
141+
master_doc,
142+
'Flask-MonitoringDashboard.tex',
143+
'Flask-MonitoringDashboard Documentation',
144+
author,
145+
'manual',
146+
)
145147
]
146148

147149

@@ -150,8 +152,13 @@
150152
# One entry per manual page. List of tuples
151153
# (source start file, name, description, authors, manual section).
152154
man_pages = [
153-
(master_doc, 'flask-monitoringdashboard', 'Flask-MonitoringDashboard Documentation',
154-
[author], 1)
155+
(
156+
master_doc,
157+
'flask-monitoringdashboard',
158+
'Flask-MonitoringDashboard Documentation',
159+
[author],
160+
1,
161+
)
155162
]
156163

157164

@@ -161,9 +168,15 @@
161168
# (source start file, target name, title, author,
162169
# dir menu entry, description, category)
163170
texinfo_documents = [
164-
(master_doc, 'Flask-MonitoringDashboard', 'Flask-MonitoringDashboard Documentation',
165-
author, 'Flask-MonitoringDashboard', 'One line description of project.',
166-
'Miscellaneous'),
171+
(
172+
master_doc,
173+
'Flask-MonitoringDashboard',
174+
'Flask-MonitoringDashboard Documentation',
175+
author,
176+
'Flask-MonitoringDashboard',
177+
'One line description of project.',
178+
'Miscellaneous',
179+
)
167180
]
168181

169182

docs/developing.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ this page shows FMD from the point of view of the developer. We explain the
1010
architecture of the project, take a look at the main components, and then
1111
present some useful tools that we use during development.
1212

13+
Getting started
14+
----------------
15+
In order to get started with the environment of the FMD, run the following script
16+
17+
.. code-block:: bash
18+
19+
. ./config/install.sh
20+
21+
Note the '. ' before the script. This will activate your virtual environment. This script is
22+
responsible for setting up the project, and installing the following pre-commit hooks:
23+
24+
- `Black`_: for automatic formatting the code. Note that we use a width-length of 100 characters.
25+
- `Flake8`_: for checking style error.
26+
- Auto increase the Python version. This can either be a major, minor, or patch version increase. For more info, see
27+
the Versions-section below.
28+
1329
Architecture
1430
--------------
1531

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

0 commit comments

Comments
 (0)