Skip to content

Commit

Permalink
black formatting (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
MateoLostanlen authored Jul 18, 2022
1 parent 33c928f commit 6565aaa
Show file tree
Hide file tree
Showing 20 changed files with 237 additions and 190 deletions.
16 changes: 10 additions & 6 deletions .github/validate_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
starting_year = 2020
current_year = datetime.now().year

year_options = [f"{current_year}"] + [f"{year}-{current_year}" for year in range(starting_year, current_year)]
year_options = [f"{current_year}"] + [
f"{year}-{current_year}" for year in range(starting_year, current_year)
]
copyright_notices = [
[f"# Copyright (C) {year_str}, Pyronear.\n"]
for year_str in year_options
[f"# Copyright (C) {year_str}, Pyronear.\n"] for year_str in year_options
]
license_notice = [
"# This program is licensed under the Apache License version 2.\n",
"# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.\n"
"# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.\n",
]

# Define all header options
Expand All @@ -38,7 +39,9 @@ def main():

# For every python file in the repository
for folder in FOLDERS:
for source_path in Path(__file__).parent.parent.joinpath(folder).rglob('**/*.py'):
for source_path in (
Path(__file__).parent.parent.joinpath(folder).rglob("**/*.py")
):
if source_path.name not in IGNORED_FILES:
# Parse header
header_length = max(len(option) for option in HEADERS)
Expand All @@ -50,7 +53,8 @@ def main():
break
# Validate it
if not any(
"".join(current_header[:min(len(option), len(current_header))]) == "".join(option)
"".join(current_header[: min(len(option), len(current_header))])
== "".join(option)
for option in HEADERS
):
invalid_files.append(source_path)
Expand Down
52 changes: 26 additions & 26 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

# -- Project information -----------------------------------------------------

master_doc = 'index'
project = 'pyroengine'
copyright = '2019, Pyronear Contributors'
author = 'Pyronear Contributors'
master_doc = "index"
project = "pyroengine"
copyright = "2019, Pyronear Contributors"
author = "Pyronear Contributors"

# The full version, including alpha/beta/rc tags
version = pyroengine.__version__
release = pyroengine.__version__ + '-git'
release = pyroengine.__version__ + "-git"


# -- General configuration ---------------------------------------------------
Expand All @@ -40,21 +40,21 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax'
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx.ext.autosummary",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
]

napoleon_use_ivar = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -63,37 +63,37 @@


# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
highlight_language = 'python3'
pygments_style = "sphinx"
highlight_language = "python3"

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
'collapse_navigation': False,
'display_version': True,
'logo_only': True,
"collapse_navigation": False,
"display_version": True,
"logo_only": True,
}

html_logo = '_static/img/pyronear-logo-dark.png'
html_logo = "_static/img/pyronear-logo-dark.png"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

html_context = {
'css_files': [
'https://fonts.googleapis.com/css?family=Lato',
'_static/css/custom_theme.css'
"css_files": [
"https://fonts.googleapis.com/css?family=Lato",
"_static/css/custom_theme.css",
],
}
6 changes: 3 additions & 3 deletions pyroengine/pi_utils/ip_hostname_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import socket


with open('../../server/data/ip_hostname_mapping.json') as f:
with open("../../server/data/ip_hostname_mapping.json") as f:
ip_hostname_mapping = json.load(f)

inv_map = {v: k for k, v in ip_hostname_mapping.items()}
Expand All @@ -17,12 +17,12 @@

for hostname in hostnames:
try:
ip = socket.gethostbyname(hostname + '.local')
ip = socket.gethostbyname(hostname + ".local")
ip_hostname_mapping[ip] = hostname
except Exception:
ip = inv_map[hostname]
ip_hostname_mapping[ip] = hostname


with open('../../server/data/ip_hostname_mapping.json', 'w') as fp:
with open("../../server/data/ip_hostname_mapping.json", "w") as fp:
json.dump(ip_hostname_mapping, fp, indent=4)
2 changes: 1 addition & 1 deletion pyroengine/pi_utils/pi_zeros/monitor_pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_record(self):
metrics = {
"id": 0,
"cpu_temperature_C": self.cpu_temp.temperature,
"mem_available_GB": psutil.virtual_memory().available / 1024 ** 3,
"mem_available_GB": psutil.virtual_memory().available / 1024**3,
"cpu_usage_percent": psutil.cpu_percent(),
}

Expand Down
19 changes: 14 additions & 5 deletions pyroengine/pi_utils/pi_zeros/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,22 @@ def stop_runner(self):


if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Take picture(s) and send to local web server')
parser.add_argument('--single', action='store_true', help='Single picture instead of eternal loop')
parser.add_argument('--write', action='store_true', help='Use /write_image route instead of /inference')
parser = argparse.ArgumentParser(
description="Take picture(s) and send to local web server"
)
parser.add_argument(
"--single", action="store_true", help="Single picture instead of eternal loop"
)
parser.add_argument(
"--write",
action="store_true",
help="Use /write_image route instead of /inference",
)
args = parser.parse_args()

webserver_local_url = f"http://{WEBSERVER_IP}:{WEBSERVER_PORT}" + \
("/inference/file" if not args.write else "/write_image/file")
webserver_local_url = f"http://{WEBSERVER_IP}:{WEBSERVER_PORT}" + (
"/inference/file" if not args.write else "/write_image/file"
)
runner = Runner(webserver_local_url)
if args.single:
files = runner.capture_stream()
Expand Down
Loading

0 comments on commit 6565aaa

Please sign in to comment.