Skip to content

Commit 69814bf

Browse files
committed
fix issue
1 parent 038443f commit 69814bf

4 files changed

Lines changed: 47 additions & 85 deletions

File tree

.github/workflows/dagger-fraud-sim.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ jobs:
2424
2525
dagger run --cloud authentication-service/auth-service:fraud-v1 \
2626
call run-fraud-sim \
27-
--gemini-api-key secret:GEMINI_API_KEY \
28-
--groq-api-key secret:GROQ_API_KEY
27+
--gemini-api-key env:GEMINI_API_KEY \
28+
--groq-api-key env:GROQ_API_KEY

.secrets.baseline

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
{
9191
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
9292
},
93+
{
94+
"path": "detect_secrets.filters.common.is_baseline_file",
95+
"filename": ".secrets.baseline"
96+
},
9397
{
9498
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
9599
"min_level": 2
@@ -123,15 +127,6 @@
123127
}
124128
],
125129
"results": {
126-
".github/workflows/dagger-fraud-sim.yml": [
127-
{
128-
"type": "Secret Keyword",
129-
"filename": ".github/workflows/dagger-fraud-sim.yml",
130-
"hashed_secret": "86ac1a7088a5e5b345ffbff04ea68577f644efff",
131-
"is_verified": false,
132-
"line_number": 19
133-
}
134-
],
135130
"COMPLETE_TESTING_GUIDE.md": [
136131
{
137132
"type": "Secret Keyword",
@@ -362,5 +357,5 @@
362357
}
363358
]
364359
},
365-
"generated_at": "2026-01-03T05:38:20Z"
360+
"generated_at": "2026-01-03T06:46:05Z"
366361
}
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +0,0 @@
1-
"""A generated module for FraudSimulation functions
2-
3-
This module has been generated via dagger init and serves as a reference to
4-
basic module structure as you get started with Dagger.
5-
6-
Two functions have been pre-created. You can modify, delete, or add to them,
7-
as needed. They demonstrate usage of arguments and return types using simple
8-
echo and grep commands. The functions can be called from the dagger CLI or
9-
from one of the SDKs.
10-
11-
The first line in this comment block is a short description line and the
12-
rest is a long description with more detail on the module's purpose or usage,
13-
if appropriate. All modules should have a short description.
14-
"""
15-
16-
from .main import FraudSimulation as FraudSimulation
Lines changed: 40 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,41 @@
1-
"""Dagger module for fraud simulation."""
1+
# dagger/module.py
22
import dagger
3-
from dagger import dag, function, object_type, Doc
4-
from typing import Annotated
5-
6-
@object_type
7-
class FraudSimulation:
8-
"""A Dagger module to run fraud simulation pipelines."""
9-
@function
10-
async def run_fraud_sim(
11-
self,
12-
gemini_api_key: Annotated[dagger.Secret, Doc("Gemini API token")],
13-
groq_api_key: Annotated[dagger.Secret, Doc("Groq API token")],
14-
) -> str:
15-
"""
16-
Runs the fraud simulation pipeline with the provided AI API keys.
17-
"""
18-
# Get the host directory (where dagger call is executed)
19-
# In Dagger Cloud, this will be the workspace directory.
20-
host_dir = dag.host().directory(".")
21-
22-
# Define the base container with Python
23-
base = (
24-
dag.container()
25-
.from_("python:3.11-slim")
26-
.with_directory("/app", host_dir)
27-
.with_workdir("/app")
28-
.with_exec(["pip", "install", "pydantic"])
29-
)
30-
31-
print("\n" + "="*50)
32-
print("🚀 STARTING DAGGER FRAUD SIMULATION (CLOUD/MODULE)")
33-
print("="*50 + "\n")
34-
35-
# Step 1: Generate Accounts
36-
print("👉 Step 1: Generating Accounts...")
37-
step1 = base.with_exec(["python3", "fraud_simulation/generate_accounts.py"])
38-
39-
# Step 2: Generate Logs
40-
print("👉 Step 2: Generating Logs...")
41-
step2 = step1.with_exec(["python3", "fraud_simulation/generate_logs.py"])
42-
43-
# Step 3: Process Logs with Secrets
44-
print("👉 Step 3: Running Fraud Analysis Agent (Comparing Gemini & Groq)...")
45-
step3 = (
46-
step2
47-
.with_secret_variable("GEMINI_API_KEY", gemini_api_key)
48-
.with_secret_variable("GROQ_API_KEY", groq_api_key)
49-
.with_exec(["python3", "fraud_simulation/process_logs.py"])
50-
)
51-
52-
# Step 4: Expose Output
53-
# This makes the results available via the Dagger API/UI
54-
55-
# To make it "complete" the simulation and show status
56-
await step3.stdout()
57-
58-
return "✅ Simulation complete! Results available in fraud_simulation_reports/summary.json"
3+
from dagger import function
4+
5+
@function
6+
async def run_fraud_sim(
7+
gemini_api_key: dagger.Secret,
8+
groq_api_key: dagger.Secret,
9+
) -> str:
10+
"""
11+
Runs the fraud simulation using the global Dagger context.
12+
"""
13+
14+
# Use global `dagger` / `dag`, not self
15+
host_dir = dagger.host().directory(".")
16+
17+
base = (
18+
dagger.container()
19+
.from_("python:3.11-slim")
20+
.with_directory("/app", host_dir)
21+
.with_workdir("/app")
22+
.with_exec(["pip", "install", "pydantic"])
23+
)
24+
25+
print("\n" + "=" * 50)
26+
print("🚀 STARTING DAGGER FRAUD SIMULATION")
27+
print("=" * 50 + "\n")
28+
29+
step1 = base.with_exec(["python3", "fraud_simulation/generate_accounts.py"])
30+
step2 = step1.with_exec(["python3", "fraud_simulation/generate_logs.py"])
31+
step3 = (
32+
step2
33+
.with_secret_variable("GEMINI_API_KEY", gemini_api_key)
34+
.with_secret_variable("GROQ_API_KEY", groq_api_key)
35+
.with_exec(["python3", "fraud_simulation/process_logs.py"])
36+
)
37+
38+
# Force streaming stdout to trigger execution
39+
await step3.stdout()
40+
41+
return "✅ Simulation complete! Results available in fraud_simulation_reports/summary.json"

0 commit comments

Comments
 (0)