fabric-job-trigger 0.1.0
A Python library for triggering and monitoring Microsoft Fabric jobs
Requires Python: >=3.8

# Fabric Job Trigger

A Python library for triggering and monitoring Microsoft Fabric jobs with ease.

## Features

- Trigger Microsoft Fabric jobs programmatically
- Monitor job execution status
- Support for both YAML configuration and direct dictionary input
- Flexible parameter handling with nested structures
- Global parameter support
- Comprehensive logging system
- CLI support for easy integration

## Installation

You can install the package using pip:

```bash
pip install fabric-job-trigger
```

## Quick Start

### Using Python Code

```python
from fabric_job_trigger import FabricJobTrigger

# Basic configuration
config = {
    "workspace_id": "your-workspace-id",
    "item_id": "your-item-id",
    "job_type": "pipeline",
    "parameters": {
        "date": "2024-01-01"
    }
}

# Initialize and run jobs
trigger = FabricJobTrigger(config=config)
results = trigger.run_jobs()
```

### Using YAML Configuration

Create a `config.yaml` file:

```yaml
- workspace_id: workspace-1
  item_id: item-1
  job_type: pipeline
  etl_name: daily-load  # optional
  parameters:
    date: "2024-01-01"
    settings:
      timeout: 3600
      retry: 3
```

Run using Python:

```python
trigger = FabricJobTrigger(config_path="config.yaml")
results = trigger.run_jobs()
```

Or use the CLI:

```bash
fabric-job-trigger --config-path config.yaml
```

## Advanced Usage

### Global Parameters

```python
# Define global parameters
global_params = {
    "env": "prod",
    "settings": {
        "timeout": 3600,
        "retry": 3
    }
}

# Initialize with global parameters
trigger = FabricJobTrigger(
    config=config,
    parameters=global_params
)
```

### Custom Logging

```python
import logging

trigger = FabricJobTrigger(
    config=config,
    log_level=logging.DEBUG
)
```

### Monitoring Configuration

```python
trigger = FabricJobTrigger(
    config=config,
    monitoring_duration=120,  # minutes
    polling_interval=2        # minutes
)
```

## Configuration Options

### Job Configuration

Required fields:
- `workspace_id`: Microsoft Fabric workspace ID
- `item_id`: Item ID in the workspace
- `job_type`: Type of job to execute

Optional fields:
- `etl_name`: Name of the ETL process
- `parameters`: Job-specific parameters

### FabricJobTrigger Parameters

- `config`: Dictionary containing job configurations
- `config_path`: Path to YAML configuration file
- `etl_names`: List of ETL names to execute
- `parameters`: Global parameters for all jobs
- `log_level`: Logging level (default: INFO)
- `monitoring_duration`: Maximum duration to monitor jobs in minutes (default: 60)
- `polling_interval`: Time between status checks in minutes (default: 1)

## CLI Usage

```bash
fabric-job-trigger [-h] -cp CONFIG_PATH [-e ETL_NAMES [ETL_NAMES ...]]
                   [-l {DEBUG,INFO,WARNING,ERROR}] [-md MONITORING_DURATION]
                   [-pi POLLING_INTERVAL]
```

Arguments:
- `-cp, --config-path`: Path to configuration YAML file
- `-e, --etl-names`: Space-separated list of ETL names to execute
- `-l, --log-level`: Logging level (default: INFO)
- `-md, --monitoring-duration`: Maximum monitoring duration in minutes
- `-pi, --polling-interval`: Polling interval in minutes

## Requirements

- Python >= 3.8
- requests >= 2.25.0
- azure-identity >= 1.7.0
- PyYAML >= 5.4.1

## Development

To contribute to this project:

1. Clone the repository
2. Install development dependencies:
```bash
pip install -e ".[dev]"
```

3. Run tests:
```bash
pytest
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.