wandb 0.18.0rc1__py3-none-win32.whl → 0.18.2__py3-none-win32.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. wandb/__init__.py +4 -4
  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 +18 -5
  8. wandb/bin/wandb-core +0 -0
  9. wandb/cli/cli.py +0 -5
  10. wandb/data_types.py +9 -2019
  11. wandb/env.py +0 -5
  12. wandb/errors/__init__.py +11 -40
  13. wandb/errors/errors.py +37 -0
  14. wandb/errors/warnings.py +2 -0
  15. wandb/{sklearn → integration/sklearn}/calculate/calibration_curves.py +7 -7
  16. wandb/{sklearn → integration/sklearn}/calculate/class_proportions.py +1 -1
  17. wandb/{sklearn → integration/sklearn}/calculate/confusion_matrix.py +3 -2
  18. wandb/{sklearn → integration/sklearn}/calculate/elbow_curve.py +6 -6
  19. wandb/{sklearn → integration/sklearn}/calculate/learning_curve.py +2 -2
  20. wandb/{sklearn → integration/sklearn}/calculate/outlier_candidates.py +2 -2
  21. wandb/{sklearn → integration/sklearn}/calculate/residuals.py +8 -8
  22. wandb/{sklearn → integration/sklearn}/calculate/silhouette.py +2 -2
  23. wandb/{sklearn → integration/sklearn}/calculate/summary_metrics.py +2 -2
  24. wandb/{sklearn → integration/sklearn}/plot/classifier.py +5 -5
  25. wandb/{sklearn → integration/sklearn}/plot/clusterer.py +10 -6
  26. wandb/{sklearn → integration/sklearn}/plot/regressor.py +5 -5
  27. wandb/{sklearn → integration/sklearn}/plot/shared.py +3 -3
  28. wandb/{sklearn → integration/sklearn}/utils.py +8 -8
  29. wandb/integration/tensorboard/log.py +1 -1
  30. wandb/{wandb_torch.py → integration/torch/wandb_torch.py} +36 -32
  31. wandb/old/core.py +2 -80
  32. wandb/plot/bar.py +7 -4
  33. wandb/plot/confusion_matrix.py +5 -4
  34. wandb/plot/histogram.py +7 -4
  35. wandb/plot/line.py +7 -4
  36. wandb/proto/v3/wandb_base_pb2.py +2 -1
  37. wandb/proto/v3/wandb_internal_pb2.py +2 -1
  38. wandb/proto/v3/wandb_server_pb2.py +2 -1
  39. wandb/proto/v3/wandb_settings_pb2.py +3 -2
  40. wandb/proto/v3/wandb_telemetry_pb2.py +2 -1
  41. wandb/proto/v4/wandb_base_pb2.py +2 -1
  42. wandb/proto/v4/wandb_internal_pb2.py +2 -1
  43. wandb/proto/v4/wandb_server_pb2.py +2 -1
  44. wandb/proto/v4/wandb_settings_pb2.py +3 -2
  45. wandb/proto/v4/wandb_telemetry_pb2.py +2 -1
  46. wandb/proto/v5/wandb_base_pb2.py +3 -2
  47. wandb/proto/v5/wandb_internal_pb2.py +3 -2
  48. wandb/proto/v5/wandb_server_pb2.py +3 -2
  49. wandb/proto/v5/wandb_settings_pb2.py +4 -3
  50. wandb/proto/v5/wandb_telemetry_pb2.py +3 -2
  51. wandb/sdk/artifacts/_validators.py +48 -3
  52. wandb/sdk/artifacts/artifact.py +157 -183
  53. wandb/sdk/artifacts/artifact_file_cache.py +13 -11
  54. wandb/sdk/artifacts/artifact_instance_cache.py +4 -2
  55. wandb/sdk/artifacts/artifact_manifest.py +13 -11
  56. wandb/sdk/artifacts/artifact_manifest_entry.py +24 -22
  57. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +9 -7
  58. wandb/sdk/artifacts/artifact_saver.py +27 -25
  59. wandb/sdk/artifacts/exceptions.py +26 -25
  60. wandb/sdk/artifacts/storage_handler.py +11 -9
  61. wandb/sdk/artifacts/storage_handlers/azure_handler.py +16 -14
  62. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +15 -13
  63. wandb/sdk/artifacts/storage_handlers/http_handler.py +15 -14
  64. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +10 -8
  65. wandb/sdk/artifacts/storage_handlers/multi_handler.py +14 -12
  66. wandb/sdk/artifacts/storage_handlers/s3_handler.py +19 -19
  67. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +10 -8
  68. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +12 -10
  69. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +9 -7
  70. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +31 -29
  71. wandb/sdk/artifacts/storage_policy.py +20 -20
  72. wandb/sdk/backend/backend.py +8 -26
  73. wandb/sdk/data_types/audio.py +165 -0
  74. wandb/sdk/data_types/base_types/wb_value.py +1 -3
  75. wandb/sdk/data_types/bokeh.py +70 -0
  76. wandb/sdk/data_types/graph.py +405 -0
  77. wandb/sdk/data_types/image.py +156 -0
  78. wandb/sdk/data_types/table.py +1204 -0
  79. wandb/sdk/data_types/trace_tree.py +2 -2
  80. wandb/sdk/data_types/utils.py +49 -0
  81. wandb/sdk/data_types/video.py +2 -2
  82. wandb/sdk/interface/interface.py +0 -24
  83. wandb/sdk/interface/interface_shared.py +0 -12
  84. wandb/sdk/internal/handler.py +0 -10
  85. wandb/sdk/internal/internal_api.py +71 -0
  86. wandb/sdk/internal/sender.py +0 -43
  87. wandb/sdk/internal/tb_watcher.py +1 -1
  88. wandb/sdk/lib/_settings_toposort_generated.py +1 -0
  89. wandb/sdk/lib/hashutil.py +34 -12
  90. wandb/sdk/lib/service_connection.py +216 -0
  91. wandb/sdk/lib/service_token.py +94 -0
  92. wandb/sdk/lib/sock_client.py +7 -3
  93. wandb/sdk/service/server.py +2 -5
  94. wandb/sdk/service/service.py +2 -31
  95. wandb/sdk/service/streams.py +0 -7
  96. wandb/sdk/wandb_init.py +42 -25
  97. wandb/sdk/wandb_run.py +18 -159
  98. wandb/sdk/wandb_settings.py +2 -0
  99. wandb/sdk/wandb_setup.py +25 -16
  100. wandb/sdk/wandb_sync.py +9 -3
  101. wandb/sdk/wandb_watch.py +31 -15
  102. wandb/sklearn.py +35 -0
  103. wandb/util.py +14 -3
  104. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/METADATA +6 -5
  105. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/RECORD +114 -110
  106. wandb/sdk/internal/update.py +0 -113
  107. wandb/sdk/lib/console.py +0 -39
  108. wandb/sdk/service/service_base.py +0 -50
  109. wandb/sdk/service/service_sock.py +0 -70
  110. wandb/sdk/wandb_manager.py +0 -232
  111. /wandb/{sklearn → integration/sklearn}/__init__.py +0 -0
  112. /wandb/{sklearn → integration/sklearn}/calculate/__init__.py +0 -0
  113. /wandb/{sklearn → integration/sklearn}/calculate/decision_boundaries.py +0 -0
  114. /wandb/{sklearn → integration/sklearn}/calculate/feature_importances.py +0 -0
  115. /wandb/{sklearn → integration/sklearn}/plot/__init__.py +0 -0
  116. /wandb/{sdk/lib → plot}/viz.py +0 -0
  117. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/WHEEL +0 -0
  118. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/entry_points.txt +0 -0
  119. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/licenses/LICENSE +0 -0
