wandb 0.17.6__py3-none-win32.whl → 0.17.7__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 (39) hide show
  1. wandb/__init__.py +3 -16
  2. wandb/agents/pyagent.py +1 -2
  3. wandb/bin/wandb-core +0 -0
  4. wandb/cli/cli.py +21 -0
  5. wandb/data_types.py +3 -3
  6. wandb/integration/kfp/wandb_logging.py +1 -1
  7. wandb/integration/lightning/fabric/logger.py +1 -1
  8. wandb/integration/openai/fine_tuning.py +13 -5
  9. wandb/integration/ultralytics/pose_utils.py +0 -1
  10. wandb/sdk/artifacts/artifact.py +1 -1
  11. wandb/sdk/data_types/_dtypes.py +5 -5
  12. wandb/sdk/data_types/base_types/media.py +3 -1
  13. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +3 -1
  14. wandb/sdk/data_types/helper_types/image_mask.py +3 -1
  15. wandb/sdk/data_types/image.py +3 -1
  16. wandb/sdk/data_types/saved_model.py +3 -1
  17. wandb/sdk/interface/interface.py +17 -16
  18. wandb/sdk/interface/interface_shared.py +6 -9
  19. wandb/sdk/internal/datastore.py +1 -1
  20. wandb/sdk/internal/handler.py +0 -2
  21. wandb/sdk/internal/internal.py +1 -1
  22. wandb/sdk/internal/job_builder.py +5 -2
  23. wandb/sdk/internal/tb_watcher.py +2 -2
  24. wandb/sdk/internal/update.py +2 -2
  25. wandb/sdk/launch/builder/kaniko_builder.py +13 -5
  26. wandb/sdk/launch/create_job.py +2 -0
  27. wandb/sdk/lib/apikey.py +1 -1
  28. wandb/sdk/service/streams.py +2 -4
  29. wandb/sdk/wandb_config.py +1 -1
  30. wandb/sdk/wandb_init.py +55 -7
  31. wandb/sdk/wandb_run.py +109 -68
  32. wandb/sdk/wandb_settings.py +1 -1
  33. wandb/sdk/wandb_setup.py +66 -3
  34. wandb/sdk/wandb_sweep.py +5 -2
  35. {wandb-0.17.6.dist-info → wandb-0.17.7.dist-info}/METADATA +1 -1
  36. {wandb-0.17.6.dist-info → wandb-0.17.7.dist-info}/RECORD +39 -39
  37. {wandb-0.17.6.dist-info → wandb-0.17.7.dist-info}/WHEEL +0 -0
  38. {wandb-0.17.6.dist-info → wandb-0.17.7.dist-info}/entry_points.txt +0 -0
  39. {wandb-0.17.6.dist-info → wandb-0.17.7.dist-info}/licenses/LICENSE +0 -0
wandb/sdk/wandb_init.py CHANGED
@@ -15,6 +15,7 @@ import os
15
15
  import platform
16
16
  import sys
17
17
  import tempfile
18
+ import time
18
19
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union
19
20
 
20
21
  import wandb
@@ -174,7 +175,9 @@ class _WandbInit:
174
175
  # we add this logic to be backward compatible with the old behavior of disable
175
176
  # where it would disable the service if the mode was set to disabled
176
177
  mode = kwargs.get("mode")
177
- settings_mode = (kwargs.get("settings") or {}).get("mode")
178
+ settings_mode = (kwargs.get("settings") or {}).get("mode") or os.environ.get(
179
+ "WANDB_MODE"
180
+ )
178
181
  _disable_service = mode == "disabled" or settings_mode == "disabled"
179
182
  setup_settings = {"_disable_service": _disable_service}
180
183
 
@@ -262,7 +265,7 @@ class _WandbInit:
262
265
 
263
266
  monitor_gym = kwargs.pop("monitor_gym", None)
