> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/api-sdk-cli/ko/get-started/cli-quickstart.md).

# CLI 빠른 시작

unitlab CLI로 터미널에서 프로젝트를 만들고, 이미지 폴더를 업로드하고, 처리 상태를 확인하는 방법을 단계별로 안내합니다.

터미널에서 프로젝트를 만들고, 이미지 폴더를 업로드하고, 모든 파일이 처리되었는지 확인합니다. 예제는 macOS 또는 Linux 셸을 기준으로 하며, JSON을 읽는 데 [`jq`](https://jqlang.github.io/jq/)를 사용합니다.

## 시작하기 전에 <a href="#before-you-begin" id="before-you-begin"></a>

* [CLI를 설치](https://docs.unitlab.ai/api-sdk-cli/ko/get-started/install-the-python-sdk-and-cli.md)하고 [`UNITLAB_API_KEY`를 설정](https://docs.unitlab.ai/api-sdk-cli/ko/get-started/authentication-and-api-keys.md)합니다. 키에는 **Manage projects**와 **Manage data** 권한이 필요합니다.
* JPG 또는 PNG 파일 몇 개가 든 `images/` 폴더가 있는 위치에서 터미널을 엽니다.

## 업로드와 확인 <a href="#upload-and-check" id="upload-and-check"></a>

{% stepper %}
{% step %}

### 프로젝트 만들기 <a href="#create-a-project" id="create-a-project"></a>

```bash
PROJECT_ID=$(unitlab project create "Warehouse picks" --json | jq -r .id)
echo "$PROJECT_ID"
```

명령이 새 프로젝트의 ID를 출력합니다. 기존 프로젝트를 사용하려면 `unitlab project list`로 ID를 찾습니다.
{% endstep %}

{% step %}

### 폴더 업로드 <a href="#upload-the-folder" id="upload-the-folder"></a>

```bash
unitlab project upload "$PROJECT_ID" --source ./images --json | tee upload.json
BATCH_QUEUE_ID=$(jq -r .batch_queue_id upload.json)
```

```json
{
  "total": 2,
  "uploaded": 2,
  "failed": 0,
  "batch_queue_id": "0b6c5f3e-6a0b-4b8e-9f43-2f1f0f8f5a10"
}
```

업로드에 실패한 파일이 하나라도 있으면 명령은 종료 코드 `1`로 끝납니다. 나머지 파일은 그대로 업로드됩니다.
{% endstep %}

{% step %}

### 처리 완료 대기 <a href="#wait-for-processing" id="wait-for-processing"></a>

```bash
unitlab batch-queue wait "$PROJECT_ID" "$BATCH_QUEUE_ID" --timeout 1800
```

```json
{
  "status": "completed",
  "total": 2,
  "completed": 2,
  "processing": 0,
  "failed": 0,
  "error": null,
  "frame_count": null
}
```

처리 중인 파일이 없어지면 대기가 끝납니다. 이때 `status`는 `completed`, `partial_failure`, `failed` 중 하나이며, `failed`는 서버가 처리하지 못한 파일 수입니다.
{% endstep %}

{% step %}

### 항목 목록 보기 <a href="#list-the-items" id="list-the-items"></a>

```bash
unitlab project data-units "$PROJECT_ID" --batch-queue "$BATCH_QUEUE_ID"
```

```
id=5f0e...  name=bin-001.jpg  kind=datasource  status=annotate  data_type=image
id=a41c...  name=bin-002.jpg  kind=datasource  status=annotate  data_type=image
```

{% endstep %}
{% endstepper %}

{% hint style="success" %}
앱에서 프로젝트를 엽니다. 두 이미지가 **Data**에 있으며, 프로젝트에 온톨로지가 있으면 바로 라벨링할 수 있습니다.
{% endhint %}

## 스크립트용 출력 <a href="#output-for-scripts" id="output-for-scripts"></a>

모든 명령은 사람이 읽기 쉬운 짧은 `key=value` 줄을 출력합니다. 스크립트가 출력을 읽는다면 `--json`을 추가합니다. 오류는 종료 코드 `1`과 함께 표준 오류로 출력되므로, errexit를 켠 스크립트는 첫 오류에서 멈춥니다.

```bash
set -euo pipefail
unitlab release list --json | jq -r '.[] | [.id, .name, .version] | @tsv'
```

## 다음 단계 <a href="#next-steps" id="next-steps"></a>

* [업로드, 라벨링, 내보내기](https://docs.unitlab.ai/api-sdk-cli/ko/get-started/upload-label-and-export.md): 릴리스 다운로드까지 포함한 전체 흐름.
* [CLI 명령 레퍼런스](https://docs.unitlab.ai/api-sdk-cli/ko/clis/cli-command-reference.md): 모든 명령과 옵션.
* [CLI: 프로젝트와 Data Unit](https://docs.unitlab.ai/api-sdk-cli/ko/clis/cli-projects-and-data-units.md): 비디오 프레임 레이트, LiDAR 씬, 벤치마크.

## 관련 문서 <a href="#related" id="related"></a>

[Python SDK 빠른 시작](https://docs.unitlab.ai/api-sdk-cli/ko/get-started/python-sdk-quickstart.md) · [CLI 개요와 출력 모드](https://docs.unitlab.ai/api-sdk-cli/ko/clis/cli-overview-and-output-modes.md) · [CLI 자동화와 종료 동작](https://docs.unitlab.ai/api-sdk-cli/ko/clis/cli-automation-and-exit-behavior.md)
