Skip to content

Commit

Permalink
Tuning pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
dittmar committed Feb 26, 2024
1 parent 754a922 commit 2a99fd5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
pip install pylint
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
pylint --rcfile=.pylintrc $(git ls-files '*.py')
10 changes: 7 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[MASTER]
disable=
C0115, # missing-class-docstring
CO116, # missing-function-docstring
missing-class-docstring,
missing-function-docstring,
too-many-arguments

[FORMAT]
max-line-length=120
max-line-length=120

[MISCELLANEOUS]
notes=FIXME
25 changes: 14 additions & 11 deletions src/cadenzaanalytics/cadenza_analytics_extension.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import pandas as pd
from flask import Response, request
"""Represents a disy Cadenza analytics extension that is accessible via disy Cadenza at entry points
depending on the extension type. The extension will run its main analytics function when invoked
with a POST on the relative path."""
import json
from io import StringIO
from io import StringIO
from typing import Callable
import pandas as pd
from flask import Response, request

from cadenzaanalytics.data.analytics_extension import AnalyticsExtension
from cadenzaanalytics.data.extension_type import ExtensionType
from cadenzaanalytics.data.attribute_group import AttributeGroup
from cadenzaanalytics.data.parameter import Parameter
from cadenzaanalytics.request.analytics_request import AnalyticsRequest
from cadenzaanalytics.request.request_metadata import RequestMetadata
from cadenzaanalytics.response.extension_response import ExtensionResponse
from cadenzaanalytics.response.extension_response import ExtensionResponse


class CadenzaAnalyticsExtension:
Expand All @@ -21,15 +24,15 @@ def __init__(self,
extension_type: ExtensionType,
attribute_groups: list[AttributeGroup],
parameters: list[Parameter] = None):
self._relative_path = relative_path # TODO: consider renaming to extension_id
self._analytics_function = analytics_function
self._relative_path = relative_path
self._analytics_function = analytics_function

self._analytics_extension = AnalyticsExtension(print_name, extension_type, attribute_groups, parameters)

@property
def relative_path(self) -> str:
return self._relative_path

@property
def print_name(self) -> str:
return self._analytics_extension.print_name
Expand All @@ -48,12 +51,12 @@ def handle_request(self) -> Response:
def get_capabilities(self) -> Response:
return Response(response=self._analytics_extension.to_json(), status=200, mimetype="application/json")

def _get_request_data(self, request) -> AnalyticsRequest:
metadata_dict = json.loads(request.form['metadata'])
def _get_request_data(self, multipart_request) -> AnalyticsRequest:
metadata_dict = json.loads(multipart_request.form['metadata'])
metadata = RequestMetadata(metadata_dict)

if metadata.has_columns():
csv_data = StringIO(request.form['data'])
if metadata.has_columns():
csv_data = StringIO(multipart_request.form['data'])
df_data = pd.read_csv(csv_data, sep=";")
else:
df_data = pd.DataFrame()
Expand Down
4 changes: 3 additions & 1 deletion src/cadenzaanalytics/cadenza_analytics_extension_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Configures and starts the service that runs a http server to allow disy Cadenza to detect individual extensions
and execute their analytics function."""
import json
from flask import Flask, Response
from flask_cors import CORS
import json

from cadenzaanalytics.cadenza_analytics_extension import CadenzaAnalyticsExtension

Expand Down

0 comments on commit 2a99fd5

Please sign in to comment.