Skip to content

Commit 623bca9

Browse files
authored
Merge pull request #100 from andrewm4894/develop
develop
2 parents 361c3d5 + dba7d9d commit 623bca9

34 files changed

+254
-115
lines changed

.github/workflows/branch_deployments.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ env:
1111
DAGSTER_CLOUD_URL: "http://andrewm4894.dagster.cloud"
1212
DAGSTER_CLOUD_API_TOKEN: ${{ secrets.DAGSTER_CLOUD_API_TOKEN }}
1313
ENABLE_FAST_DEPLOYS: 'true'
14-
PYTHON_VERSION: '3.10'
14+
PYTHON_VERSION: '3.11'
15+
DAGSTER_CLOUD_WORKSPACE_PATH: 'workspace.yaml'
1516
DAGSTER_CLOUD_FILE: 'dagster_cloud.yaml'
1617

1718
jobs:

.github/workflows/deploy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ env:
1313
DAGSTER_CLOUD_URL: "http://andrewm4894.dagster.cloud"
1414
DAGSTER_CLOUD_API_TOKEN: ${{ secrets.DAGSTER_CLOUD_API_TOKEN }}
1515
ENABLE_FAST_DEPLOYS: 'true'
16-
PYTHON_VERSION: '3.10'
16+
PYTHON_VERSION: '3.11'
17+
DAGSTER_CLOUD_WORKSPACE_PATH: 'workspace.yaml'
1718
DAGSTER_CLOUD_FILE: 'dagster_cloud.yaml'
1819

1920
jobs:

.github/workflows/pre-commit.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ jobs:
2424

2525
- uses: actions/setup-python@v4
2626
with:
27-
python-version: "3.10"
27+
python-version: "3.11"
2828
cache: "pip"
2929
cache-dependency-path: "**/requirements*.txt"
3030
- uses: pre-commit/[email protected]
31+
with:
32+
extra_args: --config .pre-commit-config.yaml
3133
- name: Post PR comment on failure
3234
if: failure() && github.event_name == 'pull_request_target'
3335
uses: peter-evans/create-or-update-comment@v2

.github/workflows/pytest.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v2
17-
- name: Set up Python 3.10
17+
- name: Set up Python 3.11
1818
uses: actions/setup-python@v2
1919
with:
20-
python-version: "3.10"
20+
python-version: "3.11"
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
2424
pip install pytest
25-
pip install .
2625
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
2726
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
2827
- name: Test with pytest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ cython_debug/
161161

162162
# dagster
163163
tmp*
164+
dagster.log
164165

