wandb 0.19.12rc1__py3-none-win32.whl → 0.20.1__py3-none-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. wandb/__init__.py +1 -2
  2. wandb/__init__.pyi +3 -6
  3. wandb/_iterutils.py +26 -7
  4. wandb/_pydantic/__init__.py +2 -1
  5. wandb/_pydantic/utils.py +7 -0
  6. wandb/agents/pyagent.py +9 -15
  7. wandb/analytics/sentry.py +1 -2
  8. wandb/apis/attrs.py +3 -4
  9. wandb/apis/importers/internals/util.py +1 -1
  10. wandb/apis/importers/validation.py +2 -2
  11. wandb/apis/importers/wandb.py +30 -25
  12. wandb/apis/normalize.py +2 -2
  13. wandb/apis/public/__init__.py +1 -0
  14. wandb/apis/public/api.py +37 -33
  15. wandb/apis/public/artifacts.py +103 -72
  16. wandb/apis/public/jobs.py +3 -2
  17. wandb/apis/public/registries/registries_search.py +4 -2
  18. wandb/apis/public/registries/registry.py +1 -1
  19. wandb/apis/public/registries/utils.py +9 -9
  20. wandb/apis/public/runs.py +18 -6
  21. wandb/automations/_filters/expressions.py +1 -1
  22. wandb/automations/_filters/operators.py +1 -1
  23. wandb/automations/_filters/run_metrics.py +1 -1
  24. wandb/beta/workflows.py +6 -5
  25. wandb/bin/gpu_stats.exe +0 -0
  26. wandb/bin/wandb-core +0 -0
  27. wandb/cli/cli.py +54 -73
  28. wandb/docker/__init__.py +21 -74
  29. wandb/docker/names.py +40 -0
  30. wandb/env.py +0 -1
  31. wandb/errors/util.py +1 -1
  32. wandb/filesync/step_checksum.py +1 -1
  33. wandb/filesync/step_upload.py +1 -1
  34. wandb/integration/diffusers/resolvers/multimodal.py +1 -2
  35. wandb/integration/gym/__init__.py +5 -6
  36. wandb/integration/keras/callbacks/model_checkpoint.py +2 -2
  37. wandb/integration/keras/keras.py +13 -19
  38. wandb/integration/kfp/kfp_patch.py +2 -3
  39. wandb/integration/langchain/wandb_tracer.py +1 -1
  40. wandb/integration/metaflow/metaflow.py +13 -13
  41. wandb/integration/openai/fine_tuning.py +3 -2
  42. wandb/integration/sagemaker/auth.py +2 -1
  43. wandb/integration/sklearn/utils.py +2 -1
  44. wandb/integration/tensorboard/__init__.py +1 -1
  45. wandb/integration/tensorboard/log.py +2 -5
  46. wandb/integration/tensorflow/__init__.py +2 -2
  47. wandb/jupyter.py +20 -17
  48. wandb/plot/confusion_matrix.py +1 -1
  49. wandb/plot/utils.py +8 -7
  50. wandb/proto/v3/wandb_internal_pb2.py +355 -335
  51. wandb/proto/v3/wandb_settings_pb2.py +2 -2
  52. wandb/proto/v3/wandb_telemetry_pb2.py +12 -12
  53. wandb/proto/v4/wandb_internal_pb2.py +339 -335
  54. wandb/proto/v4/wandb_settings_pb2.py +2 -2
  55. wandb/proto/v4/wandb_telemetry_pb2.py +12 -12
  56. wandb/proto/v5/wandb_internal_pb2.py +339 -335
  57. wandb/proto/v5/wandb_settings_pb2.py +2 -2
  58. wandb/proto/v5/wandb_telemetry_pb2.py +12 -12
  59. wandb/proto/v6/wandb_internal_pb2.py +339 -335
  60. wandb/proto/v6/wandb_settings_pb2.py +2 -2
  61. wandb/proto/v6/wandb_telemetry_pb2.py +12 -12
  62. wandb/proto/wandb_deprecated.py +6 -8
  63. wandb/sdk/artifacts/_internal_artifact.py +43 -0
  64. wandb/sdk/artifacts/_validators.py +55 -35
  65. wandb/sdk/artifacts/artifact.py +117 -115
  66. wandb/sdk/artifacts/artifact_download_logger.py +2 -0
  67. wandb/sdk/artifacts/artifact_saver.py +1 -3
  68. wandb/sdk/artifacts/artifact_state.py +2 -0
  69. wandb/sdk/artifacts/artifact_ttl.py +2 -0
  70. wandb/sdk/artifacts/exceptions.py +14 -0
  71. wandb/sdk/artifacts/staging.py +2 -0
  72. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +2 -6
  73. wandb/sdk/artifacts/storage_handlers/multi_handler.py +1 -1
  74. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +2 -6
  75. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +1 -5
  76. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +1 -1
  77. wandb/sdk/artifacts/storage_layout.py +2 -0
  78. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +3 -3
  79. wandb/sdk/backend/backend.py +11 -182
  80. wandb/sdk/data_types/_dtypes.py +2 -6
  81. wandb/sdk/data_types/audio.py +20 -3
  82. wandb/sdk/data_types/base_types/media.py +12 -7
  83. wandb/sdk/data_types/base_types/wb_value.py +8 -18
  84. wandb/sdk/data_types/bokeh.py +19 -2
  85. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +17 -1
  86. wandb/sdk/data_types/helper_types/image_mask.py +7 -1
  87. wandb/sdk/data_types/html.py +4 -4
  88. wandb/sdk/data_types/image.py +178 -103
  89. wandb/sdk/data_types/molecule.py +6 -6
  90. wandb/sdk/data_types/object_3d.py +10 -5
  91. wandb/sdk/data_types/saved_model.py +11 -6
  92. wandb/sdk/data_types/table.py +313 -83
  93. wandb/sdk/data_types/table_decorators.py +108 -0
  94. wandb/sdk/data_types/utils.py +43 -7
  95. wandb/sdk/data_types/video.py +21 -3
  96. wandb/sdk/interface/interface.py +10 -0
  97. wandb/sdk/internal/datastore.py +2 -6
  98. wandb/sdk/internal/file_pusher.py +1 -5
  99. wandb/sdk/internal/file_stream.py +8 -17
  100. wandb/sdk/internal/handler.py +2 -2
  101. wandb/sdk/internal/incremental_table_util.py +53 -0
  102. wandb/sdk/internal/internal.py +3 -5
  103. wandb/sdk/internal/internal_api.py +66 -89
  104. wandb/sdk/internal/job_builder.py +2 -7
  105. wandb/sdk/internal/profiler.py +2 -2
  106. wandb/sdk/internal/progress.py +1 -3
  107. wandb/sdk/internal/run.py +1 -6
  108. wandb/sdk/internal/sender.py +24 -36
  109. wandb/sdk/internal/system/assets/aggregators.py +1 -7
  110. wandb/sdk/internal/system/assets/disk.py +3 -3
  111. wandb/sdk/internal/system/assets/gpu.py +4 -4
  112. wandb/sdk/internal/system/assets/gpu_amd.py +4 -4
  113. wandb/sdk/internal/system/assets/interfaces.py +6 -6
  114. wandb/sdk/internal/system/assets/tpu.py +1 -1
  115. wandb/sdk/internal/system/assets/trainium.py +6 -6
  116. wandb/sdk/internal/system/system_info.py +5 -7
  117. wandb/sdk/internal/system/system_monitor.py +4 -4
  118. wandb/sdk/internal/tb_watcher.py +5 -7
  119. wandb/sdk/launch/_launch.py +1 -1
  120. wandb/sdk/launch/_project_spec.py +19 -20
  121. wandb/sdk/launch/agent/agent.py +3 -3
  122. wandb/sdk/launch/agent/config.py +1 -1
  123. wandb/sdk/launch/agent/job_status_tracker.py +2 -2
  124. wandb/sdk/launch/builder/build.py +2 -3
  125. wandb/sdk/launch/builder/kaniko_builder.py +5 -4
  126. wandb/sdk/launch/environment/gcp_environment.py +1 -2
  127. wandb/sdk/launch/registry/azure_container_registry.py +2 -2
  128. wandb/sdk/launch/registry/elastic_container_registry.py +2 -2
  129. wandb/sdk/launch/registry/google_artifact_registry.py +3 -3
  130. wandb/sdk/launch/runner/abstract.py +5 -5
  131. wandb/sdk/launch/runner/kubernetes_monitor.py +2 -2
  132. wandb/sdk/launch/runner/kubernetes_runner.py +1 -1
  133. wandb/sdk/launch/runner/sagemaker_runner.py +2 -4
  134. wandb/sdk/launch/runner/vertex_runner.py +2 -7
  135. wandb/sdk/launch/sweeps/__init__.py +1 -1
  136. wandb/sdk/launch/sweeps/scheduler.py +2 -2
  137. wandb/sdk/launch/sweeps/utils.py +3 -3
  138. wandb/sdk/launch/utils.py +3 -4
  139. wandb/sdk/lib/apikey.py +5 -8
  140. wandb/sdk/lib/config_util.py +3 -3
  141. wandb/sdk/lib/fsm.py +3 -18
  142. wandb/sdk/lib/gitlib.py +6 -5
  143. wandb/sdk/lib/ipython.py +2 -2
  144. wandb/sdk/lib/json_util.py +9 -14
  145. wandb/sdk/lib/printer.py +3 -8
  146. wandb/sdk/lib/redirect.py +1 -1
  147. wandb/sdk/lib/retry.py +3 -7
  148. wandb/sdk/lib/run_moment.py +2 -2
  149. wandb/sdk/lib/service_connection.py +3 -1
  150. wandb/sdk/lib/service_token.py +1 -2
  151. wandb/sdk/mailbox/mailbox_handle.py +3 -7
  152. wandb/sdk/mailbox/response_handle.py +2 -6
  153. wandb/sdk/service/streams.py +3 -7
  154. wandb/sdk/verify/verify.py +5 -6
  155. wandb/sdk/wandb_config.py +1 -1
  156. wandb/sdk/wandb_init.py +38 -106
  157. wandb/sdk/wandb_login.py +7 -6
  158. wandb/sdk/wandb_run.py +52 -240
  159. wandb/sdk/wandb_settings.py +71 -60
  160. wandb/sdk/wandb_setup.py +40 -14
  161. wandb/sdk/wandb_watch.py +5 -7
  162. wandb/sync/__init__.py +1 -1
  163. wandb/sync/sync.py +13 -13
  164. wandb/util.py +17 -35
  165. wandb/wandb_agent.py +8 -11
  166. {wandb-0.19.12rc1.dist-info → wandb-0.20.1.dist-info}/METADATA +5 -5
  167. {wandb-0.19.12rc1.dist-info → wandb-0.20.1.dist-info}/RECORD +170 -168
  168. wandb/docker/auth.py +0 -435
  169. wandb/docker/www_authenticate.py +0 -94
  170. {wandb-0.19.12rc1.dist-info → wandb-0.20.1.dist-info}/WHEEL +0 -0
  171. {wandb-0.19.12rc1.dist-info → wandb-0.20.1.dist-info}/entry_points.txt +0 -0
  172. {wandb-0.19.12rc1.dist-info → wandb-0.20.1.dist-info}/licenses/LICENSE +0 -0
