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

Refresh #278

Merged
merged 4 commits into from
Jul 6, 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
27 changes: 0 additions & 27 deletions .github/workflows/license.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.272'
rev: 'v0.0.277'
hooks:
- id: ruff
args: [--fix]
Expand All @@ -24,5 +24,5 @@ repos:
hooks:
- id: nbqa-black
- id: nbqa-ruff
additional_dependencies: [ruff==v0.0.270]
additional_dependencies: [ruff==v0.0.277]

5 changes: 3 additions & 2 deletions popmon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

import pandas as pd
from histogrammar.dfinterface.make_histograms import get_time_axes
from pydantic import BaseModel, BaseSettings
from pydantic import BaseModel
from pydantic_settings import BaseSettings
from typing_extensions import Literal

# Global configuration for the joblib parallelization. Could be used to change the number of jobs, and/or change
Expand All @@ -32,7 +33,7 @@

class ValidatedSettings(BaseSettings):
class Config:
validate_all = True
validate_default = True
validate_assignment = True


Expand Down
19 changes: 19 additions & 0 deletions popmon/version.py
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
# Copyright (c) 2023 ING Analytics Wholesale Banking
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

version = "1.4.1"
5 changes: 1 addition & 4 deletions popmon/visualization/histogram_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ def transform(self, data_obj: dict, sections: list | None = None):
histogram = []

# filter out potential empty heatmap plots, then prepend them to the sorted histograms
hplots = []
for h in heatmaps:
if isinstance(h, dict) and len(h["plot"]):
hplots.append(h)
hplots = [h for h in heatmaps if isinstance(h, dict) and len(h["plot"])]

if len(hplots) > 0:
plot_type_layouts["heatmap"] = hplots[0]["layout"]
Expand Down
8 changes: 4 additions & 4 deletions popmon/visualization/templates/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ <h4 class="card-title">{{metric.name | fmt_metric}}</h4>
</div>
<div id="{{ card_id }}"> </div>
{%- if metric.type in ['traffic_light', 'alert'] -%}
{{ metric.plot }}
{{ metric.plot | safe }}
{%- else -%}
<div class="skeleton-loader" id="{{ card_id }}-loading"></div>
<script>
rendered["{{ card_id }}"] = false;
render_func["{{ card_id }}"] = (function(){
var layout = deepCopy(layouts["{{ section_index }}{{ curr }}-{{ metric.type }}"]);
{%- if metric.shapes | length -%}
layout["shapes"] = {{ metric.shapes | json_plot}};
layout["shapes"] = {{ metric.shapes | json_plot | safe }};
{%- endif -%}
{%- if metric.yaxis_range | length -%}
layout["yaxis"]["range"] = {{ metric.yaxis_range | json_plot }};
layout["yaxis"]["range"] = {{ metric.yaxis_range | json_plot | safe }};
{%- endif -%}
Plotly.newPlot(document.getElementById("{{ card_id }}"), {{ metric.plot | json_plot }}, layout, plotly_config).then(function() { document.getElementById("{{ card_id }}-loading").remove(); rendered["{{ card_id }}"] = true;});
Plotly.newPlot(document.getElementById("{{ card_id }}"), {{ metric.plot | json_plot | safe }}, layout, plotly_config).then(function() { document.getElementById("{{ card_id }}-loading").remove(); rendered["{{ card_id }}"] = true;});
});

var io = new IntersectionObserver(function(entries) {
Expand Down
2 changes: 1 addition & 1 deletion popmon/visualization/templates/core.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
var render_func = {};
</script>
{%- include 'header.html' -%}
{{ sections }}
{{ sections | safe }}
{%- include 'footer.html' -%}
</body>
</html>
4 changes: 2 additions & 2 deletions popmon/visualization/templates/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2>{{ section_title }}</h2>
<script>
{%- set curr = loop.index -%}
{%- for plot_type, layout in feature.plot_type_layouts.items() -%}
layouts["{{ section_index }}{{ curr }}-{{ plot_type }}"] = {{ layout | json_plot }};
layouts["{{ section_index }}{{ curr }}-{{ plot_type }}"] = {{ layout | json_plot | safe }};
{%- endfor -%}
</script>
<div class="section_feature" data-section-feature="{{ feature.name }}">
Expand Down Expand Up @@ -57,7 +57,7 @@ <h3> {{ feature.titles.get(ref, ref) }} </h3>
{%- for metric in plots -%}
<script>
{%- set curr = loop.index -%}
layouts["{{ section_index }}{{ curr }}-{{ metric.type }}"] = {{ metric.layout | json_plot }};
layouts["{{ section_index }}{{ curr }}-{{ metric.type }}"] = {{ metric.layout | json_plot | safe }};
</script>
{%- with metric=metric -%}
{%- include 'card.html' -%}
Expand Down
24 changes: 22 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ dependencies = [
"plotly>=5.8.0",
"joblib>=0.14.0",
"htmlmin",
"pydantic",
"pydantic>=2",
"pydantic-settings",
"typing_extensions",
"tomli >= 1.1.0 ; python_version < '3.11'"
]
Expand Down Expand Up @@ -76,7 +77,7 @@ popmon_run = "popmon.pipeline.amazing_pipeline:run"
target-version = "py37"
line-length = 120
namespace-packages = ["popmon"]
select = ["ALL"]
select = ["ALL", "CPY001"]
ignore = [
# COM812 is incompatible with COM819
"COM",
Expand Down Expand Up @@ -106,6 +107,10 @@ ignore = [
"TRY003",
"E501",
"DTZ",
"PERF203", # `try`-`except` within a loop incurs performance overhead

# False positive
"PERF401", # Use a list comprehension to create a transformed list

# Prefer autofix
"PD011", # .to_numpy() instead of values
Expand Down Expand Up @@ -140,6 +145,8 @@ ignore = [
"PT011",
# Too many statements
"PLR0915",
# Copyright
"CPY001",
]

# Sphinx config
Expand All @@ -152,6 +159,13 @@ ignore = [

# implicit namespaces
"INP001",

# Copyright
"CPY001",
]

"popmon/config.py" = [
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
]

# Notebooks & NBQA
Expand All @@ -168,8 +182,14 @@ ignore = [

# Found useless expression. Either assign it to a variable or remove it.
"B018",

# Copyright
"CPY001",
]

[tool.ruff.flake8-copyright]
notice-rgx = """(?mis)Copyright \\(c\\) 2023 ING Analytics Wholesale Banking.+"""

[tool.pytest.ini_options]
markers = ["spark"]

Expand Down