File size: 1,173 Bytes
9381502
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from __future__ import annotations

from datetime import datetime

from airflow.decorators import dag, task


@dag(
    dag_id="cert_study_visual_analysis",
    start_date=datetime(2025, 1, 1),
    schedule=None,
    catchup=False,
    tags=["cert-study", "qwen", "visual"],
)
def cert_study_visual_analysis():
    @task
    def analyze_visual_questions(
        source_name: str | None = None,
        limit: str | int = 10,
        model: str = "qwen3.5:9b",
    ) -> dict:
        from cert_study_app.db import SessionLocal, init_db
        from cert_study_app.services.visual_question_service import run_visual_analysis

        init_db(verbose=False)
        db = SessionLocal()
        try:
            return run_visual_analysis(
                db,
                source=source_name or None,
                limit=int(limit or 10),
                model=model,
            )
        finally:
            db.close()

    analyze_visual_questions(
        source_name="{{ dag_run.conf.get('source_name', '') }}",
        limit="{{ dag_run.conf.get('limit', 10) }}",
        model="{{ dag_run.conf.get('model', 'qwen3.5:9b') }}",
    )


cert_study_visual_analysis()