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

Add pre-commit linter #54

Merged
merged 4 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.267'
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-ast
- id: check-yaml
- id: check-added-large-files
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.formatting.provider": "none"
}
1 change: 0 additions & 1 deletion deepview_profile/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import argparse
import enum
import sys

import deepview_profile
Expand Down
15 changes: 7 additions & 8 deletions deepview_profile/analysis/request_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from concurrent.futures import ThreadPoolExecutor

from deepview_profile.analysis.runner import analyze_project
from deepview_profile.config import Config
from deepview_profile.exceptions import AnalysisError
from deepview_profile.nvml import NVML
import deepview_profile.protocol_gen.innpv_pb2 as pm
Expand Down Expand Up @@ -135,7 +134,7 @@ def _handle_analysis_request(self, analysis_request, context):
except AnalysisError as ex:
self._enqueue_response(self._send_analysis_error, ex, context)

except:
except Exception:
logger.exception(
'Exception occurred when handling analysis request.')
self._enqueue_response(
Expand Down Expand Up @@ -164,38 +163,38 @@ def _send_breakdown_response(self, breakdown, context):
# Called from the main executor. Do not call directly!
try:
self._message_sender.send_breakdown_response(breakdown, context)
except:
except Exception:
logger.exception(
'Exception occurred when sending a breakdown response.')

def _send_analysis_error(self, exception, context):
# Called from the main executor. Do not call directly!
try:
self._message_sender.send_analysis_error(exception, context)
except:
except Exception:
logger.exception(
'Exception occurred when sending an analysis error.')

def _send_throughput_response(self, throughput, context):
# Called from the main executor. Do not call directly!
try:
self._message_sender.send_throughput_response(throughput, context)
except:
except Exception:
logger.exception(
'Exception occurred when sending a throughput response.')

def _send_habitat_response(self, habitat_resp, context):
# Called from the main executor. Do not call directly!
try:
self._message_sender.send_habitat_response(habitat_resp, context)
except:
except Exception:
logger.exception(
'Exception occurred when sending a DeepView.Predict response.')

def _send_energy_response(self, energy_resp, context):
# Called from the main executor. Do not call directly!
try:
self._message_sender.send_energy_response(energy_resp, context)
except:
except Exception:
logger.exception(
'Exception occurred when sending an energy response.')
'Exception occurred when sending an energy response.')
Loading