Skip to content

Commit 4e99af8

Browse files
strickvlclaude
andcommitted
Simplify deployment workflow with new flag defaults
- Auto-approve is now the default behavior (use --manual-approve to disable) - Slack notifications are disabled by default (use --enable-slack to enable) - Modal secrets are now optional, only required when --enable-slack is used - Primary workflow is now just `python run.py --all` with no flags needed - Full EU AI Act compliance available via `python run.py --all --enable-slack` This makes the project much easier to test and get started with while keeping all compliance features available when explicitly requested. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent a5c89a7 commit 4e99af8

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

credit-scorer/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ zenml alerter register slack_alerter \
115115
zenml stack update <STACK_NAME> -al slack_alerter
116116
```
117117

118-
5. Set up Modal secrets for deployment (required for deployment pipeline):
118+
5. Set up Modal secrets for deployment (optional, only needed with `--enable-slack` flag):
119119

120120
```bash
121121
# Create Modal secret with Slack credentials for incident reporting
@@ -124,15 +124,17 @@ modal secret create credit-scoring-secrets \
124124
SLACK_CHANNEL_ID=<your_slack_channel_id>
125125
```
126126

127-
> **Note:** The deployment pipeline uses Modal for cloud deployment and requires Slack integration for EU AI Act compliance incident reporting (Article 18). The `credit-scoring-secrets` Modal secret stores the necessary Slack credentials for automated notifications when the deployed model API detects high or critical severity incidents.
127+
> **Note:** The deployment pipeline uses Modal for cloud deployment. By default, Slack notifications are disabled for easier testing. The `credit-scoring-secrets` Modal secret stores the necessary Slack credentials for automated notifications when the deployed model API detects high or critical severity incidents.
128+
129+
> **Enabling full compliance features:** For complete EU AI Act compliance incident reporting (Article 18), use the `--enable-slack` flag (e.g., `python run.py --deploy --enable-slack`). This requires the Modal secret to be configured with your Slack credentials for automated incident notifications.
128130
129131
## 📊 Running Pipelines
130132

131133
### Basic Commands
132134

133135
```bash
134136
# Run complete workflow (recommended)
135-
python run.py --all --auto-approve # Feature → Training → Deployment
137+
python run.py --all # Feature → Training → Deployment (auto-approved, no Slack)
136138

137139
# Run individual pipelines
138140
python run.py --feature # Feature engineering (Articles 10, 12)
@@ -141,8 +143,9 @@ python run.py --deploy # Deployment (Articles 14, 17, 18)
141143

142144
# Pipeline options
143145
python run.py --all --no-cache # Complete workflow without caching
144-
python run.py --train --auto-approve # Skip manual approval steps
146+
python run.py --all --manual-approve # Complete workflow with manual approval steps
145147
python run.py --deploy --config-dir ./my-configs # Custom config directory
148+
python run.py --all --enable-slack # Complete workflow with Slack notifications (requires Modal secrets)
146149
```
147150

148151
### View Compliance Dashboard

credit-scorer/modal_app/modal_deployment.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,24 @@ def create_modal_app(python_version: str = "3.12.9"):
8181

8282
app_config = {
8383
"image": base_image,
84-
"secrets": [modal.Secret.from_name(SECRET_NAME)],
8584
}
8685

86+
# Only add secrets if Slack notifications are explicitly enabled
87+
enable_slack = os.getenv("ENABLE_SLACK", "false").lower() == "true"
88+
if enable_slack:
89+
try:
90+
app_config["secrets"] = [modal.Secret.from_name(SECRET_NAME)]
91+
logger.info(f"Added secret {SECRET_NAME} to Modal app")
92+
except Exception as e:
93+
logger.warning(f"Could not add secret {SECRET_NAME}: {e}")
94+
logger.info(
95+
"Continuing without secrets - Slack notifications will be disabled"
96+
)
97+
else:
98+
logger.info(
99+
"Slack notifications disabled by default - Modal app created without secrets"
100+
)
101+
87102
try:
88103
volume = modal.Volume.from_name(VOLUME_NAME)
89104
app_config["volumes"] = {"/mnt": volume}
@@ -167,7 +182,8 @@ def _report_incident(incident_data: dict, model_checksum: str) -> dict:
167182
logger.warning(f"Could not write to local incident log: {e}")
168183

169184
# 2. Direct Slack notification for high/critical severity (not using ZenML)
170-
if incident["severity"] in ("high", "critical"):
185+
enable_slack = os.getenv("ENABLE_SLACK", "false").lower() == "true"
186+
if incident["severity"] in ("high", "critical") and enable_slack:
171187
try:
172188
slack_token = os.getenv("SLACK_BOT_TOKEN")
173189
slack_channel = os.getenv("SLACK_CHANNEL_ID", SC.CHANNEL_ID)
@@ -209,6 +225,10 @@ def _report_incident(incident_data: dict, model_checksum: str) -> dict:
209225
)
210226
except Exception as e:
211227
logger.warning(f"Failed to send Slack notification: {e}")
228+
elif not enable_slack:
229+
logger.info(
230+
"Slack notifications disabled (use --enable-slack flag to enable)"
231+
)
212232

213233
return {
214234
"status": "reported",

credit-scorer/run.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,32 @@
8181
help="Directory containing configuration files.",
8282
)
8383
@click.option(
84-
"--auto-approve",
84+
"--manual-approve",
8585
is_flag=True,
8686
default=False,
87-
help="Auto-approve deployment (for CI/CD pipelines).",
87+
help="Require manual approval for deployment (disables auto-approve).",
8888
)
8989
@click.option(
9090
"--no-cache",
9191
is_flag=True,
9292
default=False,
9393
help="Disable caching for pipeline runs.",
9494
)
95+
@click.option(
96+
"--enable-slack",
97+
is_flag=True,
98+
default=False,
99+
help="Enable Slack notifications in deployment (requires Modal secrets setup).",
100+
)
95101
def main(
96102
feature: bool = False,
97103
train: bool = False,
98104
deploy: bool = False,
99105
all: bool = False,
100106
config_dir: str = "src/configs",
101-
auto_approve: bool = True,
107+
manual_approve: bool = False,
102108
no_cache: bool = False,
109+
enable_slack: bool = False,
103110
):
104111
"""Main entry point for EU AI Act compliance pipelines.
105112
@@ -115,14 +122,19 @@ def main(
115122
if not config_dir.exists():
116123
raise ValueError(f"Configuration directory {config_dir} not found")
117124

118-
# Handle auto-approve setting for deployment
125+
# Handle approval setting for deployment (auto-approve is now default)
126+
auto_approve = not manual_approve
119127
if auto_approve:
120128
os.environ["DEPLOY_APPROVAL"] = "y"
121129
os.environ["APPROVER"] = "automated_ci"
122130
os.environ["APPROVAL_RATIONALE"] = (
123-
"Automatic approval via --auto-approve flag"
131+
"Automatic approval (default behavior)"
124132
)
125133

134+
# Handle Slack setting for deployment (Slack disabled by default)
135+
if enable_slack:
136+
os.environ["ENABLE_SLACK"] = "true"
137+
126138
# Common pipeline options
127139
pipeline_args = {}
128140
if no_cache:

0 commit comments

Comments
 (0)