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_wandb_save.py
.py
import glob as glob_module import os import pathlib import platform import pytest # ---------------------------------- # wandb.save # ---------------------------------- def test_save_glob_metacharacters_not_matched_by_default( monkeypatch, tmp_path: pathlib.Path, mock_run, parse_records, record_...
407
11,998
wandb
tests/unit_tests/test_internal_api.py
.py
from __future__ import annotations import base64 import hashlib import os import pathlib import tempfile from collections.abc import Callable, Mapping from itertools import chain from pathlib import Path from typing import TypeVar from unittest.mock import Mock, patch import pytest import requests import wandb.errors...
882
29,187
wandb
tests/unit_tests/test_cli_beta_core.py
.py
from __future__ import annotations from dataclasses import dataclass from click.testing import CliRunner from wandb import env as wandb_env from wandb.cli import beta_core, cli from wandb.proto import wandb_server_pb2 as spb from wandb.sdk.lib.service import service_token @dataclass class _FakeProc: token: serv...
85
2,383
wandb
tests/unit_tests/test_eval_table.py
.py
"""Unit tests for wandb.EvalTable.""" from __future__ import annotations import datetime import sys import types from unittest.mock import MagicMock import pytest import wandb import wandb.data_types as wandb_data_types from wandb.errors import UsageError from wandb.sdk.data_types import eval_table as eval_table_mod...
1,029
31,899
wandb
tests/unit_tests/test_trace_tree.py
.py
import time import pytest from wandb.sdk.data_types.trace_tree import Span, SpanKind, StatusCode, Trace def test_trace_creation(): t = Trace(name="test_trace", kind="LLM", status_code="SUCCESS") assert isinstance(t._span, Span) assert t._span.name == "test_trace" assert t._span.span_kind == SpanKind....
306
8,676
wandb
tests/unit_tests/test_wandb_summary.py
.py
"""summary test.""" from __future__ import annotations from typing import TYPE_CHECKING, Any from typing_extensions import Self from wandb.sdk import Summary if TYPE_CHECKING: from wandb.sdk.interface.summary_record import SummaryRecord class MockCallback: current_dict: dict summary_record: SummaryRec...
127
3,143
wandb
tests/unit_tests/test_wandb_config.py
.py
"""config tests.""" import pytest import yaml from wandb import sdk as wandb_sdk def get_callback(d): def callback_func(key=None, val=None, data=None): if data: d.update(data) if key: d[key] = val return callback_func @pytest.fixture() def consolidated(): return...
133
3,742
wandb
tests/unit_tests/test_sender.py
.py
from unittest.mock import MagicMock import yaml from wandb.sdk.internal.sender import SendManager from wandb.sdk.internal.settings_static import SettingsStatic def test_config_save_preserve_order(tmp_path, test_settings): config_file = tmp_path / "config.yaml" settings = test_settings({"x_files_dir": str(tmp...
25
738
wandb
tests/unit_tests/test_mode_disabled.py
.py
import pickle import tempfile import pytest import wandb def test_mode_disabled(): """Test that the user can access all attributes of a Run object in disabled mode.""" run = wandb.init(mode="disabled") symbols = [s for s in dir(run) if not s.startswith("_") and s != "log"] # try logging some stuff ...
53
1,511
wandb
tests/unit_tests/test_weave_integration.py
.py
from unittest import mock import pytest import wandb.integration.weave from wandb.sdk import wandb_setup @pytest.fixture def mock_singleton(monkeypatch): m = mock.Mock() monkeypatch.setattr(wandb_setup, "singleton", lambda: m) return m def test_active_run_path__returns_path(mock_singleton): mock_si...
61
1,392
wandb
tests/unit_tests/test_file_stream.py
.py
import itertools import os import random import string from dataclasses import dataclass from wandb import util from wandb.sdk.internal.file_stream import CRDedupeFilePolicy from wandb.sdk.lib.file_stream_utils import split_files @dataclass class Chunk: data: str = None def test_split_files(): def choices(...
191
6,495
wandb
tests/unit_tests/test_retry.py
.py
"""retry tests.""" import dataclasses import datetime from collections.abc import Generator from unittest import mock import pytest from wandb.sdk.lib import retry @dataclasses.dataclass class MockTime: now: datetime.datetime sleep: mock.Mock @pytest.fixture(autouse=True) def mock_time() -> Generator[Mock...
178
4,528
wandb
tests/unit_tests/test_iterutils.py
.py
from itertools import repeat, tee from hypothesis import example, given from hypothesis.strategies import integers, iterables, sampled_from from pytest import raises from wandb._iterutils import one @given(iterable=iterables(integers(), min_size=1, max_size=1)) def test_one_on_single_item_iterable(iterable): """...
32
1,198
wandb
tests/unit_tests/test_metaflow.py
.py
import platform from pathlib import Path import pytest if platform.system() == "Windows": pytest.skip("metaflow does not support native Windows", allow_module_level=True) pytest.importorskip("metaflow") import pandas as pd from metaflow import FlowSpec, step from sklearn.ensemble import GradientBoostingClassifi...
290
8,897
wandb
tests/unit_tests/test_wandb_clean.py
.py
import pathlib from datetime import datetime from typing import NoReturn import pytest from click.testing import CliRunner from wandb.cli import clean @pytest.fixture def wandb_dir( tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch, ) -> pathlib.Path: monkeypatch.chdir(tmp_path) monkeypatch.set...
189
6,010
wandb
tests/unit_tests/test_wandb_define_metric.py
.py
"""metric user tests.""" import pytest import wandb from wandb.proto import wandb_internal_pb2 as pb def test_metric_none(mock_run, parse_records, record_q): run = mock_run() run.log(dict(this=1)) run.log(dict(that=2)) parsed = parse_records(record_q) assert len(parsed.records) == 2 history ...
230
5,325
wandb
tests/unit_tests/test_wandb_logger_handler.py
.py
import logging from unittest.mock import MagicMock from wandb.sdk.lib.logger_capture import LoggerHandler def _make_logger(name: str) -> logging.Logger: """Create a uniquely-named logger for test isolation.""" logger = logging.getLogger(f"{__name__}.{name}") logger.setLevel(logging.DEBUG) return logg...
59
1,694
wandb
tests/unit_tests/test_wandb_verify.py
.py
import unittest.mock import pytest import wandb import wandb.sdk.verify.verify as wandb_verify from wandb.proto import wandb_api_pb2 as apb from wandb.sdk.lib.service.service_connection import WandbApiFailedError def test_print_results(capsys): failed_test_or_tests = ["test1", "test2"] wandb_verify.print_res...
140
4,398
wandb
tests/unit_tests/test_wandb_init.py
.py
import glob import os import stat import tempfile import time import pytest import wandb def test_no_root_dir_access__uses_temp_dir(tmp_path, monkeypatch): temp_dir = tempfile.gettempdir() root_dir = tmp_path / "create_dir_test" os.makedirs(root_dir, exist_ok=True) monkeypatch.setattr( os, ...
120
3,400
wandb
tests/unit_tests/test_asyncio_manager.py
.py
import threading import unittest.mock import pytest from wandb.sdk.lib import asyncio_manager class _TestError(Exception): """Intentional error raised in a test.""" async def _return_value(value: str) -> str: return value async def _raise_test_error() -> None: raise _TestError def test_run_returns_...
110
2,360
wandb
tests/unit_tests/test_data_types_box3d.py
.py
import numpy as np import pytest from hypothesis import assume, given from hypothesis.strategies import floats, tuples from wandb import data_types small_floats = floats(min_value=-1e5, max_value=1e5) quaternions = tuples( small_floats, small_floats, small_floats, small_floats, ) @given( center=t...
88
2,675
wandb
tests/unit_tests/test_util.py
.py
import enum import json import os import platform import random import sys import tarfile import tempfile from dataclasses import dataclass from unittest import mock import matplotlib.pyplot as plt import numpy as np import plotly import pytest import wandb from wandb import util #####################################...
701
21,520
wandb
tests/unit_tests/test_wandb_run.py
.py
import copy import platform import numpy as np import pytest import wandb from wandb.apis import public from wandb.sdk import wandb_run REFERENCE_ATTRIBUTES = set( [ "alert", "config", "config_static", "define_metric", "dir", "disabled", "display", "...
363
9,514
wandb
tests/unit_tests/test_step_prepare.py
.py
from __future__ import annotations import concurrent.futures import dataclasses import queue import threading from collections.abc import Iterable, Mapping from typing import TYPE_CHECKING from unittest.mock import Mock, call import pytest from wandb.filesync.step_prepare import ( Request, RequestFinish, ...
351
10,587
wandb
tests/unit_tests/test_profiler.py
.py
import pytest import wandb from wandb.errors import UsageError def test_profiler_without_init(): pytest.importorskip("torch") import torch with pytest.raises(UsageError) as e_info: with torch.profiler.profile( schedule=torch.profiler.schedule(wait=1, warmup=1, active=3, repeat=1), ...
22
615
wandb
tests/unit_tests/test_reports.py
.py
import json from unittest import mock import pytest import wandb from wandb import Api from wandb.apis.public.reports import BetaReport @pytest.mark.usefixtures("patch_apikey", "patch_prompt", "skip_verify_login") def test_report_properties_from_path(): """Test that BetaReport properties work correctly when crea...
152
4,623
wandb
tests/unit_tests/test_wandb_log.py
.py
import pytest import wandb # ---------------------------------- # wandb.log # ---------------------------------- def test_nice_log_error(): with pytest.raises(wandb.Error): wandb.log({"no": "init"}) def test_nice_log_error_config(): with pytest.raises( wandb.Error, match=r"You must call wan...
49
1,214
wandb
tests/unit_tests/test_require_user.py
.py
"""require user tests.""" import pytest import wandb from wandb.sdk import wandb_require @pytest.fixture def mock_require(mocker): cleanup = [] def fn(require, func): cleanup.append(require) mocker.patch.object( wandb_require._Requires, "require_" + require, ...
69
1,820
wandb
tests/unit_tests/test_run_moment.py
.py
import pytest from wandb.sdk.lib.run_moment import RunMoment def test_run_moment_from_uri_valid(): uri = "ans3bsax?_step=123" run_moment = RunMoment.from_uri(uri) assert run_moment.run == "ans3bsax" assert run_moment.metric == "_step" assert run_moment.value == 123 def test_run_moment_from_uri_i...
58
1,507
wandb
tests/unit_tests/test_autolog_patch_integration.py
.py
from typing import Any from unittest.mock import MagicMock import pytest import wandb from wandb.sdk.integration_utils.auto_logging import AutologAPI, PatchAPI class PatchAPITest(PatchAPI): def __init__(self, *args, **kwargs): self._test_api = kwargs.pop("test_api") super().__init__(*args, **kwar...
105
2,824
wandb
tests/unit_tests/test_file_stats.py
.py
import pytest from wandb.filesync import stats @pytest.mark.parametrize( ["init_file_kwargs", "expected_stats"], [ ( {"save_name": "foo", "size": 10}, stats.FileCountsByCategory(artifact=0, wandb=0, media=0, other=1), ), ( {"save_name": "foo", "size"...
97
3,011
wandb
tests/unit_tests/test_weave.py
.py
from __future__ import annotations import sys import types from unittest.mock import MagicMock import pytest import wandb import wandb.integration.weave.weave as wandb_weave_integration from wandb.errors import UsageError from tests.fixtures.mock_wandb_log import MockWandbLog @pytest.fixture() def fake_weave_init(...
262
7,793
wandb
tests/unit_tests/test_api_utils.py
.py
import pytest from wandb.apis.public.utils import ( fetch_org_from_settings_or_entity, parse_org_from_registry_path, ) from wandb.sdk.internal.internal_api import _OrgNames @pytest.mark.parametrize( "path, path_type, expected", [ # Valid cases ("my-org/wandb-registry-model", "project",...
98
3,944
wandb
tests/unit_tests/test_sagemaker_config_parse.py
.py
import io import json import os from unittest import mock from wandb.integration.sagemaker.config import parse_sm_config @mock.patch("os.path.exists") @mock.patch("os.getenv") @mock.patch("json.load") @mock.patch( "builtins.open", new_callable=mock.mock_open, read_data=json.dumps({"param1": "2022-04-01"}...
122
3,960
wandb
tests/unit_tests/test_ssl.py
.py
import contextlib import dataclasses import http.server import ssl import threading from collections.abc import Callable, Generator, Mapping from pathlib import Path from unittest.mock import patch import pytest import requests import wandb.apis import wandb.env @dataclasses.dataclass class SSLCredPaths: ca_path...
135
3,587
wandb
tests/unit_tests/test_dir_watcher.py
.py
"""dir_watcher tests.""" from __future__ import annotations import os import tempfile import time from collections.abc import Callable from pathlib import Path from typing import TYPE_CHECKING from unittest.mock import Mock, patch import pytest import wandb.filesync.dir_watcher from wandb.filesync.dir_watcher import...
264
8,077
wandb
tests/unit_tests/test_error_util.py
.py
import pytest from wandb.errors import Error from wandb.errors.util import ProtobufErrorHandler from wandb.proto import wandb_internal_pb2 as pb @pytest.mark.parametrize( "error, expected", [ (pb.ErrorInfo(), type(None)), (pb.ErrorInfo(code=-2), Error), ], ) def test_protobuf_error_handler...
22
584
wandb
tests/unit_tests/test_weave_media_adapters.py
.py
"""Unit tests for Weave media adapter helpers.""" from __future__ import annotations import sys import types from io import BytesIO import pytest import wandb from wandb.integration.weave.media_adapters import ( handle_nested_wandb_values, unwrap_value, ) def _install_fake_weave(monkeypatch, **attrs): ...
593
17,756
wandb
tests/unit_tests/test_wandb_login.py
.py
from unittest.mock import MagicMock import pytest import wandb from wandb.errors import UsageError from wandb.sdk import wandb_login, wandb_setup from wandb.sdk.lib.service.service_connection import WandbApiFailedError @pytest.fixture(autouse=True) def suppress_logged_in_message(monkeypatch: pytest.MonkeyPatch) -> N...
201
6,198
wandb
tests/unit_tests/test_handler.py
.py
import queue from unittest.mock import MagicMock from wandb.proto import wandb_internal_pb2 as pb from wandb.sdk.internal import handler, settings_static def test_handle_sampled_history_empty(test_settings): result_q = queue.Queue() settings = test_settings({}) hm = handler.HandleManager( setting...
27
736
wandb
tests/unit_tests/test_wandb_agent_signals.py
.py
import os import signal import subprocess from unittest import mock import pytest from wandb import wandb_agent class _DummyPopen: def __init__(self, *args, **kwargs): self.stdin = mock.Mock() self.sent = [] def send_signal(self, signum): self.sent.append(signum) def kill(self):...
417
13,950
wandb
tests/unit_tests/test_step_upload.py
.py
from __future__ import annotations import concurrent.futures import queue import random import threading import time from collections.abc import Callable, Iterable, MutableSequence from pathlib import Path from typing import Any from unittest.mock import DEFAULT, Mock import pytest from wandb.filesync import stats fr...
664
20,962
wandb
tests/unit_tests/test_dtypes.py
.py
import datetime import numpy as np import pytest import wandb from wandb import data_types from wandb.sdk.data_types._dtypes import ( AnyType, BooleanType, ConstType, InvalidType, ListType, NoneType, NumberType, OptionalType, StringType, TimestampType, TypedDictType, Typ...
977
33,463
wandb
tests/unit_tests/test_term.py
.py
from __future__ import annotations import pytest import wandb from wandb import util from wandb.errors import term def test_no_dynamic_text_if_silent(emulated_terminal): # Set up as if stderr is a terminal. _ = emulated_terminal wandb.termsetup(wandb.Settings(silent=True), None) with term.dynamic_t...
168
4,811
wandb
tests/unit_tests/test_wb_logging.py
.py
import contextlib import logging import pathlib from collections.abc import Generator from wandb.sdk.lib import wb_logging wb_logging.configure_wandb_logger() @contextlib.contextmanager def _wandb_file_handler( run_id: str, path: pathlib.Path, ) -> Generator[None]: handler = wb_logging.add_file_handler(...
58
1,970
wandb
tests/unit_tests/test_library_public.py
.py
"""Library public tests. *NOTE*: If you need to add a symbol, make sure this has been discussed and the name of the object or method is agreed upon. Todo: - clean up / hide symbols, which shouldn't be public - deprecate ones that were public but we want to remove """ import inspect import wandb SYMBOLS_RO...
309
5,531
wandb
tests/unit_tests/test_tables.py
.py
import datetime import json import numpy as np import pytest import wandb from wandb.sdk.data_types.table import _ForeignKeyType, _PrimaryKeyType def test_basic_ndx(): # Base Case table_a = wandb.Table(columns=["b"], data=[["a"], ["b"]]) table = wandb.Table(columns=["fi", "c"]) for _ndx, _ in table_a...
447
14,289
wandb
tests/unit_tests/test_plot.py
.py
import pytest from wandb.plot import confusion_matrix, line_series, pr_curve, roc_curve def test_roc_curve_no_title(): """Test ROC curve with no title. The ROC curve is created with two sets of probabilities. The expected data is pre-defined and compared with the actual data. The title is also checked. ...
253
6,710
wandb
tests/unit_tests/test_import_wandb.py
.py
import sys def test_path_is_unchanged(): # Ideally we would compare directly to the user's starting path, # but that seems to be mutilated with tox. So, we check for known # leaks. import wandb # noqa: F401 for item in sys.path: assert "wandb/vendor" not in item
12
295
wandb
tests/unit_tests/test_cli_leet.py
.py
from __future__ import annotations import pathlib import pytest from wandb.cli import cli, leet from wandb.errors import WandbCoreNotAvailableError @pytest.fixture def core_calls(monkeypatch) -> list[list[str]]: """Stub out wandb-core and record the arguments it would be invoked with.""" calls: list[list[st...
102
3,273
wandb
tests/unit_tests/test_cli.py
.py
import getpass import importlib import netrc import os import subprocess import time import traceback from unittest import mock import pytest import wandb import wandb.docker from wandb import env from wandb.cli import cli DOCKER_SHA = ( "wandb/deepo@sha256:" "3ddd2547d83a056804cac6aac48d46c5394a76df76b672539...
638
18,284
wandb
tests/unit_tests/test_torch.py
.py
import pytest import torch import torch.nn as nn from wandb.integration.torch import wandb_torch def test_nested_shape(): shape = wandb_torch.nested_shape([2, 4, 5]) assert shape == [[], [], []] shape = wandb_torch.nested_shape( [ torch.ones((2, 3), requires_grad=True), to...
106
3,302
wandb
tests/unit_tests/test_kfp.py
.py
"""Unit tests for the Kubeflow Pipelines (kfp) v2 integration.""" import inspect import json import os from typing import NamedTuple from unittest.mock import MagicMock, patch from kfp import dsl from kfp.compiler import Compiler from kfp.dsl import Artifact, Dataset, Input, InputPath, Output from wandb.integration.k...
762
22,566
wandb
tests/unit_tests/test_wandb_agent_teardown.py
.py
"""Unit tests for agent teardown behavior. These tests verify that after wandb.agent() exits (normally or by exception), global state is cleared so a subsequent wandb.init() creates a normal run, not a sweep run. Open-source developers can use these to ensure changes around agent teardown do not break this functionali...
57
2,247
wandb
tests/unit_tests/test_normalize.py
.py
from __future__ import annotations import re from typing import NoReturn import pytest import requests from wandb.apis.normalize import normalize_exceptions from wandb.errors import CommError def _http_response( status_code: int, body: bytes | None = None, reason: str | None = None, ): response = re...
88
2,318
wandb
tests/unit_tests/test_wandb_settings.py
.py
import copy import json import os import pathlib import platform import re import subprocess import sys import tempfile from unittest import mock import pytest import wandb from wandb import Settings from wandb.errors import UsageError from wandb.sdk.lib.run_moment import RunMoment from tests.fixtures.mock_wandb_log ...
740
20,101
wandb
tests/unit_tests/test_sender_config.py
.py
from wandb.proto import wandb_internal_pb2 from wandb.sdk.internal import sender_config from wandb.sdk.lib import telemetry def test_config_record_update(): config = sender_config.ConfigState({"b": {"x": 9, "c": "old"}}) config.update_from_proto( wandb_internal_pb2.ConfigRecord( update=[ ...
82
2,095
wandb
tests/unit_tests/test_pydantic_helpers.py
.py
"""Basic tests for W&B's Pydantic helper layer.""" from __future__ import annotations import json from typing import Any from pydantic import ConfigDict, Field, Json, ValidationError from pytest import raises from wandb._pydantic import ( AliasChoices, CompatBaseModel, GQLInput, GQLResult, comput...
411
12,230
wandb
tests/unit_tests/test_job_builder.py
.py
import json import os import random import string import pytest from wandb.sdk.internal.job_builder import JobBuilder from wandb.sdk.internal.settings_static import SettingsStatic from wandb.util import make_artifact_name_safe def str_of_length(n): return "".join(random.choices(string.ascii_uppercase + string.di...
369
11,746
wandb
tests/unit_tests/test_asyncio_compat.py
.py
from __future__ import annotations import asyncio from collections.abc import Coroutine from typing import Any import pytest from wandb.sdk.lib import asyncio_compat async def _fail_after_timeout( coro: Coroutine[Any, Any, Any], failure_message: str, ) -> None: try: await asyncio.wait_for(coro, ...
324
8,397
wandb
tests/unit_tests/test_data_types.py
.py
import io import os import platform from pathlib import Path from unittest import mock import matplotlib.pyplot as plt import numpy as np import pandas as pd import pytest import rdkit.Chem import responses import torch import wandb from bokeh.plotting import figure from PIL import Image from wandb import data_types, ...
1,768
51,977
wandb
tests/unit_tests/test_docker.py
.py
import platform from unittest import mock import pytest from wandb.docker import is_buildx_installed, should_add_load_argument @pytest.fixture def mock_shell(): with mock.patch("wandb.docker.shell") as mock_shell: mock_shell.return_value = None yield mock_shell @pytest.mark.skipif( platform...
32
884
wandb
tests/unit_tests/test_datastore.py
.py
"""datastore tests.""" import json import os import pytest from wandb.proto import wandb_internal_pb2 # type: ignore from wandb.sdk.internal import datastore FNAME = "test.dat" try: FileNotFoundError # noqa: B018 except NameError: FileNotFoundError = OSError def check( ds, chunk_sizes=tuple(), ...
140
3,726
wandb
tests/unit_tests/test_wait_with_progress.py
.py
import asyncio from typing import NoReturn import pytest import wandb.sdk.mailbox as mb from wandb.proto import wandb_server_pb2 as spb from wandb.sdk.lib import asyncio_manager async def _loop_forever() -> NoReturn: while True: await asyncio.sleep(1) @pytest.fixture(scope="module") def asyncer(): ...
119
3,002
wandb
tests/unit_tests/conftest.py
.py
import dataclasses import json import threading import unittest.mock import urllib.parse from collections.abc import Callable, Generator from datetime import timedelta from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from pathlib import Path from queue import Queue import pytest import wandb from hy...
238
7,469
wandb
tests/unit_tests/test_mailbox.py
.py
import asyncio import math import unittest.mock import pytest from wandb.proto import wandb_internal_pb2 as pb from wandb.proto import wandb_server_pb2 as spb from wandb.sdk import mailbox as mb from wandb.sdk.lib import asyncio_manager from wandb.sdk.mailbox.mailbox_handle import HandleAbandonedError from wandb.sdk.m...
264
7,709
wandb
tests/unit_tests/test_sandbox/__init__.py
.py
from __future__ import annotations import sys import pytest if sys.version_info < (3, 11): pytest.skip("wandb.sandbox requires Python 3.11+", allow_module_level=True)
9
174
wandb
tests/unit_tests/test_sandbox/test_sandbox_wrapper.py
.py
from typing import Any import cwsandbox import pytest import wandb.sandbox as wandb_sandbox import wandb.sandbox._sandbox as sandbox_module from wandb.errors import UsageError from wandb.sandbox import Secret from wandb.sandbox._secret import WANDB_SECRET_STORE _HIDDEN_EXPORT_NAMES = {"AuthHeaders", "set_auth_mode"} ...
268
8,738
wandb
tests/unit_tests/test_sandbox/test_cli_beta_sandbox.py
.py
from __future__ import annotations import cwsandbox.cli.list as cwsandbox_list import pytest from click.testing import CliRunner from wandb.cli import cli from wandb.sandbox import CWSandboxError @pytest.mark.parametrize( ("argv", "expected_strings"), [ ( ["sandbox", "--help"], ...
80
2,127
wandb
tests/unit_tests/test_sandbox/test_sandbox_auth.py
.py
from __future__ import annotations from unittest.mock import Mock import pytest import wandb.sandbox._auth as sandbox_auth _VALID_API_KEY = "x" * 40 _SETTINGS_API_KEY = "y" * 40 def _singleton( *, entity: str | None = "default-entity", project: str | None = "default-project", api_key: str | None = ...
199
6,338
wandb
tests/unit_tests/test_launch/test_create_job.py
.py
import json import os import platform import sys import tempfile from unittest.mock import MagicMock import pytest from wandb.sdk.internal.job_builder import JobBuilder from wandb.sdk.launch.create_job import ( _configure_job_builder_for_partial, _create_artifact_metadata, _create_repo_metadata, _dump_...
174
6,028
wandb
tests/unit_tests/test_launch/test_internal_api.py
.py
import json from unittest.mock import MagicMock import pytest from wandb.apis import internal from wandb.errors import CommError from wandb.sdk.lib.service.service_connection import WandbApiFailedError def test_push_to_run_queue_by_name(): _api = internal.Api() mock_run_spec = {"test-key": "test-value"} ...
94
2,927
wandb
tests/unit_tests/test_launch/test_git_reference.py
.py
"""Tests for `GitReference.fetch` against real local git repositories.""" from __future__ import annotations import pathlib import subprocess import pytest from wandb.sdk.launch import git_reference as git_reference_module from wandb.sdk.launch.errors import LaunchError from wandb.sdk.launch.git_reference import Git...
247
8,411
wandb
tests/unit_tests/test_launch/test_util.py
.py
import random import pytest from wandb.docker import DockerError from wandb.sdk.launch.errors import LaunchError from wandb.sdk.launch.runner.local_container import get_docker_command from wandb.sdk.launch.utils import ( diff_pip_requirements, load_wandb_config, macro_sub, make_k8s_label_safe, pars...
675
21,923
wandb
tests/unit_tests/test_launch/test_job.py
.py
import json import os from unittest.mock import MagicMock from wandb.apis.public import Job from wandb.sdk.internal.job_builder import JobBuilder def test_configure_notebook_repo_job(mocker, tmp_path): new_fname = "test.py" mocker.patch( "wandb.apis.public.jobs.convert_jupyter_notebook_to_script", ...
124
3,979
wandb
tests/unit_tests/test_launch/conftest.py
.py
import pytest from wandb.apis.internal import InternalApi @pytest.fixture def test_api(test_settings): return InternalApi(default_settings=test_settings(), load_settings=False)
8
183
wandb
tests/unit_tests/test_launch/test_builder/test_kaniko.py
.py
import os from unittest.mock import MagicMock import boto3 import kubernetes_asyncio import pytest import wandb from google.cloud import storage from wandb.sdk.launch._project_spec import EntryPoint, LaunchProject from wandb.sdk.launch.builder import kaniko_builder from wandb.sdk.launch.builder.kaniko_builder import (...
535
19,297
wandb
tests/unit_tests/test_launch/test_builder/test_build.py
.py
import hashlib import json import re from unittest.mock import MagicMock import pytest from wandb.sdk.artifacts.artifact import Artifact from wandb.sdk.launch._project_spec import EntryPoint, LaunchProject from wandb.sdk.launch.builder import build from wandb.sdk.launch.builder.abstract import registry_from_uri from w...
342
11,954
wandb
tests/unit_tests/test_launch/test_builder/test_context_manager.py
.py
"""Tests for the BuildContextManager class in the builder module.""" import pathlib from unittest.mock import MagicMock import pytest from wandb.sdk.launch.builder.context_manager import BuildContextManager @pytest.fixture def mock_git_project(mocker, tmp_path): mock_project = MagicMock() mock_project.proje...
150
6,190
wandb
tests/unit_tests/test_launch/test_builder/test_bootstrap.py
.py
import re import pytest from wandb.sdk.launch.builder.templates._wandb_bootstrap import TORCH_DEP_REGEX @pytest.mark.parametrize( "dep,expected", [ ("torch", None), ("torch==1.7.0", (None, None)), ("torch==1.7.0+cu110", (None, "+cu110")), ( "torch==1.7.0+cu110 -f h...
33
947
wandb
tests/unit_tests/test_launch/test_builder/test_docker.py
.py
import platform from unittest.mock import MagicMock import pytest from wandb.sdk.launch._project_spec import EntryPoint from wandb.sdk.launch.builder.docker_builder import DockerBuilder from wandb.sdk.launch.registry.local_registry import LocalRegistry @pytest.fixture def mock_ecr_registry(monkeypatch): monkeypa...
126
3,664
wandb
tests/unit_tests/test_launch/test_agent/test_config.py
.py
import os from unittest.mock import MagicMock import pytest import yaml from wandb.sdk.launch._launch import create_and_run_agent, resolve_agent_config from wandb.sdk.launch.agent.config import validate_registry_uri from wandb.sdk.launch.errors import LaunchError class MockAgent: def __init__(self, api, config):...
147
4,143
wandb
tests/unit_tests/test_launch/test_agent/test_agent.py
.py
import asyncio import platform import threading from unittest.mock import MagicMock import pytest from wandb.analytics import TelemetryRecorder from wandb.errors import CommError from wandb.sdk.launch.agent.agent import ( _DEFAULT_BASE_IMAGE, InternalAgentLogger, JobAndRunStatusTracker, LaunchAgent, ) ...
1,015
31,523
wandb
tests/unit_tests/test_launch/test_agent/test_run_queue_item_saver.py
.py
import os from unittest.mock import MagicMock import wandb from wandb.sdk.launch.agent.run_queue_item_file_saver import RunQueueItemFileSaver def test_no_run(): saver = RunQueueItemFileSaver(None, "test_run_queue_item_id") assert saver.save_contents("contents", "fname", "error") is None def test_run(): ...
32
965
wandb
tests/unit_tests/test_launch/test_project/test_project.py
.py
import os from unittest.mock import MagicMock import pytest from wandb.sdk.launch._project_spec import LaunchProject, LaunchSource from wandb.sdk.launch.errors import LaunchError def test_project_build_required(): mock_args = { "job": "mock-test-entity/mock-test-project/mock-test-job:v0", "api": ...
332
10,747
wandb
tests/unit_tests/test_launch/test_runner/test_kubernetes.py
.py
import asyncio import base64 import json import platform import shlex from unittest.mock import MagicMock, patch import pytest import wandb import wandb.sdk.launch.runner.kubernetes_runner from kubernetes_asyncio import client from kubernetes_asyncio.client import ApiException from wandb.sdk.launch._project_spec impor...
2,131
68,306
wandb
tests/unit_tests/test_launch/test_runner/test_kubernetes_integration.py
.py
"""Integration tests for KubernetesRunner. These tests exercise runner.run() end-to-end with mocked Kubernetes APIs, verifying that the correct volume configuration is applied to the submitted job manifest based on the presence/absence of PVC env vars and base image settings. """ import platform from unittest.mock im...
168
5,547
wandb
tests/unit_tests/test_launch/test_runner/test_sagemaker.py
.py
"""Tests for the sagemaker runner.""" from unittest.mock import MagicMock import pytest from wandb.sdk.launch.runner.sagemaker_runner import launch_sagemaker_job @pytest.fixture def mock_launch_project(): return MagicMock() @pytest.fixture def mock_sagemaker_client(): mock_client = MagicMock() mock_cl...
67
1,803
wandb
tests/unit_tests/test_launch/test_runner/test_vertex.py
.py
from unittest.mock import MagicMock import pytest from wandb.apis.internal import Api from wandb.sdk.launch._project_spec import LaunchProject from wandb.sdk.launch.errors import LaunchError from wandb.sdk.launch.runner.vertex_runner import VertexRunner, VertexSubmittedRun class MockCustomJob: """Mock of the Cus...
214
7,289
wandb
tests/unit_tests/test_launch/test_runner/test_local_process.py
.py
import shlex from unittest.mock import MagicMock import pytest from wandb.sdk.launch._project_spec import EntryPoint from wandb.sdk.launch.runner.local_process import LocalProcessRunner @pytest.fixture def mock_launch_project(): """Mock the launch project for testing.""" project = MagicMock() project.ove...
99
3,257
wandb
tests/unit_tests/test_launch/test_runner/test_safe_watch.py
.py
from unittest.mock import MagicMock import pytest from kubernetes.client import ApiException from urllib3.exceptions import ProtocolError from wandb.sdk.launch.runner.kubernetes_monitor import SafeWatch class MockWatch: """Mock class for testing.""" def __init__(self): self.is_alive = True s...
85
2,388
wandb
tests/unit_tests/test_launch/test_runner/test_local_container.py
.py
import os import platform import shlex from unittest.mock import MagicMock import pytest from wandb.sdk.launch.errors import LaunchError from wandb.sdk.launch.runner import local_container from wandb.sdk.launch.runner.local_container import LocalContainerRunner @pytest.fixture def mock_launch_project(tmpdir): ""...
305
10,571
wandb
tests/unit_tests/test_launch/test_runner/conftest.py
.py
import asyncio from typing import Any from unittest.mock import MagicMock import pytest from wandb.sdk.launch.agent.agent import LaunchAgent from wandb.sdk.launch.runner.kubernetes_monitor import LaunchKubernetesMonitor class MockDict(dict): # use a dict to mock an object __getattr__ = dict.get __setattr...
198
5,980
wandb
tests/unit_tests/test_launch/test_inputs/test_files_helpers.py
.py
import json import pytest from wandb.sdk.launch.errors import LaunchError from wandb.sdk.launch.inputs.files import ( FileOverrides, config_path_is_valid, override_file, ) @pytest.fixture def fresh_config_singleton(): """Fixture to reset the config singleton.""" FileOverrides._instance = None d...
202
5,096
wandb
tests/unit_tests/test_launch/test_inputs/test_internal.py
.py
"""Test internal methods of the job input management sdk.""" import platform import sys from enum import Enum from unittest.mock import MagicMock import pytest from pydantic import BaseModel, Field from wandb.sdk.launch.errors import LaunchError from wandb.sdk.launch.inputs.internal import ( ConfigTmpDir, Job...
771
25,827
wandb
tests/unit_tests/test_launch/test_cli/test_job_create.py
.py
import pytest from wandb.cli import cli def test_parse_service_config_valid_single(): """Test parsing a single valid service configuration.""" result = cli.parse_service_config(None, None, ["test_service=always"]) assert result == {"test_service": "always"} def test_parse_service_config_valid_multiple()...
90
3,547
wandb
tests/unit_tests/test_launch/test_registry/test_acr.py
.py
from unittest.mock import MagicMock import pytest from wandb.sdk.launch.errors import LaunchError from wandb.sdk.launch.registry.azure_container_registry import ( AzureContainerRegistry, ResourceNotFoundError, ) @pytest.fixture def mock_default_azure_credential(monkeypatch): mock = MagicMock() monkey...
108
3,715
wandb
tests/unit_tests/test_launch/test_registry/test_ecr.py
.py
from unittest.mock import MagicMock import botocore.exceptions import pytest from wandb.sdk.launch.errors import LaunchError from wandb.sdk.launch.registry.elastic_container_registry import ( ElasticContainerRegistry, ) @pytest.mark.parametrize( "uri, account_id, region, repo_name, expected_uri", [ ...
189
5,900
wandb
tests/unit_tests/test_launch/test_registry/test_gcp_artifact_registry.py
.py
from unittest.mock import MagicMock import google.api_core.exceptions import pytest from wandb.sdk.launch.registry.google_artifact_registry import GoogleArtifactRegistry from wandb.sdk.launch.utils import LaunchError @pytest.fixture def mock_gcp_default_credentials(monkeypatch): """Mock the default credentials f...
170
5,526
wandb
tests/unit_tests/test_launch/test_environment/test_gcp.py
.py
import os from unittest.mock import MagicMock import pytest from google.api_core.exceptions import Forbidden, GoogleAPICallError, NotFound from google.auth.exceptions import DefaultCredentialsError, RefreshError from wandb.sdk.launch.environment.gcp_environment import ( GCP_REGION_ENV_VAR, GcpEnvironment, ...
221
7,760