wandb 0.15.3__py3-none-any.whl → 0.15.5__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- wandb/__init__.py +1 -1
- wandb/analytics/sentry.py +1 -0
- wandb/apis/importers/base.py +20 -5
- wandb/apis/importers/mlflow.py +7 -1
- wandb/apis/internal.py +12 -0
- wandb/apis/public.py +247 -1387
- wandb/apis/reports/_panels.py +58 -35
- wandb/beta/workflows.py +6 -7
- wandb/cli/cli.py +130 -60
- wandb/data_types.py +3 -1
- wandb/filesync/dir_watcher.py +21 -27
- wandb/filesync/step_checksum.py +8 -8
- wandb/filesync/step_prepare.py +23 -10
- wandb/filesync/step_upload.py +13 -13
- wandb/filesync/upload_job.py +4 -8
- wandb/integration/cohere/__init__.py +3 -0
- wandb/integration/cohere/cohere.py +21 -0
- wandb/integration/cohere/resolver.py +347 -0
- wandb/integration/gym/__init__.py +4 -6
- wandb/integration/huggingface/__init__.py +3 -0
- wandb/integration/huggingface/huggingface.py +18 -0
- wandb/integration/huggingface/resolver.py +213 -0
- wandb/integration/langchain/wandb_tracer.py +16 -179
- wandb/integration/openai/__init__.py +1 -3
- wandb/integration/openai/openai.py +11 -143
- wandb/integration/openai/resolver.py +111 -38
- wandb/integration/sagemaker/config.py +2 -2
- wandb/integration/tensorboard/log.py +4 -4
- wandb/old/settings.py +24 -7
- wandb/proto/v3/wandb_telemetry_pb2.py +12 -12
- wandb/proto/v4/wandb_telemetry_pb2.py +12 -12
- wandb/proto/wandb_deprecated.py +3 -1
- wandb/sdk/__init__.py +1 -1
- wandb/sdk/artifacts/__init__.py +0 -0
- wandb/sdk/artifacts/artifact.py +2101 -0
- wandb/sdk/artifacts/artifact_download_logger.py +42 -0
- wandb/sdk/artifacts/artifact_manifest.py +67 -0
- wandb/sdk/artifacts/artifact_manifest_entry.py +159 -0
- wandb/sdk/artifacts/artifact_manifests/__init__.py +0 -0
- wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +91 -0
- wandb/sdk/{internal → artifacts}/artifact_saver.py +6 -5
- wandb/sdk/artifacts/artifact_state.py +10 -0
- wandb/sdk/{interface/artifacts/artifact_cache.py → artifacts/artifacts_cache.py} +22 -12
- wandb/sdk/artifacts/exceptions.py +55 -0
- wandb/sdk/artifacts/storage_handler.py +59 -0
- wandb/sdk/artifacts/storage_handlers/__init__.py +0 -0
- wandb/sdk/artifacts/storage_handlers/azure_handler.py +192 -0
- wandb/sdk/artifacts/storage_handlers/gcs_handler.py +224 -0
- wandb/sdk/artifacts/storage_handlers/http_handler.py +112 -0
- wandb/sdk/artifacts/storage_handlers/local_file_handler.py +134 -0
- wandb/sdk/artifacts/storage_handlers/multi_handler.py +53 -0
- wandb/sdk/artifacts/storage_handlers/s3_handler.py +301 -0
- wandb/sdk/artifacts/storage_handlers/tracking_handler.py +67 -0
- wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +132 -0
- wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +72 -0
- wandb/sdk/artifacts/storage_layout.py +6 -0
- wandb/sdk/artifacts/storage_policies/__init__.py +0 -0
- wandb/sdk/artifacts/storage_policies/s3_bucket_policy.py +61 -0
- wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +386 -0
- wandb/sdk/{interface/artifacts/artifact_storage.py → artifacts/storage_policy.py} +5 -57
- wandb/sdk/data_types/_dtypes.py +7 -12
- wandb/sdk/data_types/base_types/json_metadata.py +3 -2
- wandb/sdk/data_types/base_types/media.py +8 -8
- wandb/sdk/data_types/base_types/wb_value.py +12 -13
- wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +5 -6
- wandb/sdk/data_types/helper_types/classes.py +6 -8
- wandb/sdk/data_types/helper_types/image_mask.py +5 -6
- wandb/sdk/data_types/histogram.py +4 -3
- wandb/sdk/data_types/html.py +3 -4
- wandb/sdk/data_types/image.py +11 -9
- wandb/sdk/data_types/molecule.py +5 -3
- wandb/sdk/data_types/object_3d.py +7 -5
- wandb/sdk/data_types/plotly.py +3 -2
- wandb/sdk/data_types/saved_model.py +11 -11
- wandb/sdk/data_types/trace_tree.py +5 -4
- wandb/sdk/data_types/utils.py +3 -5
- wandb/sdk/data_types/video.py +5 -4
- wandb/sdk/integration_utils/auto_logging.py +215 -0
- wandb/sdk/interface/interface.py +15 -15
- wandb/sdk/internal/file_pusher.py +8 -16
- wandb/sdk/internal/file_stream.py +5 -11
- wandb/sdk/internal/handler.py +13 -1
- wandb/sdk/internal/internal_api.py +287 -13
- wandb/sdk/internal/job_builder.py +119 -30
- wandb/sdk/internal/sender.py +6 -26
- wandb/sdk/internal/settings_static.py +2 -0
- wandb/sdk/internal/system/assets/__init__.py +2 -0
- wandb/sdk/internal/system/assets/gpu.py +42 -0
- wandb/sdk/internal/system/assets/gpu_amd.py +216 -0
- wandb/sdk/internal/system/env_probe_helpers.py +13 -0
- wandb/sdk/internal/system/system_info.py +3 -3
- wandb/sdk/internal/tb_watcher.py +32 -22
- wandb/sdk/internal/thread_local_settings.py +18 -0
- wandb/sdk/launch/_project_spec.py +57 -11
- wandb/sdk/launch/agent/agent.py +147 -65
- wandb/sdk/launch/agent/job_status_tracker.py +34 -0
- wandb/sdk/launch/agent/run_queue_item_file_saver.py +45 -0
- wandb/sdk/launch/builder/abstract.py +5 -1
- wandb/sdk/launch/builder/build.py +21 -18
- wandb/sdk/launch/builder/docker_builder.py +10 -4
- wandb/sdk/launch/builder/kaniko_builder.py +113 -23
- wandb/sdk/launch/builder/noop.py +6 -3
- wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +46 -14
- wandb/sdk/launch/environment/aws_environment.py +3 -2
- wandb/sdk/launch/environment/azure_environment.py +124 -0
- wandb/sdk/launch/environment/gcp_environment.py +2 -4
- wandb/sdk/launch/environment/local_environment.py +1 -1
- wandb/sdk/launch/errors.py +19 -0
- wandb/sdk/launch/github_reference.py +32 -19
- wandb/sdk/launch/launch.py +3 -8
- wandb/sdk/launch/launch_add.py +6 -2
- wandb/sdk/launch/loader.py +21 -2
- wandb/sdk/launch/registry/azure_container_registry.py +132 -0
- wandb/sdk/launch/registry/elastic_container_registry.py +39 -5
- wandb/sdk/launch/registry/google_artifact_registry.py +68 -26
- wandb/sdk/launch/registry/local_registry.py +2 -1
- wandb/sdk/launch/runner/abstract.py +24 -3
- wandb/sdk/launch/runner/kubernetes_runner.py +479 -26
- wandb/sdk/launch/runner/local_container.py +103 -51
- wandb/sdk/launch/runner/local_process.py +1 -1
- wandb/sdk/launch/runner/sagemaker_runner.py +60 -10
- wandb/sdk/launch/runner/vertex_runner.py +10 -5
- wandb/sdk/launch/sweeps/__init__.py +7 -9
- wandb/sdk/launch/sweeps/scheduler.py +307 -77
- wandb/sdk/launch/sweeps/scheduler_sweep.py +2 -1
- wandb/sdk/launch/sweeps/utils.py +82 -35
- wandb/sdk/launch/utils.py +89 -75
- wandb/sdk/lib/_settings_toposort_generated.py +7 -0
- wandb/sdk/lib/capped_dict.py +26 -0
- wandb/sdk/lib/{git.py → gitlib.py} +76 -59
- wandb/sdk/lib/hashutil.py +12 -4
- wandb/sdk/lib/paths.py +96 -8
- wandb/sdk/lib/sock_client.py +2 -2
- wandb/sdk/lib/timer.py +1 -0
- wandb/sdk/service/server.py +22 -9
- wandb/sdk/service/server_sock.py +1 -1
- wandb/sdk/service/service.py +27 -8
- wandb/sdk/verify/verify.py +4 -7
- wandb/sdk/wandb_config.py +2 -6
- wandb/sdk/wandb_init.py +57 -53
- wandb/sdk/wandb_require.py +7 -0
- wandb/sdk/wandb_run.py +61 -223
- wandb/sdk/wandb_settings.py +28 -4
- wandb/testing/relay.py +15 -2
- wandb/util.py +74 -36
- {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/METADATA +15 -9
- {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/RECORD +151 -116
- {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/entry_points.txt +1 -0
- wandb/integration/langchain/util.py +0 -191
- wandb/sdk/interface/artifacts/__init__.py +0 -33
- wandb/sdk/interface/artifacts/artifact.py +0 -615
- wandb/sdk/interface/artifacts/artifact_manifest.py +0 -131
- wandb/sdk/wandb_artifacts.py +0 -2226
- {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/LICENSE +0 -0
- {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/WHEEL +0 -0
- {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/top_level.txt +0 -0
@@ -1,191 +0,0 @@
|
|
1
|
-
"""Common utilities for the LangChain integration.
|
2
|
-
|
3
|
-
This file exposes 4 primary functions:
|
4
|
-
- `print_wandb_init_message`: Prints a message to the user when the `WandbTracer` is initialized.
|
5
|
-
- `safely_convert_lc_run_to_wb_span`: Converts a LangChain Run into a W&B Trace Span.
|
6
|
-
- `safely_get_span_producing_model`: Retrieves the model that produced a given LangChain Run.
|
7
|
-
- `safely_convert_model_to_dict`: Converts a LangChain model into a dictionary.
|
8
|
-
|
9
|
-
These functions are used by the `WandbTracer` to extract and save the relevant information.
|
10
|
-
"""
|
11
|
-
|
12
|
-
from typing import TYPE_CHECKING, Any, Optional, Union
|
13
|
-
|
14
|
-
from langchain.callbacks.tracers.schemas import Run, RunTypeEnum
|
15
|
-
|
16
|
-
import wandb
|
17
|
-
from wandb.sdk.data_types import trace_tree
|
18
|
-
|
19
|
-
if TYPE_CHECKING:
|
20
|
-
from langchain.chains.base import Chain
|
21
|
-
from langchain.llms.base import BaseLLM
|
22
|
-
from langchain.schema import BaseLanguageModel
|
23
|
-
from langchain.tools.base import BaseTool
|
24
|
-
|
25
|
-
|
26
|
-
PRINT_WARNINGS = True
|
27
|
-
|
28
|
-
|
29
|
-
def print_wandb_init_message(run_url: str) -> None:
|
30
|
-
wandb.termlog(
|
31
|
-
f"Streaming LangChain activity to W&B at {run_url}\n"
|
32
|
-
"`WandbTracer` is currently in beta.\n"
|
33
|
-
"Please report any issues to https://github.com/wandb/wandb/issues with the tag `langchain`."
|
34
|
-
)
|
35
|
-
|
36
|
-
|
37
|
-
def safely_convert_lc_run_to_wb_span(run: Run) -> Optional["trace_tree.Span"]:
|
38
|
-
try:
|
39
|
-
return _convert_lc_run_to_wb_span(run)
|
40
|
-
except Exception as e:
|
41
|
-
if PRINT_WARNINGS:
|
42
|
-
wandb.termwarn(
|
43
|
-
f"Skipping trace saving - unable to safely convert LangChain Run into W&B Trace due to: {e}"
|
44
|
-
)
|
45
|
-
return None
|
46
|
-
|
47
|
-
|
48
|
-
def safely_get_span_producing_model(run: Run) -> Any:
|
49
|
-
try:
|
50
|
-
return run.serialized.get("_self")
|
51
|
-
except Exception as e:
|
52
|
-
if PRINT_WARNINGS:
|
53
|
-
wandb.termwarn(
|
54
|
-
f"Skipping model saving - unable to safely retrieve LangChain model due to: {e}"
|
55
|
-
)
|
56
|
-
return None
|
57
|
-
|
58
|
-
|
59
|
-
def safely_convert_model_to_dict(
|
60
|
-
model: Union["BaseLanguageModel", "BaseLLM", "BaseTool", "Chain"]
|
61
|
-
) -> Optional[dict]:
|
62
|
-
"""Returns the model dict if possible, otherwise returns None.
|
63
|
-
|
64
|
-
Given that Models are all user defined, this operation is not always possible.
|
65
|
-
"""
|
66
|
-
data = None
|
67
|
-
message = None
|
68
|
-
try:
|
69
|
-
data = model.dict()
|
70
|
-
except Exception as e:
|
71
|
-
message = str(e)
|
72
|
-
if hasattr(model, "agent"):
|
73
|
-
try:
|
74
|
-
data = model.agent.dict()
|
75
|
-
except Exception as e:
|
76
|
-
message = str(e)
|
77
|
-
|
78
|
-
if data is not None and not isinstance(data, dict):
|
79
|
-
message = (
|
80
|
-
f"Model's dict transformation resulted in {type(data)}, expected a dict."
|
81
|
-
)
|
82
|
-
data = None
|
83
|
-
|
84
|
-
if data is not None:
|
85
|
-
data = _replace_type_with_kind(data)
|
86
|
-
else:
|
87
|
-
if PRINT_WARNINGS:
|
88
|
-
wandb.termwarn(
|
89
|
-
f"Skipping model saving - unable to safely convert LangChain Model to dictionary due to: {message}"
|
90
|
-
)
|
91
|
-
|
92
|
-
return data
|
93
|
-
|
94
|
-
|
95
|
-
def _convert_lc_run_to_wb_span(run: "Run") -> "trace_tree.Span":
|
96
|
-
if run.run_type == RunTypeEnum.llm:
|
97
|
-
return _convert_llm_run_to_wb_span(run)
|
98
|
-
elif run.run_type == RunTypeEnum.chain:
|
99
|
-
return _convert_chain_run_to_wb_span(run)
|
100
|
-
elif run.run_type == RunTypeEnum.tool:
|
101
|
-
return _convert_tool_run_to_wb_span(run)
|
102
|
-
else:
|
103
|
-
return _convert_run_to_wb_span(run)
|
104
|
-
|
105
|
-
|
106
|
-
def _convert_llm_run_to_wb_span(run: "Run") -> "trace_tree.Span":
|
107
|
-
base_span = _convert_run_to_wb_span(run)
|
108
|
-
|
109
|
-
base_span.results = [
|
110
|
-
trace_tree.Result(
|
111
|
-
inputs={"prompt": prompt},
|
112
|
-
outputs={
|
113
|
-
f"gen_{g_i}": gen["text"]
|
114
|
-
for g_i, gen in enumerate(run.outputs["generations"][ndx])
|
115
|
-
}
|
116
|
-
if (
|
117
|
-
run.outputs is not None
|
118
|
-
and len(run.outputs["generations"]) > ndx
|
119
|
-
and len(run.outputs["generations"][ndx]) > 0
|
120
|
-
)
|
121
|
-
else None,
|
122
|
-
)
|
123
|
-
for ndx, prompt in enumerate(run.inputs["prompts"] or [])
|
124
|
-
]
|
125
|
-
base_span.span_kind = trace_tree.SpanKind.LLM
|
126
|
-
|
127
|
-
return base_span
|
128
|
-
|
129
|
-
|
130
|
-
def _convert_chain_run_to_wb_span(run: "Run") -> "trace_tree.Span":
|
131
|
-
base_span = _convert_run_to_wb_span(run)
|
132
|
-
|
133
|
-
base_span.results = [trace_tree.Result(inputs=run.inputs, outputs=run.outputs)]
|
134
|
-
base_span.child_spans = [
|
135
|
-
_convert_lc_run_to_wb_span(child_run) for child_run in run.child_runs
|
136
|
-
]
|
137
|
-
base_span.span_kind = (
|
138
|
-
trace_tree.SpanKind.AGENT
|
139
|
-
if "agent" in run.serialized.get("name").lower()
|
140
|
-
else trace_tree.SpanKind.CHAIN
|
141
|
-
)
|
142
|
-
|
143
|
-
return base_span
|
144
|
-
|
145
|
-
|
146
|
-
def _convert_tool_run_to_wb_span(run: "Run") -> "trace_tree.Span":
|
147
|
-
base_span = _convert_run_to_wb_span(run)
|
148
|
-
|
149
|
-
base_span.attributes["input"] = run.inputs["input"]
|
150
|
-
base_span.results = [trace_tree.Result(inputs=run.inputs, outputs=run.outputs)]
|
151
|
-
base_span.child_spans = [
|
152
|
-
_convert_lc_run_to_wb_span(child_run) for child_run in run.child_runs
|
153
|
-
]
|
154
|
-
base_span.span_kind = trace_tree.SpanKind.TOOL
|
155
|
-
|
156
|
-
return base_span
|
157
|
-
|
158
|
-
|
159
|
-
def _convert_run_to_wb_span(run: "Run") -> "trace_tree.Span":
|
160
|
-
attributes = {**run.extra} if run.extra else {}
|
161
|
-
attributes["execution_order"] = run.execution_order
|
162
|
-
|
163
|
-
return trace_tree.Span(
|
164
|
-
span_id=str(run.id) if run.id is not None else None,
|
165
|
-
name=run.serialized.get("name"),
|
166
|
-
start_time_ms=int(run.start_time.timestamp() * 1000),
|
167
|
-
end_time_ms=int(run.end_time.timestamp() * 1000),
|
168
|
-
status_code=trace_tree.StatusCode.SUCCESS
|
169
|
-
if run.error is None
|
170
|
-
else trace_tree.StatusCode.ERROR,
|
171
|
-
status_message=run.error,
|
172
|
-
attributes=attributes,
|
173
|
-
)
|
174
|
-
|
175
|
-
|
176
|
-
def _replace_type_with_kind(data: dict) -> dict:
|
177
|
-
if isinstance(data, dict):
|
178
|
-
# W&B TraceTree expects "_kind" instead of "_type" since `_type` is special
|
179
|
-
# in W&B.
|
180
|
-
if "_type" in data:
|
181
|
-
_type = data.pop("_type")
|
182
|
-
data["_kind"] = _type
|
183
|
-
return {k: _replace_type_with_kind(v) for k, v in data.items()}
|
184
|
-
elif isinstance(data, list):
|
185
|
-
return [_replace_type_with_kind(v) for v in data]
|
186
|
-
elif isinstance(data, tuple):
|
187
|
-
return tuple(_replace_type_with_kind(v) for v in data)
|
188
|
-
elif isinstance(data, set):
|
189
|
-
return {_replace_type_with_kind(v) for v in data}
|
190
|
-
else:
|
191
|
-
return data
|
@@ -1,33 +0,0 @@
|
|
1
|
-
from wandb.sdk.interface.artifacts.artifact import (
|
2
|
-
Artifact,
|
3
|
-
ArtifactFinalizedError,
|
4
|
-
ArtifactNotLoggedError,
|
5
|
-
ArtifactStatusError,
|
6
|
-
)
|
7
|
-
from wandb.sdk.interface.artifacts.artifact_cache import (
|
8
|
-
ArtifactsCache,
|
9
|
-
get_artifacts_cache,
|
10
|
-
)
|
11
|
-
from wandb.sdk.interface.artifacts.artifact_manifest import (
|
12
|
-
ArtifactManifest,
|
13
|
-
ArtifactManifestEntry,
|
14
|
-
)
|
15
|
-
from wandb.sdk.interface.artifacts.artifact_storage import (
|
16
|
-
StorageHandler,
|
17
|
-
StorageLayout,
|
18
|
-
StoragePolicy,
|
19
|
-
)
|
20
|
-
|
21
|
-
__all__ = [
|
22
|
-
"Artifact",
|
23
|
-
"ArtifactFinalizedError",
|
24
|
-
"ArtifactManifest",
|
25
|
-
"ArtifactManifestEntry",
|
26
|
-
"ArtifactNotLoggedError",
|
27
|
-
"ArtifactsCache",
|
28
|
-
"ArtifactStatusError",
|
29
|
-
"get_artifacts_cache",
|
30
|
-
"StorageHandler",
|
31
|
-
"StorageLayout",
|
32
|
-
"StoragePolicy",
|
33
|
-
]
|