264
267
  if monitor_gym and len(wandb.patched["gym"]) == 0:
265
- wandb.gym.monitor()
268
+ wandb.gym.monitor() # type: ignore
266
269
 
267
270
  if wandb.patched["tensorboard"]:
268
271
  with telemetry.context(obj=self._init_telemetry_obj) as tel:
@@ -271,7 +274,7 @@ class _WandbInit:
271
274
  tensorboard = kwargs.pop("tensorboard", None)
272
275
  sync_tensorboard = kwargs.pop("sync_tensorboard", None)
273
276
  if tensorboard or sync_tensorboard and len(wandb.patched["tensorboard"]) == 0:
274
- wandb.tensorboard.patch()
277
+ wandb.tensorboard.patch() # type: ignore
275
278
  with telemetry.context(obj=self._init_telemetry_obj) as tel:
276
279
  tel.feature.tensorboard_sync = True
277
280
 
@@ -459,7 +462,7 @@ class _WandbInit:
459
462
 
460
463
  def _jupyter_setup(self, settings: Settings) -> None:
461
464
  """Add hooks, and session history saving."""
462
- self.notebook = wandb.jupyter.Notebook(settings)
465
+ self.notebook = wandb.jupyter.Notebook(settings) # type: ignore
463
466
  ipython = self.notebook.shell
464
467
 
465
468
  # Monkey patch ipython publish to capture displayed outputs
@@ -522,17 +525,62 @@ class _WandbInit:
522
525
  logger.info(f"Logging internal logs to {settings.log_internal}")
523
526
 
524
527
  def _make_run_disabled(self) -> Run:
528
+ """Returns a Run-like object where all methods are no-ops.
529
+
530
+ This method is used when wandb.init(mode="disabled") is called or WANDB_MODE=disabled
531
+ is set. It creates a Run object that mimics the behavior of a normal Run but doesn't
532
+ communicate with the W&B servers.
533
+
534
+ The returned Run object has all expected attributes and methods, but they are
535
+ no-op versions that don't perform any actual logging or communication.
536
+ """
525
537
  drun = Run(settings=Settings(mode="disabled", files_dir=tempfile.gettempdir()))
526
- drun._config = wandb.wandb_sdk.wandb_config.Config()
538
+ # config and summary objects
539
+ drun._config = wandb.sdk.wandb_config.Config()
527
540
  drun._config.update(self.sweep_config)
528
541
  drun._config.update(self.config)
529
542
  drun.summary = SummaryDisabled() # type: ignore
543
+ # methods
530
544
  drun.log = lambda data, *_, **__: drun.summary.update(data) # type: ignore
531
545
  drun.finish = lambda *_, **__: module.unset_globals() # type: ignore
546
+ drun.join = drun.finish # type: ignore
547
+ drun.define_metric = lambda *_, **__: wandb.sdk.wandb_metric.Metric("dummy") # type: ignore
548
+ drun.save = lambda *_, **__: False # type: ignore
549
+ for symbol in (
550
+ "alert",
551
+ "finish_artifact",
552
+ "get_project_url",
553
+ "get_sweep_url",
554
+ "get_url",
555
+ "link_artifact",
556
+ "link_model",
557
+ "use_artifact",
558
+ "log_artifact",
559
+ "log_code",
560
+ "log_model",
561
+ "use_model",
562
+ "mark_preempting",
563
+ "plot_table",
564
+ "restore",
565
+ "status",
566
+ "watch",
567
+ "unwatch",
568
+ "upsert_artifact",
569
+ ):
570
+ setattr(drun, symbol, lambda *_, **__: None) # type: ignore
571
+ # attributes
532
572
  drun._step = 0
573
+ drun._attach_id = None
533
574
  drun._run_obj = None
534
575
  drun._run_id = runid.generate_id()
535
576
  drun._name = "dummy-" + drun.id