wandb/sdk/lib/gitlib.py CHANGED
@@ -51,12 +51,12 @@ class GitRepo:
51
51
  return Repo(self._root or os.getcwd(), search_parent_directories=True)
52
52
  except FileNotFoundError:
53
53
  wandb.termwarn("current working directory has been invalidated")
54
- logger.warn("current working directory has been invalidated")
54
+ logger.warning("current working directory has been invalidated")
55
55
  except InvalidGitRepositoryError:
56
56
  logger.debug("git repository is invalid")
57
57
  except NoSuchPathError:
58
58
  wandb.termwarn(f"git root {self._root} does not exist")
59
- logger.warn(f"git root {self._root} does not exist")
59
+ logger.warning(f"git root {self._root} does not exist")
60
60
  return None
61
61
 
62
62
  @property
@@ -87,9 +87,9 @@ class GitRepo:
87
87
  return None
88
88
  try:
89
89
  return self.repo.git.rev_parse("--show-toplevel")
90
- except GitCommandError as e:
90
+ except GitCommandError:
91
91
  # todo: collect telemetry on this
92
- logger.error(f"git root error: {e}")
92
+ logger.exception("git root error")
93
93
  return None
94
94
 
95
95
  @property
@@ -214,12 +214,13 @@ class GitRepo:
214
214
  most_recent_ancestor = ancestor
