> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/roboflow/roboflow-hi/deploy/batch-processing/cli-usage.md).

# CLI Usage

इंस्टॉल करके `inference-cli` आपको एक्सेस मिलता है `inference rf-cloud` कमांड, जो आपको Batch Processing और Data Staging के साथ इंटरैक्ट करने देती है — Roboflow Batch Processing के मुख्य घटक।

## सेटअप

```bash
pip install inference-cli
export ROBOFLOW_API_KEY="YOUR-API-KEY-GOES-HERE"
```

cloud storage सपोर्ट के लिए:

```bash
pip install 'inference-cli[cloud-storage]'
```

यदि आपको अपना API key ढूँढने में मदद चाहिए, तो हमारा देखें [authentication guide](https://docs.roboflow.com/api-reference/authentication).

## डेटा Ingest करें

### इमेजेज़

```bash
inference rf-cloud data-staging create-batch-of-images \
  --images-dir <your-images-dir-path> \
  --batch-id <your-batch-id>
```

### वीडियो

```bash
inference rf-cloud data-staging create-batch-of-videos \
  --videos-dir <your-videos-dir-path> \
  --batch-id <your-batch-id>
```

{% hint style="info" %}
**Batch ID फ़ॉर्मेट:** लोअरकेस होना चाहिए, अधिकतम 64 वर्ण, और केवल अक्षर, अंक, हाइफ़न (`-`), और अंडरस्कोर (`_`).
{% endhint %}

### Cloud Storage

यदि आपका डेटा पहले से ही cloud storage (S3, Google Cloud Storage, या Azure) में है, तो आप इसे स्थानीय रूप से फ़ाइलें डाउनलोड किए बिना सीधे प्रोसेस कर सकते हैं।

**इमेजेज़ के लिए:**

```bash
inference rf-cloud data-staging create-batch-of-images \
  --data-source cloud-storage \
  --bucket-path <cloud-path> \
  --batch-id <your-batch-id>
```

**वीडियो के लिए:**

```bash
inference rf-cloud data-staging create-batch-of-videos \
  --data-source cloud-storage \
  --bucket-path <cloud-path> \
  --batch-id <your-batch-id>
```

यह `--bucket-path` पैरामीटर इनका समर्थन करता है:

* **S3**: `s3://bucket-name/path/`
* **Google Cloud Storage**: `gs://bucket-name/path/`
* **Azure Blob Storage**: `az://container-name/path/`

फ़ाइलों को फ़िल्टर करने के लिए आप glob patterns शामिल कर सकते हैं:

* `s3://my-bucket/training-data/**/*.jpg` — सभी JPG फ़ाइलें recursively
* `gs://my-bucket/videos/2024-*/*.mp4` — 2024-\* folders में MP4 फ़ाइलें
* `az://container/images/*.png` — images folder में PNG फ़ाइलें

{% hint style="info" %}
आपके cloud storage credentials का उपयोग **केवल स्थानीय रूप से** CLI द्वारा presigned URLs जनरेट करने के लिए। वे **कभी अपलोड नहीं किए जाते** Roboflow servers पर।
{% endhint %}

{% hint style="warning" %}
जनरेट किए गए presigned URLs 24 घंटे तक मान्य रहते हैं। सुनिश्चित करें कि आपका batch processing job इस समयावधि के भीतर पूरा हो जाए।
{% endhint %}

बड़े datasets के लिए, सिस्टम स्वचालित रूप से images को 20,000 फ़ाइलों के chunks में विभाजित करता है। Videos 1,000 से कम batches में सबसे अच्छा काम करते हैं।

### Signed URL Ingestion

उन्नत automation के लिए, आप local files के बजाय signed URLs के माध्यम से data ingest कर सकते हैं:

* `--data-source references-file` — signed URLs के माध्यम से संदर्भित फ़ाइलों को process करें।
* `--references <path_or_url>` — file URLs वाली JSONL फ़ाइल का path, या ऐसी फ़ाइल की ओर संकेत करने वाला signed URL।

**Reference File Format (JSONL):**

```
{"name": "<unique-file-name-1>", "url": "https://<signed-url>"}
{"name": "<unique-file-name-2>", "url": "https://<signed-url>"}
```

{% hint style="info" %}
Signed URL ingestion Growth Plan और Enterprise customers के लिए उपलब्ध है।
{% endhint %}

## Staged Data Inspect करें

```bash
inference rf-cloud data-staging show-batch-details --batch-id <your-batch-id>
```

## एक Job शुरू करें

### Images Process करें

```bash
inference rf-cloud batch-processing process-images-with-workflow \
  --workflow-id <workflow-id> \
  --batch-id <batch-id> \
  --machine-type gpu
```

### Videos Process करें

```bash
inference rf-cloud batch-processing process-videos-with-workflow \
  --workflow-id <workflow-id> \
  --batch-id <batch-id> \
  --machine-type gpu \
  --max-video-fps <your-desired-fps>
```

{% hint style="info" %}
**अपना Workflow ID कैसे ढूँढें:** Roboflow App में Workflow Editor खोलें, "Deploy" पर क्लिक करें, और code snippet में identifier ढूँढें।
{% endhint %}

{% hint style="info" %}
डिफ़ॉल्ट रूप से, processing CPU पर चलती है। उपयोग करें `--machine-type gpu` multiple या large models वाले Workflows के लिए।
{% endhint %}

## Job Progress मॉनिटर करें

start command एक **Job ID**. स्थिति जाँचने के लिए इसका उपयोग करें:

```bash
inference rf-cloud batch-processing show-job-details --job-id <your-job-id>
```

## परिणाम Export करें

job details में **output batch ID**. परिणाम export करने के लिए इसका उपयोग करें:

```bash
inference rf-cloud data-staging export-batch \
  --target-dir <dir-to-export-result> \
  --batch-id <output-batch-of-a-job>
```

## Webhook Automation

स्थिति के लिए polling करने के बजाय, आप ingestion या processing पूरी होने पर सूचना पाने के लिए webhooks का उपयोग कर सकते हैं।

### Data Ingestion Webhooks

CLI commands `create-batch-of-images` और `create-batch-of-videos` इनका समर्थन करते हैं:

* `--notifications-url <webhook_url>` — notifications के लिए Webhook endpoint.
* `--notification-category <value>` — notifications फ़िल्टर करें:
  * `ingest-status` (default) — समग्र ingestion process status.
  * `files-status` — individual file processing status.

Notifications HTTP POST के माध्यम से भेजी जाती हैं, साथ में एक `Authorization` header जिसमें आपका Roboflow Publishable Key होता है।

#### Ingest Status Notification

```json
{
    "type": "roboflow-data-staging-notification-v1",
    "event_id": "8c20f970-fe10-41e1-9ef2-e057c63c07ff",
    "ingest_id": "8cd48813430f2be70b492db67e07cc86",
    "batch_id": "test-batch-117",
    "shard_id": null,
    "notification": {
        "type": "ingest-status-notification-v1",
        "success": false,
        "error_details": {
            "type": "unsafe-url-detected",
            "reason": "अविश्वसनीय डोमेन मिला: https://example.com/image.png"
        }
    },
    "delivery_attempt": 1
}
```

#### File Status Notification

```json
{
    "type": "roboflow-data-staging-notification-v1",
    "event_id": "8f42708b-aeb7-4b73-9d83-cf18518b6d81",
    "ingest_id": "d5cb69aa-b2d1-4202-a1c1-0231f180bda9",
    "batch_id": "prod-batch-1",
    "shard_id": "0d40fa12-349e-439f-83f8-42b9b7987b33",
    "notification": {
        "type": "ingest-files-status-notification-v1",
        "success": true,
        "ingested_files": [
            "000000494869.jpg",
            "000000186042.jpg"
        ],
        "failed_files": [
            {
                "type": "file-size-limit-exceeded",
                "file_name": "big_image.png",
                "reason": "एकल image का अधिकतम आकार 20971520B है."
            }
        ],
        "content_truncated": false
    },
    "delivery_attempt": 1
}
```

### Job Completion Webhooks

जोड़ें `--notifications-url` जब job शुरू करते हैं:

```bash
inference rf-cloud batch-processing process-images-with-workflow \
  --workflow-id <workflow-id> \
  --batch-id <batch-id> \
  --notifications-url <webhook_url>
```

#### Job Completion Notification

```json
{
  "type": "roboflow-batch-job-notification-v1",
  "event_id": "8f42708b-aeb7-4b73-9d83-cf18518b6d81",
  "job_id": "<your-batch-job-id>",
  "job_state": "success | fail",
  "delivery_attempt": 1
}
```

## Cloud Storage Authentication

### AWS S3 और S3-Compatible Storage

Credentials स्वतः इनसे detect की जाती हैं:

1. **Environment variables:**

```bash
export AWS_ACCESS_KEY_ID=your-access-key-id
export AWS_SECRET_ACCESS_KEY=your-secret-access-key
export AWS_SESSION_TOKEN=your-session-token  # Optional
```

2. **AWS credential files** (`~/.aws/credentials`, `~/.aws/config`)
3. **IAM roles** (EC2, ECS, Lambda)

**Named profiles:**

```bash
export AWS_PROFILE=production
```

**S3-compatible services (Cloudflare R2, MinIO, आदि):**

```bash
export AWS_ENDPOINT_URL=https://account-id.r2.cloudflarestorage.com
export AWS_REGION=auto  # R2 requires region='auto'
export AWS_ACCESS_KEY_ID=your-r2-access-key
export AWS_SECRET_ACCESS_KEY=your-r2-secret-key
```

### Google Cloud Storage

Credentials यहाँ से detect होती हैं:

1. **Service account key file** (automation के लिए recommended):

```bash
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
```

2. **User credentials** gcloud CLI से (`gcloud auth login`)
3. **GCP metadata service** (जब Google Cloud Platform पर चल रहा हो)

### Azure Blob Storage

**SAS Token (recommended):**

```bash
export AZURE_STORAGE_ACCOUNT_NAME=mystorageaccount
export AZURE_STORAGE_SAS_TOKEN="sv=2021-06-08&ss=b&srt=sco&sp=rl&se=2024-12-31"
```

**Account Key:**

```bash
export AZURE_STORAGE_ACCOUNT_NAME=mystorageaccount
export AZURE_STORAGE_ACCOUNT_KEY=your-account-key
```

Azure CLI के माध्यम से SAS token जनरेट करें:

```bash
az storage container generate-sas \
  --account-name mystorageaccount \
  --name my-container \
  --permissions rl \
  --expiry 2024-12-31T23:59:59Z
```

### Custom Scripts

उन्नत उपयोग मामलों के लिए, signed URL files जनरेट करने वाले reference scripts देखें:

* **AWS S3:** [generateS3SignedUrls.sh](https://raw.githubusercontent.com/roboflow/roboflow-python/main/scripts/generateS3SignedUrls.sh)
* **Google Cloud Storage:** [generateGCSSignedUrls.sh](https://github.com/roboflow/roboflow-python/blob/main/scripts/generateGCSSignedUrls.sh)
* **Azure Blob Storage:** [generateAzureSasUrls.sh](https://raw.githubusercontent.com/roboflow/roboflow-python/main/scripts/generateAzureSasUrls.sh)

## सभी विकल्प देखें

```bash
inference rf-cloud --help
inference rf-cloud data-staging --help
inference rf-cloud batch-processing --help
```
