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

> Spark 클러스터에서 실험 추적, 메트릭 로깅, Model Management를 위해 W&B를 Databricks와 통합하세요.

# Databricks

W\&B는 Databricks 환경에서 W\&B Jupyter 노트북 사용 환경을 맞춤화하는 방식으로 [Databricks](https://www.databricks.com/)와 통합됩니다.

<div id="configure-databricks">
  ## Databricks 설정
</div>

1. 클러스터에 wandb 설치

   클러스터 설정으로 이동해 클러스터를 선택한 다음 **Libraries**를 클릭합니다. **Install New**를 클릭하고 **PyPI**를 선택한 후 `wandb` 패키지를 추가합니다.

2. 인증 설정

   W\&B 계정을 인증하려면 노트북에서 조회할 수 있도록 Databricks 시크릿을 추가하면 됩니다.

   ```bash theme={null}
   # Databricks CLI 설치
   pip install databricks-cli

   # Databricks UI에서 토큰 생성
   databricks configure --token

   # 두 명령 중 하나로 scope 생성(Databricks에서 보안 기능이 활성화되어 있는지에 따라 다름):
   # 보안 추가 기능 사용
   databricks secrets create-scope --scope wandb
   # 보안 추가 기능 미사용
   databricks secrets create-scope --scope wandb --initial-manage-principal users

   # https://wandb.ai/settings 에서 API 키 생성
   databricks secrets put --scope wandb --key api_key
   ```

<div id="examples">
  ## 예제
</div>

<div id="simple-example">
  ### 단순한 예제
</div>

```python theme={null}
import os
import wandb

api_key = dbutils.secrets.get("wandb", "api_key")
wandb.login(key=api_key)

with wandb.init() as run:
    run.log({"foo": 1})
```

<div id="sweeps">
  ### Sweeps
</div>

wandb.sweep() 또는 wandb.agent()를 사용하려는 노트북에 필요한 임시 설정:

```python theme={null}
import os

# 향후에는 이 설정이 필요하지 않을 예정입니다
os.environ["WANDB_ENTITY"] = "my-entity"
os.environ["WANDB_PROJECT"] = "my-project-that-exists"
```