215
215
  elif self.repo.is_ancestor(most_recent_ancestor, ancestor): # type: ignore
216
216
  most_recent_ancestor = ancestor
217
- return most_recent_ancestor
218
217
  except GitCommandError as e:
219
218
  logger.debug("git remote upstream fork point could not be found")
220
219
  logger.debug(str(e))
221
220
  return None
222
221
 
222
+ return most_recent_ancestor
223
+
223
224
  def tag(self, name: str, message: Optional[str]) -> Any:
224
225
  if not self.repo:
225
226
  return None
wandb/sdk/lib/ipython.py CHANGED
@@ -95,9 +95,9 @@ class ProgressWidget:
95
95
  if not self._displayed:
96
96
  self._displayed = True
97
97
  self._ipython_display.display(self._widget)
98
- except Exception as e:
98
+ except Exception:
99
+ logger.exception("Error in ProgressWidget.update()")
99
100
  self._disabled = True
100
- logger.exception(e)
101
101
  wandb.termwarn(
102
102
  "Unable to render progress bar, see the user log for details"
103
103
  )
@@ -25,8 +25,8 @@ try:
25
25
  encoded = orjson.dumps(
26
26
  obj, option=orjson.OPT_NON_STR_KEYS, **_kwargs
27
27
  ).decode()
