Skip to content

Commit c41cea1

Browse files
committed
Improved linting and fixed minor issues
1 parent b0832a7 commit c41cea1

File tree

5 files changed

+41
-21
lines changed

5 files changed

+41
-21
lines changed

.pylintrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[MESSAGES CONTROL]
2+
3+
# Enable the message, report, category or checker with the given id(s). You can
4+
# either give multiple identifier separated by comma (,) or put this option
5+
# multiple time.
6+
#enable=
7+
8+
# Disable the message, report, category or checker with the given id(s). You
9+
# can either give multiple identifier separated by comma (,) or put this option
10+
# multiple time (only on the command line, not in the configuration file where
11+
# it should appear only once).
12+
disable=C0103, C0114, C0116

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"python.analysis.diagnosticMode": "workspace",
66
"python.linting.pylintEnabled": true,
77
"python.linting.pylintArgs": [
8-
"--enable=W0611"
8+
"--rcfile=.pylintrc"
99
]
1010
}

backend/specialized_databases/files/s3/S3PersistenceService.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
""" S3 compatible persistence service """
2+
13
import boto3
24
from botocore.client import Config
35

@@ -7,6 +9,12 @@
79

810

911
class S3PersistenceService(FilesPersistenceService):
12+
"""S3 compatible persistence service
13+
14+
Args:
15+
FilesPersistenceService (_type_): _description_
16+
"""
17+
1018
def __init__(self, **kwargs):
1119
super().__init__(**kwargs)
1220

@@ -43,8 +51,8 @@ def stream_file(
4351
:return:
4452
:raise IdNotFoundException: if the iri is not found
4553
"""
46-
object = self.bucket.Object(iri)
47-
response = object.get()
54+
file_object = self.bucket.Object(iri)
55+
response = file_object.get()
4856
file_stream = response["Body"]
4957
return file_stream
5058

dt_backend.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import json
1+
"""
2+
Main entry point for the application layer
3+
Handles the sensor-connections and provides a API
4+
Introducing services for querying the KG
5+
Separated from api.py to avoid circular dependencies with endpoint
6+
files importing the "app" instance.
7+
"""
28

39
import uvicorn
410

511
from backend.api.api import app
612
from backend.knowledge_graph.KnowledgeGraphPersistenceService import (
713
KnowledgeGraphPersistenceService,
814
)
9-
from backend.knowledge_graph.dao.DatabaseConnectionsDao import DatabaseConnectionsDao
1015
from backend.knowledge_graph.dao.TimeseriesNodesDao import TimeseriesNodesDao
1116
from backend.runtime_connections.RuntimeConnectionContainer import (
1217
RuntimeConnectionContainer,
1318
)
1419
from backend.specialized_databases.DatabasePersistenceServiceContainer import (
1520
DatabasePersistenceServiceContainer,
1621
)
17-
from backend.specialized_databases.timeseries.influx_db.InfluxDbPersistenceService import (
18-
InfluxDbPersistenceService,
19-
)
2022

2123

2224
# Import endpoint files (indirectly used through annotation)
@@ -45,20 +47,14 @@
4547
get_environment_variable_int,
4648
)
4749

48-
"""
49-
Main entry point for the application layer
50-
Handles the sensor-connections and provides a API
51-
Introducing services for querying the KG
52-
Separated from api.py to avoid circular dependencies with endpoint files importing the "app" instance.
53-
"""
54-
5550

5651
# #############################################################################
5752
# Setup sensor connections and timeseries persistence
5853
# #############################################################################
5954
def init_database_connections():
6055
print("Initializing database connections...")
6156

57+
# pylint: disable=W0612
6258
db_con_container: DatabasePersistenceServiceContainer = (
6359
DatabasePersistenceServiceContainer.instance()
6460
)
@@ -69,6 +65,7 @@ def init_database_connections():
6965
def init_sensors():
7066
print("Initializing timeseries inputs...")
7167

68+
# pylint: disable=W0612
7269
kg_service: KnowledgeGraphPersistenceService = (
7370
KnowledgeGraphPersistenceService.instance()
7471
)

frontend/main_column/factory_graph/factory_graph_callbacks.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from datetime import datetime
2-
from dash import ctx
2+
from dash import ctx, Input, Output, State
33
from dash.exceptions import PreventUpdate
44
import pytz
5-
from dash.dependencies import Input, Output, State
65
from util.environment_and_configuration import (
76
ConfigGroups,
87
get_configuration_int,
@@ -48,7 +47,8 @@ def update_factory_graph(
4847
:return:
4948
"""
5049

51-
# Reload from backend when button manually clicked (n > 1), no graph is stored locally, or the stored one is older than the configured max age
50+
# Reload from backend when button manually clicked (n > 1), no graph is stored locally,
51+
# or the stored one is older than the configured max age
5252
if (
5353
n_clicks > 1
5454
or stored_graph is None
@@ -75,6 +75,7 @@ def update_factory_graph(
7575
return cygraph_elements, cygraph_elements, datetime.now().isoformat(), True
7676

7777

78+
# pylint: disable=W0613
7879
@app.callback(
7980
Output("graph-reload-button", "n_clicks"),
8081
Input("interval-component-factory-graph", "n_intervals"),
@@ -109,7 +110,8 @@ def factory_graph_update_trigger(
109110
raise PreventUpdate()
110111
elif graph_loaded is None and n_init_intervall == 4:
111112
print(
112-
"Graph not loaded after first intervall. Checking if reloading from backend or local storage..."
113+
"Graph not loaded after first intervall. "
114+
"Checking if reloading from backend or local storage..."
113115
)
114116
if _get_graph_age_seconds(local_timestamp) > get_configuration_int(
115117
group=ConfigGroups.FRONTEND, key="max_graph_age"
@@ -221,7 +223,7 @@ def update_node_position(n_clicks, selected_el_json):
221223
)
222224

223225
# Notify the user with an auto-dismissing alert:
224-
return f"New node position saved!", True, datetime.now()
226+
return "New node position saved!", True, datetime.now()
225227

226228

227229
@app.callback(
@@ -233,7 +235,8 @@ def update_node_position(n_clicks, selected_el_json):
233235
def toggle_layout_saver_visibility(selected_el_json, elements):
234236
"""
235237
Called whenever a element is selected (or de-selected) in the graph, or when the graph changes.
236-
Provides the user with a visible save-functionality for the altered node position, if a node is selected, that
238+
Provides the user with a visible save-functionality for the altered node position,
239+
if a node is selected, that
237240
the user moved via drag and drop.
238241
:param selected_el_json:
239242
:param elements:

0 commit comments

Comments
 (0)