Skip to content

Commit

Permalink
move to legacy: environment
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Aug 27, 2024
1 parent 0339298 commit 9fe5bc9
Show file tree
Hide file tree
Showing 32 changed files with 51 additions and 49 deletions.
4 changes: 2 additions & 2 deletions weave/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 *
Expand Down
3 changes: 2 additions & 1 deletion weave/deploy/gcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion weave/deploy/modal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions weave/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/artifact_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__"

Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/engine_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
6 changes: 3 additions & 3 deletions weave/environment.py → weave/legacy/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from collections.abc import Mapping

from weave import (
environment,
errors,
)
from weave import weave_types as types
Expand All @@ -23,6 +22,7 @@
# Language Features
from weave.legacy import (
engine_trace,
environment,
parallelism,
ref_base,
registry_mem,
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/gql_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/op_def_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/ops_domain/wbgqlquery_op.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/ops_primitives/file.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/ops_primitives/file_local.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/ops_primitives/projection_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/runfiles_wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/signal_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import typing
from types import FrameType

from weave import environment
from weave.legacy import environment


def dump_folder() -> pathlib.Path:
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/usage_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from weave.legacy import context_state

from .. import environment
from . import environment

analytics.write_key = "uJ8vZgKqTBVH6ZdhD4GZGZYsR7ucfJmb"

Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/wandb_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/wandb_file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion weave/legacy/wandb_interface/wandb_stream_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion weave/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from pythonjsonlogger import jsonlogger

from . import environment
from weave.legacy import environment

try:
from flask.logging import wsgi_errors_stream
Expand Down
4 changes: 2 additions & 2 deletions weave/tests/legacy/test_access.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions weave/tests/legacy/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions weave/tests/legacy/test_file.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
4 changes: 3 additions & 1 deletion weave/tests/legacy/test_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import pytest

from ... import environment, errors, filesystem
from weave.legacy import environment

from ... import errors, filesystem


@pytest.fixture()
Expand Down
3 changes: 2 additions & 1 deletion weave/trace/op_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/remote_http_trace_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions weave/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion weave/weave_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from werkzeug.exceptions import HTTPException

from weave import (
environment,
errors,
filesystem,
logs,
Expand All @@ -36,6 +35,7 @@
from weave.legacy import (
context_state,
engine_trace,
environment,
graph,
registry_mem,
server,
Expand Down

0 comments on commit 9fe5bc9

Please sign in to comment.