28
- except Exception as e:
29
- logger.exception(f"Error using orjson.dumps: {e}")
28
+ except Exception:
29
+ logger.exception("Error using orjson.dumps")
30
30
  if cls:
31
31
  kwargs["cls"] = cls
32
32
  encoded = json.dumps(obj, **kwargs)
@@ -42,8 +42,8 @@ try:
42
42
  _kwargs["default"] = cls.default
43
43
  encoded = orjson.dumps(obj, option=orjson.OPT_NON_STR_KEYS, **_kwargs)
44
44
  fp.write(encoded)
45
- except Exception as e:
46
- logger.exception(f"Error using orjson.dump: {e}")
45
+ except Exception:
46
+ logger.exception("Error using orjson.dump")
47
47
  if cls:
48
48
  kwargs["cls"] = cls
49
49
  json.dump(obj, fp, **kwargs)
@@ -52,8 +52,8 @@ try:
52
52
  """Wrapper for orjson.loads."""
53
53
  try:
54
54
  decoded = orjson.loads(obj)
55
- except Exception as e:
56
- logger.exception(f"Error using orjson.loads: {e}")
55
+ except Exception:
56
+ logger.exception("Error using orjson.loads")
57
57
  decoded = json.loads(obj)
58
58
 
59
59
  return decoded
@@ -62,19 +62,14 @@ try:
62
62
  """Wrapper for orjson.load."""
63
63
  try:
64
64
  decoded = orjson.loads(fp.read())
65
- except Exception as e:
66
- logger.exception(f"Error using orjson.load: {e}")
65
+ except Exception:
66
+ logger.exception("Error using orjson.load")
67
67
  decoded = json.load(fp)
68
68
 
69
69
  return decoded
70
70
 
71
71
  else:
72
- from json import ( # type: ignore[assignment] # noqa: F401
73
- dump,
74
- dumps,
75
- load,
76
- loads,
77
- )
72
+ from json import dump, dumps, load, loads # type: ignore[assignment]
78
73
 
79
74
  except ImportError:
80
75
  from json import dump, dumps, load, loads # type: ignore[assignment] # noqa: F401
wandb/sdk/lib/printer.py CHANGED
@@ -9,16 +9,11 @@ import platform
9
9
  import sys
10
10
  from typing import Callable, Iterator
11
11
 
12
- import wandb.util
13
-
14
- if sys.version_info >= (3, 12):
15
- from typing import override
16
- else:
17
- from typing_extensions import override
18
-
19
12
  import click
13
+ from typing_extensions import override
20
14
 
21
15
  import wandb
16
+ import wandb.util
22
17
  from wandb.errors import term
23
18
  from wandb.sdk import wandb_setup
24
19
 
@@ -107,7 +102,7 @@ def new_printer(settings: wandb.Settings | None = None) -> Printer:
107
102
  has been called, then global settings are used. Otherwise,
108
103
  settings (such as silent mode) are ignored.
109
104
  """
110
- if not settings and (singleton := wandb_setup.singleton()):
105
+ if not settings and (singleton := wandb_setup.singleton_if_setup()):
111
106
  settings = singleton.settings
112
107
 
113
108
  if ipython.in_jupyter():
wandb/sdk/lib/redirect.py CHANGED
@@ -510,7 +510,7 @@ class RedirectBase:
510
510
 
511
511
  @property
512
512
  def src_stream(self):
513
- return getattr(sys, "__{}__".format(self.src))
513
+ return getattr(sys, f"__{self.src}__")
514
514
 
515
515
  @property
516
516
  def src_fd(self):
wandb/sdk/lib/retry.py CHANGED
@@ -94,7 +94,7 @@ class Retry(Generic[_R]):
94
94
  """The number of iterations the previous __call__ retried."""
95
95
  return self._num_iter
96
96
 
97
- def __call__(self, *args: Any, **kwargs: Any) -> _R: # noqa: C901
97
+ def __call__(self, *args: Any, **kwargs: Any) -> _R:
98
98
  """Call the wrapped function, with retries.
99
99
 
100
100
  Args:
@@ -140,9 +140,7 @@ class Retry(Generic[_R]):
140
140
  if self.retry_callback:
141
141
  self.retry_callback(
142
142
  200,
143
- "{} resolved after {}, resuming normal operation.".format(
144
- self._error_prefix, NOW_FN() - start_time
145
- ),
143
+ f"{self._error_prefix} resolved after {NOW_FN() - start_time}, resuming normal operation.",
146
144
  )
147
145
  return result
