Commit b6ac54fa authored by Joschka Birk's avatar Joschka Birk
Browse files

Merge branch mguth-pylint-init with refs/heads/master into refs/merge-requests/321/train

parents 5048aac3 3091c899
Pipeline #3366504 passed with stages
in 14 minutes and 20 seconds
......@@ -23,7 +23,7 @@ stages:
checking_mr:
stage: check_mr
image: python:3.7-slim
image: python:3.8-slim
before_script:
- pip install --upgrade pip setuptools wheel
- pip install python-gitlab
......@@ -35,7 +35,7 @@ checking_mr:
linter:
stage: linting
image: python:3.7-slim
image: python:3.8-slim
script:
- mkdir coverage_files/
- pip install flake8
......@@ -59,7 +59,7 @@ yaml_linter:
doc_string_check:
stage: linting
image: python:3.7-slim
image: python:3.8-slim
script:
- pip install darglint
- darglint --list-errors
......@@ -69,6 +69,19 @@ doc_string_check:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
allow_failure: True
pylint:
stage: linting
image: python:3.8-slim
before_script:
- pip install pylint==2.12.2
script:
- pylint ./umami
rules:
- if: $CI_COMMIT_BRANCH != ''
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
allow_failure: True
include:
- 'pipelines/.unit_test-gitlab-ci.yaml'
- 'pipelines/.docker-gitlab-ci.yaml'
......
......@@ -14,7 +14,7 @@ repos:
language: system
entry: black
types: [python]
args: ["--experimental-string-processing", "--line-length", "88"]
args: ["--experimental-string-processing"]
- id: flake8
name: flake8
stages: [commit]
......
......@@ -4,7 +4,7 @@
test_coverage:
stage: coverage_test_stage
image: python:3.7-slim
image: python:3.8-slim
script:
- pip install --upgrade pip setuptools wheel
- pip install pytest==6.2.4
......@@ -46,7 +46,7 @@ coverage_html_report:
test_coverage_post_report:
stage: publish
image: python:3.7-slim
image: python:3.8-slim
needs: ["test_coverage"]
before_script:
- pip install --upgrade pip setuptools wheel
......
[tool.black]
line-length = 79
line-length = 88
target-version = ['py38']
include = '\.pyi?$'
exclude = '''
......
......@@ -35,4 +35,5 @@ uproot==4.0.7
xarray==0.16.2
xhistogram==0.1.3
yamllint==1.26.2
zarr==2.8.1
\ No newline at end of file
zarr==2.8.1
python-gitlab
......@@ -11,4 +11,10 @@ max-line-length = 88
select = B,C,E,F,W,T4
[darglint]
ignore=DAR203
\ No newline at end of file
ignore=DAR203
[pylint.FORMAT]
max-line-length = 88
[pylint.'MESSAGES CONTROL']
disable = missing-docstring,invalid-name,unspecified-encoding,wrong-import-order,logging-fstring-interpolation,no-name-in-module,too-many-arguments,too-many-locals,too-many-lines,no-member,too-many-statements,too-many-branches
\ No newline at end of file
......@@ -103,9 +103,9 @@ def hist_ratio(nominator, denominator, nominator_unc, denominator_unc):
"""
if nominator.shape != denominator.shape:
raise (AssertionError("Nominator and denominator don't have the same legth"))
raise AssertionError("Nominator and denominator don't have the same legth")
if nominator.shape != nominator_unc.shape:
raise (AssertionError("Nominator and nominator_unc don't have the same legth"))
raise AssertionError("Nominator and nominator_unc don't have the same legth")
if denominator.shape != denominator_unc.shape:
raise (
AssertionError("Denominator and denominator_unc don't have the same legth")
......
......@@ -29,8 +29,7 @@ class CompositingComposer(ruamel.yaml.composer.Composer):
compositor = self.get_compositor(event.tag, nodeType) or callback
if isinstance(compositor, types.MethodType):
return compositor(anchor)
else:
return compositor(self, anchor)
return compositor(self, anchor)
def compose_scalar_node(self, anchor):
return self.__compose_dispatch(anchor, ScalarNode, super().compose_scalar_node)
......@@ -50,11 +49,11 @@ class ExcludingConstructor(ruamel.yaml.constructor.Constructor):
filters = {k: [] for k in (MappingNode, SequenceNode)}
@classmethod
def add_filter(cls, filter, *, nodeTypes=(MappingNode,)):
def add_filter(cls, filter_yaml, *, nodeTypes=(MappingNode,)):
for nodeType in nodeTypes:
cls.filters[nodeType].append(filter)
cls.filters[nodeType].append(filter_yaml)
def construct_mapping(self, node):
def construct_mapping(self, node): # pylint: disable=arguments-differ
node.value = [
(key_node, value_node)
for key_node, value_node in node.value
......@@ -62,7 +61,7 @@ class ExcludingConstructor(ruamel.yaml.constructor.Constructor):
]
return super().construct_mapping(node)
def construct_sequence(self, node):
def construct_sequence(self, node): # pylint: disable=arguments-differ
node.value = [
value_node
for value_node in node.value
......@@ -75,7 +74,7 @@ class YAML(ruamel.yaml.YAML):
def __init__(self, *args, **kwargs):
if "typ" not in kwargs:
kwargs["typ"] = "safe"
if type(kwargs["typ"]) is list and len(kwargs["typ"]) == 1:
if isinstance(kwargs["typ"], list) and len(kwargs["typ"]) == 1:
kwargs["typ"] = kwargs["typ"][0]
elif kwargs["typ"] not in ["safe", "unsafe"]:
raise Exception(
......@@ -101,7 +100,7 @@ class YAML(ruamel.yaml.YAML):
If either the Scanner or Reader are set, you cannot use the non-pure Parser,
so reset it to the pure parser and set the Reader resp. Scanner if necessary
"""
constructor, parser = self.get_constructor_parser(stream)
_, parser = self.get_constructor_parser(stream)
try:
return self.composer.get_single_node()
finally:
......@@ -116,17 +115,17 @@ class YAML(ruamel.yaml.YAML):
pass
def fork(self):
yaml = type(self)(typ=self.typ, pure=self.pure)
yaml.composer.anchors = self.composer.anchors
return yaml
yml = type(self)(typ=self.typ, pure=self.pure)
yml.composer.anchors = self.composer.anchors
return yml
def include_compositor(self, anchor):
def include_compositor(self, anchor): # pylint: disable=unused-argument
event = self.parser.get_event()
yaml = self.loader.fork()
yml = self.loader.fork()
path = os.path.join(os.path.dirname(self.loader.reader.name), event.value)
with open(path) as f:
return yaml.compose(f)
return yml.compose(f)
def exclude_filter(key_node, value_node=None):
......@@ -143,10 +142,10 @@ if __name__ == "__main__":
import pprint
yaml = YAML(typ="safe", pure=True)
parser = argparse.ArgumentParser()
parser.add_argument("file")
argparser = argparse.ArgumentParser()
argparser.add_argument("file")
args = parser.parse_args()
parse_args = argparser.parse_args()
with open(args.file) as f:
pprint.pprint(yaml.load(f))
with open(parse_args.file) as yaml_file:
pprint.pprint(yaml.load(yaml_file))
......@@ -2471,8 +2471,10 @@ def calc_validation_metrics(
]
)
except ValueError:
raise ValueError(f"Epoch could not be extracted from {model_string}!")
except ValueError as val_error:
raise ValueError(
f"Epoch could not be extracted from {model_string}!"
) from val_error
# Load the epoch from json and add it to dict
for train_epoch in training_output_list:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment