wandb 0.15.4__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.
Files changed (102) hide show
  1. wandb/__init__.py +1 -1
  2. wandb/analytics/sentry.py +1 -0
  3. wandb/apis/internal.py +3 -0
  4. wandb/apis/public.py +18 -20
  5. wandb/beta/workflows.py +5 -6
  6. wandb/cli/cli.py +27 -27
  7. wandb/data_types.py +2 -0
  8. wandb/integration/langchain/wandb_tracer.py +16 -179
  9. wandb/integration/sagemaker/config.py +2 -2
  10. wandb/integration/tensorboard/log.py +4 -4
  11. wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
  12. wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
  13. wandb/proto/wandb_deprecated.py +3 -1
  14. wandb/sdk/__init__.py +1 -4
  15. wandb/sdk/artifacts/__init__.py +0 -14
  16. wandb/sdk/artifacts/artifact.py +1757 -277
  17. wandb/sdk/artifacts/artifact_manifest_entry.py +26 -6
  18. wandb/sdk/artifacts/artifact_state.py +10 -0
  19. wandb/sdk/artifacts/artifacts_cache.py +7 -8
  20. wandb/sdk/artifacts/exceptions.py +4 -4
  21. wandb/sdk/artifacts/storage_handler.py +2 -2
  22. wandb/sdk/artifacts/storage_handlers/azure_handler.py +16 -6
  23. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +2 -2
  24. wandb/sdk/artifacts/storage_handlers/http_handler.py +2 -2
  25. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +2 -2
  26. wandb/sdk/artifacts/storage_handlers/multi_handler.py +2 -2
  27. wandb/sdk/artifacts/storage_handlers/s3_handler.py +35 -32
  28. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +2 -2
  29. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +5 -9
  30. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +2 -2
  31. wandb/sdk/artifacts/storage_policies/s3_bucket_policy.py +2 -2
  32. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +24 -16
  33. wandb/sdk/artifacts/storage_policy.py +3 -3
  34. wandb/sdk/data_types/_dtypes.py +7 -12
  35. wandb/sdk/data_types/base_types/json_metadata.py +2 -2
  36. wandb/sdk/data_types/base_types/media.py +5 -6
  37. wandb/sdk/data_types/base_types/wb_value.py +12 -13
  38. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +4 -5
  39. wandb/sdk/data_types/helper_types/classes.py +5 -8
  40. wandb/sdk/data_types/helper_types/image_mask.py +4 -5
  41. wandb/sdk/data_types/histogram.py +3 -3
  42. wandb/sdk/data_types/html.py +3 -4
  43. wandb/sdk/data_types/image.py +4 -5
  44. wandb/sdk/data_types/molecule.py +2 -2
  45. wandb/sdk/data_types/object_3d.py +3 -3
  46. wandb/sdk/data_types/plotly.py +2 -2
  47. wandb/sdk/data_types/saved_model.py +7 -8
  48. wandb/sdk/data_types/trace_tree.py +4 -4
  49. wandb/sdk/data_types/video.py +4 -4
  50. wandb/sdk/interface/interface.py +8 -10
  51. wandb/sdk/internal/file_stream.py +2 -3
  52. wandb/sdk/internal/internal_api.py +99 -4
  53. wandb/sdk/internal/job_builder.py +15 -7
  54. wandb/sdk/internal/sender.py +4 -0
  55. wandb/sdk/internal/settings_static.py +1 -0
  56. wandb/sdk/launch/_project_spec.py +9 -7
  57. wandb/sdk/launch/agent/agent.py +115 -58
  58. wandb/sdk/launch/agent/job_status_tracker.py +34 -0
  59. wandb/sdk/launch/agent/run_queue_item_file_saver.py +45 -0
  60. wandb/sdk/launch/builder/abstract.py +5 -1
  61. wandb/sdk/launch/builder/build.py +16 -10
  62. wandb/sdk/launch/builder/docker_builder.py +9 -2
  63. wandb/sdk/launch/builder/kaniko_builder.py +108 -22
  64. wandb/sdk/launch/builder/noop.py +3 -1
  65. wandb/sdk/launch/environment/aws_environment.py +2 -1
  66. wandb/sdk/launch/environment/azure_environment.py +124 -0
  67. wandb/sdk/launch/github_reference.py +30 -18
  68. wandb/sdk/launch/launch.py +1 -1
  69. wandb/sdk/launch/loader.py +15 -0
  70. wandb/sdk/launch/registry/azure_container_registry.py +132 -0
  71. wandb/sdk/launch/registry/elastic_container_registry.py +38 -4
  72. wandb/sdk/launch/registry/google_artifact_registry.py +46 -7
  73. wandb/sdk/launch/runner/abstract.py +19 -3
  74. wandb/sdk/launch/runner/kubernetes_runner.py +111 -47
  75. wandb/sdk/launch/runner/local_container.py +101 -48
  76. wandb/sdk/launch/runner/sagemaker_runner.py +59 -9
  77. wandb/sdk/launch/runner/vertex_runner.py +8 -4
  78. wandb/sdk/launch/sweeps/scheduler.py +102 -27
  79. wandb/sdk/launch/sweeps/utils.py +21 -0
  80. wandb/sdk/launch/utils.py +19 -7
  81. wandb/sdk/lib/_settings_toposort_generated.py +3 -0
  82. wandb/sdk/service/server.py +22 -9
  83. wandb/sdk/service/service.py +27 -8
  84. wandb/sdk/verify/verify.py +6 -9
  85. wandb/sdk/wandb_config.py +2 -4
  86. wandb/sdk/wandb_init.py +2 -0
  87. wandb/sdk/wandb_require.py +7 -0
  88. wandb/sdk/wandb_run.py +32 -35
  89. wandb/sdk/wandb_settings.py +10 -3
  90. wandb/testing/relay.py +15 -2
  91. wandb/util.py +55 -23
  92. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/METADATA +11 -8
  93. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/RECORD +97 -97
  94. wandb/integration/langchain/util.py +0 -191
  95. wandb/sdk/artifacts/invalid_artifact.py +0 -23
  96. wandb/sdk/artifacts/lazy_artifact.py +0 -162
  97. wandb/sdk/artifacts/local_artifact.py +0 -719
  98. wandb/sdk/artifacts/public_artifact.py +0 -1188
  99. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/LICENSE +0 -0
  100. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/WHEEL +0 -0
  101. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/entry_points.txt +0 -0
  102. {wandb-0.15.4.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,23 +0,0 @@
1
- """Invalid artifact."""
2
- from typing import TYPE_CHECKING, Any
3
-
4
- from wandb.sdk.artifacts.exceptions import ArtifactNotLoggedError
5
-
6
- if TYPE_CHECKING:
7
- from wandb.sdk.artifacts.artifact import Artifact as ArtifactInterface
8
-
9
-
10
- class InvalidArtifact:
11
- """An "artifact" that raises an error when any properties are accessed."""
12
-
13
- def __init__(self, base_artifact: "ArtifactInterface"):
14
- super().__setattr__("base_artifact", base_artifact)
15
-
16
- def __getattr__(self, __name: str) -> Any:
17
- raise ArtifactNotLoggedError(artifact=self.base_artifact, attr=__name)
18
-
19
- def __setattr__(self, __name: str, __value: Any) -> None:
20
- raise ArtifactNotLoggedError(artifact=self.base_artifact, attr=__name)
21
-
22
- def __bool__(self) -> bool:
23
- return False
@@ -1,162 +0,0 @@
1
- """Lazy artifact."""
2
- from typing import TYPE_CHECKING, Any, List, Optional, Union
3
-
4
- from wandb.apis import PublicApi
5
- from wandb.sdk.artifacts.artifact import Artifact as ArtifactInterface
6
- from wandb.sdk.artifacts.exceptions import WaitTimeoutError
7
- from wandb.sdk.artifacts.invalid_artifact import InvalidArtifact
8
- from wandb.sdk.artifacts.public_artifact import Artifact as PublicArtifact
9
- from wandb.sdk.lib.paths import FilePathStr, StrPath
10
-
11
- if TYPE_CHECKING:
12
- import wandb.apis.public
13
- from wandb.data_types import WBValue
14
- from wandb.sdk.artifacts.artifact_manifest import ArtifactManifest
15
- from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
16
-
17
-
18
- class LazyArtifact(ArtifactInterface):
19
- _api: PublicApi
20
- _instance: Union[ArtifactInterface, InvalidArtifact]
21
- _future: Any
22
-
23
- def __init__(self, api: PublicApi, future: Any):
24
- self._api = api
25
- self._instance = InvalidArtifact(self)
26
- self._future = future
27
-
28
- def __getattr__(self, item: str) -> Any:
29
- return getattr(self._instance, item)
30
-
31
- def wait(self, timeout: Optional[int] = None) -> ArtifactInterface:
32
- if not self._instance:
33
- future_get = self._future.get(timeout)
34
- if not future_get:
35
- raise WaitTimeoutError(
36
- "Artifact upload wait timed out, failed to fetch Artifact response"
37
- )
38
- resp = future_get.response.log_artifact_response
39
- if resp.error_message:
40
- raise ValueError(resp.error_message)
41
- instance = PublicArtifact.from_id(resp.artifact_id, self._api.client)
42
- assert instance is not None
43
- self._instance = instance
44
- assert isinstance(
45
- self._instance, ArtifactInterface
46
- ), "Insufficient permissions to fetch Artifact with id {} from {}".format(
47
- resp.artifact_id, self._api.client.app_url
48
- )
49
- return self._instance
50
-
51
- @property
52
- def id(self) -> Optional[str]:
53
- return self._instance.id
54
-
55
- @property
56
- def entity(self) -> str:
57
- return self._instance.entity
58
-
59
- @property
60
- def project(self) -> str:
61
- return self._instance.project
62
-
63
- @property
64
- def name(self) -> str:
65
- return self._instance.name
66
-
67
- @property
68
- def version(self) -> str:
69
- return self._instance.version
70
-
71
- @property
72
- def source_entity(self) -> str:
73
- return self._instance.source_entity
74
-
75
- @property
76
- def source_project(self) -> str:
77
- return self._instance.source_project
78
-
79
- @property
80
- def source_name(self) -> str:
81
- return self._instance.source_name
82
-
83
- @property
84
- def source_version(self) -> str:
85
- return self._instance.source_version
86
-
87
- @property
88
- def type(self) -> str:
89
- return self._instance.type
90
-
91
- @property
92
- def manifest(self) -> "ArtifactManifest":
93
- return self._instance.manifest
94
-
95
- @property
96
- def digest(self) -> str:
97
- return self._instance.digest
98
-
99
- @property
100
- def state(self) -> str:
101
- return self._instance.state
102
-
103
- @property
104
- def size(self) -> int:
105
- return self._instance.size
106
-
107
- @property
108
- def commit_hash(self) -> str:
109
- return self._instance.commit_hash
110
-
111
- @property
112
- def description(self) -> Optional[str]:
113
- return self._instance.description
114
-
115
- @description.setter
116
- def description(self, desc: Optional[str]) -> None:
117
- self._instance.description = desc
118
-
119
- @property
120
- def metadata(self) -> dict:
121
- return self._instance.metadata
122
-
123
- @metadata.setter
124
- def metadata(self, metadata: dict) -> None:
125
- self._instance.metadata = metadata
126
-
127
- @property
128
- def aliases(self) -> List[str]:
129
- return self._instance.aliases
130
-
131
- @aliases.setter
132
- def aliases(self, aliases: List[str]) -> None:
133
- self._instance.aliases = aliases
134
-
135
- def used_by(self) -> List["wandb.apis.public.Run"]:
136
- return self._instance.used_by()
137
-
138
- def logged_by(self) -> Optional["wandb.apis.public.Run"]:
139
- return self._instance.logged_by()
140
-
141
- def get_path(self, name: StrPath) -> "ArtifactManifestEntry":
142
- return self._instance.get_path(name)
143
-
144
- def get(self, name: str) -> Optional["WBValue"]:
145
- return self._instance.get(name)
146
-
147
- def download(
148
- self, root: Optional[str] = None, recursive: bool = False
149
- ) -> FilePathStr:
150
- return self._instance.download(root, recursive)
151
-
152
- def checkout(self, root: Optional[str] = None) -> str:
153
- return self._instance.checkout(root)
154
-
155
- def verify(self, root: Optional[str] = None) -> None:
156
- self._instance.verify(root)
157
-
158
- def save(self) -> None:
159
- self._instance.save()
160
-
161
- def delete(self, delete_aliases: bool = False) -> None:
162
- self._instance.delete(delete_aliases=delete_aliases)