wandb/sdk/wandb_run.py CHANGED
@@ -43,12 +43,13 @@ from wandb.apis import internal, public
43
43
  from wandb.apis.internal import Api
44
44
  from wandb.apis.public import Api as PublicApi
45
45
  from wandb.errors import CommError
46
+ from wandb.integration.torch import wandb_torch
47
+ from wandb.plot.viz import CustomChart, Visualize, custom_chart
46
48
  from wandb.proto.wandb_internal_pb2 import (
47
49
  MetricRecord,
48
50
  PollExitResponse,
49
51
  Result,
50
52
  RunRecord,
51
- ServerInfoResponse,
52
53
  )
53
54
  from wandb.sdk.artifacts.artifact import Artifact
54
55
  from wandb.sdk.internal import job_builder
@@ -57,12 +58,11 @@ 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,
64
64
  _is_artifact_version_weave_dict,
65
- _is_py_or_dockerfile,
65
+ _is_py_requirements_or_dockerfile,
66
66
  _resolve_aliases,
67
67
  add_import_hook,
68
68
  parse_artifact_string,
@@ -105,7 +105,6 @@ if TYPE_CHECKING:
105
105
  import wandb.sdk.backend.backend
106
106
  import wandb.sdk.interface.interface_queue
107
107
  from wandb.proto.wandb_internal_pb2 import (
108
- CheckVersionResponse,
109
108
  GetSummaryResponse,
110
109
  InternalMessagesResponse,
111
110
  SampledHistoryResponse,
@@ -561,12 +560,10 @@ class Run:
561
560
 
562
561
  _run_status_checker: Optional[RunStatusChecker]
563
562
 
564
- _check_version: Optional["CheckVersionResponse"]
565
563
  _sampled_history: Optional["SampledHistoryResponse"]
566
564
  _final_summary: Optional["GetSummaryResponse"]
567
565
  _poll_exit_handle: Optional[MailboxHandle]
568
566
  _poll_exit_response: Optional[PollExitResponse]
569
- _server_info_response: Optional[ServerInfoResponse]
570
567
  _internal_messages_response: Optional["InternalMessagesResponse"]
571
568
 
572
569
  _stdout_slave_fd: Optional[int]
@@ -595,12 +592,14 @@ class Run:
595
592
  ) -> None:
