diff --git a/weave/conftest.py b/weave/conftest.py index 9ff85968cc8b..c11f8c7a41e0 100644 --- a/weave/conftest.py +++ b/weave/conftest.py @@ -15,7 +15,7 @@ import weave from weave import weave_init from weave.legacy import client as client_legacy -from weave.legacy import context_state, io_service, serialize +from weave.legacy import context_state, environment, io_service, serialize from weave.legacy.language_features.tagging.tag_store import isolated_tagging_context from weave.trace_server import ( clickhouse_trace_server_batched, @@ -24,7 +24,7 @@ ) from weave.trace_server import trace_server_interface as tsi -from . import environment, logs +from . import logs from .tests import fixture_fakewandb from .tests.trace.trace_server_clickhouse_conftest import * from .tests.wandb_system_tests_conftest import * diff --git a/weave/deploy/gcp/__init__.py b/weave/deploy/gcp/__init__.py index b827eca817a6..3100723a4ced 100644 --- a/weave/deploy/gcp/__init__.py +++ b/weave/deploy/gcp/__init__.py @@ -7,7 +7,8 @@ import typing from pathlib import Path -from weave import __version__, environment +from weave import __version__ +from weave.legacy import environment from weave.legacy.artifact_wandb import WeaveWBArtifactURI as WeaveWBArtifactURI from weave.trace.refs import ObjectRef, parse_uri diff --git a/weave/deploy/modal/__init__.py b/weave/deploy/modal/__init__.py index 691e79032899..947cbb2f057e 100644 --- a/weave/deploy/modal/__init__.py +++ b/weave/deploy/modal/__init__.py @@ -5,8 +5,8 @@ import typing from pathlib import Path -from weave import environment from weave.legacy import artifact_wandb as artifact_wandb +from weave.legacy import environment from weave.trace.refs import ObjectRef, parse_uri try: diff --git a/weave/filesystem.py b/weave/filesystem.py index 8af0aac9bbbc..a3b03bee1ec3 100644 --- a/weave/filesystem.py +++ b/weave/filesystem.py @@ -20,9 +20,9 @@ from aiofiles.threadpool import binary as aiofiles_binary from aiofiles.threadpool import text as aiofiles_text -from weave.legacy import cache, engine_trace +from weave.legacy import cache, engine_trace, environment -from . import environment, errors, util +from . import errors, util tracer = engine_trace.tracer() # type: ignore async_utime = aiofiles_os.wrap(os.utime) # type: ignore diff --git a/weave/legacy/artifact_local.py b/weave/legacy/artifact_local.py index f8854e5cc854..3bc114b8d96d 100644 --- a/weave/legacy/artifact_local.py +++ b/weave/legacy/artifact_local.py @@ -9,9 +9,9 @@ import typing from datetime import datetime -from weave import environment, errors, filesystem, util +from weave import errors, filesystem, util from weave import weave_types as types -from weave.legacy import artifact_fs, artifact_wandb, file_base, file_util, uris +from weave.legacy import artifact_fs, artifact_wandb, environment, file_base, file_util, uris WORKING_DIR_PREFIX = "__working__" diff --git a/weave/legacy/cache.py b/weave/legacy/cache.py index 0bee0170fd3a..7ebe820a715e 100644 --- a/weave/legacy/cache.py +++ b/weave/legacy/cache.py @@ -6,8 +6,8 @@ import time import typing -from weave import environment, errors -from weave.legacy import context_state, wandb_api, engine_trace +from weave import errors +from weave.legacy import context_state, environment, wandb_api, engine_trace statsd = engine_trace.statsd() # type: ignore logger = logging.getLogger("root") diff --git a/weave/legacy/engine_trace.py b/weave/legacy/engine_trace.py index 6a9284a29326..c522afeefab3 100644 --- a/weave/legacy/engine_trace.py +++ b/weave/legacy/engine_trace.py @@ -18,8 +18,8 @@ import time import typing -from .. import environment, logs -from . import stream_data_interfaces +from .. import logs +from . import environment, stream_data_interfaces # Thanks co-pilot! diff --git a/weave/environment.py b/weave/legacy/environment.py similarity index 99% rename from weave/environment.py rename to weave/legacy/environment.py index b54d1cfd7dcb..eb5a5271ce5a 100644 --- a/weave/environment.py +++ b/weave/legacy/environment.py @@ -11,10 +11,10 @@ from distutils.util import strtobool from urllib.parse import urlparse -from . import errors, util +from .. import errors, util if typing.TYPE_CHECKING: - from . import logs + from .. import logs WANDB_ERROR_REPORTING = "WANDB_ERROR_REPORTING" WEAVE_USAGE_ANALYTICS = "WEAVE_USAGE_ANALYTICS" @@ -105,7 +105,7 @@ def is_public() -> bool: def weave_log_format(default: "logs.LogFormat") -> "logs.LogFormat": - from .logs import LogFormat + from ..logs import LogFormat return LogFormat(os.getenv("WEAVE_LOG_FORMAT", default)) diff --git a/weave/legacy/execute.py b/weave/legacy/execute.py index 8c9bb02475e8..4fe5da5e78c3 100644 --- a/weave/legacy/execute.py +++ b/weave/legacy/execute.py @@ -10,7 +10,6 @@ from collections.abc import Mapping from weave import ( - environment, errors, ) from weave import weave_types as types @@ -23,6 +22,7 @@ # Language Features from weave.legacy import ( engine_trace, + environment, parallelism, ref_base, registry_mem, diff --git a/weave/legacy/file_util.py b/weave/legacy/file_util.py index b21f04bfc5eb..b43c6dad627a 100644 --- a/weave/legacy/file_util.py +++ b/weave/legacy/file_util.py @@ -2,8 +2,8 @@ import pathlib import typing -from weave import environment, filesystem -from weave.legacy import cache, path_util +from weave import filesystem +from weave.legacy import cache, environment, path_util def get_allowed_dir() -> pathlib.Path: diff --git a/weave/legacy/gql_schema.py b/weave/legacy/gql_schema.py index 5128d1eab503..6ee16b3cd7ba 100644 --- a/weave/legacy/gql_schema.py +++ b/weave/legacy/gql_schema.py @@ -2,7 +2,7 @@ import graphql -from weave import environment +from weave.legacy import environment from weave.legacy import wandb_client_api _GQL_SCHEMA_CACHE: dict[typing.Optional[str], graphql.GraphQLSchema] = {} diff --git a/weave/legacy/op_def_type.py b/weave/legacy/op_def_type.py index bb5fccf45258..030ffad85c4d 100644 --- a/weave/legacy/op_def_type.py +++ b/weave/legacy/op_def_type.py @@ -11,9 +11,9 @@ from _ast import AsyncFunctionDef, ExceptHandler from typing import Any -from weave import environment, errors, storage +from weave import errors, storage from weave import weave_types as types -from weave.legacy import artifact_fs, artifact_local, context_state, infer_types, registry_mem +from weave.legacy import artifact_fs, artifact_local, context_state, environment, infer_types, registry_mem if typing.TYPE_CHECKING: from .op_def import OpDef diff --git a/weave/legacy/ops_domain/wbgqlquery_op.py b/weave/legacy/ops_domain/wbgqlquery_op.py index 662fbc339bc9..2ed399410b7b 100644 --- a/weave/legacy/ops_domain/wbgqlquery_op.py +++ b/weave/legacy/ops_domain/wbgqlquery_op.py @@ -1,10 +1,10 @@ import logging import typing -from weave import environment, errors +from weave import errors from weave import weave_types as types from weave.legacy.api import op -from weave.legacy import engine_trace, mappers_gql, partial_object +from weave.legacy import engine_trace, environment, mappers_gql, partial_object from weave.legacy.language_features.tagging import tagged_value_type from weave.legacy.ops_domain import wb_domain_types as wdt from weave.legacy.wandb_client_api import wandb_gql_query diff --git a/weave/legacy/ops_primitives/file.py b/weave/legacy/ops_primitives/file.py index fdc4ea7908e9..854da41e8662 100644 --- a/weave/legacy/ops_primitives/file.py +++ b/weave/legacy/ops_primitives/file.py @@ -1,7 +1,7 @@ import json import typing -from weave import environment as weave_env +from weave.legacy import environment as weave_env from weave import errors from weave import weave_types as types from weave.legacy.api import op diff --git a/weave/legacy/ops_primitives/file_local.py b/weave/legacy/ops_primitives/file_local.py index 45940d7500c1..f6e2a29f2065 100644 --- a/weave/legacy/ops_primitives/file_local.py +++ b/weave/legacy/ops_primitives/file_local.py @@ -1,7 +1,7 @@ import os import typing -from weave import environment +from weave.legacy import environment from weave import weave_types as types from weave.legacy.api import op from weave.legacy import file_local diff --git a/weave/legacy/ops_primitives/projection_utils.py b/weave/legacy/ops_primitives/projection_utils.py index 250037323bd9..8e05cf2753a8 100644 --- a/weave/legacy/ops_primitives/projection_utils.py +++ b/weave/legacy/ops_primitives/projection_utils.py @@ -9,8 +9,8 @@ from sklearn.decomposition import PCA from sklearn.manifold import TSNE -from weave import environment, errors -from weave.legacy import context_state +from weave import errors +from weave.legacy import context_state, environment umap_lib = {} diff --git a/weave/legacy/runfiles_wandb.py b/weave/legacy/runfiles_wandb.py index bd5d0074c044..d61f91f4c534 100644 --- a/weave/legacy/runfiles_wandb.py +++ b/weave/legacy/runfiles_wandb.py @@ -6,7 +6,7 @@ import shutil import typing -from weave import environment as weave_env +from weave.legacy import environment as weave_env from weave import errors, filesystem from weave import weave_types as types from weave.legacy import artifact_fs, file_util, memo, uris, wandb_client_api diff --git a/weave/legacy/signal_handlers.py b/weave/legacy/signal_handlers.py index 0f74db86d5b0..d9c1e89e683b 100644 --- a/weave/legacy/signal_handlers.py +++ b/weave/legacy/signal_handlers.py @@ -10,7 +10,7 @@ import typing from types import FrameType -from weave import environment +from weave.legacy import environment def dump_folder() -> pathlib.Path: diff --git a/weave/legacy/usage_analytics.py b/weave/legacy/usage_analytics.py index a9fe6866a588..5fd8bddc571d 100644 --- a/weave/legacy/usage_analytics.py +++ b/weave/legacy/usage_analytics.py @@ -5,7 +5,7 @@ from weave.legacy import context_state -from .. import environment +from . import environment analytics.write_key = "uJ8vZgKqTBVH6ZdhD4GZGZYsR7ucfJmb" diff --git a/weave/legacy/wandb_api.py b/weave/legacy/wandb_api.py index b551538a6aef..2ef082916f68 100644 --- a/weave/legacy/wandb_api.py +++ b/weave/legacy/wandb_api.py @@ -15,7 +15,7 @@ from requests.auth import HTTPBasicAuth from weave import errors -from weave import environment as weave_env +from weave.legacy import environment as weave_env from weave.legacy import wandb_client_api, engine_trace # Importing at the top-level namespace so other files can import from here. diff --git a/weave/legacy/wandb_file_manager.py b/weave/legacy/wandb_file_manager.py index 21c29a064af3..6fd5a14a1769 100644 --- a/weave/legacy/wandb_file_manager.py +++ b/weave/legacy/wandb_file_manager.py @@ -13,7 +13,7 @@ from wandb.sdk.lib import hashutil from weave import errors, filesystem, weave_http -from weave import environment as weave_env +from weave.legacy import environment as weave_env from weave.legacy import artifact_wandb, cache, wandb_api, engine_trace tracer = engine_trace.tracer() # type: ignore diff --git a/weave/legacy/wandb_interface/wandb_stream_table.py b/weave/legacy/wandb_interface/wandb_stream_table.py index 31070b588c67..4f69e6b72998 100644 --- a/weave/legacy/wandb_interface/wandb_stream_table.py +++ b/weave/legacy/wandb_interface/wandb_stream_table.py @@ -15,10 +15,11 @@ from wandb.sdk.lib.paths import LogicalPath from wandb.sdk.lib.printer import get_printer -from weave import environment, errors, storage, weave_types +from weave import errors, storage, weave_types from weave.legacy import ( artifact_base, box, + environment, file_util, graph, runfiles_wandb, diff --git a/weave/logs.py b/weave/logs.py index c9b039f6fc4e..30c3127834b0 100644 --- a/weave/logs.py +++ b/weave/logs.py @@ -12,7 +12,7 @@ from pythonjsonlogger import jsonlogger -from . import environment +from weave.legacy import environment try: from flask.logging import wsgi_errors_stream diff --git a/weave/tests/legacy/test_access.py b/weave/tests/legacy/test_access.py index d83a58491b34..1006a9e400b2 100644 --- a/weave/tests/legacy/test_access.py +++ b/weave/tests/legacy/test_access.py @@ -1,9 +1,9 @@ import pytest import weave -from weave.legacy import artifact_fs, artifact_local, wandb_api +from weave.legacy import artifact_fs, artifact_local, environment, wandb_api -from ... import environment, errors, storage +from ... import errors, storage @pytest.fixture() diff --git a/weave/tests/legacy/test_cache.py b/weave/tests/legacy/test_cache.py index 9970efecda8b..0fe6243504c1 100644 --- a/weave/tests/legacy/test_cache.py +++ b/weave/tests/legacy/test_cache.py @@ -2,8 +2,7 @@ import os import time -from weave import environment -from weave.legacy import cache +from weave.legacy import cache, environment def test_lru_time_window_cache(): diff --git a/weave/tests/legacy/test_execute.py b/weave/tests/legacy/test_execute.py index c7a33bf10500..fc8cd4133327 100644 --- a/weave/tests/legacy/test_execute.py +++ b/weave/tests/legacy/test_execute.py @@ -4,9 +4,9 @@ import pytest import weave -from weave.legacy import execute, ops +from weave.legacy import environment, execute, ops -from ... import api, environment, weave_internal +from ... import api, weave_internal from ... import weave_types as types from . import test_wb diff --git a/weave/tests/legacy/test_file.py b/weave/tests/legacy/test_file.py index b1bfd214f62b..0fed90136c33 100644 --- a/weave/tests/legacy/test_file.py +++ b/weave/tests/legacy/test_file.py @@ -1,9 +1,9 @@ import pytest import weave -from weave.legacy import context_state, ops +from weave.legacy import context_state, environment, ops -from ... import api, environment, errors +from ... import api, errors def test_dir(): diff --git a/weave/tests/legacy/test_filesystem.py b/weave/tests/legacy/test_filesystem.py index c16d005d2023..7faa4668230e 100644 --- a/weave/tests/legacy/test_filesystem.py +++ b/weave/tests/legacy/test_filesystem.py @@ -2,7 +2,9 @@ import pytest -from ... import environment, errors, filesystem +from weave.legacy import environment + +from ... import errors, filesystem @pytest.fixture() diff --git a/weave/trace/op_type.py b/weave/trace/op_type.py index db3eaa25bae7..c7566e077566 100644 --- a/weave/trace/op_type.py +++ b/weave/trace/op_type.py @@ -21,7 +21,8 @@ ) from weave.trace.refs import ObjectRef -from .. import environment, errors, storage +from .. import errors, storage +from ..legacy import environment from . import serializer from .op import Op diff --git a/weave/trace_server/remote_http_trace_server.py b/weave/trace_server/remote_http_trace_server.py index 145d2f509067..842e5c43893c 100644 --- a/weave/trace_server/remote_http_trace_server.py +++ b/weave/trace_server/remote_http_trace_server.py @@ -6,7 +6,7 @@ import tenacity from pydantic import BaseModel, ValidationError -from weave.environment import weave_trace_server_url +from weave.legacy.environment import weave_trace_server_url from weave.legacy.wandb_interface import project_creator from . import requests diff --git a/weave/urls.py b/weave/urls.py index 6793462842b3..cf7d53cbf382 100644 --- a/weave/urls.py +++ b/weave/urls.py @@ -2,9 +2,7 @@ from wandb import util as wb_util -from weave.legacy import context_state - -from . import environment +from weave.legacy import context_state, environment BROWSE3_PATH = "browse3" WEAVE_SLUG = "weave" diff --git a/weave/weave_server.py b/weave/weave_server.py index f76a27f7493b..cb77de12faf1 100644 --- a/weave/weave_server.py +++ b/weave/weave_server.py @@ -26,7 +26,6 @@ from werkzeug.exceptions import HTTPException from weave import ( - environment, errors, filesystem, logs, @@ -36,6 +35,7 @@ from weave.legacy import ( context_state, engine_trace, + environment, graph, registry_mem, server,