577
+ drun._project = "dummy"
578
+ drun._entity = "dummy"
579
+ drun._tags = tuple()
580
+ drun._notes = None
581
+ drun._group = None
582
+ drun._start_time = time.time()
583
+ drun._starting_step = 0
536
584
  module.set_global(
537
585
  run=drun,
538
586
  config=drun.config,
@@ -868,7 +916,7 @@ def _attach(
868
916
  raise UsageError(
869
917
  "Either `attach_id` or `run_id` must be specified or `run` must have `_attach_id`"
870
918
  )
871
- wandb._assert_is_user_process()
919
+ wandb._assert_is_user_process() # type: ignore
872
920
 
873
921
  _wl = wandb_setup._setup()
874
922
  assert _wl
@@ -1157,7 +1205,7 @@ def init(
1157
1205
  Returns:
1158
1206
  A `Run` object.
1159
1207
  """
1160
- wandb._assert_is_user_process()
1208
+ wandb._assert_is_user_process() # type: ignore
1161
1209
 
1162
1210
  kwargs = dict(locals())
1163
1211
 
wandb/sdk/wandb_run.py CHANGED
@@ -42,6 +42,7 @@ from wandb._globals import _datatypes_set_callback
42
42
  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
+ from wandb.errors import CommError
45
46
  from wandb.proto.wandb_internal_pb2 import (
46
47
  MetricRecord,
47
48
  PollExitResponse,
@@ -69,7 +70,7 @@ from wandb.viz import CustomChart, Visualize, custom_chart
69
70
 
70
71
  from . import wandb_config, wandb_metric, wandb_summary
71
72
  from .data_types._dtypes import TypeRegistry
72
- from .interface.interface import GlobStr, InterfaceBase
73
+ from .interface.interface import FilesDict, GlobStr, InterfaceBase, PolicyName
73
74
  from .interface.summary_record import SummaryRecord
74
75
  from .lib import (
75
76
  config_util,
@@ -89,6 +90,7 @@ from .lib.printer import get_printer
89
90
  from .lib.proto_util import message_to_dict
90
91
  from .lib.reporting import Reporter
91
92
  from .lib.wburls import wburls
93
+ from .wandb_alerts import AlertLevel
92
94
  from .wandb_settings import Settings
93
95
  from .wandb_setup import _WandbSetup
94
96
 
@@ -108,9 +110,7 @@ if TYPE_CHECKING:
108
110
  SampledHistoryResponse,
109
111
  )
110
112
 
111
- from .interface.interface import FilesDict, PolicyName
112
113
  from .lib.printer import PrinterJupyter, PrinterTerm
113
- from .wandb_alerts import AlertLevel
114
114
 
115
115
  class GitSourceDict(TypedDict):
116
116
  remote: str
@@ -295,7 +295,7 @@ class RunStatusChecker:
295
295
  if stop_status.run_should_stop:
296
296
  # TODO(frz): This check is required
297
297
  # until WB-3606 is resolved on server side.
298
- if not wandb.agents.pyagent.is_running():
298
+ if not wandb.agents.pyagent.is_running(): # type: ignore
299
299
  thread.interrupt_main()
300
300
  return
301
301
 
@@ -621,7 +621,7 @@ class Run:
621
621
  )
622
622
  self.summary._set_update_callback(self._summary_update_callback)
623
623
  self._step = 0
624
- self._torch_history: Optional[wandb.wandb_torch.TorchHistory] = None
624
+ self._torch_history: Optional[wandb.wandb_torch.TorchHistory] = None # type: ignore
625
625
 
626
626
  # todo: eventually would be nice to make this configurable using self._settings._start_time
627
627
  # need to test (jhr): if you set start time to 2 days ago and run a test for 15 minutes,
@@ -920,9 +920,9 @@ class Run:
920
920
  self.__dict__.update(state)
921
921
 
922
922
  @property
923
- def _torch(self) -> "wandb.wandb_torch.TorchHistory":
923
+ def _torch(self) -> "wandb.wandb_torch.TorchHistory": # type: ignore
924
924
  if self._torch_history is None:
925
- self._torch_history = wandb.wandb_torch.TorchHistory()
925
+ self._torch_history = wandb.wandb_torch.TorchHistory() # type: ignore
926
926
  return self._torch_history
927
927
 
928
928
  @property
@@ -1089,13 +1089,14 @@ class Run:
1089
1089
  @_run_decorator._attach
1090
1090
  def mode(self) -> str:
1091
1091
  """For compatibility with `0.9.x` and earlier, deprecate eventually."""
1092
- deprecate.deprecate(
1093
- field_name=deprecate.Deprecated.run__mode,
1094
- warning_message=(
1095
- "The mode property of wandb.run is deprecated "
1096
- "and will be removed in a future release."
1097
- ),
1098
- )
1092
+ if hasattr(self, "_telemetry_obj"):
1093
+ deprecate.deprecate(
1094
+ field_name=deprecate.Deprecated.run__mode,
1095
+ warning_message=(
1096
+ "The mode property of wandb.run is deprecated "
1097
+ "and will be removed in a future release."
1098
+ ),
1099
+ )
1099
1100
  return "dryrun" if self._settings._offline else "run"
1100
1101
 
1101
1102
  @property
@@ -1675,15 +1676,15 @@ class Run:
1675
1676
  commit: Optional[bool] = None,
1676
1677
  sync: Optional[bool] = None,
1677
1678
  ) -> None:
1678
- """Log a dictionary of data to the current run's history.
1679
+ """Upload run data.
1679
1680
 
1680
- Use `wandb.log` to log data from runs, such as scalars, images, video,
1681
+ Use `log` to log data from runs, such as scalars, images, video,
1681
1682
  histograms, plots, and tables.
1682
1683
 
1683
1684
  See our [guides to logging](https://docs.wandb.ai/guides/track/log) for
1684
1685
  live examples, code snippets, best practices, and more.
1685
1686
 
1686
- The most basic usage is `wandb.log({"train-loss": 0.5, "accuracy": 0.9})`.
1687
+ The most basic usage is `run.log({"train-loss": 0.5, "accuracy": 0.9})`.
1687
1688
  This will save the loss and accuracy to the run's history and update
1688
1689
  the summary values for these metrics.
1689
1690
 
@@ -1692,48 +1693,91 @@ class Run:
1692
1693
  of the W&B app, or export data to visualize and explore locally, e.g. in
1693
1694
  Jupyter notebooks, with [our API](https://docs.wandb.ai/guides/track/public-api-guide).
1694
1695
 
1695
- In the UI, summary values show up in the run table to compare single values across runs.
1696
- Summary values can also be set directly with `wandb.run.summary["key"] = value`.
1697
-
1698
1696
  Logged values don't have to be scalars. Logging any wandb object is supported.
1699
- For example `wandb.log({"example": wandb.Image("myimage.jpg")})` will log an
1697
+ For example `run.log({"example": wandb.Image("myimage.jpg")})` will log an
1700
1698
  example image which will be displayed nicely in the W&B UI.
1701
1699
  See the [reference documentation](https://docs.wandb.com/ref/python/data-types)
1702
1700
  for all of the different supported types or check out our
1703
1701
  [guides to logging](https://docs.wandb.ai/guides/track/log) for examples,
1704
1702
  from 3D molecular structures and segmentation masks to PR curves and histograms.
1705
- `wandb.Table`s can be used to logged structured data. See our
1703
+ You can use `wandb.Table` to log structured data. See our
1706
1704
  [guide to logging tables](https://docs.wandb.ai/guides/data-vis/log-tables)
1707
1705
  for details.
1708
1706
 
1709
- Logging nested metrics is encouraged and is supported in the W&B UI.
1710
- If you log with a nested dictionary like `wandb.log({"train":
1711
- {"acc": 0.9}, "val": {"acc": 0.8}})`, the metrics will be organized into
1712
- `train` and `val` sections in the W&B UI.
1707
+ The W&B UI organizes metrics with a forward slash (`/`) in their name
1708
+ into sections named using the text before the final slash. For example,
1709
+ the following results in two sections named "train" and "validate":
1710
+
1711
+ ```
1712
+ run.log({
1713
+ "train/accuracy": 0.9,
1714
+ "train/loss": 30,
1715
+ "validate/accuracy": 0.8,
1716
+ "validate/loss": 20,
1717
+ })
1718
+ ```
1719
+
1720
+ Only one level of nesting is supported; `run.log({"a/b/c": 1})`
1721
+ produces a section named "a/b".
1722
+
1723
+ `run.log` is not intended to be called more than a few times per second.
1724
+ For optimal performance, limit your logging to once every N iterations,
1725
+ or collect data over multiple iterations and log it in a single step.
1726
+
1727
+ ### The W&B step
1728
+
1729
+ With basic usage, each call to `log` creates a new "step".
1730
+ The step must always increase, and it is not possible to log
1731
+ to a previous step.
1713
1732
 
1714
- wandb keeps track of a global step, which by default increments with each
1715
- call to `wandb.log`, so logging related metrics together is encouraged.
1716
- If it's inconvenient to log related metrics together
1717
- calling `wandb.log({"train-loss": 0.5}, commit=False)` and then
1718
- `wandb.log({"accuracy": 0.9})` is equivalent to calling
1719
- `wandb.log({"train-loss": 0.5, "accuracy": 0.9})`.
1733
+ Note that you can use any metric as the X axis in charts.
1734
+ In many cases, it is better to treat the W&B step like
1735
+ you'd treat a timestamp rather than a training step.
1720
1736
 
1721
- `wandb.log` is not intended to be called more than a few times per second.
1722
- If you want to log more frequently than that it's better to aggregate
1723
- the data on the client side or you may get degraded performance.
1737
+ ```
1738
+ # Example: log an "epoch" metric for use as an X axis.
1739
+ run.log({"epoch": 40, "train-loss": 0.5})
1740
+ ```
1741
+
1742
+ See also [define_metric](https://docs.wandb.ai/ref/python/run#define_metric).
1743
+
1744
+ It is possible to use multiple `log` invocations to log to
1745
+ the same step with the `step` and `commit` parameters.
1746
+ The following are all equivalent:
1747
+
1748
+ ```
1749
+ # Normal usage:
1750
+ run.log({"train-loss": 0.5, "accuracy": 0.8})
1751
+ run.log({"train-loss": 0.4, "accuracy": 0.9})
1752
+
1753
+ # Implicit step without auto-incrementing:
1754
+ run.log({"train-loss": 0.5}, commit=False)
1755
+ run.log({"accuracy": 0.8})
1756
+ run.log({"train-loss": 0.4}, commit=False)
1757
+ run.log({"accuracy": 0.9})
1758
+
1759
+ # Explicit step:
1760
+ run.log({"train-loss": 0.5}, step=current_step)
1761
+ run.log({"accuracy": 0.8}, step=current_step)
1762
+ current_step += 1
1763
+ run.log({"train-loss": 0.4}, step=current_step)
1764
+ run.log({"accuracy": 0.9}, step=current_step)
1765
+ ```
1724
1766
 
1725
1767
  Arguments:
1726
- data: (dict, optional) A dict of serializable python objects i.e `str`,
1727
- `ints`, `floats`, `Tensors`, `dicts`, or any of the `wandb.data_types`.
1728
- commit: (boolean, optional) Save the metrics dict to the wandb server
1729
- and increment the step. If false `wandb.log` just updates the current
1730
- metrics dict with the data argument and metrics won't be saved until
1731
- `wandb.log` is called with `commit=True`.
1732
- step: (integer, optional) The global step in processing. This persists
1733
- any non-committed earlier steps but defaults to not committing the
1734
- specified step.
1735
- sync: (boolean, True) This argument is deprecated and currently doesn't
1736
- change the behaviour of `wandb.log`.
1768
+ data: A `dict` with `str` keys and values that are serializable
1769
+ Python objects including: `int`, `float` and `string`;
1770
+ any of the `wandb.data_types`; lists, tuples and NumPy arrays
1771
+ of serializable Python objects; other `dict`s of this
1772
+ structure.
1773
+ step: The step number to log. If `None`, then an implicit
1774
+ auto-incrementing step is used. See the notes in
1775
+ the description.
1776
+ commit: If true, finalize and upload the step. If false, then
1777
+ accumulate data for the step. See the notes in the description.
1778
+ If `step` is `None`, then the default is `commit=True`;
1779
+ otherwise, the default is `commit=False`.
1780
+ sync: This argument is deprecated and does nothing.
1737
1781
 
1738
1782
  Examples:
1739
1783
  For more and more detailed examples, see
@@ -1885,7 +1929,7 @@ class Run:
1885
1929
  self,
1886
1930
  glob_str: Optional[Union[str, os.PathLike]] = None,
1887
1931
  base_path: Optional[Union[str, os.PathLike]] = None,
1888
- policy: "PolicyName" = "live",
1932
+ policy: PolicyName = "live",
1889
1933
  ) -> Union[bool, List[str]]:
1890
1934
  """Sync one or more files to W&B.
1891
1935
 
@@ -2158,12 +2202,13 @@ class Run:
2158
2202
  @_run_decorator._attach
2159
2203
  def join(self, exit_code: Optional[int] = None) -> None:
2160
2204
  """Deprecated alias for `finish()` - use finish instead."""
2161
- deprecate.deprecate(
2162
- field_name=deprecate.Deprecated.run__join,
2163
- warning_message=(
2164
- "wandb.run.join() is deprecated, please use wandb.run.finish()."
2165
- ),
2166
- )
2205
+ if hasattr(self, "_telemetry_obj"):
2206
+ deprecate.deprecate(
2207
+ field_name=deprecate.Deprecated.run__join,
2208
+ warning_message=(
2209
+ "wandb.run.join() is deprecated, please use wandb.run.finish()."
2210
+ ),
2211
+ )
2167
2212
  self._finish(exit_code=exit_code)
2168
2213
 
2169
2214
  @_run_decorator._noop_on_finish()
@@ -2368,11 +2413,7 @@ class Run:
2368
2413
  return
2369
2414
  self._atexit_cleanup_called = True
2370
2415
 
2371
- exit_code = (
2372
- exit_code #
2373
- or (self._hooks and self._hooks.exit_code)
2374
- or 0
2375
- )
2416
+ exit_code = exit_code or (self._hooks and self._hooks.exit_code) or 0
2376
2417
  self._exit_code = exit_code
2377
2418
  logger.info(f"got exitcode: {exit_code}")
2378
2419
 
@@ -2389,7 +2430,7 @@ class Run:
2389
2430
  self._on_finish()
2390
2431
 
2391
2432
  except KeyboardInterrupt:
2392
- if not wandb.wandb_agent._is_running():
2433
+ if not wandb.wandb_agent._is_running(): # type: ignore
2393
2434
  wandb.termerror("Control-C detected -- Run data was not synced")
2394
2435
  raise
2395
2436
 
@@ -2839,12 +2880,12 @@ class Run:
2839
2880
  idx=None,
2840
2881
  log_graph=False,
2841
2882
  ) -> None:
2842
- wandb.watch(models, criterion, log, log_freq, idx, log_graph)
2883
+ wandb.watch(models, criterion, log, log_freq, idx, log_graph) # type: ignore
2843
2884
 
2844
2885
  # TODO(jhr): annotate this
2845
2886
  @_run_decorator._attach
2846
2887
  def unwatch(self, models=None) -> None: # type: ignore
2847
- wandb.unwatch(models=models)
2888
+ wandb.unwatch(models=models) # type: ignore
2848
2889
 
2849
2890
  # TODO(kdg): remove all artifact swapping logic
2850
2891
  def _swap_artifact_name(self, artifact_name: str, use_as: Optional[str]) -> str:
@@ -3514,7 +3555,7 @@ class Run:
3514
3555
  artifact = self._log_artifact(
3515
3556
  artifact_or_path=path, name=name, type=artifact.type
3516
3557
  )
3517
- except (ValueError, wandb.CommError):
3558
+ except (ValueError, CommError):
3518
3559
  artifact = self._log_artifact(
3519
3560
  artifact_or_path=path, name=name, type="model"
3520
3561
  )
@@ -3534,13 +3575,13 @@ class Run:
3534
3575
  Arguments:
3535
3576
  title: (str) The title of the alert, must be less than 64 characters long.
3536
3577
  text: (str) The text body of the alert.
3537
- level: (str or wandb.AlertLevel, optional) The alert level to use, either: `INFO`, `WARN`, or `ERROR`.
3578
+ level: (str or AlertLevel, optional) The alert level to use, either: `INFO`, `WARN`, or `ERROR`.
3538
3579
  wait_duration: (int, float, or timedelta, optional) The time to wait (in seconds) before sending another
3539
3580
  alert with this title.
3540
3581
  """
3541
- level = level or wandb.AlertLevel.INFO
3542
- level_str: str = level.value if isinstance(level, wandb.AlertLevel) else level
3543
- if level_str not in {lev.value for lev in wandb.AlertLevel}:
3582
+ level = level or AlertLevel.INFO
3583
+ level_str: str = level.value if isinstance(level, AlertLevel) else level
3584
+ if level_str not in {lev.value for lev in AlertLevel}:
3544
3585
  raise ValueError("level must be one of 'INFO', 'WARN', or 'ERROR'")
3545
3586
 
3546
3587
  wait_duration = wait_duration or timedelta(minutes=1)
@@ -3723,12 +3764,12 @@ class Run:
3723
3764
  return
3724
3765
 
3725
3766
  if printer._html:
3726
- if not wandb.jupyter.maybe_display():
3767
+ if not wandb.jupyter.maybe_display(): # type: ignore
3727
3768
  run_line = f"<strong>{printer.link(run_url, run_name)}</strong>"
3728
3769
  project_line, sweep_line = "", ""
3729
3770
 
3730
3771
  # TODO(settings): make settings the source of truth
3731
- if not wandb.jupyter.quiet():
3772
+ if not wandb.jupyter.quiet(): # type: ignore
3732
3773
  doc_html = printer.link(wburls.get("doc_run"), "docs")
3733
3774
 
3734
3775
  project_html = printer.link(project_url, "Weights & Biases")
@@ -1715,7 +1715,7 @@ class Settings(SettingsData):
1715
1715
 
1716
1716
  # Attempt to get notebook information if not already set by the user
1717
1717
  if self._jupyter and (self.notebook_name is None or self.notebook_name == ""):
1718
- meta = wandb.jupyter.notebook_metadata(self.silent)
1718
+ meta = wandb.jupyter.notebook_metadata(self.silent) # type: ignore
1719
1719
  settings["_jupyter_path"] = meta.get("path")
1720
1720
  settings["_jupyter_name"] = meta.get("name")
1721
1721
  settings["_jupyter_root"] = meta.get("root")
wandb/sdk/wandb_setup.py CHANGED
@@ -319,14 +319,77 @@ def _setup(
319
319
  return wl
320
320
 
321
321
 
322
- def setup(
323
- settings: Optional[Settings] = None,
324
- ) -> Optional["_WandbSetup"]:
322
+ def setup(settings: Optional[Settings] = None) -> Optional["_WandbSetup"]:
323
+ """Prepares W&B for use in the current process and its children.
324
+
325
+ You can usually ignore this as it is implicitly called by `wandb.init()`.
326
+
327
+ When using wandb in multiple processes, calling `wandb.setup()`
328
+ in the parent process before starting child processes may improve
329
+ performance and resource utilization.
330
+
331
+ Note that `wandb.setup()` modifies `os.environ`, and it is important
332
+ that child processes inherit the modified environment variables.
333
+
334
+ See also `wandb.teardown()`.
335
+
336
+ Args:
337
+ settings (Optional[Union[Dict[str, Any], wandb.Settings]]): Configuration settings
338
+ to apply globally. These can be overridden by subsequent `wandb.init()` calls.
339
+
340
+ Example:
341
+ ```python
342
+ import multiprocessing
343
+
344
+ import wandb
345
+
346
+
347
+ def run_experiment(params):
348
+ with wandb.init(config=params):
349
+ # Run experiment
350
+ pass
351
+
352
+
353
+ if __name__ == "__main__":
354
+ # Start backend and set global config
355
+ wandb.setup(settings={"project": "my_project"})
356
+
357
+ # Define experiment parameters
358
+ experiment_params = [
359
+ {"learning_rate": 0.01, "epochs": 10},
360
+ {"learning_rate": 0.001, "epochs": 20},
361
+ ]
362
+
363
+ # Start multiple processes, each running a separate experiment
364
+ processes = []
365
+ for params in experiment_params:
366
+ p = multiprocessing.Process(target=run_experiment, args=(params,))
367
+ p.start()
368
+ processes.append(p)
369
+
370
+ # Wait for all processes to complete
371
+ for p in processes:
372
+ p.join()
373
+
374
+ # Optional: Explicitly shut down the backend
375
+ wandb.teardown()
376
+ ```
377
+ """
325
378
  ret = _setup(settings=settings)
326
379
  return ret
327
380
 
328
381
 
329
382
  def teardown(exit_code: Optional[int] = None) -> None:
383
+ """Waits for wandb to finish and frees resources.
384
+
385
+ Completes any runs that were not explicitly finished
386
+ using `run.finish()` and waits for all data to be uploaded.
387
+
388
+ It is recommended to call this at the end of a session
389
+ that used `wandb.setup()`. It is invoked automatically
390
+ in an `atexit` hook, but this is not reliable in certain setups
391
+ such as when using Python's `multiprocessing` module.
392
+ """
330
393
  setup_instance = _WandbSetup._instance
331
394
  _WandbSetup._instance = None
332
395
 
wandb/sdk/wandb_sweep.py CHANGED
@@ -1,5 +1,5 @@
1
1
  import urllib.parse
2
- from typing import Callable, Dict, List, Optional, Union
2
+ from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Union
3
3
 
4
4
  import wandb
5
5
  from wandb import env
@@ -8,6 +8,9 @@ from wandb.sdk.launch.sweeps.utils import handle_sweep_config_violations
8
8
 
9
9
  from . import wandb_login
10
10
 
11
+ if TYPE_CHECKING:
12
+ from wandb.wandb_controller import _WandbController
13
+
11
14
 
12
15
  def _get_sweep_url(api, sweep_id):
13
16
  """Return sweep url if we can figure it out."""
@@ -93,7 +96,7 @@ def controller(
93
96
  sweep_id_or_config: Optional[Union[str, Dict]] = None,
94
97
  entity: Optional[str] = None,
95
98
  project: Optional[str] = None,
96
- ):
99
+ ) -> "_WandbController":
97
100
  """Public sweep controller constructor.
98
101
 
99
102
  Usage:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wandb
3
- Version: 0.17.6
3
+ Version: 0.17.7
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