wandb 0.18.1__py3-none-win32.whl → 0.18.3__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 (79) hide show
  1. wandb/__init__.py +3 -3
  2. wandb/__init__.pyi +67 -12
  3. wandb/apis/internal.py +3 -0
  4. wandb/apis/public/api.py +128 -2
  5. wandb/apis/public/artifacts.py +11 -7
  6. wandb/apis/public/jobs.py +8 -0
  7. wandb/apis/public/runs.py +16 -5
  8. wandb/bin/nvidia_gpu_stats.exe +0 -0
  9. wandb/bin/wandb-core +0 -0
  10. wandb/cli/cli.py +0 -3
  11. wandb/errors/__init__.py +11 -40
  12. wandb/errors/errors.py +37 -0
  13. wandb/errors/warnings.py +2 -0
  14. wandb/integration/tensorboard/log.py +1 -1
  15. wandb/old/core.py +2 -80
  16. wandb/plot/bar.py +7 -4
  17. wandb/plot/confusion_matrix.py +5 -4
  18. wandb/plot/histogram.py +7 -4
  19. wandb/plot/line.py +7 -4
  20. wandb/proto/v3/wandb_internal_pb2.py +31 -21
  21. wandb/proto/v3/wandb_settings_pb2.py +2 -2
  22. wandb/proto/v4/wandb_internal_pb2.py +23 -21
  23. wandb/proto/v4/wandb_settings_pb2.py +2 -2
  24. wandb/proto/v5/wandb_internal_pb2.py +23 -21
  25. wandb/proto/v5/wandb_settings_pb2.py +2 -2
  26. wandb/sdk/artifacts/_validators.py +48 -3
  27. wandb/sdk/artifacts/artifact.py +160 -186
  28. wandb/sdk/artifacts/artifact_file_cache.py +13 -11
  29. wandb/sdk/artifacts/artifact_instance_cache.py +4 -2
  30. wandb/sdk/artifacts/artifact_manifest.py +13 -11
  31. wandb/sdk/artifacts/artifact_manifest_entry.py +24 -22
  32. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +9 -7
  33. wandb/sdk/artifacts/artifact_saver.py +27 -25
  34. wandb/sdk/artifacts/exceptions.py +26 -25
  35. wandb/sdk/artifacts/storage_handler.py +11 -9
  36. wandb/sdk/artifacts/storage_handlers/azure_handler.py +16 -14
  37. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +15 -13
  38. wandb/sdk/artifacts/storage_handlers/http_handler.py +15 -14
  39. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +10 -8
  40. wandb/sdk/artifacts/storage_handlers/multi_handler.py +14 -12
  41. wandb/sdk/artifacts/storage_handlers/s3_handler.py +19 -19
  42. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +10 -8
  43. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +12 -10
  44. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +9 -7
  45. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +31 -29
  46. wandb/sdk/artifacts/storage_policy.py +20 -20
  47. wandb/sdk/backend/backend.py +8 -26
  48. wandb/sdk/data_types/base_types/wb_value.py +1 -3
  49. wandb/sdk/data_types/video.py +2 -2
  50. wandb/sdk/interface/interface.py +0 -24
  51. wandb/sdk/interface/interface_shared.py +0 -12
  52. wandb/sdk/internal/handler.py +0 -10
  53. wandb/sdk/internal/internal_api.py +71 -0
  54. wandb/sdk/internal/sender.py +0 -43
  55. wandb/sdk/internal/tb_watcher.py +1 -1
  56. wandb/sdk/lib/_settings_toposort_generated.py +1 -0
  57. wandb/sdk/lib/hashutil.py +34 -12
  58. wandb/sdk/lib/service_connection.py +216 -0
  59. wandb/sdk/lib/service_token.py +94 -0
  60. wandb/sdk/lib/sock_client.py +7 -3
  61. wandb/sdk/service/server.py +2 -5
  62. wandb/sdk/service/service.py +0 -22
  63. wandb/sdk/wandb_init.py +33 -22
  64. wandb/sdk/wandb_run.py +45 -33
  65. wandb/sdk/wandb_settings.py +2 -0
  66. wandb/sdk/wandb_setup.py +25 -16
  67. wandb/sdk/wandb_sync.py +9 -3
  68. wandb/sdk/wandb_watch.py +31 -15
  69. wandb/util.py +8 -1
  70. {wandb-0.18.1.dist-info → wandb-0.18.3.dist-info}/METADATA +3 -2
  71. {wandb-0.18.1.dist-info → wandb-0.18.3.dist-info}/RECORD +75 -74
  72. wandb/sdk/internal/update.py +0 -113
  73. wandb/sdk/service/service_base.py +0 -50
  74. wandb/sdk/service/service_sock.py +0 -70
  75. wandb/sdk/wandb_manager.py +0 -232
  76. /wandb/{sdk/lib → plot}/viz.py +0 -0
  77. {wandb-0.18.1.dist-info → wandb-0.18.3.dist-info}/WHEEL +0 -0
  78. {wandb-0.18.1.dist-info → wandb-0.18.3.dist-info}/entry_points.txt +0 -0
  79. {wandb-0.18.1.dist-info → wandb-0.18.3.dist-info}/licenses/LICENSE +0 -0