148
146
  except self._retryable_exceptions as e:
@@ -184,9 +182,7 @@ class Retry(Generic[_R]):
184
182
  # but some of these can be raised before the retry handler thread (RunStatusChecker) is
185
183
  # spawned in wandb_init
186
184
  wandb.termlog(
187
- "{} ({}), entering retry loop.".format(
188
- self._error_prefix, e.__class__.__name__
189
- )
185
+ f"{self._error_prefix} ({e.__class__.__name__}), entering retry loop."
190
186
  )
191
187
  # if wandb.env.is_debug():
192
188
  # traceback.print_exc()
@@ -33,11 +33,11 @@ class RunMoment:
33
33
  f"Only the metric '_step' is supported, got '{self.metric}'."
34
34
  )
35
35
  if not isinstance(self.value, (int, float)):
36
- raise ValueError(
36
+ raise TypeError(
37
37
  f"Only int or float values are supported, got '{self.value}'."
38
38
  )
39
39
  if not isinstance(self.run, str):
40
- raise ValueError(f"Only string run names are supported, got '{self.run}'.")
40
+ raise TypeError(f"Only string run names are supported, got '{self.run}'.")
41
41
 
42
42
  @classmethod
43
43
  def from_uri(cls, uri: str) -> RunMoment:
@@ -167,7 +167,6 @@ class ServiceConnection:
167
167
  handle = self._mailbox.require_response(request)
168
168
  self._client.send_server_request(request)
169
169
  response = handle.wait_or(timeout=10)
170
- return response.inform_attach_response.settings
171
170
 
172
171
  except (MailboxClosedError, HandleAbandonedError, SockClientClosedError):
173
172
  raise WandbAttachFailedError(
@@ -181,6 +180,9 @@ class ServiceConnection:
181
180
  " process is busy (unlikely)."
182
181
  ) from None
183
182
 
183
+ else:
184
+ return response.inform_attach_response.settings
185
+
184
186
  def inform_start(
185
187
  self,
186
188
  settings: wandb_settings_pb2.Settings,
@@ -31,8 +31,7 @@ def get_service_token() -> ServiceToken | None:
31
31
 
32
32
  if version != _CURRENT_VERSION:
33
33
  raise ValueError(
34
- f"Expected version {_CURRENT_VERSION},"
35
- f" but got {version} (token={token})"
34
+ f"Expected version {_CURRENT_VERSION}, but got {version} (token={token})"
36
35
  )
37
36
  if transport not in _SUPPORTED_TRANSPORTS:
38
37
  raise ValueError(
@@ -1,18 +1,14 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import abc
4
- import sys
5
- from typing import TYPE_CHECKING, Callable, Generic, TypeVar
4
+ from typing import TYPE_CHECKING, Callable, Generic
5
+
6
+ from typing_extensions import TypeVar, override
6
7
 
7
8
  # Necessary to break an import loop.
8
9
  if TYPE_CHECKING:
9
10
  from wandb.sdk.interface import interface
10
11
 
11
- if sys.version_info >= (3, 12):
12
- from typing import override
13
- else:
14
- from typing_extensions import override
15
-
16
12
 
17
13
  _T = TypeVar("_T")
18
14
  _S = TypeVar("_S")
@@ -2,10 +2,11 @@ from __future__ import annotations
2
2
 
3
3
  import asyncio
4
4
  import math
5
- import sys
6
5
  import threading
7
6
  from typing import TYPE_CHECKING
8
7
 
8
+ from typing_extensions import override
9
+
9
10
  from wandb.proto import wandb_server_pb2 as spb
10
11
 
11
12
  from .mailbox_handle import HandleAbandonedError, MailboxHandle
@@ -14,11 +15,6 @@ from .mailbox_handle import HandleAbandonedError, MailboxHandle
14
15
  if TYPE_CHECKING:
15
16
  from wandb.sdk.interface import interface
16
17
 
17
- if sys.version_info >= (3, 12):
18
- from typing import override
19
- else:
20
- from typing_extensions import override
21
-
22
18
 
23
19
  class MailboxResponseHandle(MailboxHandle[spb.ServerResponse]):
24
20
  """A general handle for any ServerResponse."""
@@ -18,11 +18,10 @@ from typing import Any, Callable, NoReturn
18
18
 
19
19
  import psutil
20
20
 
21
- import wandb
22
- import wandb.util
23
21
  from wandb.proto import wandb_internal_pb2 as pb
24
22
  from wandb.sdk.interface.interface_relay import InterfaceRelay
25
23
  from wandb.sdk.interface.router_relay import MessageRelayRouter
24
+ from wandb.sdk.internal.internal import wandb_internal
26
25
  from wandb.sdk.internal.settings_static import SettingsStatic
27
26
  from wandb.sdk.lib import asyncio_compat, progress
28
27
  from wandb.sdk.lib import printer as printerlib
@@ -212,7 +211,7 @@ class StreamMux:
212
211
  # run_id = action.stream_id # will want to fix if a streamid != runid
213
212
  settings = action._data
214
213
  thread = StreamThread(
215
- target=wandb.wandb_sdk.internal.internal.wandb_internal, # type: ignore
214
+ target=wandb_internal,
216
215
  kwargs=dict(
217
216
  settings=settings,
218
217
  record_q=stream._record_q,
@@ -420,10 +419,7 @@ class StreamMux:
420
419
  self._action_q.join()
421
420
 
422
421
  def loop(self) -> None:
423
- try:
424
- self._loop()
425
- except Exception as e:
426
- raise e
422
+ self._loop()
427
423
 
428
424
  def cleanup(self) -> None:
429
425
  pass
@@ -474,13 +474,12 @@ def check_wandb_version(api: Api) -> None:
474
474
  min_cli_version = server_info.get("cliVersionInfo", {}).get(
475
475
  "min_cli_version", "0.0.1"
476
476
  )
477
- from wandb.util import parse_version
478
477
 
479
- if parse_version(wandb.__version__) < parse_version(min_cli_version):
480
- fail_string = "wandb version out of date, please run pip install --upgrade wandb=={}".format(
481
- max_cli_version
482
- )
483
- elif parse_version(wandb.__version__) > parse_version(max_cli_version):
478
+ from packaging.version import parse
479
+
480
+ if parse(wandb.__version__) < parse(min_cli_version):
481
+ fail_string = f"wandb version out of date, please run pip install --upgrade wandb=={max_cli_version}"
482
+ elif parse(wandb.__version__) > parse(max_cli_version):
484
483
  fail_string = (
485
484
  "wandb version is not supported by your local installation. This could "
486
485
  "cause some issues. If you're having problems try: please run `pip "
wandb/sdk/wandb_config.py CHANGED
@@ -272,7 +272,7 @@ class Config:
272
272
  # TODO: enable WBValues in the config in the future
273
273
  # refuse all WBValues which is all Media and Histograms
274
274
  if isinstance(val, wandb.sdk.data_types.base_types.wb_value.WBValue):
275
- raise ValueError("WBValue objects cannot be added to the run config")
275
+ raise TypeError("WBValue objects cannot be added to the run config")
276
276
  # Let jupyter change config freely by default
277
277
  if self._settings and self._settings._jupyter and allow_val_change is None:
278
278
  allow_val_change = True
wandb/sdk/wandb_init.py CHANGED
@@ -21,12 +21,9 @@ import platform
21
21
  import sys
22
22
  import tempfile
23
23
  import time
24
- from typing import TYPE_CHECKING, Any, Iterable, Iterator, Literal, Protocol, Sequence
24
+ from typing import TYPE_CHECKING, Iterable, Iterator, Sequence
25
25
 
26
- if sys.version_info >= (3, 11):
27
- from typing import Self
28
- else:
29
- from typing_extensions import Self
26
+ from typing_extensions import Any, Literal, Protocol, Self
30
27
 
31
28
  import wandb
32
29
  import wandb.env
@@ -62,20 +59,6 @@ def _huggingface_version() -> str | None:
62
59
  return None
63
60
 
64
61
 
65
- def _maybe_mp_process(backend: Backend) -> bool:
66
- parent_process = getattr(
67
- backend._multiprocessing, "parent_process", None
68
- ) # New in version 3.8.
69
- if parent_process:
70
- return parent_process() is not None
71
- process = backend._multiprocessing.current_process()
72
- if process.name == "MainProcess":
73
- return False
74
- if process.name.startswith("Process-"):
75
- return True
76
- return False
77
-
78
-
79
62
  def _handle_launch_config(settings: Settings) -> dict[str, Any]:
80
63
  launch_run_config: dict[str, Any] = {}
81
64
  if not settings.launch:
@@ -219,15 +202,11 @@ class _WandbInit:
219
202
  Returns:
220
203
  A callback to print any generated warnings.
221
204
  """
222
- singleton = wandb_setup.singleton()
223
- if singleton is None:
224
- return _noop_printer_callback()
225
-
226
205
  exclude_env_vars = {"WANDB_SERVICE", "WANDB_KUBEFLOW_URL"}
227
206
  # check if environment variables have changed
228
207
  singleton_env = {
229
208
  k: v
230
- for k, v in singleton._environ.items()
209
+ for k, v in wandb_setup.singleton()._environ.items()
231
210
  if k.startswith("WANDB_") and k not in exclude_env_vars
232
211
  }
233
212
  os_env = {
@@ -381,7 +360,7 @@ class _WandbInit:
381
360
  return None
382
361
 
383
362
  except KeyError:
384
- self._logger.error(
363
+ self._logger.exception(
385
364
  f"resume file at {resume_file} did not store a run_id"
386
365
  )
387
366
  return None
@@ -892,15 +871,12 @@ class _WandbInit:
892
871
 
893
872
  self._logger.info("starting backend")
894
873
 
895
- if not settings.x_disable_service:
896
- service = self._wl.ensure_service()
897
- self._logger.info("sending inform_init request")
898
- service.inform_init(
899
- settings=settings.to_proto(),
900
- run_id=settings.run_id, # type: ignore
901
- )
902
- else:
903
- service = None
874
+ service = self._wl.ensure_service()
875
+ self._logger.info("sending inform_init request")
876
+ service.inform_init(
877
+ settings=settings.to_proto(),
878
+ run_id=settings.run_id, # type: ignore
879
+ )
904
880
 
905
881
  backend = Backend(settings=settings, service=service)
906
882
  backend.ensure_launched()
@@ -939,35 +915,12 @@ class _WandbInit:
939
915
  for module_name in telemetry.list_telemetry_imports(only_imported=True):
940
916
  setattr(tel.imports_init, module_name, True)
941
917
 
942
- # probe the active start method
943
- active_start_method: str | None = None
944
- if settings.start_method == "thread":
945
- active_start_method = settings.start_method
946
- else:
947
- active_start_method = getattr(
948
- backend._multiprocessing, "get_start_method", lambda: None
949
- )()
950
-
951
- if active_start_method == "spawn":
952
- tel.env.start_spawn = True
953
- elif active_start_method == "fork":
954
- tel.env.start_fork = True
955
- elif active_start_method == "forkserver":
956
- tel.env.start_forkserver = True
957
- elif active_start_method == "thread":
958
- tel.env.start_thread = True
959
-
960
918
  if os.environ.get("PEX"):
961
919
  tel.env.pex = True
962
920
 
963
921
  if settings._aws_lambda:
964
922
  tel.env.aws_lambda = True
965
923
 
966
- if os.environ.get(wandb.env._DISABLE_SERVICE):
967
- tel.feature.service_disabled = True
968
-
969
- if service:
970
- tel.feature.service = True
971
924
  if settings.x_flow_control_disabled:
972
925
  tel.feature.flow_control_disabled = True
973
926
  if settings.x_flow_control_custom:
@@ -987,8 +940,6 @@ class _WandbInit:
987
940
  if wandb.env.dcgm_profiling_enabled():
988
941
  tel.feature.dcgm_profiling_enabled = True
989
942
 
990
- tel.env.maybe_mp = _maybe_mp_process(backend)
991
-
992
943
  if not settings.label_disable:
993
944
  if self.notebook:
994
945
  run._label_probe_notebook(self.notebook)
@@ -1044,56 +995,33 @@ class _WandbInit:
1044
995
  backend.interface,
1045
996
  )
1046
997
 
1047
- # Raise an error if deliver_run failed.
1048
- #
1049
- # This is wrapped in a try-except to perform additional cleanup logic
1050
- # when x_disable_service is True.
1051
- #
1052
- # TODO: Remove try-except once x_disable_service is removed.
1053
998
  try:
1054
- try:
1055
- result = wait_with_progress(
1056
- run_init_handle,
1057
- timeout=timeout,
1058
- progress_after=1,
1059
- display_progress=display_init_message,
1060
- )
1061
-
1062
- except TimeoutError:
1063
- run_init_handle.cancel(backend.interface)
1064
-
1065
- # This may either be an issue with the W&B server (a CommError)
1066
- # or a bug in the SDK (an Error). We cannot distinguish between
1067
- # the two causes here.
1068
- raise CommError(
1069
- f"Run initialization has timed out after {timeout} sec."
1070
- " Please try increasing the timeout with the `init_timeout`"
1071
- " setting: `wandb.init(settings=wandb.Settings(init_timeout=120))`."
1072
- )
999
+ result = wait_with_progress(
1000
+ run_init_handle,
1001
+ timeout=timeout,
1002
+ progress_after=1,
1003
+ display_progress=display_init_message,
1004
+ )
1073
1005
 
1074
- assert result.run_result
1006
+ except TimeoutError:
1007
+ run_init_handle.cancel(backend.interface)
1008
+
1009
+ # This may either be an issue with the W&B server (a CommError)
1010
+ # or a bug in the SDK (an Error). We cannot distinguish between
1011
+ # the two causes here.
1012
+ raise CommError(
1013
+ f"Run initialization has timed out after {timeout} sec."
1014
+ " Please try increasing the timeout with the `init_timeout`"
1015
+ " setting: `wandb.init(settings=wandb.Settings(init_timeout=120))`."
1016
+ )
1075
1017
 
1076
- if error := ProtobufErrorHandler.to_exception(result.run_result.error):
1077
- raise error
1018
+ assert result.run_result
1078
1019
 
1079
- if not result.run_result.HasField("run"):
1080
- raise Error("Assertion failed: run_result is missing the run field")
1020
+ if error := ProtobufErrorHandler.to_exception(result.run_result.error):
1021
+ raise error
1081
1022
 
1082
- except Exception:
1083
- if not service:
1084
- # Kill the background thread or process.
1085
- backend.cleanup()
1086
-
1087
- # Do some Jupyter and logger cleanup.
1088
- #
1089
- # NOTE: This shouldn't be necessary. The logger is global,
1090
- # so on any error outside of this try-catch, we fail to
1091
- # clean it up, causing the next run to write some of its
1092
- # initial logs to this run's log file. The Jupyter
1093
- # monkeypatching should probably happen at the library level
1094
- # (in wandb.setup()) rather than per-run.
1095
- self.teardown()
1096
- raise
1023
+ if not result.run_result.HasField("run"):
1024
+ raise Error("Assertion failed: run_result is missing the run field")
1097
1025
 
1098
1026
  if result.run_result.run.resumed:
1099
1027
  self._logger.info("run resumed")
@@ -1177,7 +1105,7 @@ def _attach(
1177
1105
  )
1178
1106
  wandb._assert_is_user_process() # type: ignore
1179
1107
 
1180
- _wl = wandb.setup()
1108
+ _wl = wandb_setup.singleton()
1181
1109
  logger = _wl._get_logger()
1182
1110
 
1183
1111
  service = _wl.ensure_service()
@@ -1616,7 +1544,7 @@ def init( # noqa: C901
1616
1544
  wl: wandb_setup._WandbSetup | None = None
1617
1545
 
1618
1546
  try:
1619
- wl = wandb_setup._setup(start_service=False)
1547
+ wl = wandb_setup.singleton()
1620
1548
 
1621
1549
  wi = _WandbInit(wl, init_telemetry)
1622
1550
 
@@ -1637,6 +1565,10 @@ def init( # noqa: C901
1637
1565
  init_telemetry.feature.set_init_tags = True
1638
1566
  if run_settings._offline:
1639
1567
  init_telemetry.feature.offline = True
1568
+ if run_settings.fork_from is not None:
1569
+ init_telemetry.feature.fork_mode = True
1570
+ if run_settings.resume_from is not None:
1571
+ init_telemetry.feature.rewind_mode = True
1640
1572
 
1641
1573
  wi.set_run_id(run_settings)
1642
1574
  run_printer = printer.new_printer(run_settings)
wandb/sdk/wandb_login.py CHANGED
@@ -13,6 +13,7 @@ from requests.exceptions import ConnectionError
13
13
  import wandb
14
14
  from wandb.errors import AuthenticationError, UsageError
15
15
  from wandb.old.settings import Settings as OldSettings
16
+ from wandb.sdk import wandb_setup
16
17
 
17
18
  from ..apis import InternalApi
18
19
  from .internal.internal_api import Api
@@ -115,7 +116,7 @@ class _WandbLogin:
115
116
  }
116
117
  self.is_anonymous = anonymous == "must"
117
118
 
118
- self._wandb_setup = wandb.setup()
119
+ self._wandb_setup = wandb_setup.singleton()
119
120
  self._wandb_setup.settings.update_from_dict(login_settings)
120
121
  self._settings = self._wandb_setup.settings
121
122
 
@@ -248,11 +249,6 @@ class _WandbLogin:
248
249
 
249
250
  try:
250
251
  is_api_key_valid = api.validate_api_key()
251
-
252
- if not is_api_key_valid:
253
- raise AuthenticationError(
254
- "API key verification failed. Make sure your API key is valid."
255
- )
256
252
  except ConnectionError:
257
253
  raise AuthenticationError(
258
254
  "Unable to connect to server to verify API token."
@@ -260,6 +256,11 @@ class _WandbLogin:
260
256
  except Exception:
261
257
  raise AuthenticationError("An error occurred while verifying the API key.")
262
258
 
259
+ if not is_api_key_valid:
260
+ raise AuthenticationError(
261
+ "API key verification failed. Make sure your API key is valid."
262
+ )
263
+
263
264
 
264
265
  def _login(
265
266
  *,