# ADFMentor

A Python package that evaluates student Azure Data Factory (ADF) submissions using Google Gemini AI.

## Features

- 🤖 **AI-Powered Evaluation** — Gemini analyzes ADF JSON files and scores them against lecture tasks
- 🎯 **Auto Task Identification** — AI identifies which lecture task each submitted file belongs to
- 📦 **ZIP Support** — Automatically extracts `.zip` submissions
- 📄 **Single JSON** — Also accepts individual `.json` files
- 📊 **Per-Task Scoring** — Returns overall score + per-task breakdown with feedback

## Installation

```bash
pip install ADFMentor
```

Or from source:

```bash
git clone https://github.com/yourusername/ADFMentor.git
cd ADFMentor
pip install -e .
```

## Quick Start

```python
from ADFmentor import ADFMentor

mentor = ADFMentor(api_key="your-gemini-api-key")

questions = """
Part 1 — Create a pipeline named API_Customers_To_SQL that copies CSV data from HTTP API to Azure SQL.
Part 2 — Create a dynamic pipeline that processes multiple CSV files from an API folder.
"""

prompt = """Evaluate the ADF pipeline for correctness, best practices, and requirements alignment.
Provide a score out of 100 and concise feedback."""

result = mentor.evaluate(
    answer_path="submission.json",   # or "submission.zip"
    questions=questions,
    prompt=prompt,
)

print(f"Score: {result['score']}/100")
print(f"Feedback: {result['feedback']}")

for task in result.get("task_mapping", []):
    print(f"\n  File: {task['file']}")
    print(f"  Task: {task['identified_task']}")
    print(f"  Score: {task['score']}/100")
    print(f"  Feedback: {task['feedback']}")
```

## Response Format

```json
{
  "score": 85,
  "feedback": "Overall summary...",
  "task_mapping": [
    {
      "file": "taskA.json",
      "identified_task": "Part 1 — Static API CSV Pipeline",
      "score": 90,
      "feedback": "Pipeline correctly implements..."
    },
    {
      "file": "taskB.json",
      "identified_task": "Part 2 — Dynamic Pipeline",
      "score": 80,
      "feedback": "Good structure but missing..."
    }
  ]
}
```

## Package Structure

```
ADFmentor/
├── __init__.py        # Package entry point
├── core.py            # ADFMentor class with evaluate() method
├── utils.py           # File handling, ZIP extraction, JSON reading
└── models/
    ├── __init__.py
    ├── model.py       # Abstract base model
    └── gemini.py      # Google Gemini implementation
```

## API Reference

### `ADFMentor(api_key, model_name="gemini-2.0-flash-exp")`

Initialize the mentor with your Gemini API key.

### `mentor.evaluate(answer_path, questions, prompt) -> dict`

| Parameter | Type | Description |
|-----------|------|-------------|
| `answer_path` | `str` | Path to a `.json` file or `.zip` archive |
| `questions` | `str` | Full lecture task descriptions (all tasks) |
| `prompt` | `str` | Evaluation criteria for the AI |

**Returns** a dict with `score`, `feedback`, and `task_mapping`.

## Configuration

Create a `.env` file:

```env
API_KEY=your_gemini_api_key_here
```

```python
from dotenv import load_dotenv
import os

load_dotenv()
mentor = ADFMentor(api_key=os.getenv("API_KEY"))
```

## Requirements

- Python 3.9+
- Google Gemini API key ([get one here](https://makersuite.google.com/app/apikey))

## License

MIT License — see LICENSE file for details.
