Skip to content

Commit f8beeb2

Browse files
committed
run format/lint scripts
1 parent f614dcc commit f8beeb2

File tree

13 files changed

+94
-69
lines changed

13 files changed

+94
-69
lines changed

credit-scorer/modal_app/modal_deployment.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ def create_modal_app(python_version: str = "3.12.9"):
6161
)
6262
.add_local_python_source("modal_app")
6363
.add_local_file(
64-
"src/constants/config.py", remote_path="/root/src/constants/config.py"
64+
"src/constants/config.py",
65+
remote_path="/root/src/constants/config.py",
6566
)
6667
.add_local_file(
67-
"src/constants/annotations.py", remote_path="/root/src/constants/annotations.py"
68+
"src/constants/annotations.py",
69+
remote_path="/root/src/constants/annotations.py",
6870
)
6971
.add_local_file(
7072
"src/utils/incidents.py",

credit-scorer/src/constants/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717

1818
from .annotations import *
1919
from .config import *
20-
from .risk import *
20+
from .risk import *

credit-scorer/src/pipelines/deployment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def deployment(
9292
)
9393

9494
# Generate Software Bill of Materials for Article 15 (Accuracy & Robustness)
95-
sbom_artifact = generate_sbom(
95+
generate_sbom(
9696
deployment_info=deployment_info,
97-
) # noqa: F841
97+
)
9898

9999
# Post-market monitoring plan (Article 17)
100100
monitoring_plan = post_market_monitoring(

credit-scorer/src/steps/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
# feature engineering
2929
from .feature_engineering.data_preprocessor import data_preprocessor
30+
from .feature_engineering.data_profiler import data_profiler
3031
from .feature_engineering.data_splitter import data_splitter
3132
from .feature_engineering.ingest import ingest
32-
from .feature_engineering.data_profiler import data_profiler
3333
from .training.evaluate import evaluate_model
3434
from .training.risk_assessment import risk_assessment
3535

credit-scorer/src/steps/deployment/post_market_monitoring.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
from zenml import get_step_context, log_metadata, step
2424
from zenml.logger import get_logger
2525

26-
from src.constants import Artifacts as A, Directories
26+
from src.constants import Artifacts as A
27+
from src.constants import Directories
2728

2829
logger = get_logger(__name__)
2930

credit-scorer/src/steps/feature_engineering/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"""Feature engineering steps for the project."""
1919

2020
from .data_preprocessor import data_preprocessor
21+
from .data_profiler import data_profiler
2122
from .data_splitter import data_splitter
2223
from .ingest import ingest
23-
from .data_profiler import data_profiler
2424

2525
__all__ = ["data_preprocessor", "data_splitter", "ingest", "data_profiler"]

credit-scorer/src/steps/training/evaluate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from typing import Annotated, Any, Dict, List, Optional, Tuple
1919

20-
import numpy as np
2120
import pandas as pd
2221
from sklearn.metrics import (
2322
accuracy_score,

credit-scorer/src/utils/compliance/annex_iv.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,15 @@
1919
import shutil
2020
from datetime import datetime
2121
from pathlib import Path
22-
from typing import Any, Dict, List, Optional, Tuple
22+
from typing import Any, Dict, List, Optional
2323

24-
import yaml
2524
from git import Repo
2625
from zenml.client import Client
2726
from zenml.logger import get_logger
2827
from zenml.models.v2.core.pipeline_run import PipelineRunResponseBody
2928

30-
from src.constants import Artifacts as A
3129
from src.constants import Directories, Pipelines
3230
from src.utils.compliance.data_loader import ComplianceDataLoader
33-
from src.utils.storage import (
34-
save_evaluation_visualization,
35-
save_whylogs_profile,
36-
)
3731

3832
logger = get_logger(__name__)
3933

credit-scorer/src/utils/incidents.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
from pathlib import Path
2121
from typing import Any, Dict, Optional
2222

23-
from src.constants import Artifacts as A, Incident
23+
from src.constants import Artifacts as A
24+
from src.constants import Incident
2425
from src.utils.storage import save_artifact_to_modal
2526

2627

credit-scorer/streamlit_app/components/api_dashboard.py

Lines changed: 76 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def get_modal_app_url() -> Optional[str]:
5151
try:
5252
releases_dir = "docs/releases"
5353
release_folders = [
54-
f for f in os.listdir(releases_dir)
54+
f
55+
for f in os.listdir(releases_dir)
5556
if os.path.isdir(os.path.join(releases_dir, f))
5657
]
5758

@@ -62,19 +63,26 @@ def get_modal_app_url() -> Optional[str]:
6263
latest_timestamp = None
6364

6465
for folder in release_folders:
65-
approval_path = os.path.join(releases_dir, folder, "approval_record.json")
66+
approval_path = os.path.join(
67+
releases_dir, folder, "approval_record.json"
68+
)
6669
if os.path.exists(approval_path):
6770
with open(approval_path, "r") as f:
6871
try:
6972
record = json.load(f)
7073
timestamp = record.get("timestamp")
71-
if timestamp and (latest_timestamp is None or timestamp > latest_timestamp):
74+
if timestamp and (
75+
latest_timestamp is None
76+
or timestamp > latest_timestamp
77+
):
7278
latest_timestamp = timestamp
7379
latest_approval = record
7480
except json.JSONDecodeError:
7581
continue
7682

77-
return latest_approval.get("deployment_url") if latest_approval else None
83+
return (
84+
latest_approval.get("deployment_url") if latest_approval else None
85+
)
7886
except Exception as e:
7987
logger.error(f"Error getting Modal app URL: {e}")
8088
return None
@@ -92,12 +100,12 @@ def display_api_dashboard():
92100

93101
# Get and display API URL
94102
modal_url = get_modal_app_url()
95-
103+
96104
if not modal_url:
97105
modal_url = st.text_input(
98106
"API Base URL",
99107
value="https://marwan-ext-main--credit-scoring-app.modal.run",
100-
help="Enter your deployed Modal API URL"
108+
help="Enter your deployed Modal API URL",
101109
)
102110

103111
if modal_url:
@@ -106,19 +114,19 @@ def display_api_dashboard():
106114

107115
# Quick reference
108116
st.markdown("### 📋 Available Endpoints")
109-
117+
110118
endpoints_data = {
111119
"Endpoint": ["/", "/health", "/predict", "/monitor", "/incident"],
112120
"Method": ["GET", "GET", "POST", "GET", "POST"],
113121
"Purpose": [
114122
"API Information",
115-
"Health Check",
123+
"Health Check",
116124
"Make Predictions",
117125
"Check Data Drift",
118-
"Report Issues"
119-
]
126+
"Report Issues",
127+
],
120128
}
121-
129+
122130
df = pd.DataFrame(endpoints_data)
123131
st.dataframe(df, use_container_width=True, hide_index=True)
124132

@@ -131,13 +139,16 @@ def display_api_dashboard():
131139
with tabs[0]:
132140
st.markdown("## Prediction Endpoint")
133141
st.markdown(f"**URL:** `POST {modal_url}/predict`")
134-
142+
135143
col1, col2 = st.columns(2)
136-
144+
137145
with col1:
138146
st.markdown("#### Request Body")
139-
st.code(json.dumps(SAMPLE_PREDICTION_REQUEST, indent=2), language="json")
140-
147+
st.code(
148+
json.dumps(SAMPLE_PREDICTION_REQUEST, indent=2),
149+
language="json",
150+
)
151+
141152
with col2:
142153
st.markdown("#### Response")
143154
example_response = {
@@ -173,40 +184,37 @@ def display_api_dashboard():
173184
# Monitoring Tab
174185
with tabs[1]:
175186
st.markdown("## Monitoring Endpoints")
176-
187+
177188
# Health Check
178189
col1, col2 = st.columns(2)
179-
190+
180191
with col1:
181192
st.markdown("#### Health Check")
182193
st.markdown(f"**URL:** `GET {modal_url}/health`")
183-
194+
184195
health_response = {
185196
"status": "healthy",
186-
"timestamp": "2024-03-20T10:00:00Z"
197+
"timestamp": "2024-03-20T10:00:00Z",
187198
}
188199
st.code(json.dumps(health_response, indent=2), language="json")
189-
200+
190201
with col2:
191202
st.markdown("#### Data Drift Monitoring")
192203
st.markdown(f"**URL:** `GET {modal_url}/monitor`")
193-
204+
194205
monitor_response = {
195206
"drift_detected": False,
196207
"drift_score": 0.05,
197-
"model_performance": {
198-
"accuracy": 0.92,
199-
"auc": 0.95
200-
},
201-
"last_check": "2024-03-20T10:00:00Z"
208+
"model_performance": {"accuracy": 0.92, "auc": 0.95},
209+
"last_check": "2024-03-20T10:00:00Z",
202210
}
203211
st.code(json.dumps(monitor_response, indent=2), language="json")
204212

205213
# Sample monitoring charts
206214
st.markdown("#### Sample Monitoring Data")
207-
215+
208216
col1, col2 = st.columns(2)
209-
217+
210218
with col1:
211219
st.markdown("**Drift Scores by Feature**")
212220
drift_data = {
@@ -216,32 +224,47 @@ def display_api_dashboard():
216224
"credit_history": 0.03,
217225
}
218226
st.bar_chart(drift_data)
219-
227+
220228
with col2:
221229
st.markdown("**Model Performance Over Time**")
222-
performance_data = pd.DataFrame({
223-
"Week": range(1, 11),
224-
"Accuracy": [0.92, 0.91, 0.915, 0.905, 0.91, 0.90, 0.895, 0.89, 0.885, 0.88],
225-
})
230+
performance_data = pd.DataFrame(
231+
{
232+
"Week": range(1, 11),
233+
"Accuracy": [
234+
0.92,
235+
0.91,
236+
0.915,
237+
0.905,
238+
0.91,
239+
0.90,
240+
0.895,
241+
0.89,
242+
0.885,
243+
0.88,
244+
],
245+
}
246+
)
226247
st.line_chart(performance_data.set_index("Week"))
227248

228249
# Incidents Tab
229250
with tabs[2]:
230251
st.markdown("## Incident Reporting")
231252
st.markdown(f"**URL:** `POST {modal_url}/incident`")
232-
253+
233254
col1, col2 = st.columns(2)
234-
255+
235256
with col1:
236257
st.markdown("#### Request Body")
237-
st.code(json.dumps(SAMPLE_INCIDENT_REQUEST, indent=2), language="json")
238-
258+
st.code(
259+
json.dumps(SAMPLE_INCIDENT_REQUEST, indent=2), language="json"
260+
)
261+
239262
st.markdown("**Severity Levels:**")
240263
st.markdown("- `low` - Minor issues")
241-
st.markdown("- `medium` - Moderate problems")
264+
st.markdown("- `medium` - Moderate problems")
242265
st.markdown("- `high` - Serious issues")
243266
st.markdown("- `critical` - System failures")
244-
267+
245268
with col2:
246269
st.markdown("#### Response")
247270
incident_response = {
@@ -269,21 +292,28 @@ def display_api_dashboard():
269292
# Simple error reference
270293
st.markdown("---")
271294
st.markdown("### ❌ Common HTTP Response Codes")
272-
295+
273296
error_data = {
274297
"Code": ["200", "400", "422", "500"],
275-
"Status": ["Success", "Bad Request", "Validation Error", "Server Error"],
298+
"Status": [
299+
"Success",
300+
"Bad Request",
301+
"Validation Error",
302+
"Server Error",
303+
],
276304
"Description": [
277305
"Request completed successfully",
278-
"Invalid request format",
306+
"Invalid request format",
279307
"Data validation failed",
280-
"Internal server error"
281-
]
308+
"Internal server error",
309+
],
282310
}
283-
311+
284312
error_df = pd.DataFrame(error_data)
285313
st.dataframe(error_df, use_container_width=True, hide_index=True)
286314

287315
# Footer
288316
st.markdown("---")
289-
st.info("💡 **Need help?** Check the endpoint responses for detailed error messages.")
317+
st.info(
318+
"💡 **Need help?** Check the endpoint responses for detailed error messages."
319+
)

credit-scorer/streamlit_app/components/documentation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def display_annex_iv_documentation():
5959
# Export options
6060
st.markdown("---")
6161
st.subheader("Export Options")
62-
62+
6363
col1, col2 = st.columns(2)
6464

6565
with col1:
@@ -87,4 +87,4 @@ def display_annex_iv_documentation():
8787
file_name="annex_iv_documentation.md",
8888
mime="text/markdown",
8989
key="download_annex_iv_md",
90-
)
90+
)

credit-scorer/streamlit_app/components/executive_summary.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,18 @@
1919

2020
from datetime import datetime
2121

22-
import plotly.graph_objects as go
2322
import streamlit as st
2423
from src.utils.visualizations.dashboard import (
2524
format_activities,
2625
)
2726
from streamlit.components.v1 import html
2827

29-
from streamlit_app.config import PRIMARY_COLOR, RISK_COLORS
28+
from streamlit_app.config import RISK_COLORS
3029
from streamlit_app.data.compliance_utils import (
3130
format_compliance_findings,
3231
get_compliance_data_sources,
3332
get_compliance_results,
3433
get_compliance_summary,
35-
get_last_update_timestamps,
3634
)
3735
from streamlit_app.data.processor import compute_article_compliance
3836

credit-scorer/streamlit_app/styling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,4 @@ def apply_custom_css():
311311
</style>
312312
""",
313313
unsafe_allow_html=True,
314-
)
314+
)

0 commit comments

Comments
 (0)