Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(weave): Legacy Refactor pt1 #2218

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:
# github actions does something funky with the std file descriptors, they end up
# being closed. tqdm (for example) raises an exception when the descriptor it
# wants to write to is closed.
run: nohup ./weave_server_test.sh < /dev/null &> /tmp/weave/log/stdout.log &
run: nohup ./scripts/weave_server_test.sh < /dev/null &> /tmp/weave/log/stdout.log &
shell: bash
- name: Cypress run
# Use the following to run just a single test
Expand Down
3 changes: 1 addition & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ yarn dev
Weave backend server. This does not currently auto-reload, so you need to restart it if you change stuff.

```
sh weave_server.sh
sh scripts/weave_server.sh
```

Now you should be able to go to localhost:3000 to see the weave home page.
Expand All @@ -92,7 +92,6 @@ You can tell everything is working if the weave UI renders and you see your serv

Some ops require environment variables to be set, like OPENAI_API_KEY. You need to set these for the server environment and your Jupyter notebook.


## Unit tests

Some of the unit tests try to run a wandb server container, and will produce 403s if that container is out of date. The container is only accessible to wandb developers currently.
Expand Down
1 change: 0 additions & 1 deletion build_test_container.sh

This file was deleted.

5 changes: 0 additions & 5 deletions dd_weave_server_replay.sh

This file was deleted.

2 changes: 1 addition & 1 deletion integration_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ yarn && yarn run cypress open

Start the weave server with

bash weave_server_test.sh
bash scripts/weave_server_test.sh
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions scripts/build_test_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
docker buildx build \
--platform linux/amd64 \
-t us-east4-docker.pkg.dev/weave-support-367421/weave-images/weave-test:latest \
-f Dockerfile.test \
.
19 changes: 11 additions & 8 deletions dd_weave_server.sh → scripts/dd_weave_server.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/sh

DD_SERVICE="weave-python" DD_ENV="dev-$(whoami)" DD_LOGS_INJECTION=true \
DD_TRACE_PROPAGATION_STYLE_EXTRACT=b3,datadog \
DD_TRACE_PROPAGATION_STYLE_INJECT=b3,datadog \
WEAVE_DISABLE_ANALYTICS=true \
WEAVE_SERVER_ENABLE_LOGGING=true \
FLASK_ENV=development \
FLASK_APP=weave.weave_server \
ddtrace-run flask run --port 9994
DD_SERVICE="weave-python"
DD_ENV="dev-$(whoami)"
DD_LOGS_INJECTION=true
DD_TRACE_PROPAGATION_STYLE_EXTRACT=b3,datadog
DD_TRACE_PROPAGATION_STYLE_INJECT=b3,datadog
WEAVE_DISABLE_ANALYTICS=true
WEAVE_SERVER_ENABLE_LOGGING=true
FLASK_ENV=development
FLASK_APP=weave.weave_server

ddtrace-run flask run --port 9994

# This runs with the datadog profiler on, but it is expensive!
# I noticed a 2x increase in query time for some queries
Expand Down
10 changes: 10 additions & 0 deletions scripts/dd_weave_server_replay.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

WEAVE_SERVER_DEBUG=true
DD_SERVICE="weave-python"
DD_ENV="dev-$(whoami)"
DD_LOGS_INJECTION=true
WEAVE_SERVER_ENABLE_LOGGING=true
FLASK_APP=weave.weave_server

ddtrace-run flask run --port 9994
12 changes: 12 additions & 0 deletions scripts/weave_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

# We could set WEAVE_BACKEND_HOST=http://localhost:9994/__weave but the frontend dev server
# automatically forwards so it shouldn't be necessary.
source ./config/auth_modes.sh

WEAVE_DISABLE_ANALYTICS=true
WEAVE_SERVER_ENABLE_LOGGING=true
FLASK_DEBUG=1
FLASK_APP=weave.weave_server

flask run --port 9994
7 changes: 7 additions & 0 deletions scripts/weave_server_replay.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