165166
# vscode
166167
.vscode/*

.pre-commit-config.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,16 @@ repos:
1818
rev: 5.12.0
1919
hooks:
2020
- id: isort
21-
args: ["--profile", "black"]
21+
args:
22+
- "--profile"
23+
- "black"
24+
- repo: https://github.com/charliermarsh/ruff-pre-commit
25+
rev: v0.0.241
26+
hooks:
27+
- id: ruff
28+
args:
29+
- "--fix"
30+
- "--exclude"
31+
- "metrics/defaults/python/prompt.py"
32+
- "--exclude"
33+
- "anomstack/llm/completion.py"

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,14 @@
99
"openai"
1010
],
1111
"python.pythonPath": "venv\\Scripts\\python.exe",
12-
"cloudcode.duetAI.inlineSuggestions.enableAuto": true
12+
"cloudcode.duetAI.inlineSuggestions.enableAuto": true,
13+
"sqltools.connections": [
14+
{
15+
"previewLimit": 50,
16+
"driver": "SQLite",
17+
"database": "${workspaceFolder:anomstack}/tmpdata/anomstack.db",
18+
"name": "tmpdata/anomstack.db"
19+
}
20+
],
21+
"sqltools.useNodeRuntime": true
1322
}

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ SHELL=/bin/bash
88
.PHONY: tests
99
.PHONY: docs
1010
.PHONY: requirements
11+
.PHONY: kill-locald
12+
.PHONY: ps-locald
1113

1214
# start streamlit dashboard
1315
dashboard:
@@ -21,13 +23,21 @@ local:
2123
locald:
2224
nohup dagster dev -f anomstack/main.py > dagster.log 2>&1 &
2325

26+
# kill any running dagster process
27+
kill-locald:
28+
kill -9 $(shell ps aux | grep dagster | grep -v grep | awk '{print $$2}')
29+
30+
# list running dagster process
31+
ps-locald:
32+
ps aux | grep dagster | grep -v grep
33+
2434
# start docker containers
2535
docker:
2636
docker compose up -d --build
2737

2838
# pre-commit
2939
pre-commit:
30-
pre-commit run --all-files
40+
pre-commit run --all-files --config .pre-commit-config.yaml
3141

3242
# run tests
3343
tests:

anomstack/alerts/asciiart.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# copied from: https://raw.githubusercontent.com/kakwa/py-ascii-graph/09ca5901be94ec3563bdcc25d6396e18fd8ca5df/ascii_graph/__init__.py
33
# copied from: https://raw.githubusercontent.com/nyurik/py-ascii-graph/fix-python310/ascii_graph/__init__.py
44
"""
5+
56
from __future__ import unicode_literals
67

78
import copy
@@ -115,8 +116,7 @@ def __init__(
115116

116117
@staticmethod
117118
def _len_noansi(string):
118-
l = len(re.sub("\x1b[^m]*m", "", string))
119-
return l
119+
return len(re.sub("\x1b[^m]*m", "", string))
120120

121121
def _trans_hr(self, value):
122122
if self.divider is None:
@@ -165,7 +165,6 @@ def _get_thresholds(self, data):
165165

166166
# If we have a list of values for the item
167167
if isinstance(value, Iterable):
168-
icount = 0
169168
maxvalue = 0
170169
minvalue = 0
171170
for ivalue, icolor in value:
@@ -235,14 +234,12 @@ def _gen_graph_string_part(
235234
all_width = max_value + abs(min_neg_value)
236235

237236
if all_width == 0:
238-
bar_width = 0
239237
neg_width = 0
240-
pos_width = 0
241238
else:
242239
neg_width = int(
243240
abs(float(min_neg_value)) * float(graph_length) / float(all_width)
244241
)
245-
pos_width = int(abs(max_value) * graph_length / all_width)
242+
int(abs(max_value) * graph_length / all_width)
246243

247244
if isinstance(value, Iterable):
248245
accuvalue = 0
@@ -372,14 +369,14 @@ def _sanitize_string(self, string):
372369
input_type = type(string)
373370
if input_type is str:
374371
if sys.version < "3":
375-
info = unicode(string)
372+
info = unicode(string) # noqa: F821
376373
else:
377374
info = string
378375
elif input_type is unicode_type:
379376
info = string
380377
elif input_type is int or input_type is float:
381378
if sys.version < "3":
382-
info = unicode(string)
379+
info = unicode(string) # noqa: F821
383380
else:
384381
info = str(string)
385382
return info
@@ -441,7 +438,7 @@ def graph(self, label=None, data=[]):
441438
san_data = self._sanitize_data(data)
442439
all_thre = self._get_thresholds(san_data)
443440

444-
if not label is None:
441+
if label is not None:
445442
san_label = self._sanitize_string(label)
446443
label_len = self._len_noansi(san_label)
447444
else:
@@ -477,7 +474,7 @@ def graph(self, label=None, data=[]):
477474
# calcul of the real line length
478475
real_line_length = min_line_length
479476

480-
if not label is None:
477+
if label is not None:
481478
result.append(san_label)
482479
result.append(Pyasciigraph._u(self.titlebar) * real_line_length)
483480

anomstack/alerts/email.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ def send_email_with_plot(
3434
subject (str): The subject of the email.
3535
body (str): The body of the email.
3636
attachment_name (str): The name of the attachment.
37-
threshold (float, optional): The threshold for the anomaly detection. Defaults to 0.8.
38-
score_col (str, optional): The name of the column containing the anomaly scores. Defaults to 'metric_score_smooth'.
37+
threshold (float, optional): The threshold for the anomaly detection.
38+
Defaults to 0.8.
39+
score_col (str, optional): The name of the column containing the
40+
anomaly scores. Defaults to 'metric_score_smooth'.
3941
4042
Returns:
4143
None
@@ -118,7 +120,7 @@ def send_email(
118120
with smtplib.SMTP(host, port) as server:
119121
server.connect(host, port)
120122
server.starttls(context=context)
121-
server.login(sender, password)
123+
server.login(sender, password) # type: ignore
122124
text = msg.as_string()
123125
server.sendmail(sender, to, text)
124126
server.quit()

0 commit comments

Comments
 (0)