596
593
  # pid is set, so we know if this run object was initialized by this process
597
594
  self._init_pid = os.getpid()
598
- self._settings = settings
599
595
 
600
596
  if settings._noop:
597
+ # TODO: properly handle setting for disabled mode
598
+ self._settings = settings
601
599
  return
602
600
 
603
601
  self._init(
602
+ settings=settings,
604
603
  config=config,
605
604
  sweep_config=sweep_config,
606
605
  launch_config=launch_config,
@@ -608,10 +607,13 @@ class Run:
608
607
 
609
608
  def _init(
610
609
  self,
610
+ settings: Settings,
611
611
  config: Optional[Dict[str, Any]] = None,
612
612
  sweep_config: Optional[Dict[str, Any]] = None,
613
613
  launch_config: Optional[Dict[str, Any]] = None,
614
614
  ) -> None:
615
+ self._settings = settings
616
+
615
617
  self._config = wandb_config.Config()
616
618
  self._config._set_callback(self._config_callback)
617
619
  self._config._set_artifact_callback(self._config_artifact_callback)
@@ -624,7 +626,7 @@ class Run:
624
626
  )
625
627
  self.summary._set_update_callback(self._summary_update_callback)
626
628
  self._step = 0
627
- self._torch_history: Optional[wandb.wandb_torch.TorchHistory] = None # type: ignore
629
+ self._torch_history: Optional[wandb_torch.TorchHistory] = None # type: ignore
628
630
 
629
631
  # todo: eventually would be nice to make this configurable using self._settings._start_time
630
632
  # need to test (jhr): if you set start time to 2 days ago and run a test for 15 minutes,
@@ -669,11 +671,9 @@ class Run:
669
671
  # Created when the run "starts".
670
672
  self._run_status_checker = None
671
673
 
672
- self._check_version = None
673
674
  self._sampled_history = None
674
675
  self._final_summary = None
675
676
  self._poll_exit_response = None
676
- self._server_info_response = None
677
677
  self._internal_messages_response = None
678
678
  self._poll_exit_handle = None
679
679
 
@@ -927,9 +927,9 @@ class Run:
927
927
  self.__dict__.update(state)
928
928
 
929
929
  @property
930
- def _torch(self) -> "wandb.wandb_torch.TorchHistory": # type: ignore
930
+ def _torch(self) -> "wandb_torch.TorchHistory": # type: ignore
931
931
  if self._torch_history is None:
932
- self._torch_history = wandb.wandb_torch.TorchHistory() # type: ignore
932
+ self._torch_history = wandb_torch.TorchHistory() # type: ignore
933
933
  return self._torch_history
934
934
 
935
935
  @property
@@ -1152,7 +1152,7 @@ class Run:
1152
1152
  name: Optional[str] = None,
1153
1153
  include_fn: Union[
1154
1154
  Callable[[str, str], bool], Callable[[str], bool]
1155
- ] = _is_py_or_dockerfile,
1155
+ ] = _is_py_requirements_or_dockerfile,
1156
1156
  exclude_fn: Union[
1157
1157
  Callable[[str, str], bool], Callable[[str], bool]
1158
1158
  ] = filenames.exclude_wandb_fn,
@@ -2199,9 +2199,9 @@ class Run:
2199
2199
  # Inform the service that we're done sending messages for this run.
