> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# W&B run에 연결하여 함수 호출 트레이스하기

> 실험 추적을 위해 Weave 트레이스를 W&B run과 연결합니다

W\&B Weave를 사용하면 코드의 함수 호출을 트레이스하고, 해당 호출이 실행된 [W\&B run](/ko/products/wandb/runs)에 직접 연결할 수 있습니다.
`@weave.op()`으로 함수를 트레이스하고 `wandb.init()` 컨텍스트 안에서 호출하면 Weave가 해당 트레이스를 W\&B run에 자동으로 연결합니다.
**Traces** 테이블에는 연결된 run으로 이동하는 링크가 표시됩니다.

<h2 id="view-a-wb-run-in-the-traces-table">
  Traces 테이블에서 W\&B run 보기
</h2>

<Tabs>
  <Tab title="Python">
    다음 Python 코드는 `wandb.init()` 컨텍스트 안에서 트레이스된 Op를 실행할 때 Weave가 이를 W\&B
    run에 연결하는 방식을 보여줍니다. 이 트레이스는
    Weights & Biases UI에 표시되며 해당 run에 연결됩니다.

    W\&B run을 Weave 트레이스로 보려면 다음 단계를 따르세요.

    1. 터미널에서 의존성을 설치하세요.

    ```bash lines theme={"system"}
    pip install wandb weave
    ```

    2. Forge에 로그인하세요.

    ```bash lines theme={"system"}
    wandb login
    ```

    3. 다음 스크립트에서 `your-team-name/your-project-name`을 사용 중인 W\&B entity와 프로젝트로 바꾸세요.

    ```python lines theme={"system"}
    import wandb
    import weave

    def example_wandb(projname):
        # projname을 entity와 프로젝트로 분리
        entity, project = projname.split("/", 1)

        # 트레이싱을 위한 Weave 컨텍스트 초기화
        weave.init(projname)

        # 트레이스 가능한 Op 정의
        @weave.op()
        def say(message: str) -> str:
            return f"I said: {message}"

        # 첫 번째 W&B run
        with wandb.init(
            entity=entity,
            project=project,
            notes="Experiment 1",
            tags=["baseline", "paper1"],
        ) as run:
            say("Hello, world!")
            say("How are you!")
            run.log({"messages": 2})

        # 두 번째 W&B run
        with wandb.init(
            entity=entity,
            project=project,
            notes="Experiment 2",
            tags=["baseline", "paper1"],
        ) as run:
            say("Hello, world from experiment 2!")
            say("How are you!")
            run.log({"messages": 2})

    if __name__ == "__main__":
        # 실제 W&B 사용자 이름/프로젝트로 바꾸세요
        example_wandb("your-team-name/your-project-name")
    ```

    4. 스크립트를 실행하세요.

    ```bash lines theme={"system"}
    python weave_trace_with_wandb.py
    ```

    5. [W\&B app](https://forge.coreweave.com/wandb)으로 이동하여 프로젝트를 선택하세요.
    6. **Weave 프로젝트 사이드바**에서 **Traces**를 클릭하세요. **Traces** 테이블에 연결된 run의 링크가 모두 표시됩니다.

    이제 **Traces** 테이블에서 트레이스를 열어 연결된 W\&B run을 살펴보고 관련 실험 컨텍스트를 확인할 수 있습니다.
  </Tab>

  <Tab title="TypeScript">
    ```text theme={"system"}
    이 기능은 아직 TypeScript SDK에서 사용할 수 없습니다.
    ```
  </Tab>
</Tabs>
