> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-workspaces-notebooks.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Serverless Sandboxes

> W&B Serverless Sandboxes를 사용해 Python에서 생성하고 사용한 뒤 폐기할 수 있는 주문형 격리된 컴퓨팅 환경입니다.

<Warning>
  **`wandb.sandbox`는 사용이 중단되었으며** W\&B Python SDK의 향후 릴리스에서 제거됩니다. 대신 `cwsandbox` 패키지를 사용하세요. 자세한 내용은 [CoreWeave 샌드박스 문서](https://docs.coreweave.com/products/sandboxes)를 참조하세요.

  마이그레이션하면 다음 두 가지가 달라집니다.

  * **임포트 방식.** W\&B extra와 함께 `cwsandbox`를 설치하고(`pip install "cwsandbox[wandb]"`), `wandb.sandbox` 대신 `cwsandbox`에서 임포트하세요.
  * **credential.** `cwsandbox`는 기본적으로 `CWSANDBOX_API_KEY`에 지정된 CoreWeave API access token으로 인증하므로, 기존 W\&B API 키를 계속 사용하려면 `auth=AuthStrategy.WANDB`를 전달하세요. [Choose a credential](https://docs.coreweave.com/products/sandboxes/get-started#choose-a-credential)을 참조하세요.

  이 페이지의 예시는 아직 `wandb.sandbox`를 사용합니다. 이에 해당하는 `cwsandbox` 코드는 [Migrate to `cwsandbox`](/ko/sandboxes#migrate-to-cwsandbox)를 참조하세요.
</Warning>

<Warning>
  Serverless Sandboxes는 **공개 프리뷰**로 제공됩니다. 조직별로 액세스가 활성화됩니다. 조직에 대한 액세스를 요청하려면 [지원팀](mailto:support@wandb.com)에 문의하세요.
</Warning>

Serverless Sandboxes는 Python으로 생성하고 사용한 뒤 삭제할 수 있는 주문형 격리된 컴퓨팅 환경을 제공합니다.

Serverless Sandboxes는 CoreWeave Sandbox 라이브러리를 기반으로 합니다. 기반이 되는 API 레퍼런스와 라이브러리 문서는 [CoreWeave Sandbox documentation](https://docs.coreweave.com/products/coreweave-sandbox)을 참조하세요.

<div id="how-it-works">
  ## 작동 방식
</div>

\_샌드박스\_는 하나의 격리된 컴퓨팅 환경입니다. [생성](/ko/sandboxes/create-sandbox)하고, [내부에서 명령을 실행](/ko/sandboxes/run-commands)하고, 작업이 끝나면 중지합니다. 각 샌드박스는 자체 파일 시스템, 네트워크, 프로세스 공간을 갖춘 별도의 컨테이너에서 실행됩니다.

샌드박스를 생성하고 관리할 때 W\&B가 사용자의 ID를 인증합니다. 샌드박스 내에서 W\&B 또는 Weave를 사용하려면 [W\&B Secrets Manager](/ko/platform/secrets#manage-access-to-secrets) 또는 환경 변수를 통해 API 키를 전달하세요. 샌드박스에서 시크릿을 사용하는 방법에 대한 자세한 내용은 [Secrets](/ko/sandboxes/secrets)를 참조하세요.

샌드박스는 [라이프사이클 동안 여러 상태](/ko/sandboxes/lifecycle)를 거칩니다. 컨테이너가 실행 중이면 그 안에서 [명령을 실행](/ko/sandboxes/run-commands)할 수 있습니다.

샌드박스에 파일을 [조회, 쓰기, 읽기 전용으로 마운트](/ko/sandboxes/file-access)할 수 있습니다. 일반적인 예로는 실행할 Python 스크립트를 읽어오거나, 로그 또는 결과를 기록하거나, 샌드박스가 액세스할 수 있도록 데이터 디렉터리를 읽기 전용으로 마운트하는 것이 있습니다.

공유 설정을 사용하는 여러 샌드박스를 관리하려면 *session* 을 사용하세요. 세션이 닫히면 해당 세션의 모든 샌드박스가 자동으로 중지됩니다. 자세한 내용은 [여러 샌드박스 관리](/ko/sandboxes/create-sandbox#create-multiple-sandboxes-with-a-session)를 참조하세요.

<div id="basic-usage">
  ## 기본 사용법
</div>

다음 단계에 따라 샌드박스를 생성하고 그 안에서 명령어를 실행하세요:

1. 다음 명령어로 W\&B Python SDK(`wandb`)와 Serverless Sandboxes 의존성을 설치하세요:
   ```bash theme={null}
   pip install wandb[sandbox]
   ```

2. [`wandb login`](/ko/models/ref/cli/wandb-login) CLI 명령어로 W\&B에 로그인하세요. 메시지가 표시되면 API 키를 입력하여 ID를 인증하고 W\&B 계정에 액세스하세요:

   ```bash theme={null}
   wandb login
   ```

3. 다음 코드 스니펫을 Python 파일에 복사하여 붙여넣고 실행하세요. 이 코드 스니펫은 다음을 수행합니다:

   1. [`Sandbox.run()`](https://docs.coreweave.com/products/coreweave-sandbox/client/ref/core/sandbox#run)으로 샌드박스를 생성하세요.
   2. [`Sandbox.exec()`](https://docs.coreweave.com/products/coreweave-sandbox/client/ref/core/sandbox#exec) 방법을 사용하여 샌드박스 내부에서 `echo "Hello from Serverless Sandboxes!"` 명령어를 실행하세요.
   3. `Sandbox.exec()`가 반환한 `Process` 객체를 사용하여 출력을 콘솔에 표시하세요.

   ```python show lines title="hello_sandbox.py" theme={null}
   from wandb.sandbox import Sandbox

   with Sandbox.run() as sandbox:
       process = sandbox.exec(["echo", "Hello from Serverless Sandboxes!"]).result()
       print(process.stdout)
   ```

   콘솔에 `Hello from Serverless Sandboxes!`가 출력됩니다.

   컨텍스트 관리자(`with` 블록)를 벗어나면 샌드박스가 자동으로 중지됩니다. 샌드박스 라이프사이클 및 상태에 대한 자세한 내용은 [샌드박스의 라이프사이클](/ko/sandboxes/lifecycle)을 참조하세요.

<div id="migrate-to-cwsandbox">
  ## cwsandbox로 마이그레이션
</div>

`wandb.sandbox`는 사용 중단되었으며 향후 W\&B Python SDK 릴리스에서 제거됩니다. 이를 대체하는 `cwsandbox` 패키지는 W\&B API 키와 CoreWeave API access token 중 어느 것이든 사용할 수 있습니다. 레퍼런스 문서는 [CoreWeave sandbox 문서](https://docs.coreweave.com/products/sandboxes)에서 확인할 수 있습니다.

마이그레이션하려면 패키지 설치 방법, 임포트 방법, credential 선택 방법을 변경하세요.

1. W\&B extra와 함께 `cwsandbox`를 설치하세요. 이 extra는 `cwsandbox`가 W\&B credential을 확인하는 데 사용하는 `wandb` 라이브러리를 함께 설치합니다.

   ```bash theme={null}
   pip install "cwsandbox[wandb]"
   ```

2. `wandb.sandbox` 대신 `cwsandbox`에서 임포트하고, 샌드박스 또는 Session을 생성할 때 `auth=AuthStrategy.WANDB`를 전달하세요. `cwsandbox`는 기본적으로 `CWSANDBOX_API_KEY`에서 CoreWeave API access token을 읽으므로, W\&B 인증은 명시적으로 선택해야 합니다.

   ```python title="이전: wandb.sandbox" theme={null}
   from wandb.sandbox import Sandbox

   with Sandbox.run() as sandbox:
       process = sandbox.exec(["echo", "Hello from Serverless Sandboxes!"]).result()
       print(process.stdout)
   ```

   ```python title="이후: cwsandbox" theme={null}
   from cwsandbox import AuthStrategy, Sandbox

   with Sandbox.run(auth=AuthStrategy.WANDB) as sandbox:
       process = sandbox.exec(["echo", "Hello from Serverless Sandboxes!"]).result()
       print(process.stdout)
   ```

W\&B credential은 현재와 동일한 방식으로, 즉 active 상태인 `wandb login` 세션, `WANDB_API_KEY` 환경 변수 또는 `~/.netrc`의 `api.wandb.ai` 항목에서 확인됩니다. 샌드박스 비용을 CoreWeave 계정으로 청구하려면 `auth`를 생략하고 `CWSANDBOX_API_KEY`에 CoreWeave API access token을 설정하세요. 두 credential의 비교는 [Choose a credential](https://docs.coreweave.com/products/sandboxes/get-started#choose-a-credential)을 참조하세요.

<div id="behavior-that-changes-after-you-migrate">
  ### 마이그레이션 후 달라지는 동작
</div>

`wandb.sandbox`는 `cwsandbox`를 래핑하면서, `cwsandbox` 패키지만 사용할 때는 적용되지 않는 W\&B Serverless 기본값을 적용합니다. 마이그레이션할 때 다음 차이점을 고려하세요.

| 동작               | `wandb.sandbox`                                       | `cwsandbox`                               |
| ---------------- | ----------------------------------------------------- | ----------------------------------------- |
| 최대 샌드박스 lifetime | 기본값 12시간                                              | 기본값 없음. `max_lifetime_seconds`를 직접 설정해야 함 |
| 시크릿 저장소          | `Secret`이 기본적으로 W\&B 팀 시크릿 저장소를 사용                    | `Secret`에 `store` 인수를 명시적으로 지정해야 함        |
| 배치 인수            | `profile_ids`, `profile_names`, `runner_ids`를 허용하지 않음 | CoreWeave 샌드박스 러너용으로 허용                   |

<div id="serverless-sandboxes-tutorials">
  ## Serverless Sandboxes 튜토리얼
</div>

더 자세한 예시는 다음을 참조하세요.

* [Serverless Sandbox에서 에이전트 호출하기 튜토리얼](/ko/sandboxes/invoke-agent-sandbox-tutorial)
* [Serverless Sandbox에서 PyTorch 모델 학습하기 튜토리얼](/ko/sandboxes/mltrain-in-sandbox-tutorial)

<div id="integrations">
  ## Integrations
</div>

다음 타사 프레임워크는 샌드박스 공급자로 Serverless Sandboxes를 지원합니다.

* [Harbor](https://github.com/harbor-framework/harbor)