wandb/sdk/wandb_run.py CHANGED
@@ -44,6 +44,7 @@ from wandb.apis.internal import Api
44
44
  from wandb.apis.public import Api as PublicApi
45
45
  from wandb.errors import CommError
46
46
  from wandb.integration.torch import wandb_torch
47
+ from wandb.plot.viz import CustomChart, Visualize, custom_chart
47
48
  from wandb.proto.wandb_internal_pb2 import (
48
49
  MetricRecord,
49
50
  PollExitResponse,
@@ -57,7 +58,6 @@ from wandb.sdk.lib.import_hooks import (
57
58
  unregister_post_import_hook,
58
59
  )
59
60
  from wandb.sdk.lib.paths import FilePathStr, LogicalPath, StrPath
60
- from wandb.sdk.lib.viz import CustomChart, Visualize, custom_chart
61
61
  from wandb.util import (
62
62
  _is_artifact_object,
63
63
  _is_artifact_string,
@@ -592,12 +592,14 @@ class Run:
592
592
  ) -> None:
593
593
  # pid is set, so we know if this run object was initialized by this process
594
594
  self._init_pid = os.getpid()
595
- self._settings = settings
596
595
 
597
596
  if settings._noop:
597
+ # TODO: properly handle setting for disabled mode
598
+ self._settings = settings
598
599
  return
599
600
 
600
601
  self._init(
602
+ settings=settings,
601
603
  config=config,
602
604
  sweep_config=sweep_config,
603
605
  launch_config=launch_config,
@@ -605,10 +607,13 @@ class Run:
605
607
 
606
608
  def _init(
607
609
  self,
610
+ settings: Settings,
608
611
  config: Optional[Dict[str, Any]] = None,
609
612
  sweep_config: Optional[Dict[str, Any]] = None,
610
613
  launch_config: Optional[Dict[str, Any]] = None,
611
614
  ) -> None:
615
+ self._settings = settings
616
+
612
617
  self._config = wandb_config.Config()
613
618
  self._config._set_callback(self._config_callback)
614
619
  self._config._set_artifact_callback(self._config_artifact_callback)
@@ -1085,6 +1090,7 @@ class Run:
1085
1090
  return self._step
1086
1091
 
1087
1092
  def project_name(self) -> str:
1093
+ # TODO: deprecate this in favor of project
1088
1094
  return self._run_obj.project if self._run_obj else ""
1089
1095
 
1090
1096
  @property
@@ -2194,9 +2200,9 @@ class Run:
2194
2200
  # Inform the service that we're done sending messages for this run.
2195
2201
  #
2196
2202
  # TODO: Why not do this in _atexit_cleanup()?
2197
- manager = self._wl and self._wl._get_manager()
2198
- if manager:
2199
- manager._inform_finish(run_id=self._run_id)
2203
+ service = self._wl and self._wl.service
2204
+ if service:
2205
+ service.inform_finish(run_id=self._run_id)
2200
2206
 
2201
2207
  finally:
2202
2208
  module.unset_globals()
@@ -2459,8 +2465,8 @@ class Run:
2459
2465
  logger.info("atexit reg")
2460
2466
  self._hooks = ExitHooks()
2461
2467
 
2462
- manager = self._wl and self._wl._get_manager()
2463
- if not manager:
2468
+ service = self._wl and self._wl.service
2469
+ if not service:
2464
2470
  self._hooks.hook()
2465
2471
  # NB: manager will perform atexit hook like behavior for outstanding runs
2466
2472
  atexit.register(lambda: self._atexit_cleanup())
@@ -2942,32 +2948,38 @@ class Run:
2942
2948
  if aliases is None:
2943
2949
  aliases = []
2944
2950
 
2945
- if self._backend and self._backend.interface:
2946
- if artifact.is_draft() and not artifact._is_draft_save_started():
2947
- artifact = self._log_artifact(artifact)
2948
- if not self._settings._offline:
2949
- handle = self._backend.interface.deliver_link_artifact(
2950
- self,
2951
- artifact,
2952
- portfolio,
2953
- aliases,
2954
- entity,
2955
- project,
2956
- )
2957
- if artifact._ttl_duration_seconds is not None:
2958
- wandb.termwarn(
2959
- "Artifact TTL will be disabled for source artifacts that are linked to portfolios."
2960
- )
2961
- result = handle.wait(timeout=-1)
2962
- if result is None:
2963
- handle.abandon()
2964
- else:
2965
- response = result.response.link_artifact_response
2966
- if response.error_message:
2967
- wandb.termerror(response.error_message)
2968
- else:
2969
- # TODO: implement offline mode + sync
2970
- raise NotImplementedError
2951
+ if not self._backend or not self._backend.interface:
2952
+ return
2953
+
2954
+ if artifact.is_draft() and not artifact._is_draft_save_started():
2955
+ artifact = self._log_artifact(artifact)
2956
+
2957
+ if self._settings._offline:
2958
+ # TODO: implement offline mode + sync
2959
+ raise NotImplementedError
2960
+
2961
+ # Wait until the artifact is committed before trying to link it.
2962
+ artifact.wait()
2963
+
2964
+ handle = self._backend.interface.deliver_link_artifact(
2965
+ self,
2966
+ artifact,
2967
+ portfolio,
2968
+ aliases,
2969
+ entity,
2970
+ project,
2971
+ )
2972
+ if artifact._ttl_duration_seconds is not None:
2973
+ wandb.termwarn(
2974
+ "Artifact TTL will be disabled for source artifacts that are linked to portfolios."
2975
+ )
2976
+ result = handle.wait(timeout=-1)
2977
+ if result is None:
2978
+ handle.abandon()
2979
+ else:
2980
+ response = result.response.link_artifact_response
2981
+ if response.error_message:
2982
+ wandb.termerror(response.error_message)
2971
2983
 
2972
2984
  @_run_decorator._noop_on_finish()
2973
2985
  @_run_decorator._attach
@@ -315,6 +315,7 @@ class SettingsData:
315
315
  _executable: str
316
316
  _extra_http_headers: Mapping[str, str]
317
317
  _file_stream_max_bytes: int # max size for filestream requests in core
318
+ _file_stream_transmit_interval: float # tx interval for filestream requests in core
318
319
  # file stream retry client configuration
319
320
  _file_stream_retry_max: int # max number of retries
320
321
  _file_stream_retry_wait_min_seconds: float # min wait time between retries
@@ -664,6 +665,7 @@ class Settings(SettingsData):
664
665
  _disable_viewer={"preprocessor": _str_as_bool},
665
666
  _extra_http_headers={"preprocessor": _str_as_json},
666
667
  _file_stream_max_bytes={"preprocessor": int},
668
+ _file_stream_transmit_interval={"preprocessor": float},
667
669
  _file_stream_retry_max={"preprocessor": int},
668
670
  _file_stream_retry_wait_min_seconds={"preprocessor": float},
669
671
  _file_stream_retry_wait_max_seconds={"preprocessor": float},
wandb/sdk/wandb_setup.py CHANGED
@@ -20,7 +20,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
20
20
  import wandb
21
21
  from wandb.sdk.lib import import_hooks
22
22
 
23
- from . import wandb_manager, wandb_settings
23
+ from . import wandb_settings
24
24
  from .lib import config_util, server, tracelog
25
25
 
26
26
  Settings = Union["wandb.sdk.wandb_settings.Settings", Dict[str, Any]]
@@ -28,6 +28,8 @@ Settings = Union["wandb.sdk.wandb_settings.Settings", Dict[str, Any]]
28
28
  Logger = Union[logging.Logger, "_EarlyLogger"]
29
29
 
30
30
  if TYPE_CHECKING:
31
+ from wandb.sdk.lib import service_connection
32
+
31
33
  from . import wandb_run
32
34
 
33
35
  # logger will be configured to be either a standard logger instance or _EarlyLogger
@@ -82,20 +84,18 @@ class _EarlyLogger:
82
84
  class _WandbSetup__WandbSetup: # noqa: N801
83
85
  """Inner class of _WandbSetup."""
84
86
 
85
- _manager: Optional[wandb_manager._Manager]
86
- _pid: int
87
-
88
87
  def __init__(
89
88
  self,
90
89
  pid: int,
91
90
  settings: Optional[Settings] = None,
92
91
  environ: Optional[Dict[str, Any]] = None,
93
92
  ) -> None:
93
+ self._connection: Optional[service_connection.ServiceConnection] = None
94
+
94
95
  self._environ = environ or dict(os.environ)
95
96
  self._sweep_config: Optional[Dict[str, Any]] = None
96
97
  self._config: Optional[Dict[str, Any]] = None
97
98
  self._server: Optional[server.Server] = None
98
- self._manager: Optional[wandb_manager._Manager] = None
99
99
  self._pid = pid
100
100
 
101
101
  # keep track of multiple runs, so we can unwind with join()s
@@ -248,7 +248,10 @@ class _WandbSetup__WandbSetup: # noqa: N801
248
248
  print("frozen, could be trouble")
249
249
 
250
250
  def _setup(self) -> None:
251
- self._setup_manager()
251
+ if not self._settings._noop and not self._settings._disable_service:
252
+ from wandb.sdk.lib import service_connection
253
+
254
+ self._connection = service_connection.connect_to_service(self._settings)
252
255
 
253
256
  sweep_path = self._settings.sweep_param_path
254
257
  if sweep_path:
@@ -271,22 +274,21 @@ class _WandbSetup__WandbSetup: # noqa: N801
271
274
  def _teardown(self, exit_code: Optional[int] = None) -> None:
272
275
  import_hooks.unregister_all_post_import_hooks()
273
276
 
274
- if not self._manager:
277
+ if not self._connection:
275
278
  return
276
279
 
277
- internal_exit_code = self._manager._teardown(exit_code or 0)
278
- self._manager = None
280
+ internal_exit_code = self._connection.teardown(exit_code or 0)
281
+
282
+ # Reset to None so that setup() creates a new connection.
283
+ self._connection = None
279
284
 
280
285
  if internal_exit_code != 0:
281
286
  sys.exit(internal_exit_code)
282
287
 
283
- def _setup_manager(self) -> None:
284
- if self._settings._noop or self._settings._disable_service:
285
- return
286
- self._manager = wandb_manager._Manager(settings=self._settings)
287
-
288
- def _get_manager(self) -> Optional[wandb_manager._Manager]:
289
- return self._manager
288
+ @property
289
+ def service(self) -> "Optional[service_connection.ServiceConnection]":
290
+ """Returns a connection to the service process, if it exists."""
291
+ return self._connection
290
292
 
291
293
 
292
294
  class _WandbSetup:
@@ -305,6 +307,13 @@ class _WandbSetup:
305
307
  return
306
308
  _WandbSetup._instance = _WandbSetup__WandbSetup(settings=settings, pid=pid)
307
309
 
310
+ @property
311
+ def service(self) -> "Optional[service_connection.ServiceConnection]":
312
+ """Returns a connection to the service process, if it exists."""
313
+ if not self._instance:
314
+ return None
315
+ return self._instance.service
316
+
308
317
  def __getattr__(self, name: str) -> Any:
309
318
  return getattr(self._instance, name)
310
319
 
wandb/sdk/wandb_sync.py CHANGED
@@ -37,11 +37,17 @@ def _sync(
37
37
  if append:
38
38
  settings.resume.value = "allow"
39
39
 
40
- manager = wl._get_manager()
41
- manager._inform_init(settings=settings, run_id=stream_id)
40
+ service = wl.service
41
+ assert service
42
+
43
+ service.inform_init(settings=settings, run_id=stream_id)
42
44
 
43
45
  mailbox = Mailbox()
44
- backend = Backend(settings=wl.settings, manager=manager, mailbox=mailbox)
46
+ backend = Backend(
47
+ settings=wl.settings,
48
+ service=service,
49
+ mailbox=mailbox,
50
+ )
45
51
  backend.ensure_launched()
46
52
 
47
53
  assert backend.interface
wandb/sdk/wandb_watch.py CHANGED
@@ -1,7 +1,9 @@
1
1
  """watch."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  import logging
4
- from typing import Optional
6
+ from typing import TYPE_CHECKING, Sequence
5
7
 
6
8
  try:
7
9
  from typing import Literal
@@ -12,36 +14,50 @@ import wandb
12
14
 
13
15
  from .lib import telemetry
14
16
 
17
+ if TYPE_CHECKING:
18
+ import torch # type: ignore [import-not-found]
19
+
15
20
  logger = logging.getLogger("wandb")
16
21
 
17
22
  _global_watch_idx = 0
18
23
 
19
24
 
20
25
  def watch(
21
- models,
22
- criterion=None,
23
- log: Optional[Literal["gradients", "parameters", "all"]] = "gradients",
26
+ models: torch.nn.Module | Sequence[torch.nn.Module],
27
+ criterion: torch.F | None = None,
28
+ log: Literal["gradients", "parameters", "all"] | None = "gradients",
24
29
  log_freq: int = 1000,
25
- idx: Optional[int] = None,
30
+ idx: int | None = None,
26
31
  log_graph: bool = False,
27
32
  ):
28
- """Hook into the torch model to collect gradients and the topology.
33
+ """Hooks into the given PyTorch model(s) to monitor gradients and the model's computational graph.
29
34
 
30
- Should be extended to accept arbitrary ML models.
35
+ This function can track parameters, gradients, or both during training. It should be
36
+ extended to support arbitrary machine learning models in the future.
31
37
 
32
38
  Args:
33
- models: (torch.Module) The model to hook, can be a tuple
34
- criterion: (torch.F) An optional loss value being optimized
35
- log: (str) One of "gradients", "parameters", "all", or None
36
- log_freq: (int) log gradients and parameters every N batches
37
- idx: (int) an index to be used when calling wandb.watch on multiple models
38
- log_graph: (boolean) log graph topology
39
+ models (Union[torch.nn.Module, Sequence[torch.nn.Module]]):
40
+ A single model or a sequence of models to be monitored.
41
+ criterion (Optional[torch.F]):
42
+ The loss function being optimized (optional).
43
+ log (Optional[Literal["gradients", "parameters", "all"]]):
44
+ Specifies whether to log "gradients", "parameters", or "all".
45
+ Set to None to disable logging. (default="gradients")
46
+ log_freq (int):
47
+ Frequency (in batches) to log gradients and parameters. (default=1000)
48
+ idx (Optional[int]):
49
+ Index used when tracking multiple models with `wandb.watch`. (default=None)
50
+ log_graph (bool):
51
+ Whether to log the model's computational graph. (default=False)
39
52
 
40
53
  Returns:
41
- `wandb.Graph`: The graph object that will populate after the first backward pass
54
+ wandb.Graph:
55
+ The graph object, which will be populated after the first backward pass.
42
56
 
43
57
  Raises:
44
- ValueError: If called before `wandb.init` or if any of models is not a torch.nn.Module.
58
+ ValueError:
59
+ If `wandb.init` has not been called or if any of the models are not instances
60
+ of `torch.nn.Module`.
45
61
  """
46
62
  global _global_watch_idx
47
63
 
wandb/util.py CHANGED
@@ -1888,7 +1888,14 @@ def working_set() -> Iterable[InstalledDistribution]:
1888
1888
  from importlib_metadata import distributions # type: ignore
1889
1889
 
1890
1890
  for d in distributions():
1891
- yield InstalledDistribution(key=d.metadata["Name"], version=d.version)
1891
+ try:
1892
+ # In some distributions, the "Name" attribute may not be present,
1893
+ # which can raise a KeyError. To handle this, we catch the exception
1894
+ # and skip those distributions.
1895
+ # For additional context, see: https://github.com/python/importlib_metadata/issues/371.
1896
+ yield InstalledDistribution(key=d.metadata["Name"], version=d.version)
1897
+ except KeyError:
1898
+ pass
1892
1899
 
1893
1900
 
1894
1901
  def parse_version(version: str) -> "packaging.version.Version":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wandb
3
- Version: 0.18.1
3
+ Version: 0.18.3
4
4
  Summary: A CLI and library for interacting with the Weights & Biases API.
5
5
  Project-URL: Source, https://github.com/wandb/wandb
6
6
  Project-URL: Bug Reports, https://github.com/wandb/wandb/issues
@@ -105,11 +105,12 @@ Requires-Dist: tomli; extra == 'launch'
105
105
  Requires-Dist: typing-extensions; extra == 'launch'
106
106
  Provides-Extra: media
107
107
  Requires-Dist: bokeh; extra == 'media'
108
+ Requires-Dist: imageio; extra == 'media'
108
109
  Requires-Dist: moviepy; extra == 'media'
109
110
  Requires-Dist: numpy; extra == 'media'
110
111
  Requires-Dist: pillow; extra == 'media'
111
112
  Requires-Dist: plotly>=5.18.0; extra == 'media'
112
- Requires-Dist: rdkit-pypi; extra == 'media'
113
+ Requires-Dist: rdkit; extra == 'media'
113
114
  Requires-Dist: soundfile; extra == 'media'
114
115
  Provides-Extra: models
115
116
  Requires-Dist: cloudpickle; extra == 'models'