arcgis-test-agent / README.md
dduseja's picture
Update ML Intern artifact metadata
ff6427a verified
metadata
tags:
  - ml-intern

ArcGIS Test Script Generator Agent

An AI agent that reads ArcGIS tool documentation and generates test scripts following your team's template and conventions.

Quick Start

# 1. Install
pip install -e .

# 2. Set credentials
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
export AZURE_OPENAI_KEY="your-key"

# 3. Set up your directories
export DOCS_DIR="./docs"           # Tool documentation (.md files)
export TEMPLATE_DIR="./templates"  # Your test template + validators.json
export EXAMPLES_DIR="./examples"   # Example test scripts by category
export TEST_DATA_ROOT="./test_data" # With manifest.json

# 4. Generate a test
python -m arcgis_test_agent generate Buffer

How It Works

User: "Generate test for Buffer"
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PHASE 1: PLANNING                          β”‚
β”‚  β€’ read_tool_docs("Buffer")                 β”‚
β”‚  β€’ search_data_index("polygon shapefile")   β”‚
β”‚  β€’ search_data_index("polyline features")   β”‚
β”‚  β€’ read_output_validators("feature_class")  β”‚
β”‚  β€’ read_example_tests("analysis")           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PHASE 2: CODING                            β”‚
β”‚  β€’ read_test_template()                     β”‚
β”‚  β€’ [LLM writes complete test script]        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PHASE 3: REVIEW                            β”‚
β”‚  β€’ validate_script(code)                    β”‚
β”‚  β€’ [Fix issues if any, retry up to 3x]     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
  generated_tests/test_buffer.py

Directory Setup

You need to provide 4 things:

1. docs/ β€” Tool Documentation

One markdown file per tool:

docs/
β”œβ”€β”€ Buffer.md
β”œβ”€β”€ Clip.md
β”œβ”€β”€ ReconstructSurface.md
└── ...

2. templates/test_template.py β€” Your Test Template

The exact structure your generated tests must follow.

3. templates/validators.json β€” Output Validators Registry

{
    "feature_class": [
        {"name": "assertFeatureClassExists", "signature": "self.assertFeatureClassExists(path)", "description": "..."}
    ],
    "raster": [...],
    "json": [...]
}

4. test_data/manifest.json β€” Available Test Data Index

[
    {
        "path": "vector/polygon/parcels.shp",
        "data_type": "vector",
        "geometry_type": "polygon",
        "description": "Polygon shapefile with 500 parcel features in NAD83",
        "spatial_reference": "NAD83 UTM Zone 11N",
        "feature_count": 500
    }
]

CLI Usage

python -m arcgis_test_agent generate Buffer
python -m arcgis_test_agent generate Buffer --output tests/test_buffer.py
python -m arcgis_test_agent generate Buffer --context "focus on 3D polygon inputs"
python -m arcgis_test_agent generate Buffer --verbose
python -m arcgis_test_agent info

Python API

from arcgis_test_agent import TestGeneratorAgent, AzureConfig, AgentConfig

agent = TestGeneratorAgent()
result = agent.generate("Buffer")

if result.success:
    print(result.script)

Evaluation

from arcgis_test_agent.eval import evaluate_structural

with open("generated_tests/test_buffer.py") as f:
    code = f.read()

score = evaluate_structural(code)
print(f"Composite score: {score.composite:.3f}")

Demo (No Azure Credentials Required)

python arcgis_test_agent/demo/run_demo.py

Project Structure

arcgis_test_agent/
β”œβ”€β”€ __init__.py          # Package entry point
β”œβ”€β”€ __main__.py          # CLI
β”œβ”€β”€ agent.py             # Core agent loop (tool-calling)
β”œβ”€β”€ config.py            # Configuration management
β”œβ”€β”€ eval.py              # Evaluation framework
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ schemas.py       # OpenAI function schemas (6 tools)
β”‚   └── handlers.py      # Tool implementations
β”œβ”€β”€ prompts/
β”‚   └── system.py        # System prompt
└── demo/
    β”œβ”€β”€ run_demo.py      # End-to-end demo
    β”œβ”€β”€ docs/            # Sample tool docs
    β”œβ”€β”€ templates/       # Sample template + validators
    β”œβ”€β”€ examples/        # Sample test scripts
    └── test_data/       # Sample manifest

Generated by ML Intern

This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "dduseja/arcgis-test-agent"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

For non-causal architectures, replace AutoModelForCausalLM with the appropriate AutoModel class.