repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
wandb | tests/unit_tests/test_launch/test_environment/test_aws.py | .py | import os
from unittest.mock import MagicMock
import pytest
from botocore.exceptions import ClientError
from wandb.sdk.launch.environment.aws_environment import AwsEnvironment
from wandb.sdk.launch.errors import LaunchError
def _get_environment():
return AwsEnvironment(
region="us-west-2",
secret... | 282 | 9,160 |
wandb | tests/unit_tests/test_launch/test_environment/test_azure.py | .py | from unittest.mock import MagicMock
import pytest
from wandb.sdk.launch.environment.azure_environment import AzureEnvironment
from wandb.sdk.launch.errors import LaunchError
def test_azure_environment_from_config(mocker):
"""Test AzureEnvironment class."""
mocker.patch(
"wandb.sdk.launch.environment.... | 105 | 3,321 |
wandb | tests/unit_tests/test_lib/test_ratelimit.py | .py | import asyncio
import pytest
from looptime import LoopTimeProxy
from wandb.sdk.lib import asyncio_compat, ratelimit
@pytest.mark.asyncio
@pytest.mark.looptime
async def test_allows_first_event(looptime: LoopTimeProxy):
cooldown = ratelimit.Cooldown(13)
await cooldown.wait()
# Should not sleep, so no ti... | 51 | 1,371 |
wandb | tests/unit_tests/test_lib/test_service_finalizer.py | .py | from collections.abc import Generator
from unittest.mock import AsyncMock
import pytest
from wandb.proto import wandb_server_pb2 as spb
from wandb.sdk.lib import asyncio_manager
from wandb.sdk.lib.service.service_finalizer import ServiceFinalizer
@pytest.fixture(scope="module")
def asyncer() -> Generator[asyncio_man... | 39 | 1,066 |
wandb | tests/unit_tests/test_lib/test_git.py | .py | #!/usr/bin/env python
"""Tests for the `wandb.GitRepo` module."""
from __future__ import annotations
import os
import subprocess
from collections.abc import Generator
import pytest
from wandb.sdk.lib import gitlib
from wandb.sdk.lib.gitlib import GitCommandError, GitRepo, GitVersion
def run_git(cwd: str, *args: s... | 358 | 13,708 |
wandb | tests/unit_tests/test_lib/test_service_token.py | .py | import os
import pathlib
import socket
import pytest
from wandb.sdk.lib import asyncio_manager
from wandb.sdk.lib.service import ipc_support, service_token
@pytest.fixture
def chdir_to_tmp_path(tmp_path):
cwd = pathlib.Path.cwd()
os.chdir(tmp_path)
try:
yield
finally:
os.chdir(cwd)
... | 64 | 1,608 |
wandb | tests/unit_tests/test_lib/test_identity.py | .py | import pytest
import wandb
from wandb.proto.wandb_api_pb2 import AuthenticateResponse
from wandb.sdk.lib import identity
from wandb.sdk.lib.service.service_connection import WandbApiFailedError
_RESPONSE = AuthenticateResponse(
default_entity="my-entity",
username="my-user",
email="me@example.com",
tea... | 81 | 2,661 |
wandb | tests/unit_tests/test_lib/test_service_client.py | .py | from __future__ import annotations
import asyncio
import struct
import threading
from typing import Literal
import pytest
from wandb.proto import wandb_server_pb2 as spb
from wandb.sdk import mailbox
from wandb.sdk.lib import asyncio_manager
from wandb.sdk.lib.service.service_client import ServiceClient
class _Fake... | 218 | 6,242 |
wandb | tests/unit_tests/test_lib/test_auth_prompt.py | .py | from unittest.mock import MagicMock
import pytest
from wandb.errors import links, term
from wandb.sdk.lib.wbauth import host_url, prompt, saas, validation, wbnetrc
from tests.fixtures.emulated_terminal import EmulatedTerminal
pytestmark = pytest.mark.usefixtures("skip_verify_login")
@pytest.fixture(autouse=True)
d... | 264 | 8,969 |
wandb | tests/unit_tests/test_lib/test_auth.py | .py | import pathlib
import textwrap
from unittest.mock import MagicMock
import pytest
from wandb.errors import AuthenticationError
from wandb.sdk.lib.wbauth import (
AuthApiKey,
AuthIdentityTokenFile,
authenticate_session,
session_credentials,
use_explicit_auth,
validation,
)
from tests.fixtures.mo... | 213 | 6,581 |
wandb | tests/unit_tests/test_lib/test_filesystem.py | .py | import ctypes
import errno
import os
import platform
import re
import shutil
import tempfile
import time
from pathlib import Path
from unittest import mock
from unittest.mock import Mock, patch
import pytest
# from pyfakefs.fake_filesystem import OSType
from wandb.sdk.lib import filesystem
from wandb.sdk.lib.filesyst... | 611 | 21,225 |
wandb | tests/unit_tests/test_lib/test_urls.py | .py | from __future__ import annotations
import pytest
from wandb.sdk.lib import urls
_TEST_CASES: tuple[tuple[str, bool], ...] = (
("https://api.wandb.ai", True),
("http://123.123.123.123", True),
("https://", False),
("https://wandb.ai\t", False),
("https://wandb.ai\r", False),
("https://wandb.ai\... | 30 | 778 |
wandb | tests/unit_tests/test_lib/test_settings_file.py | .py | import pathlib
import re
import textwrap
import pytest
from wandb.sdk.lib import settings_file
from tests.fixtures.mock_wandb_log import MockWandbLog
def test_error_writing(tmp_path: pathlib.Path):
local_settings = tmp_path / "local_settings"
local_settings.mkdir() # Cannot read or write a directory.
... | 198 | 5,213 |
wandb | tests/unit_tests/test_lib/test_printer_asyncio.py | .py | from __future__ import annotations
import contextlib
import threading
from collections.abc import Generator
from unittest.mock import Mock
import pytest
from wandb.sdk.lib import printer, printer_asyncio
class _Tester:
"""Helper to test run_async_with_spinner."""
def __init__(self, loading_symbol: str) -> ... | 85 | 2,406 |
wandb | tests/unit_tests/test_lib/test_sparkline.py | .py | from wandb.sdk.lib import sparkline
def test_sparkline():
assert sparkline.sparkify([1, 2, 3]) == "ββ
β"
def test_sparkline_nan():
assert sparkline.sparkify([float("nan"), 2, 3]) == " ββ"
def test_sparkline_inf():
assert sparkline.sparkify([float("inf"), 2, 3]) == " ββ"
def test_sparkline_1finite():
... | 26 | 592 |
wandb | tests/unit_tests/test_lib/test_run_messages.py | .py | import asyncio
from unittest.mock import AsyncMock, Mock
import pytest
import pytest_asyncio
from looptime import LoopTimeProxy
from wandb.proto import wandb_internal_pb2 as pb
from wandb.sdk.lib import asyncio_compat, run_messages
from tests.fixtures.mock_wandb_log import MockWandbLog
@pytest_asyncio.fixture
async... | 104 | 3,096 |
wandb | tests/unit_tests/test_lib/test_auth_validation.py | .py | import pytest
from wandb.sdk.lib.wbauth import validation
@pytest.mark.parametrize(
"key, problems",
(
("", "API key is empty."),
("some_prefix-" + "A" * 39, "API key must have 40+ characters, has 39."),
("some_prefix-" + "A" * 40, None),
("some_prefix-" + "A" * 60, None),
... | 22 | 550 |
wandb | tests/unit_tests/test_lib/test_service_port_file.py | .py | from unittest import mock
import pytest
from wandb.sdk.lib.service import ipc_support, service_port_file, service_token
@pytest.fixture(autouse=True)
def make_sleep_instant(monkeypatch):
test_time = 0
def fake_sleep(seconds: float) -> None:
nonlocal test_time
test_time += seconds
monkey... | 132 | 3,391 |
wandb | tests/unit_tests/test_lib/test_json_util.py | .py | """Consistency tests for `wandb.sdk.lib.json_util`.
The wrapper delegates to `pydantic_core` for speed but must remain
behaviorally consistent with stdlib `json` for the patterns we use:
basic types, custom encoders, fallbacks, and NaN/Infinity preservation.
"""
from __future__ import annotations
import io
import js... | 249 | 7,714 |
wandb | tests/unit_tests/test_lib/test_telemetry.py | .py | """telemetry lib tests."""
from unittest.mock import MagicMock
import pytest
from wandb import env
from wandb.analytics.opentelemetry import opentelemetry_proxy
from wandb.analytics.opentelemetry.opentelemetry_proxy import (
LowCardinalityAttributes,
TelemetryRecorder,
)
from wandb.sdk.lib import telemetry
... | 119 | 4,262 |
wandb | tests/unit_tests/test_lib/test_progress.py | .py | from collections.abc import Generator
import pytest
from wandb.proto import wandb_internal_pb2 as pb
from wandb.sdk.lib import printer as p
from wandb.sdk.lib import progress
from tests.fixtures.emulated_terminal import EmulatedTerminal
from tests.fixtures.mock_wandb_log import MockWandbLog
@pytest.fixture()
def dy... | 310 | 9,236 |
wandb | tests/unit_tests/test_lib/test_auth_host_url.py | .py | import pytest
from wandb.sdk.lib.wbauth.host_url import HostUrl
def test_validates_url():
with pytest.raises(ValueError):
HostUrl("invalid")
@pytest.mark.parametrize(
"raw_url",
(
"https://api.wandb.ai",
"https://api.wandb.ai/",
"https://api.wandb.ai//",
),
)
def test... | 46 | 989 |
wandb | tests/unit_tests/test_lib/test_printer.py | .py | import pytest
import wandb
from wandb.sdk.lib import printer as p
@pytest.mark.parametrize("level", [1.3, {}, []])
def test_printer_invalid_level_type(level):
printer = p.new_printer()
with pytest.raises(ValueError, match="Unknown status level"):
printer.display("test string", level=level)
@pytest.... | 52 | 1,326 |
wandb | tests/unit_tests/test_lib/test_runid.py | .py | import multiprocessing as mp
import random
from concurrent.futures import ProcessPoolExecutor
from pytest import fixture, mark
from wandb.sdk.lib.runid import generate_fast_id, generate_id
def test_generate_id_is_base36():
# Given reasonable randomness assumptions, generating an 1000-digit string should
# hi... | 57 | 1,730 |
wandb | tests/unit_tests/test_lib/test_paths.py | .py | import itertools
import platform
import re
from pathlib import Path, PurePath, PurePosixPath, PureWindowsPath
import pytest
from wandb.sdk.lib.paths import LogicalPath
from wandb.util import to_forward_slash_path
# Once upon a time I used hypothesis and fspaths to generate test cases. This was a good
# thing, and un... | 179 | 7,616 |
wandb | tests/unit_tests/test_lib/test_filenames.py | .py | from pathlib import Path
import pytest
from wandb.sdk.lib.filenames import exclude_wandb_fn, filtered_dir
def test_filtered_dir_one_parameter(tmp_path: Path):
with open(tmp_path / "foo.txt", "w") as f:
f.write("test")
filtered_dir(tmp_path, lambda path: True, lambda path: False)
def test_filtered_d... | 40 | 1,310 |
wandb | tests/unit_tests/test_lib/test_hashutil.py | .py | from __future__ import annotations
import base64
import hashlib
import sys
from pathlib import Path
import pytest
from _pytest.fixtures import SubRequest
from pyfakefs.fake_filesystem import FakeFilesystem
from wandb.sdk.lib import hashutil
BYTE_STRS: tuple[bytes] = (
b"",
b"\xb7\xb7",
b"\x89\xf3\xa2\xe1... | 139 | 4,254 |
wandb | tests/unit_tests/test_lib/test_auth_netrc.py | .py | import netrc
import pathlib
import textwrap
import pytest
from wandb.sdk.lib.wbauth import wbnetrc
from tests.fixtures.mock_wandb_log import MockWandbLog
@pytest.fixture
def fake_netrc_path(
monkeypatch: pytest.MonkeyPatch,
tmp_path: pathlib.Path,
) -> pathlib.Path:
path = tmp_path / "test-netrc"
mo... | 230 | 6,530 |
wandb | tests/unit_tests/test_artifacts/test_references_gcs.py | .py | from __future__ import annotations
import os
from pytest import fixture, raises
from wandb import Artifact
from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
from wandb.sdk.artifacts.artifact_state import ArtifactState
from wandb.sdk.artifacts.storage_handlers.gcs_handler import (
GCSHa... | 214 | 6,790 |
wandb | tests/unit_tests/test_artifacts/test_artifact_manifest_entry.py | .py | from __future__ import annotations
from pathlib import Path, PurePath
from typing import Any
from pytest import mark, param, raises
from pytest_mock import MockerFixture
from wandb.sdk.artifacts._validators import validate_fspath
from wandb.sdk.artifacts.artifact import Artifact
from wandb.sdk.artifacts.artifact_mani... | 106 | 3,595 |
wandb | tests/unit_tests/test_artifacts/saved_model_constructors.py | .py | # This file is separated from the main test file in
# order to simulate models defined in external modules.
import pytest
torch = pytest.importorskip("torch")
tensorflow = pytest.importorskip("tensorflow")
keras = tensorflow.keras
svm = pytest.importorskip("sklearn.svm")
np = pytest.importorskip("numpy")
def sklearn... | 53 | 1,582 |
wandb | tests/unit_tests/test_artifacts/test_storage.py | .py | import errno
import os
import random
import tempfile
from multiprocessing import Pool
from pathlib import Path
from typing import Any
import wandb
from pydantic import ValidationError
from pyfakefs.fake_filesystem import FakeFilesystem
from pytest import mark, raises
from wandb.sdk.artifacts.artifact import Artifact
f... | 600 | 18,518 |
wandb | tests/unit_tests/test_artifacts/test_wandb_artifacts.py | .py | from __future__ import annotations
import functools
import queue
import shutil
import unittest.mock as mock
from collections.abc import Mapping
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from string import ascii_letters, digits
from typing import TYPE_CHECKING, Any
from unittest.mock im... | 741 | 24,943 |
wandb | tests/unit_tests/test_artifacts/test_validators.py | .py | from pathlib import Path, PurePosixPath, PureWindowsPath
from pytest import mark, raises
from wandb.sdk.artifacts._validators import (
REGISTRY_PREFIX,
RESERVED_ARTIFACT_TYPE_PREFIX,
ArtifactPath,
validate_artifact_path,
validate_artifact_type,
validate_project_name,
)
from wandb.sdk.lib.paths ... | 186 | 5,635 |
wandb | tests/unit_tests/test_artifacts/test_saved_model.py | .py | import os
import cloudpickle
import pytest
import torch
import wandb
from pytest_mock import MockerFixture
from wandb._strutils import b64encode_ascii
from wandb.apis.public.service_api import ServiceApi
from wandb.sdk.artifacts._generated import ArtifactFragment
from wandb.sdk.artifacts.artifact import Artifact
from ... | 237 | 6,453 |
wandb | tests/unit_tests/test_artifacts/test_s3_handler.py | .py | import pytest
from wandb.sdk.artifacts.storage_handlers.s3_handler import S3Handler
COREWEAVE_ENDPOINT_TEST_CASES = [
# Direct matches from the predefined list
("https://cwobject.com", True),
("https://cwobject.com/", True),
("http://cwlota.com", True),
("accel-object.lga1.coreweave.com", True),
... | 31 | 1,161 |
wandb | tests/unit_tests/test_artifacts/test_references_s3.py | .py | from __future__ import annotations
import hashlib
from typing import TYPE_CHECKING
import boto3
from moto import mock_aws
from pytest import MonkeyPatch, fixture, mark, raises
from wandb import Artifact
if TYPE_CHECKING:
from collections.abc import Iterator
from botocore.client import BaseClient
@fixture
... | 288 | 8,414 |
wandb | tests/unit_tests/test_artifacts/test_references_azure.py | .py | from __future__ import annotations
import unittest.mock
from pytest import fixture, mark
from wandb import Artifact
@fixture
def mock_azure_handler(): # noqa: C901
class BlobServiceClient:
def __init__(self, account_url, credential):
pass
def get_container_client(self, container):
... | 260 | 8,317 |
wandb | tests/unit_tests/test_artifacts/conftest.py | .py | import os
from pathlib import Path
import pytest
from pytest_mock import MockerFixture
from wandb import env
from wandb.sdk.artifacts.artifact_file_cache import (
ArtifactFileCache,
get_artifact_file_cache,
)
@pytest.fixture
def artifact_file_cache(mocker: MockerFixture, tmp_path: Path) -> ArtifactFileCache:... | 19 | 596 |
wandb | tests/unit_tests/test_automations/test_events.py | .py | """Tests on behavior of Automation events."""
from __future__ import annotations
from hypothesis import given
from pytest import mark
from wandb.apis.public import Project
from wandb.automations import (
ArtifactEvent,
EventType,
MetricChangeFilter,
MetricThresholdFilter,
MetricZScoreFilter,
O... | 292 | 12,176 |
wandb | tests/unit_tests/test_automations/test_automations.py | .py | from __future__ import annotations
import json
from typing import Any
from pydantic import ValidationError
from pytest import FixtureRequest, fixture, mark, raises
from wandb.automations import (
ActionType,
ArtifactEvent,
EventType,
NewAutomation,
OnAddArtifactAlias,
OnAddArtifactTag,
OnA... | 388 | 14,893 |
wandb | tests/unit_tests/test_automations/_strategies.py | .py | """Example generation strategies for automations tests that rely on `hypothesis`."""
from __future__ import annotations
from enum import Enum
from secrets import choice
from string import ascii_letters
from typing import Any
from hypothesis.strategies import (
DrawFn,
SearchStrategy,
booleans,
compos... | 212 | 6,739 |
wandb | tests/unit_tests/test_automations/test_run_events.py | .py | from __future__ import annotations
import json
import operator
from collections.abc import Iterable
from typing import Any
import pytest
from hypothesis import given
from hypothesis.strategies import DrawFn, SearchStrategy, composite, lists, sampled_from
from pydantic import ValidationError
from pytest import raises
... | 775 | 27,058 |
wandb | tests/unit_tests/test_automations/test_scopes.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from pydantic import BaseModel, ValidationError
from pytest import mark, raises
from wandb._strutils import nameof
from wandb.automations import (
ArtifactCollectionScope,
EntityScope,
ProjectScope,
RegistryScope,
ScopeType,
)
fro... | 202 | 6,573 |
wandb | tests/unit_tests/test_automations/test_actions.py | .py | import json
from hypothesis import given
from hypothesis.strategies import dictionaries, sampled_from, text
from wandb.automations import ActionType, SendNotification, SendWebhook
from wandb.automations._generated import AlertSeverity, TriggeredActionType
from wandb.sdk.wandb_alerts import AlertLevel
from tests.unit_... | 90 | 3,149 |
wandb | tests/unit_tests/test_automations/conftest.py | .py | from __future__ import annotations
import json
import secrets
from functools import cache
from typing import TypeAlias
from unittest.mock import Mock
from hypothesis import settings
from pytest import FixtureRequest, fixture, skip
from pytest_mock import MockerFixture
from wandb._strutils import b64encode_ascii
from ... | 613 | 19,206 |
wandb | tests/unit_tests/test_public_api/test_history.py | .py | import json
from collections.abc import Callable
from types import SimpleNamespace
from wandb.apis.public.history import HistoryScan
from wandb.proto import wandb_api_pb2 as apb
class FakeServiceApi:
def __init__(self, pages):
self.pages = list(pages)
self.scan_ranges = []
def send_api_reque... | 77 | 2,253 |
wandb | tests/unit_tests/test_public_api/test_service_api.py | .py | from typing import Any
import pytest
from wandb.apis.public.service_api import ServiceApi
from wandb.proto import wandb_api_pb2 as apb
from wandb.sdk.lib.service.service_connection import WandbApiFailedError
from wandb.sdk.wandb_settings import Settings
def test_execute_graphql_sends_query_unchanged_and_timeout():
... | 51 | 1,665 |
wandb | tests/unit_tests/test_public_api/test_summary.py | .py | import json
from pathlib import Path
from types import SimpleNamespace
from unittest import mock
from wandb.apis.public.summary import HTTPSummary, Summary
def _run(tmp_path: Path) -> SimpleNamespace:
return SimpleNamespace(
dir=str(tmp_path),
id="run-id",
entity="entity",
project... | 39 | 1,127 |
wandb | tests/unit_tests/test_public_api/test_sweeps.py | .py | import json
import pytest
from wandb.apis.public.sweeps import Sweep
from wandb.errors import UnsupportedError
from wandb.proto import wandb_internal_pb2 as pb
def _make_sweep(
mocker, *, feature_enabled: bool = True, graphql_response=None
) -> Sweep:
"""Build a Sweep backed by a mocked service API.
Pas... | 100 | 3,183 |
wandb | tests/unit_tests/test_public_api/test_public_api.py | .py | import json
import sys
from types import SimpleNamespace
from unittest import mock
from unittest.mock import MagicMock
import pytest
import wandb
from wandb import Api
from wandb.apis._generated import ProjectFragment, UserFragment
from wandb.errors import UsageError
from wandb.proto import wandb_api_pb2 as apb
from w... | 615 | 20,609 |
wandb | tests/unit_tests/test_public_api/test_registries_ordered_versions.py | .py | from __future__ import annotations
import json
import logging
from collections.abc import Iterable
from typing import TYPE_CHECKING
import pytest
from wandb._strutils import b64encode_ascii
from wandb.apis.public.registries import _utils
from wandb.apis.public.registries._utils import (
_project_id_from_gql_id,
... | 272 | 8,546 |
wandb | tests/unit_tests/test_public_api/test_runs.py | .py | import json
from unittest import mock
import pytest
import wandb
from wandb.apis.public.runs import Run, RunNotFoundError
from wandb.apis.public.sweeps import Sweep
from wandb.proto import wandb_api_pb2 as apb
def _make_upload_run(mocker, *, feature_enabled: bool):
service_api = mocker.MagicMock()
service_ap... | 364 | 11,607 |
wandb | tests/unit_tests/test_wandb_agent/test_cli_agent.py | .py | from __future__ import annotations
import contextlib
import io
import json
import multiprocessing
import pathlib
from unittest import mock
import pytest
import yaml
from wandb import env, wandb_agent
from wandb.sdk.launch.sweeps import SweepNotFoundError
from wandb.sdk.lib.service.service_connection import WandbApiFa... | 204 | 6,298 |
wandb | tests/unit_tests/test_wandb_agent/test_pyagent.py | .py | """Unit tests for sweep agent behavior without a live backend."""
from __future__ import annotations
import contextlib
import io
import threading
import pytest
import wandb
from wandb.sdk.launch.sweeps import SweepNotFoundError
from wandb.sdk.lib.service.service_connection import WandbApiFailedError
from .conftest ... | 224 | 7,185 |
wandb | tests/unit_tests/test_wandb_agent/conftest.py | .py | """Fixtures and helpers for sweep agent unit tests."""
from __future__ import annotations
import contextlib
import dataclasses
import multiprocessing
import queue
from collections.abc import Callable, Iterator
from pathlib import Path
from typing import Any
from unittest import mock
import pytest
import wandb
import... | 223 | 7,239 |
wandb | tests/unit_tests/test_wandb_agent/scripts/train_with_import_readline.py | .py | import sys
import wandb
# For use with test_pyagent.py::test_agent_subprocess_with_import_readline
def main() -> None:
with wandb.init() as run:
print("Importing readline...")
# `import readline` causes deadlock if parent launches subprocess using
# progress_group=0 without a pty
... | 40 | 976 |
wandb | tests/unit_tests/test_registries/test_freezable_list.py | .py | import pytest
from wandb.apis.public.registries._freezable_list import FreezableList
@pytest.fixture
def empty_list() -> FreezableList[str]:
return FreezableList[str]()
@pytest.fixture
def list_2_frozen() -> FreezableList[str]:
return FreezableList[str](["frozen_one", "frozen_two", "frozen_three"])
@pytes... | 365 | 11,563 |
wandb | tests/unit_tests/test_registries/test_addonly_list.py | .py | from __future__ import annotations
from collections import deque
from collections.abc import Iterable
from itertools import tee, zip_longest
from typing import TypeVar
from hypothesis import given
from hypothesis.strategies import (
SearchStrategy,
integers,
iterables,
lists,
slices,
text,
)
f... | 292 | 9,231 |
wandb | tests/unit_tests/test_registries/test_utils.py | .py | from __future__ import annotations
import json
from typing import TYPE_CHECKING
from pytest import fixture, mark, param, raises
from wandb.apis.public.registries._utils import (
prepare_artifact_types_input,
prepare_registry_filter,
)
from wandb.apis.public.registries.registries_search import Collections, Reg... | 201 | 6,004 |
wandb | tests/unit_tests/test_media/test_media_logging.py | .py | import os
import platform
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pytest
import wandb
from bokeh.plotting import figure
from rdkit import Chem
from wandb import data_types
data = np.random.randint(255, size=(1000))
@pytest.fixture
def audio_media() -> wandb.Audio:
audi... | 157 | 4,002 |
wandb | tests/unit_tests/test_analytics/sentry_relay.py | .py | from __future__ import annotations
import gzip
import socket
import threading
import time
from typing import Any
import flask
import requests
from flask import request
from sentry_sdk.envelope import Envelope
class SentryResponse:
def __init__(
self,
message: str | None,
project_id: str,... | 148 | 4,308 |
wandb | tests/unit_tests/test_analytics/test_sentry.py | .py | import os
from unittest import mock
import pytest
import wandb
import wandb.analytics
import wandb.env
from sentry_sdk.utils import sentry_sdk
from .sentry_relay import MetricRelayServer, SentryResponse
SENTRY_DSN_FORMAT = "http://{key}@127.0.0.1:{port}/{project}"
@pytest.fixture(scope="module")
def relay():
r... | 598 | 21,977 |
wandb | tests/unit_tests/test_file/test_file_public_api.py | .py | from unittest import mock
import wandb
from pytest import fixture
from wandb.apis.public.files import File
from wandb.proto import wandb_api_pb2 as apb
@fixture
def mock_client(mocker) -> mock.MagicMock:
return mocker.MagicMock()
@fixture
def termwarn_spy(mocker) -> mock.MagicMock:
return mocker.spy(wandb,... | 138 | 4,311 |
wandb | tests/unit_tests/test_filters/test_filters.py | .py | from __future__ import annotations
import json
from typing import Any
from hypothesis import given
from hypothesis.strategies import booleans, builds, integers, lists, sampled_from
from wandb._filters import (
All,
And,
Contains,
Eq,
Exists,
FilterExpr,
Gt,
Gte,
In,
Lt,
Lte... | 403 | 12,262 |
wandb | tests/unit_tests/test_filters/_strategies.py | .py | """Example generation strategies for generic MongoDB filter tests that rely on `hypothesis`."""
from __future__ import annotations
from string import ascii_letters, digits, punctuation
from typing import Any
from hypothesis.strategies import (
DrawFn,
booleans,
composite,
dictionaries,
fixed_dict... | 130 | 4,309 |
wandb | tests/fixtures/mock_wandb_log.py | .py | from __future__ import annotations
import re
import textwrap
import unittest.mock
from collections.abc import Iterable
import pytest
@pytest.fixture
def mock_wandb_log(monkeypatch: pytest.MonkeyPatch) -> MockWandbLog:
"""Mocks the wandb.term*() methods for a test.
This patches the termlog() / termwarn() / ... | 116 | 4,006 |
wandb | tests/fixtures/emulated_terminal.py | .py | from __future__ import annotations
from itertools import takewhile
import pyte
import pyte.modes
import pytest
from wandb.errors import term
@pytest.fixture
def emulated_terminal(
monkeypatch: pytest.MonkeyPatch,
capsys: pytest.CaptureFixture[str],
) -> EmulatedTerminal:
"""Emulates a terminal for the d... | 113 | 3,670 |
wandb | tests/fixtures/wandb_backend_spy/gql_match.py | .py | """GraphQL request matchers and responders."""
from __future__ import annotations
import abc
import dataclasses
import json
import re
import threading
from typing import TypeAlias
import fastapi
from typing_extensions import Any, override
# Matches queries containing an operation line, ignoring whitespace and
# Gra... | 217 | 5,452 |
wandb | tests/fixtures/wandb_backend_spy/__init__.py | .py | """Defines a proxy server that spies on requests to the W&B backend."""
__all__ = (
"spy_proxy",
"WandbBackendProxy",
"WandbBackendSpy",
)
from .proxy import WandbBackendProxy, spy_proxy
from .spy import WandbBackendSpy
| 11 | 234 |
wandb | tests/fixtures/wandb_backend_spy/proxy.py | .py | from __future__ import annotations
import asyncio
import contextlib
import socket
import threading
import time
from collections.abc import Generator
import fastapi
import httpx
import uvicorn
from .spy import WandbBackendSpy
@contextlib.contextmanager
def spy_proxy(
target_host: str,
target_port: int,
) ->... | 234 | 6,757 |
wandb | tests/fixtures/wandb_backend_spy/spy.py | .py | from __future__ import annotations
import contextlib
import dataclasses
import gzip
import json
import threading
from collections.abc import Generator
from typing import Any
import fastapi
from typing_extensions import NamedTuple
from . import gql_match
class WandbBackendSpy:
"""A spy that intercepts interacti... | 600 | 18,932 |
wandb | tests/system_tests/backend_fixtures.py | .py | from __future__ import annotations
import json
import secrets
import subprocess
import sys
from collections import deque
from dataclasses import InitVar, asdict, dataclass, field
from pathlib import Path
from string import ascii_lowercase, digits
from typing import Any, ClassVar, Final, Literal
import httpx
#: The r... | 282 | 7,985 |
wandb | tests/system_tests/test_plot.py | .py | from __future__ import annotations
import json
from typing import TYPE_CHECKING
import pytest
import wandb
if TYPE_CHECKING:
from wandb.plot.custom_chart import CustomChart
@pytest.fixture
def roc_curve() -> CustomChart:
return wandb.plot.roc_curve(
y_true=[0, 1],
y_probas=[
(0.... | 237 | 6,297 |
wandb | tests/system_tests/conftest.py | .py | from __future__ import annotations
import contextlib
from collections.abc import Callable, Generator
from dataclasses import dataclass
import pytest
import wandb
from tests.fixtures.wandb_backend_spy import (
WandbBackendProxy,
WandbBackendSpy,
spy_proxy,
)
from .backend_fixtures import (
BackendFix... | 252 | 7,503 |
wandb | tests/system_tests/test_sandbox/test_auth.py | .py | from __future__ import annotations
from dataclasses import dataclass, field
import cwsandbox
import cwsandbox._sandbox as cwsandbox_sandbox
import pytest
import wandb
from wandb.sandbox import Sandbox
class _FakeChannel:
async def close(self, grace=None) -> None:
_ = grace
@dataclass
class _SandboxStu... | 159 | 4,830 |
wandb | tests/system_tests/test_launch/test_launch_cli.py | .py | import json
from unittest.mock import AsyncMock, MagicMock, Mock
import pytest
import wandb
from wandb.cli import cli
from wandb.sdk.launch.errors import LaunchError
REPO_CONST = "test-repo"
IMAGE_CONST = "fake-image"
QUEUE_NAME = "test_queue"
def _setup_agent(monkeypatch, pop_func):
monkeypatch.setattr("wandb.... | 395 | 11,833 |
wandb | tests/system_tests/test_launch/test_wandb_controller.py | .py | import pytest
import sweeps
import wandb
SWEEP_CONFIGURATION = {
"method": "random",
"name": "sweep",
"metric": {"goal": "maximize", "name": "val_acc"},
"parameters": {
"batch_size": {"values": [16, 32, 64]},
"epochs": {"values": [5, 10, 15]},
"lr": {"distribution": "uniform", "... | 86 | 2,317 |
wandb | tests/system_tests/test_launch/test_launch_run.py | .py | import json
from unittest import mock
import wandb
from wandb.apis import internal, public
from wandb.sdk.artifacts._internal_artifact import InternalArtifact
from wandb.sdk.internal import job_builder
from wandb.sdk.launch._project_spec import _inject_wandb_config_env_vars
from wandb.util import make_artifact_name_sa... | 131 | 4,746 |
wandb | tests/system_tests/test_launch/test_launch_sweep.py | .py | import json
import wandb
from wandb.apis.public import Api as PublicApi
from wandb.cli import cli
from wandb.sdk.launch.sweeps.scheduler import Scheduler
from wandb.sdk.launch.utils import LAUNCH_DEFAULT_PROJECT, construct_launch_spec
def test_sweeps_on_launch(
use_local_wandb_backend,
user,
monkeypatch,... | 187 | 5,412 |
wandb | tests/system_tests/test_launch/test_job_status_tracker.py | .py | import base64
from unittest import mock
from unittest.mock import MagicMock
import pytest
import wandb
from wandb.sdk.launch.agent.job_status_tracker import JobAndRunStatusTracker
@pytest.mark.asyncio
async def test_check_stop_run_not_exist(user):
job_tracker = JobAndRunStatusTracker(
"run_queue_item_id"... | 51 | 1,695 |
wandb | tests/system_tests/test_launch/test_launch_public_api.py | .py | import json
import pytest
import wandb
import wandb.apis.public
from wandb import Api
from wandb.errors import UnsupportedError
SWEEP_CONFIGURATION = {
"method": "random",
"name": "sweep",
"metric": {"goal": "maximize", "name": "val_acc"},
"parameters": {
"batch_size": {"values": [16, 32, 64]}... | 148 | 4,254 |
wandb | tests/system_tests/test_launch/test_launch_sweep_cli.py | .py | import json
import subprocess
import pytest
import wandb
from wandb.apis.internal import InternalApi
from wandb.apis.public import Api
from wandb.sdk.launch.utils import LAUNCH_DEFAULT_PROJECT
def _run_cmd_check_msg(cmd: list[str], assert_str: str, *, check: bool = True) -> None:
"""Helper for asserting a statem... | 259 | 7,672 |
wandb | tests/system_tests/test_launch/test_launch_local_container.py | .py | from unittest.mock import MagicMock
import pytest
from wandb.apis.internal import Api
from wandb.sdk.launch import loader
from wandb.sdk.launch._project_spec import EntryPoint
@pytest.mark.asyncio
async def test_local_container_entrypoint(use_local_wandb_backend, monkeypatch):
_ = use_local_wandb_backend
de... | 88 | 2,857 |
wandb | tests/system_tests/test_launch/test_launch_add.py | .py | import os
from unittest import mock
import pytest
import wandb
from wandb.apis.public import Api as PublicApi
from wandb.sdk.internal.internal_api import Api as InternalApi
from wandb.sdk.launch._launch_add import launch_add
from wandb.sdk.launch.utils import LAUNCH_DEFAULT_PROJECT, LaunchError
class MockBranch:
... | 553 | 15,392 |
wandb | tests/system_tests/test_launch/test_agent.py | .py | import json
import os
import wandb
from wandb.cli import cli
def test_agent_queues_config(runner, monkeypatch, user):
run = wandb.init(project="model-registry")
run.finish()
monkeypatch.setattr(
wandb.sdk.launch._launch,
"LAUNCH_CONFIG_FILE",
os.path.join("./config/wandb/launch-co... | 31 | 904 |
wandb | tests/system_tests/test_launch/test_wandb_reference.py | .py | from wandb.sdk.launch.wandb_reference import WandbReference
def test_parse_bad() -> None:
ref = WandbReference.parse("not a url")
assert ref is None
def test_parse_hostonly() -> None:
test_cases = [
"https://wandb.ai",
"https://wandb.ai/",
]
for test_case in test_cases:
r... | 154 | 5,585 |
wandb | tests/system_tests/test_launch/test_launch_kubernetes.py | .py | from unittest.mock import AsyncMock, MagicMock
import kubernetes_asyncio
import pytest
from wandb.apis.internal import Api
from wandb.sdk.launch import loader
from wandb.sdk.launch.agent.agent import LaunchAgent
from wandb.sdk.launch.runner import kubernetes_monitor, kubernetes_runner
from wandb.sdk.launch.utils impor... | 419 | 12,574 |
wandb | tests/system_tests/test_launch/test_launch.py | .py | from unittest import mock
from unittest.mock import MagicMock
import pytest
import wandb
from wandb.errors import CommError
from wandb.sdk.internal.internal_api import Api as InternalApi
from wandb.sdk.launch._launch import _launch
from wandb.sdk.launch.errors import LaunchError
class MockBuilder:
def __init__(s... | 127 | 3,377 |
wandb | tests/system_tests/test_launch/test_launch_vertex.py | .py | from unittest.mock import MagicMock
import pytest
import wandb
from wandb.apis.internal import Api
from wandb.sdk.launch import loader
from wandb.sdk.launch._project_spec import EntryPoint
from wandb.sdk.launch.environment.gcp_environment import GcpEnvironment
@pytest.fixture
def mock_vertex_environment():
"""Mo... | 148 | 4,866 |
wandb | tests/system_tests/test_launch/test_launch_sagemaker.py | .py | from unittest.mock import MagicMock
import pytest
import wandb
from wandb.apis.internal import Api
from wandb.sdk.launch import loader
from wandb.sdk.launch._project_spec import EntryPoint, LaunchProject
from wandb.sdk.launch.environment.aws_environment import AwsEnvironment
@pytest.fixture
def mock_sagemaker_enviro... | 156 | 5,158 |
wandb | tests/system_tests/test_launch/test_job.py | .py | import json
import os
import tempfile
from unittest import mock
import pytest
import wandb
from wandb.apis.internal import Api as InternalApi
from wandb.apis.public import Api as PublicApi
from wandb.sdk.artifacts.artifact import Artifact
from wandb.sdk.launch.create_job import _create_job
from wandb.sdk.launch.git_re... | 243 | 7,599 |
wandb | tests/system_tests/test_launch/conftest.py | .py | import pytest
from wandb.apis.public.service_api import ServiceApi
from wandb.cli import cli
from wandb.proto.wandb_api_pb2 import (
ApiRequest,
CreateRunQueueRequest,
RunQueueOperationRequest,
)
@pytest.fixture(autouse=True)
def _clear_cli_api(monkeypatch: pytest.MonkeyPatch) -> None:
"""Reset cli._a... | 51 | 1,546 |
wandb | tests/system_tests/test_functional/conftest.py | .py | import pathlib
import runpy
from typing import Any
from unittest import mock
import pytest
@pytest.fixture
def execute_script():
# Define a helper function that will take in the script path and command-line arguments
def helper(train_script_path: pathlib.Path, *args: Any) -> None:
# sys_argv simulate... | 27 | 1,113 |
wandb | tests/system_tests/test_functional/multiprocessing/share_child_base.py | .py | """Example of sharing a run object with a child process."""
import argparse
import multiprocessing as mp
import wandb
def process_child(run):
"""Log to the shared run object."""
run.config.c2 = 22
run.log({"s1": 21})
# Read the summary to force the previous messages to be processed
# before the... | 51 | 1,325 |
wandb | tests/system_tests/test_functional/multiprocessing/test_mp.py | .py | import functools
import multiprocessing
import pathlib
import subprocess
import pytest
import wandb
from tests.fixtures.wandb_backend_spy import WandbBackendSpy
@pytest.mark.parametrize(
"start_method",
["spawn", "forkserver"],
)
def test_share_child_base(
wandb_backend_spy: WandbBackendSpy,
start_m... | 71 | 2,007 |
wandb | tests/system_tests/test_functional/asyncio_manager_run/interrupt_join.py | .py | """Passes if Ctrl+C during join() makes run() raise RunCancelledError."""
import asyncio
import sys
import threading
import time
from wandb.sdk.lib import asyncio_manager
_task_started = threading.Event()
_got_cancelled = threading.Event()
async def _set_task_started_then_sleep() -> None:
_task_started.set()
... | 57 | 1,579 |
wandb | tests/system_tests/test_functional/asyncio_manager_run/test_asyncio_manager_run.py | .py | import pathlib
import signal
import subprocess
import time
def test_interrupt_join():
script = pathlib.Path(__file__).parent / "interrupt_join.py"
proc = subprocess.Popen(
["python", str(script)],
stdout=subprocess.PIPE,
)
assert proc.stdout
# Wait for the process's main thread to... | 53 | 1,572 |
wandb | tests/system_tests/test_functional/asyncio_manager_run/interrupt_run.py | .py | """Tests that interrupting run() cancels its task, but not others."""
import asyncio
import sys
from wandb.sdk.lib import asyncio_manager
_queue: asyncio.Queue[str]
async def _init() -> None:
global _queue
_queue = asyncio.Queue()
async def _print_queue() -> None:
while s := await _queue.get():
... | 50 | 1,104 |
wandb | tests/system_tests/test_functional/asyncio_manager_run/does_not_block_exit.py | .py | """Tests that the asyncio thread is daemon."""
import asyncio
import threading
import time
from wandb.sdk.lib import asyncio_manager
def _avoid_hanging_ci(asyncer: asyncio_manager.AsyncioManager) -> None:
"""Join the asyncio thread if the test takes too long."""
def _join_manager():
# If the test f... | 29 | 717 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.