# 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).

## डेटा इनजेस्ट करें

### Images

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

### Videos

```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 format:** लोअरकेस होना चाहिए, अधिकतम 64 अक्षर, और केवल अक्षर, अंक, हाइफ़न (`-`) और अंडरस्कोर (`_`).
{% endhint %}

### Cloud Storage

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

**Images के लिए:**

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

**Videos के लिए:**

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

The `--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 फ़ाइलें recursive रूप से
* `gs://my-bucket/videos/2024-*/*.mp4` — 2024-\* फ़ोल्डरों में MP4 फ़ाइलें
* `az://container/images/*.png` — images फ़ोल्डर में 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 के माध्यम से संदर्भित फ़ाइलों को प्रोसेस करें।
* `--references <path_or_url>` — JSONL file का path जिसमें file URLs हों, या ऐसी file की ओर संकेत करने वाला 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 ग्राहकों के लिए उपलब्ध है।
{% endhint %}

## Staged Data की जाँच करें

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

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

### Images प्रोसेस करें

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

### Videos प्रोसेस करें

```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 या बड़े models वाले Workflows के लिए।
{% endhint %}

## Job प्रगति की निगरानी करें

start कमांड एक **Job ID**आउटपुट करता है। स्थिति जाँचने के लिए इसका उपयोग करें:

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

## परिणाम एक्सपोर्ट करें

job details में **output batch ID**शामिल होगा। परिणाम एक्सपोर्ट करने के लिए इसका उपयोग करें:

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

## Webhook Automation

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

### 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) — overall 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": "Untrusted domain found: 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": "Max size of single image is 20971520B."
            }
        ],
        "content_truncated": false
    },
    "delivery_attempt": 1
}
```

### Job Completion Webhooks

Add `--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 निम्न से अपने-आप पहचाने जाते हैं:

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, etc.):**

```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 निम्न से पहचाने जाते हैं:

1. **Service account key file** (automation के लिए अनुशंसित):

```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 (अनुशंसित):**

```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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-hi/deploy/batch-processing/cli-usage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