2200
2200
  #
2201
2201
  # TODO: Why not do this in _atexit_cleanup()?
2202
- manager = self._wl and self._wl._get_manager()
2203
- if manager:
2204
- manager._inform_finish(run_id=self._run_id)
2202
+ service = self._wl and self._wl.service
2203
+ if service:
2204
+ service.inform_finish(run_id=self._run_id)
2205
2205
 
2206
2206
  finally:
2207
2207
  module.unset_globals()
@@ -2453,8 +2453,6 @@ class Run:
2453
2453
  sampled_history=self._sampled_history,
2454
2454
  final_summary=self._final_summary,
2455
2455
  poll_exit_response=self._poll_exit_response,
2456
- server_info_response=self._server_info_response,
2457
- check_version_response=self._check_version,
2458
2456
  internal_messages_response=self._internal_messages_response,
2459
2457
  reporter=self._reporter,
2460
2458
  quiet=self._quiet,
@@ -2466,8 +2464,8 @@ class Run:
2466
2464
  logger.info("atexit reg")
2467
2465
  self._hooks = ExitHooks()
2468
2466
 
2469
- manager = self._wl and self._wl._get_manager()
2470
- if not manager:
2467
+ service = self._wl and self._wl.service
2468
+ if not service:
2471
2469
  self._hooks.hook()
2472
2470
  # NB: manager will perform atexit hook like behavior for outstanding runs
2473
2471
  atexit.register(lambda: self._atexit_cleanup())
@@ -2676,25 +2674,6 @@ class Run:
2676
2674
 
2677
2675
  assert self._backend and self._backend.interface
2678
2676
 
2679
- if not self._settings._disable_update_check:
2680
- logger.info("communicating current version")
2681
- version_handle = self._backend.interface.deliver_check_version(
2682
- current_version=wandb.__version__
2683
- )
2684
- version_result = version_handle.wait(timeout=10)
2685
- if not version_result:
2686
- version_handle.abandon()
2687
- else:
2688
- self._check_version = version_result.response.check_version_response
2689
- logger.info("got version response %s", self._check_version)
2690
-
2691
- # get the server info before starting the defer state machine as
2692
- # it will stop communication with the server
2693
- server_info_handle = self._backend.interface.deliver_request_server_info()
2694
- result = server_info_handle.wait(timeout=-1)
2695
- assert result
2696
- self._server_info_response = result.response.server_info_response
2697
-
2698
2677
  exit_handle = self._backend.interface.deliver_exit(self._exit_code)
2699
2678
  exit_handle.add_probe(on_probe=self._on_probe_exit)
2700
2679
 
@@ -3712,27 +3691,6 @@ class Run:
3712
3691
  Run._header_sync_info(settings=settings, printer=printer)
3713
3692
  Run._header_run_info(settings=settings, printer=printer)
3714
3693
 
3715
- @staticmethod
3716
- def _header_version_check_info(
3717
- check_version: Optional["CheckVersionResponse"] = None,
3718
- *,
3719
- settings: "Settings",
3720
- printer: Union["PrinterTerm", "PrinterJupyter"],
3721
- ) -> None:
3722
- if not check_version or settings._offline:
3723
- return
3724
-
3725
- if check_version.delete_message:
3726
- printer.display(check_version.delete_message, level="error")
3727
- elif check_version.yank_message:
3728
- printer.display(check_version.yank_message, level="warn")
3729
-
3730
- printer.display(
3731
- check_version.upgrade_message,
3732
- off=not check_version.upgrade_message,
3733
- level="warn",
3734
- )
3735
-
3736
3694
  @staticmethod
3737
3695
  def _header_wandb_version_info(
3738
3696
  *,
@@ -3846,8 +3804,6 @@ class Run:
3846
3804
  sampled_history: Optional["SampledHistoryResponse"] = None,
3847
3805
  final_summary: Optional["GetSummaryResponse"] = None,
3848
3806
  poll_exit_response: Optional[PollExitResponse] = None,
3849
- server_info_response: Optional[ServerInfoResponse] = None,
3850
- check_version_response: Optional["CheckVersionResponse"] = None,
3851
3807
  internal_messages_response: Optional["InternalMessagesResponse"] = None,
3852
3808
  reporter: Optional[Reporter] = None,
3853
3809
  quiet: Optional[bool] = None,
@@ -3870,23 +3826,11 @@ class Run:
3870
3826
  printer=printer,
3871
3827
  )
