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.
Files changed (156) hide show
  1. wandb/__init__.py +1 -1
  2. wandb/analytics/sentry.py +1 -0
  3. wandb/apis/importers/base.py +20 -5
  4. wandb/apis/importers/mlflow.py +7 -1
  5. wandb/apis/internal.py +12 -0
  6. wandb/apis/public.py +247 -1387
  7. wandb/apis/reports/_panels.py +58 -35
  8. wandb/beta/workflows.py +6 -7
  9. wandb/cli/cli.py +130 -60
  10. wandb/data_types.py +3 -1
  11. wandb/filesync/dir_watcher.py +21 -27
  12. wandb/filesync/step_checksum.py +8 -8
  13. wandb/filesync/step_prepare.py +23 -10
  14. wandb/filesync/step_upload.py +13 -13
  15. wandb/filesync/upload_job.py +4 -8
  16. wandb/integration/cohere/__init__.py +3 -0
  17. wandb/integration/cohere/cohere.py +21 -0
  18. wandb/integration/cohere/resolver.py +347 -0
  19. wandb/integration/gym/__init__.py +4 -6
  20. wandb/integration/huggingface/__init__.py +3 -0
  21. wandb/integration/huggingface/huggingface.py +18 -0
  22. wandb/integration/huggingface/resolver.py +213 -0
  23. wandb/integration/langchain/wandb_tracer.py +16 -179
  24. wandb/integration/openai/__init__.py +1 -3
  25. wandb/integration/openai/openai.py +11 -143
  26. wandb/integration/openai/resolver.py +111 -38
  27. wandb/integration/sagemaker/config.py +2 -2
  28. wandb/integration/tensorboard/log.py +4 -4
  29. wandb/old/settings.py +24 -7
  30. wandb/proto/v3/wandb_telemetry_pb2.py +12 -12
  31. wandb/proto/v4/wandb_telemetry_pb2.py +12 -12
  32. wandb/proto/wandb_deprecated.py +3 -1
  33. wandb/sdk/__init__.py +1 -1
  34. wandb/sdk/artifacts/__init__.py +0 -0
  35. wandb/sdk/artifacts/artifact.py +2101 -0
  36. wandb/sdk/artifacts/artifact_download_logger.py +42 -0
  37. wandb/sdk/artifacts/artifact_manifest.py +67 -0
  38. wandb/sdk/artifacts/artifact_manifest_entry.py +159 -0
  39. wandb/sdk/artifacts/artifact_manifests/__init__.py +0 -0
  40. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +91 -0
  41. wandb/sdk/{internal → artifacts}/artifact_saver.py +6 -5
  42. wandb/sdk/artifacts/artifact_state.py +10 -0
  43. wandb/sdk/{interface/artifacts/artifact_cache.py → artifacts/artifacts_cache.py} +22 -12
  44. wandb/sdk/artifacts/exceptions.py +55 -0
  45. wandb/sdk/artifacts/storage_handler.py +59 -0
  46. wandb/sdk/artifacts/storage_handlers/__init__.py +0 -0
  47. wandb/sdk/artifacts/storage_handlers/azure_handler.py +192 -0
  48. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +224 -0
  49. wandb/sdk/artifacts/storage_handlers/http_handler.py +112 -0
  50. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +134 -0
  51. wandb/sdk/artifacts/storage_handlers/multi_handler.py +53 -0
  52. wandb/sdk/artifacts/storage_handlers/s3_handler.py +301 -0
  53. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +67 -0
  54. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +132 -0
  55. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +72 -0
  56. wandb/sdk/artifacts/storage_layout.py +6 -0
  57. wandb/sdk/artifacts/storage_policies/__init__.py +0 -0
  58. wandb/sdk/artifacts/storage_policies/s3_bucket_policy.py +61 -0
  59. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +386 -0
  60. wandb/sdk/{interface/artifacts/artifact_storage.py → artifacts/storage_policy.py} +5 -57
  61. wandb/sdk/data_types/_dtypes.py +7 -12
  62. wandb/sdk/data_types/base_types/json_metadata.py +3 -2
  63. wandb/sdk/data_types/base_types/media.py +8 -8
  64. wandb/sdk/data_types/base_types/wb_value.py +12 -13
  65. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +5 -6
  66. wandb/sdk/data_types/helper_types/classes.py +6 -8
  67. wandb/sdk/data_types/helper_types/image_mask.py +5 -6
  68. wandb/sdk/data_types/histogram.py +4 -3
  69. wandb/sdk/data_types/html.py +3 -4
  70. wandb/sdk/data_types/image.py +11 -9
  71. wandb/sdk/data_types/molecule.py +5 -3
  72. wandb/sdk/data_types/object_3d.py +7 -5
  73. wandb/sdk/data_types/plotly.py +3 -2
  74. wandb/sdk/data_types/saved_model.py +11 -11
  75. wandb/sdk/data_types/trace_tree.py +5 -4
  76. wandb/sdk/data_types/utils.py +3 -5
  77. wandb/sdk/data_types/video.py +5 -4
  78. wandb/sdk/integration_utils/auto_logging.py +215 -0
  79. wandb/sdk/interface/interface.py +15 -15
  80. wandb/sdk/internal/file_pusher.py +8 -16
  81. wandb/sdk/internal/file_stream.py +5 -11
  82. wandb/sdk/internal/handler.py +13 -1
  83. wandb/sdk/internal/internal_api.py +287 -13
  84. wandb/sdk/internal/job_builder.py +119 -30
  85. wandb/sdk/internal/sender.py +6 -26
  86. wandb/sdk/internal/settings_static.py +2 -0
  87. wandb/sdk/internal/system/assets/__init__.py +2 -0
  88. wandb/sdk/internal/system/assets/gpu.py +42 -0
  89. wandb/sdk/internal/system/assets/gpu_amd.py +216 -0
  90. wandb/sdk/internal/system/env_probe_helpers.py +13 -0
  91. wandb/sdk/internal/system/system_info.py +3 -3
  92. wandb/sdk/internal/tb_watcher.py +32 -22
  93. wandb/sdk/internal/thread_local_settings.py +18 -0
  94. wandb/sdk/launch/_project_spec.py +57 -11
  95. wandb/sdk/launch/agent/agent.py +147 -65
  96. wandb/sdk/launch/agent/job_status_tracker.py +34 -0
  97. wandb/sdk/launch/agent/run_queue_item_file_saver.py +45 -0
  98. wandb/sdk/launch/builder/abstract.py +5 -1
  99. wandb/sdk/launch/builder/build.py +21 -18
  100. wandb/sdk/launch/builder/docker_builder.py +10 -4
  101. wandb/sdk/launch/builder/kaniko_builder.py +113 -23
  102. wandb/sdk/launch/builder/noop.py +6 -3
  103. wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +46 -14
  104. wandb/sdk/launch/environment/aws_environment.py +3 -2
  105. wandb/sdk/launch/environment/azure_environment.py +124 -0
  106. wandb/sdk/launch/environment/gcp_environment.py +2 -4
  107. wandb/sdk/launch/environment/local_environment.py +1 -1
  108. wandb/sdk/launch/errors.py +19 -0
  109. wandb/sdk/launch/github_reference.py +32 -19
  110. wandb/sdk/launch/launch.py +3 -8
  111. wandb/sdk/launch/launch_add.py +6 -2
  112. wandb/sdk/launch/loader.py +21 -2
  113. wandb/sdk/launch/registry/azure_container_registry.py +132 -0
  114. wandb/sdk/launch/registry/elastic_container_registry.py +39 -5
  115. wandb/sdk/launch/registry/google_artifact_registry.py +68 -26
  116. wandb/sdk/launch/registry/local_registry.py +2 -1
  117. wandb/sdk/launch/runner/abstract.py +24 -3
  118. wandb/sdk/launch/runner/kubernetes_runner.py +479 -26
  119. wandb/sdk/launch/runner/local_container.py +103 -51
  120. wandb/sdk/launch/runner/local_process.py +1 -1
  121. wandb/sdk/launch/runner/sagemaker_runner.py +60 -10
  122. wandb/sdk/launch/runner/vertex_runner.py +10 -5
  123. wandb/sdk/launch/sweeps/__init__.py +7 -9
  124. wandb/sdk/launch/sweeps/scheduler.py +307 -77
  125. wandb/sdk/launch/sweeps/scheduler_sweep.py +2 -1
  126. wandb/sdk/launch/sweeps/utils.py +82 -35
  127. wandb/sdk/launch/utils.py +89 -75
  128. wandb/sdk/lib/_settings_toposort_generated.py +7 -0
  129. wandb/sdk/lib/capped_dict.py +26 -0
  130. wandb/sdk/lib/{git.py → gitlib.py} +76 -59
  131. wandb/sdk/lib/hashutil.py +12 -4
  132. wandb/sdk/lib/paths.py +96 -8
  133. wandb/sdk/lib/sock_client.py +2 -2
  134. wandb/sdk/lib/timer.py +1 -0
  135. wandb/sdk/service/server.py +22 -9
  136. wandb/sdk/service/server_sock.py +1 -1
  137. wandb/sdk/service/service.py +27 -8
  138. wandb/sdk/verify/verify.py +4 -7
  139. wandb/sdk/wandb_config.py +2 -6
  140. wandb/sdk/wandb_init.py +57 -53
  141. wandb/sdk/wandb_require.py +7 -0
  142. wandb/sdk/wandb_run.py +61 -223
  143. wandb/sdk/wandb_settings.py +28 -4
  144. wandb/testing/relay.py +15 -2
  145. wandb/util.py +74 -36
  146. {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/METADATA +15 -9
  147. {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/RECORD +151 -116
  148. {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/entry_points.txt +1 -0
  149. wandb/integration/langchain/util.py +0 -191
  150. wandb/sdk/interface/artifacts/__init__.py +0 -33
  151. wandb/sdk/interface/artifacts/artifact.py +0 -615
  152. wandb/sdk/interface/artifacts/artifact_manifest.py +0 -131
  153. wandb/sdk/wandb_artifacts.py +0 -2226
  154. {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/LICENSE +0 -0
  155. {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/WHEEL +0 -0
  156. {wandb-0.15.3.dist-info → wandb-0.15.5.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,13 @@
1
1
  """Implementation of Elastic Container Registry class for wandb launch."""
2
2
  import base64
3
3
  import logging
4
+ import re
4
5
  from typing import Dict, Tuple
5
6
 
7
+ import yaml
8
+
6
9
  from wandb.sdk.launch.environment.aws_environment import AwsEnvironment
7
- from wandb.sdk.launch.utils import LaunchError
10
+ from wandb.sdk.launch.errors import LaunchError
8
11
  from wandb.util import get_module
9
12
 
10
13
  from .abstract import AbstractRegistry
@@ -52,7 +55,7 @@ class ElasticContainerRegistry(AbstractRegistry):
52
55
  @classmethod
53
56
  def from_config( # type: ignore[override]
54
57
  cls,
55
- config: Dict,
58
+ config: Dict[str, str],
56
59
  environment: AwsEnvironment,
57
60
  verify: bool = True,
58
61
  ) -> "ElasticContainerRegistry":
@@ -70,10 +73,41 @@ class ElasticContainerRegistry(AbstractRegistry):
70
73
  f"Could not create ElasticContainerRegistry from config. Expected type 'ecr' "
71
74
  f"but got '{config.get('type')}'."
72
75
  )
73
- repository = config.get("repository")
74
- if not repository:
76
+ if ("uri" in config) == ("repository" in config):
77
+ raise LaunchError(
78
+ "Could not create ElasticContainerRegistry from config. Either 'uri' or "
79
+ f"'repository' is required. The config received was:\n{yaml.dump(config)}."
80
+ )
81
+ if "repository" in config:
82
+ repository = config.get("repository")
83
+ else:
84
+ match = re.match(
85
+ r"^(?P<account>.*)\.dkr\.ecr\.(?P<region>.*)\.amazonaws\.com/(?P<repository>.*)/?$",
86
+ config["uri"],
87
+ )
88
+ if not match:
89
+ raise LaunchError(
90
+ f"Could not create ElasticContainerRegistry from config. The uri "
91
+ f"{config.get('uri')} is invalid."
92
+ )
93
+ repository = match.group("repository")
94
+ if match.group("region") != environment.region:
95
+ raise LaunchError(
96
+ f"Could not create ElasticContainerRegistry from config. The uri "
97
+ f"{config.get('uri')} is in region {match.group('region')} but the "
98
+ f"environment is in region {environment.region}."
99
+ )
100
+ if match.group("account") != environment._account:
101
+ raise LaunchError(
102
+ f"Could not create ElasticContainerRegistry from config. The uri "
103
+ f"{config.get('uri')} is in account {match.group('account')} but the "
104
+ f"account being used is {environment._account}."
105
+ )
106
+ if not isinstance(repository, str):
107
+ # This is for mypy. We should never get here.
75
108
  raise LaunchError(
76
- "Could not create ElasticContainerRegistry from config. 'repository' is required."
109
+ f"Could not create ElasticContainerRegistry from config. The repository "
110
+ f"{repository} is invalid: repository should be a string."
77
111
  )
78
112
  return cls(repository, environment)
79
113
 
@@ -3,8 +3,10 @@ import logging
3
3
  import re
4
4
  from typing import Tuple
5
5
 
6
+ import yaml
7
+
6
8
  from wandb.sdk.launch.environment.gcp_environment import GcpEnvironment
7
- from wandb.sdk.launch.utils import LaunchError
9
+ from wandb.sdk.launch.errors import LaunchError
8
10
  from wandb.util import get_module
9
11
 
10
12
  from .abstract import AbstractRegistry
@@ -99,20 +101,57 @@ class GoogleArtifactRegistry(AbstractRegistry):
99
101
  Arguments:
100
102
  config: A dictionary containing the following keys:
101
103
  repository: The repository name.
102
- image_name: The image name.
104
+ image-name: The image name.
103
105
  environment: A GcpEnvironment configured for access to this registry.
104
106
 
105
107
  Returns:
106
108
  A GoogleArtifactRegistry.
107
109
  """
108
- repository = config.get("repository")
109
- if not repository:
110
- raise LaunchError(
111
- "The Google Artifact Registry repository must be specified."
110
+ if "uri" in config:
111
+ if "repository" in config or "image-name" in config:
112
+ raise LaunchError(
113
+ "The Google Artifact Registry must be specified with either "
114
+ "the uri key or the repository and image-name keys, but not both. "
115
+ f"The provided config is:\n{yaml.dump(config)}."
116
+ )
117
+ match = re.match(
118
+ r"^(?P<region>[\w-]+)-docker\.pkg\.dev/(?P<project>[\w-]+)/(?P<repository>[\w-]+)/(?P<image_name>[\w-]+)$",
119
+ config["uri"],
112
120
  )
113
- image_name = config.get("image_name")
114
- if not image_name:
115
- raise LaunchError("The image name must be specified.")
121
+ if not match:
122
+ raise LaunchError(
123
+ f"The Google Artifact Registry uri {config['uri']} is invalid. "
124
+ "Please provide a uri of the form "
125
+ "REGION-docker.pkg.dev/PROJECT/REPOSITORY/IMAGE_NAME."
126
+ )
127
+ else:
128
+ repository = match.group("repository")
129
+ image_name = match.group("image_name")
130
+ if match.group("region") != environment.region:
131
+ raise LaunchError(
132
+ f"The Google Artifact Registry uri {config['uri']} does not "
133
+ f"match the configured region {environment.region}."
134
+ )
135
+ if match.group("project") != environment.project:
136
+ raise LaunchError(
137
+ f"The Google Artifact Registry uri {config['uri']} does not "
138
+ f"match the configured project {environment.project}."
139
+ )
140
+ else:
141
+ repository = config.get("repository")
142
+ if not repository:
143
+ raise LaunchError(
144
+ "The Google Artifact Registry repository must be specified "
145
+ "by setting the either the uri or repository key of your "
146
+ f"registry config. The provided config is:\n{yaml.dump(config)}."
147
+ )
148
+ image_name = config.get("image-name")
149
+ if not image_name:
150
+ raise LaunchError(
151
+ "The Google Artifact Registry repository must be specified "
152
+ "by setting the either the uri or repository key of your "
153
+ f"registry config. The provided config is:\n{yaml.dump(config)}."
154
+ )
116
155
  return cls(repository, image_name, environment, verify=verify)
117
156
 
118
157
  def verify(self) -> None:
@@ -182,22 +221,25 @@ class GoogleArtifactRegistry(AbstractRegistry):
182
221
  _logger.info(
183
222
  f"Checking if image {image_uri} exists. In Google Artifact Registry {self.uri}."
184
223
  )
224
+ repo_uri, tag = image_uri.split(":")
225
+ if repo_uri != self.get_repo_uri():
226
+ raise LaunchError(
227
+ f"The image {image_uri} does not belong to the Google Artifact "
228
+ f"Repository {self.get_repo_uri()}."
229
+ )
230
+ credentials = self.environment.get_credentials()
185
231
 
232
+ # request = google.cloud.artifactregistry.GetTagRequest(name=image_uri)
233
+ parent = f"projects/{self.environment.project}/locations/{self.environment.region}/repositories/{self.repository}"
234
+ client = google.cloud.artifactregistry.ArtifactRegistryClient(
235
+ credentials=credentials
236
+ )
237
+ try:
238
+ for image in client.list_docker_images(request={"parent": parent}):
239
+ if tag in image.tags:
240
+ return True
241
+ except google.api_core.exceptions.NotFound as e:
242
+ raise LaunchError(
243
+ f"The Google Artifact Registry repository {self.repository} does not exist."
244
+ ) from e
186
245
  return False
187
- # TODO: Test GCP Artifact Registry image exists to get working
188
- # repo_uri, _ = image_uri.split(":")
189
- # if repo_uri != self.get_repo_uri():
190
- # raise LaunchError(
191
- # f"The image {image_uri} does not belong to the Google Artifact "
192
- # f"Repository {self.get_repo_uri()}."
193
- # )
194
- # credentials = self.environment.get_credentials()
195
- # request = google.cloud.artifactregistry.GetTagRequest(parent=image_uri)
196
- # client = google.cloud.artifactregistry.ArtifactRegistryClient(
197
- # credentials=credentials
198
- # )
199
- # try:
200
- # client.get_tag(request=request)
201
- # return True
202
- # except google.api_core.exceptions.NotFound:
203
- # return False
@@ -2,7 +2,8 @@
2
2
  import logging
3
3
  from typing import Tuple
4
4
 
5
- from wandb.sdk.launch.utils import LaunchError, docker_image_exists
5
+ from wandb.sdk.launch.errors import LaunchError
6
+ from wandb.sdk.launch.utils import docker_image_exists
6
7
 
7
8
  from ..environment.abstract import AbstractEnvironment
8
9
  from .abstract import AbstractRegistry
@@ -1,9 +1,14 @@
1
+ """Implementation of the abstract runner class.
2
+
3
+ This class defines the interface that the W&B launch runner uses to manage the lifecycle
4
+ of runs launched in different environments (e.g. runs launched locally or in a cluster).
5
+ """
1
6
  import logging
2
7
  import os
3
8
  import subprocess
4
9
  import sys
5
10
  from abc import ABC, abstractmethod
6
- from typing import Any, Dict, List, Optional, Union
11
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
7
12
 
8
13
  from dockerpycreds.utils import find_executable # type: ignore
9
14
 
@@ -17,6 +22,9 @@ from .._project_spec import LaunchProject
17
22
 
18
23
  _logger = logging.getLogger(__name__)
19
24
 
25
+ if TYPE_CHECKING:
26
+ from wandb.sdk.launch.agent.job_status_tracker import JobAndRunStatusTracker
27
+
20
28
 
21
29
  if sys.version_info >= (3, 8):
22
30
  from typing import Literal
@@ -24,7 +32,14 @@ else:
24
32
  from typing_extensions import Literal
25
33
 
26
34
  State = Literal[
27
- "unknown", "starting", "running", "failed", "finished", "stopping", "stopped"
35
+ "unknown",
36
+ "starting",
37
+ "running",
38
+ "failed",
39
+ "finished",
40
+ "stopping",
41
+ "stopped",
42
+ "preempted",
28
43
  ]
29
44
 
30
45
 
@@ -56,6 +71,11 @@ class AbstractRun(ABC):
56
71
  def status(self) -> Status:
57
72
  return self._status
58
73
 
74
+ @abstractmethod
75
+ def get_logs(self) -> Optional[str]:
76
+ """Return the logs associated with the run."""
77
+ pass
78
+
59
79
  def _run_cmd(
60
80
  self, cmd: List[str], output_only: Optional[bool] = False
61
81
  ) -> Optional[Union["subprocess.Popen[bytes]", bytes]]:
@@ -101,7 +121,7 @@ class AbstractRun(ABC):
101
121
 
102
122
  @property
103
123
  @abstractmethod
104
- def id(self) -> str:
124
+ def id(self) -> Optional[str]:
105
125
  pass
106
126
 
107
127
 
@@ -147,6 +167,7 @@ class AbstractRunner(ABC):
147
167
  self,
148
168
  launch_project: LaunchProject,
149
169
  builder: AbstractBuilder,
170
+ job_tracker: Optional["JobAndRunStatusTracker"] = None,
150
171
  ) -> Optional[AbstractRun]:
151
172
  """Submit an LaunchProject to be run.
152
173