export WEAVE_SERVER_DEBUG=true
export WEAVE_SERVER_ENABLE_LOGGING=true
export FLASK_APP=weave.weave_server

flask run --port 9994
10 changes: 10 additions & 0 deletions scripts/weave_server_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

export WEAVE_CI=true
export WEAVE_DISABLE_ANALYTICS=true
export WEAVE_SERVER_DEBUG=true
export WEAVE_SERVER_ENABLE_LOGGING=true
export WEAVE_WANDB_GQL_NUM_TIMEOUT_RETRIES=1
export FLASK_APP=weave.weave_server

flask run --port 9994 "$@"
2 changes: 1 addition & 1 deletion supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ stopasgroup = true
killasgroup = true

[program:weave-python-server]
command = bash ./weave_server_test.sh
command = bash ./scripts/weave_server_test.sh
directory = .
autostart = true
autorestart = false
Expand Down
2 changes: 1 addition & 1 deletion weave-js/src/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,5 +424,5 @@ See [generateDocs.ts](./generateDocs.ts) for implementation.

# Testing Against Weave Python

1. Start a Weave Server using `./weave_server.sh` from the `weave/weave` directory
1. Start a Weave Server using `./scripts/weave_server.sh` from the `weave/weave` directory
2. Run `yarn test:python-backend` from this directory
16 changes: 0 additions & 16 deletions weave/clear_cache.py

This file was deleted.

8 changes: 2 additions & 6 deletions weave/errors.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from typing import Iterable, Optional


class WeaveUnmergableArtifactsError(Exception):
pass


class WeaveFingerprintErrorMixin:
fingerprint: Optional[Iterable] = None

Expand All @@ -30,11 +26,11 @@ class WeaveInternalError(WeaveBaseError):
pass


class WeaveConfigurationError(WeaveBaseError):
class WeaveSerializeError(WeaveBaseError):
pass


class WeaveSerializeError(WeaveBaseError):
class WeaveConfigurationError(WeaveBaseError):
pass


Expand Down
32 changes: 32 additions & 0 deletions weave/legacy/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from typing import Iterable, Optional


class WeaveUnmergableArtifactsError(Exception):
pass


class WeaveFingerprintErrorMixin:
fingerprint: Optional[Iterable] = None


class WeaveBaseError(Exception, WeaveFingerprintErrorMixin):
pass


class WeaveBaseWarning(Warning):
pass

# Only use this if you actually want to return an Http 400
# to the client. This should only happen in cases where the
# client is wrong.
class WeaveBadRequest(WeaveBaseError):
pass


class WeaveInternalError(WeaveBaseError):
"""Internal Weave Error (a programming error)"""

pass

class WeaveSerializeError(WeaveBaseError):
pass
2 changes: 1 addition & 1 deletion weave/legacy/ops_primitives/weave_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
ref_base,
registry_mem,
storage,
trace_legacy,
weave_internal,
)
from weave import weave_types as types
Expand All @@ -20,6 +19,7 @@
graph,
object_context,
runs,
trace_legacy,
uris,
)
from weave.legacy.graph import Node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from weave.legacy import cache

# TODO: This should be split out into a scripts dir
# Script to run to delete expired caches
if __name__ == "__main__":
print("Starting clear cache job", flush=True)
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions weave/trace_legacy.py → weave/legacy/trace_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from weave.legacy import artifact_local, graph, runs

from . import errors, ref_base
from . import weave_types as types
from .. import ref_base
from . import errors
from .. import weave_types as types


def get_obj_creator(ref: ref_base.Ref) -> typing.Optional[runs.Run]:
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion weave/tests/legacy/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from weave.legacy import graph

from ... import api as weave
from ... import storage, trace_legacy
from ... import storage
from ...legacy import trace_legacy
from ...weave_internal import make_const_node


Expand Down
8 changes: 0 additions & 8 deletions weave_server.sh

This file was deleted.

3 changes: 0 additions & 3 deletions weave_server_replay.sh

This file was deleted.

3 changes: 0 additions & 3 deletions weave_server_test.sh

This file was deleted.

Loading