3872
3828
  Run._footer_log_dir_info(quiet=quiet, settings=settings, printer=printer)
3873
- Run._footer_version_check_info(
3874
- check_version=check_version_response,
3875
- quiet=quiet,
3876
- settings=settings,
3877
- printer=printer,
3878
- )
3879
3829
  Run._footer_notify_wandb_core(
3880
3830
  quiet=quiet,
3881
3831
  settings=settings,
3882
3832
  printer=printer,
3883
3833
  )
3884
- Run._footer_local_warn(
3885
- server_info_response=server_info_response,
3886
- quiet=quiet,
3887
- settings=settings,
3888
- printer=printer,
3889
- )
3890
3834
  Run._footer_internal_messages(
3891
3835
  internal_messages_response=internal_messages_response,
3892
3836
  quiet=quiet,
@@ -3896,12 +3840,6 @@ class Run:
3896
3840
  Run._footer_reporter_warn_err(
3897
3841
  reporter=reporter, quiet=quiet, settings=settings, printer=printer
3898
3842
  )
3899
- Run._footer_server_messages(
3900
- server_info_response=server_info_response,
3901
- quiet=quiet,
3902
- settings=settings,
3903
- printer=printer,
3904
- )
3905
3843
 
3906
3844
  # fixme: Temporary hack until we move to rich which allows multiple spinners
3907
3845
  @staticmethod
@@ -4156,33 +4094,6 @@ class Run:
4156
4094
  if panel:
4157
4095
  printer.display(printer.panel(panel))
4158
4096
 
4159
- @staticmethod
4160
- def _footer_local_warn(
4161
- server_info_response: Optional[ServerInfoResponse] = None,
4162
- quiet: Optional[bool] = None,
4163
- *,
4164
- settings: "Settings",
4165
- printer: Union["PrinterTerm", "PrinterJupyter"],
4166
- ) -> None:
4167
- if (quiet or settings.quiet) or settings.silent:
4168
- return
4169
-
4170
- if settings._offline:
4171
- return
4172
-
4173
- if not server_info_response or not server_info_response.local_info:
4174
- return
4175
-
4176
- if settings.is_local:
4177
- local_info = server_info_response.local_info
4178
- latest_version, out_of_date = local_info.version, local_info.out_of_date
4179
- if out_of_date:
4180
- printer.display(
4181
- f"Upgrade to the {latest_version} version of W&B Server to get the latest features. "
4182
- f"Learn more: {printer.link(wburls.get('upgrade_server'))}",
4183
- level="warn",
4184
- )
4185
-
4186
4097
  @staticmethod
4187
4098
  def _footer_internal_messages(
4188
4099
  internal_messages_response: Optional["InternalMessagesResponse"] = None,
@@ -4200,58 +4111,6 @@ class Run:
4200
4111
  for message in internal_messages_response.messages.warning:
4201
4112
  printer.display(message, level="warn")
4202
4113
 
4203
- @staticmethod
4204
- def _footer_server_messages(
4205
- server_info_response: Optional[ServerInfoResponse] = None,
4206
- quiet: Optional[bool] = None,
4207
- *,
4208
- settings: "Settings",
4209
- printer: Union["PrinterTerm", "PrinterJupyter"],
4210
- ) -> None:
4211
- if (quiet or settings.quiet) or settings.silent:
4212
- return
4213
-
4214
- if settings.disable_hints:
4215
- return
4216
-
4217
- if server_info_response and server_info_response.server_messages:
4218
- for message in server_info_response.server_messages.item:
4219
- printer.display(
4220
- message.html_text if printer._html else message.utf_text,
4221
- default_text=message.plain_text,
4222
- level=message.level,
4223
- off=message.type.lower() != "footer",
4224
- )
4225
-
4226
- @staticmethod
4227
- def _footer_version_check_info(
4228
- check_version: Optional["CheckVersionResponse"] = None,
4229
- quiet: Optional[bool] = None,
4230
- *,
4231
- settings: "Settings",
4232
- printer: Union["PrinterTerm", "PrinterJupyter"],
4233
- ) -> None:
4234
- if not check_version:
4235
- return
4236
-
4237
- if settings._offline:
4238
- return
4239
-
4240
- if (quiet or settings.quiet) or settings.silent:
4241
- return
4242
-
4243
- if check_version.delete_message:
4244
- printer.display(check_version.delete_message, level="error")
4245
- elif check_version.yank_message:
4246
- printer.display(check_version.yank_message, level="warn")
4247
-
4248
- # only display upgrade message if packages are bad
4249
- if check_version.upgrade_message:
4250
- printer.display(
4251
- check_version.upgrade_message,
4252
- level="warn",
4253
- )
4254
-
4255
4114
  @staticmethod
4256
4115
  def _footer_notify_wandb_core(
4257
4116
  *,
@@ -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._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/sklearn.py ADDED
@@ -0,0 +1,35 @@
1
+ from wandb.integration.sklearn import (
2
+ plot_calibration_curve,
3
+ plot_class_proportions,
4
+ plot_classifier,
5
+ plot_clusterer,
6
+ plot_confusion_matrix,
7
+ plot_elbow_curve,
8
+ plot_feature_importances,
9
+ plot_learning_curve,
10
+ plot_outlier_candidates,
11
+ plot_precision_recall,
12
+ plot_regressor,
13
+ plot_residuals,
14
+ plot_roc,
15
+ plot_silhouette,
16
+ plot_summary_metrics,
17
+ )
18
+
19
+ __all__ = (
20
+ "plot_classifier",
21
+ "plot_clusterer",
22
+ "plot_regressor",
23
+ "plot_summary_metrics",
24
+ "plot_learning_curve",
25
+ "plot_feature_importances",
26
+ "plot_class_proportions",
27
+ "plot_calibration_curve",
28
+ "plot_roc",
29
+ "plot_precision_recall",
30
+ "plot_confusion_matrix",
31
+ "plot_elbow_curve",
32
+ "plot_silhouette",
33
+ "plot_residuals",
34
+ "plot_outlier_candidates",
35
+ )
wandb/util.py CHANGED
@@ -1554,9 +1554,13 @@ def _is_databricks() -> bool:
1554
1554
  return False
1555
1555
 
1556
1556
 
1557
- def _is_py_or_dockerfile(path: str) -> bool:
1557
+ def _is_py_requirements_or_dockerfile(path: str) -> bool:
1558
1558
  file = os.path.basename(path)
1559
- return file.endswith(".py") or file.startswith("Dockerfile")
1559
+ return (
1560
+ file.endswith(".py")
1561
+ or file.startswith("Dockerfile")
1562
+ or file == "requirements.txt"
1563
+ )
1560
1564
 
1561
1565
 
1562
1566
  def check_windows_valid_filename(path: Union[int, str]) -> bool:
@@ -1884,7 +1888,14 @@ def working_set() -> Iterable[InstalledDistribution]:
1884
1888
  from importlib_metadata import distributions # type: ignore
1885
1889
 
1886
1890
  for d in distributions():
1887
- 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
1888
1899
 
1889
1900
 
1890
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.0rc1
3
+ Version: 0.18.2
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
@@ -50,10 +50,10 @@ Requires-Dist: click!=8.0.0,>=7.1
50
50
  Requires-Dist: docker-pycreds>=0.4.0
51
51
  Requires-Dist: gitpython!=3.1.29,>=1.0.0
52
52
  Requires-Dist: platformdirs
53
- Requires-Dist: protobuf!=4.21.0,<6,>=3.12.0; python_version < '3.9' and sys_platform == 'linux'
54
- Requires-Dist: protobuf!=4.21.0,<6,>=3.15.0; python_version == '3.9' and sys_platform == 'linux'
55
- Requires-Dist: protobuf!=4.21.0,<6,>=3.19.0; python_version > '3.9' and sys_platform == 'linux'
56
- Requires-Dist: protobuf!=4.21.0,<6,>=3.19.0; sys_platform != 'linux'
53
+ Requires-Dist: protobuf!=4.21.0,!=5.28.0,<6,>=3.12.0; python_version < '3.9' and sys_platform == 'linux'
54
+ Requires-Dist: protobuf!=4.21.0,!=5.28.0,<6,>=3.15.0; python_version == '3.9' and sys_platform == 'linux'
55
+ Requires-Dist: protobuf!=4.21.0,!=5.28.0,<6,>=3.19.0; python_version > '3.9' and sys_platform == 'linux'
56
+ Requires-Dist: protobuf!=4.21.0,!=5.28.0,<6,>=3.19.0; sys_platform != 'linux'
57
57
  Requires-Dist: psutil>=5.0.0
58
58
  Requires-Dist: pyyaml
59
59
  Requires-Dist: requests<3,>=2.0.0
@@ -105,6 +105,7 @@ 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'