wandb 0.18.6__py3-none-macosx_11_0_arm64.whl → 0.19.0__py3-none-macosx_11_0_arm64.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. package_readme.md +8 -0
  2. wandb/__init__.py +5 -7
  3. wandb/__init__.pyi +51 -30
  4. wandb/analytics/sentry.py +4 -10
  5. wandb/apis/importers/internals/internal.py +6 -6
  6. wandb/apis/importers/internals/protocols.py +11 -7
  7. wandb/apis/public/api.py +5 -1
  8. wandb/apis/public/jobs.py +1 -7
  9. wandb/apis/public/reports.py +6 -17
  10. wandb/apis/public/runs.py +12 -10
  11. wandb/bin/gpu_stats +0 -0
  12. wandb/bin/wandb-core +0 -0
  13. wandb/cli/cli.py +9 -45
  14. wandb/env.py +3 -5
  15. wandb/errors/links.py +1 -1
  16. wandb/errors/term.py +1 -6
  17. wandb/filesync/dir_watcher.py +3 -3
  18. wandb/filesync/step_upload.py +2 -5
  19. wandb/integration/fastai/__init__.py +1 -6
  20. wandb/integration/gym/__init__.py +1 -7
  21. wandb/integration/keras/callbacks/metrics_logger.py +1 -8
  22. wandb/integration/keras/callbacks/model_checkpoint.py +1 -8
  23. wandb/integration/keras/keras.py +3 -5
  24. wandb/integration/lightgbm/__init__.py +1 -1
  25. wandb/integration/sb3/sb3.py +1 -7
  26. wandb/integration/sklearn/utils.py +1 -1
  27. wandb/integration/tensorboard/log.py +1 -2
  28. wandb/integration/torch/wandb_torch.py +1 -1
  29. wandb/integration/ultralytics/bbox_utils.py +9 -2
  30. wandb/jupyter.py +4 -4
  31. wandb/proto/v3/wandb_internal_pb2.py +31 -31
  32. wandb/proto/v3/wandb_settings_pb2.py +2 -2
  33. wandb/proto/v3/wandb_telemetry_pb2.py +4 -4
  34. wandb/proto/v4/wandb_internal_pb2.py +31 -31
  35. wandb/proto/v4/wandb_settings_pb2.py +2 -2
  36. wandb/proto/v4/wandb_telemetry_pb2.py +4 -4
  37. wandb/proto/v5/wandb_internal_pb2.py +31 -31
  38. wandb/proto/v5/wandb_settings_pb2.py +2 -2
  39. wandb/proto/v5/wandb_telemetry_pb2.py +4 -4
  40. wandb/proto/wandb_deprecated.py +3 -11
  41. wandb/proto/wandb_generate_deprecated.py +3 -7
  42. wandb/sdk/artifacts/artifact.py +3 -11
  43. wandb/sdk/artifacts/artifact_file_cache.py +2 -5
  44. wandb/sdk/artifacts/artifact_saver.py +2 -6
  45. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +2 -4
  46. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +2 -4
  47. wandb/sdk/artifacts/storage_handlers/s3_handler.py +2 -4
  48. wandb/sdk/backend/backend.py +1 -1
  49. wandb/sdk/data_types/base_types/wb_value.py +20 -10
  50. wandb/sdk/data_types/histogram.py +1 -3
  51. wandb/sdk/data_types/object_3d.py +2 -6
  52. wandb/sdk/data_types/table.py +1 -1
  53. wandb/sdk/data_types/utils.py +1 -2
  54. wandb/sdk/data_types/video.py +15 -4
  55. wandb/sdk/integration_utils/auto_logging.py +1 -8
  56. wandb/sdk/interface/interface.py +12 -5
  57. wandb/sdk/interface/interface_queue.py +0 -6
  58. wandb/sdk/interface/interface_shared.py +9 -0
  59. wandb/sdk/interface/router.py +1 -2
  60. wandb/sdk/interface/router_queue.py +0 -3
  61. wandb/sdk/interface/router_relay.py +0 -2
  62. wandb/sdk/internal/file_stream.py +1 -4
  63. wandb/sdk/internal/flow_control.py +1 -1
  64. wandb/sdk/internal/handler.py +8 -5
  65. wandb/sdk/internal/internal.py +3 -17
  66. wandb/sdk/internal/internal_api.py +3 -10
  67. wandb/sdk/internal/internal_util.py +0 -3
  68. wandb/sdk/internal/job_builder.py +20 -12
  69. wandb/sdk/internal/progress.py +1 -5
  70. wandb/sdk/internal/sender.py +9 -15
  71. wandb/sdk/internal/settings_static.py +4 -10
  72. wandb/sdk/internal/system/assets/cpu.py +2 -2
  73. wandb/sdk/internal/system/assets/disk.py +3 -3
  74. wandb/sdk/internal/system/assets/gpu.py +7 -7
  75. wandb/sdk/internal/system/assets/gpu_amd.py +1 -7
  76. wandb/sdk/internal/system/assets/interfaces.py +11 -13
  77. wandb/sdk/internal/system/assets/ipu.py +1 -1
  78. wandb/sdk/internal/system/assets/memory.py +2 -2
  79. wandb/sdk/internal/system/assets/open_metrics.py +2 -8
  80. wandb/sdk/internal/system/assets/trainium.py +3 -9
  81. wandb/sdk/internal/system/system_info.py +14 -13
  82. wandb/sdk/internal/system/system_monitor.py +5 -12
  83. wandb/sdk/internal/tb_watcher.py +1 -1
  84. wandb/sdk/internal/writer.py +2 -4
  85. wandb/sdk/launch/__init__.py +2 -1
  86. wandb/sdk/launch/agent/run_queue_item_file_saver.py +1 -7
  87. wandb/sdk/launch/create_job.py +2 -3
  88. wandb/sdk/launch/runner/abstract.py +1 -6
  89. wandb/sdk/launch/runner/kubernetes_monitor.py +2 -4
  90. wandb/sdk/lib/apikey.py +2 -6
  91. wandb/sdk/lib/fsm.py +12 -6
  92. wandb/sdk/lib/ipython.py +1 -6
  93. wandb/sdk/lib/module.py +0 -3
  94. wandb/sdk/lib/progress.py +2 -3
  95. wandb/sdk/lib/run_moment.py +1 -7
  96. wandb/sdk/lib/server.py +10 -24
  97. wandb/sdk/lib/sock_client.py +0 -5
  98. wandb/sdk/service/server.py +3 -12
  99. wandb/sdk/service/server_sock.py +0 -2
  100. wandb/sdk/service/service.py +5 -5
  101. wandb/sdk/wandb_init.py +215 -166
  102. wandb/sdk/wandb_login.py +17 -27
  103. wandb/sdk/wandb_run.py +129 -161
  104. wandb/sdk/wandb_settings.py +978 -1760
  105. wandb/sdk/wandb_setup.py +87 -94
  106. wandb/sdk/wandb_watch.py +1 -1
  107. wandb/sync/sync.py +1 -2
  108. wandb/util.py +7 -40
  109. wandb/wandb_controller.py +10 -12
  110. {wandb-0.18.6.dist-info → wandb-0.19.0.dist-info}/METADATA +13 -3
  111. {wandb-0.18.6.dist-info → wandb-0.19.0.dist-info}/RECORD +114 -120
  112. wandb/integration/magic.py +0 -556
  113. wandb/magic.py +0 -3
  114. wandb/sdk/lib/_settings_toposort_generate.py +0 -159
  115. wandb/sdk/lib/_settings_toposort_generated.py +0 -250
  116. wandb/sdk/lib/reporting.py +0 -99
  117. wandb/sdk/lib/tracelog.py +0 -255
  118. {wandb-0.18.6.dist-info → wandb-0.19.0.dist-info}/WHEEL +0 -0
  119. {wandb-0.18.6.dist-info → wandb-0.19.0.dist-info}/entry_points.txt +0 -0
  120. {wandb-0.18.6.dist-info → wandb-0.19.0.dist-info}/licenses/LICENSE +0 -0
wandb/sdk/wandb_run.py CHANGED
@@ -19,18 +19,15 @@ from collections.abc import Mapping
19
19
  from dataclasses import dataclass, field
20
20
  from datetime import datetime, timedelta, timezone
21
21
  from enum import IntEnum
22
+ from functools import reduce
22
23
  from types import TracebackType
23
- from typing import TYPE_CHECKING, Any, Callable, NamedTuple, Sequence, TextIO
24
-
25
- if sys.version_info < (3, 8):
26
- from typing_extensions import Literal
27
- else:
28
- from typing import Literal
24
+ from typing import TYPE_CHECKING, Any, Callable, Literal, NamedTuple, Sequence, TextIO
29
25
 
30
26
  import requests
31
27
 
32
28
  import wandb
33
29
  import wandb.env
30
+ import wandb.util
34
31
  from wandb import trigger
35
32
  from wandb._globals import _datatypes_set_callback
36
33
  from wandb.apis import internal, public
@@ -39,7 +36,7 @@ from wandb.apis.public import Api as PublicApi
39
36
  from wandb.errors import CommError, UnsupportedError, UsageError
40
37
  from wandb.errors.links import url_registry
41
38
  from wandb.integration.torch import wandb_torch
42
- from wandb.plot import CustomChart, Visualize, plot_table
39
+ from wandb.plot import CustomChart, Visualize
43
40
  from wandb.proto.wandb_internal_pb2 import (
44
41
  MetricRecord,
45
42
  PollExitResponse,
@@ -89,23 +86,18 @@ from .lib.exit_hooks import ExitHooks
89
86
  from .lib.gitlib import GitRepo
90
87
  from .lib.mailbox import MailboxError, MailboxHandle, MailboxProbe, MailboxProgress
91
88
  from .lib.proto_util import message_to_dict
92
- from .lib.reporting import Reporter
93
89
  from .wandb_alerts import AlertLevel
94
90
  from .wandb_settings import Settings
95
91
  from .wandb_setup import _WandbSetup
96
92
 
97
93
  if TYPE_CHECKING:
98
- if sys.version_info >= (3, 8):
99
- from typing import TypedDict
100
- else:
101
- from typing_extensions import TypedDict
94
+ from typing import TypedDict
102
95
 
103
96
  import torch # type: ignore [import-not-found]
104
97
 
105
98
  import wandb.apis.public
106
99
  import wandb.sdk.backend.backend
107
100
  import wandb.sdk.interface.interface_queue
108
- from wandb.data_types import Table
109
101
  from wandb.proto.wandb_internal_pb2 import (
110
102
  GetSummaryResponse,
111
103
  InternalMessagesResponse,
@@ -440,7 +432,7 @@ class _run_decorator: # noqa: N801
440
432
  # - for fork case will use the settings of the parent process
441
433
  # - only point of inconsistent behavior from forked and non-forked cases
442
434
  settings = getattr(self, "_settings", None)
443
- if settings and settings["strict"]:
435
+ if settings and settings.strict:
444
436
  wandb.termerror(message, repeat=False)
445
437
  raise UnsupportedError(
446
438
  f"`{func.__name__}` does not support multiprocessing"
@@ -539,7 +531,6 @@ class Run:
539
531
  _sweep_id: str | None
540
532
 
541
533
  _run_obj: RunRecord | None
542
- # Use string literal annotation because of type reference loop
543
534
  _backend: wandb.sdk.backend.backend.Backend | None
544
535
  _internal_run_interface: wandb.sdk.interface.interface_queue.InterfaceQueue | None
545
536
  _wl: _WandbSetup | None
@@ -549,7 +540,6 @@ class Run:
549
540
  _redirect_cb: Callable[[str, str], None] | None
550
541
  _redirect_raw_cb: Callable[[str, str], None] | None
551
542
  _output_writer: filesystem.CRDedupedFile | None
552
- _quiet: bool | None
553
543
 
554
544
  _atexit_cleanup_called: bool
555
545
  _hooks: ExitHooks | None
@@ -634,7 +624,6 @@ class Run:
634
624
 
635
625
  self._printer = printer.new_printer()
636
626
  self._wl = None
637
- self._reporter: Reporter | None = None
638
627
 
639
628
  self._entity = None
640
629
  self._project = None
@@ -657,7 +646,6 @@ class Run:
657
646
  self._stderr_slave_fd = None
658
647
  self._exit_code = None
659
648
  self._exit_result = None
660
- self._quiet = self._settings.quiet
661
649
 
662
650
  self._output_writer = None
663
651
  self._used_artifact_slots: dict[str, str] = {}
@@ -751,7 +739,7 @@ class Run:
751
739
  self._attach_pid = os.getpid()
752
740
 
753
741
  # for now, use runid as attach id, this could/should be versioned in the future
754
- if not self._settings._disable_service:
742
+ if not self._settings.x_disable_service:
755
743
  self._attach_id = self._settings.run_id
756
744
 
757
745
  def _set_iface_pid(self, iface_pid: int) -> None:
@@ -896,7 +884,7 @@ class Run:
896
884
  def __getstate__(self) -> Any:
897
885
  """Return run state as a custom pickle."""
898
886
  # We only pickle in service mode
899
- if not self._settings or self._settings._disable_service:
887
+ if not self._settings or self._settings.x_disable_service:
900
888
  return
901
889
 
902
890
  _attach_id = self._attach_id
@@ -933,9 +921,7 @@ class Run:
933
921
  @_run_decorator._attach
934
922
  def settings(self) -> Settings:
935
923
  """A frozen copy of run's Settings object."""
936
- cp = self._settings.copy()
937
- cp.freeze()
938
- return cp
924
+ return self._settings.model_copy(deep=True)
939
925
 
940
926
  @property
941
927
  @_run_decorator._attach
@@ -1193,11 +1179,11 @@ class Run:
1193
1179
  notebook_name = None
1194
1180
  if self.settings.notebook_name:
1195
1181
  notebook_name = self.settings.notebook_name
1196
- elif self.settings._jupyter_path:
1197
- if self.settings._jupyter_path.startswith("fileId="):
1198
- notebook_name = self.settings._jupyter_name
1182
+ elif self.settings.x_jupyter_path:
1183
+ if self.settings.x_jupyter_path.startswith("fileId="):
1184
+ notebook_name = self.settings.x_jupyter_name
1199
1185
  else:
1200
- notebook_name = self.settings._jupyter_path
1186
+ notebook_name = self.settings.x_jupyter_path
1201
1187
  name_string = f"{self._project}-{notebook_name}"
1202
1188
  else:
1203
1189
  name_string = f"{self._project}-{self._settings.program_relpath}"
@@ -1469,12 +1455,14 @@ class Run:
1469
1455
  files: FilesDict = dict(files=[(GlobStr(glob.escape(fname)), "now")])
1470
1456
  self._backend.interface.publish_files(files)
1471
1457
 
1472
- def _visualization_hack(self, row: dict[str, Any]) -> dict[str, Any]:
1473
- # TODO(jhr): move visualize hack somewhere else
1458
+ def _serialize_custom_charts(self, data: dict[str, Any]) -> dict[str, Any]:
1459
+ if not data:
1460
+ return data
1461
+
1474
1462
  chart_keys = set()
1475
- for k, v in row.items():
1463
+ for k, v in data.items():
1476
1464
  if isinstance(v, Visualize):
1477
- row[k] = v.table
1465
+ data[k] = v.table
1478
1466
  v.set_key(k)
1479
1467
  self._config_callback(
1480
1468
  val=v.spec.config_value,
@@ -1490,31 +1478,33 @@ class Run:
1490
1478
 
1491
1479
  for k in chart_keys:
1492
1480
  # remove the chart key from the row
1493
- v = row.pop(k)
1481
+ v = data.pop(k)
1494
1482
  if isinstance(v, CustomChart):
1495
- row[v.spec.table_key] = v.table
1496
- return row
1483
+ data[v.spec.table_key] = v.table
1484
+ return data
1497
1485
 
1498
1486
  def _partial_history_callback(
1499
1487
  self,
1500
- row: dict[str, Any],
1488
+ data: dict[str, Any],
1501
1489
  step: int | None = None,
1502
1490
  commit: bool | None = None,
1503
1491
  ) -> None:
1504
- row = row.copy()
1505
- if row:
1506
- row = self._visualization_hack(row)
1492
+ if not (self._backend and self._backend.interface):
1493
+ return
1507
1494
 
1508
- if self._backend and self._backend.interface:
1509
- not_using_tensorboard = len(wandb.patched["tensorboard"]) == 0
1510
-
1511
- self._backend.interface.publish_partial_history(
1512
- row,
1513
- user_step=self._step,
1514
- step=step,
1515
- flush=commit,
1516
- publish_step=not_using_tensorboard,
1517
- )
1495
+ data = data.copy() # avoid modifying the original data
1496
+
1497
+ # Serialize custom charts before publishing
1498
+ data = self._serialize_custom_charts(data)
1499
+
1500
+ not_using_tensorboard = len(wandb.patched["tensorboard"]) == 0
1501
+ self._backend.interface.publish_partial_history(
1502
+ data,
1503
+ user_step=self._step,
1504
+ step=step,
1505
+ flush=commit,
1506
+ publish_step=not_using_tensorboard,
1507
+ )
1518
1508
 
1519
1509
  def _console_callback(self, name: str, data: str) -> None:
1520
1510
  # logger.info("console callback: %s, %s", name, data)
@@ -1555,9 +1545,6 @@ class Run:
1555
1545
  ) -> None:
1556
1546
  self._internal_run_interface = interface
1557
1547
 
1558
- def _set_reporter(self, reporter: Reporter) -> None:
1559
- self._reporter = reporter
1560
-
1561
1548
  def _set_teardown_hooks(self, hooks: list[TeardownHook]) -> None:
1562
1549
  self._teardown_hooks = hooks
1563
1550
 
@@ -1587,8 +1574,31 @@ class Run:
1587
1574
  self._step = self._get_starting_step()
1588
1575
 
1589
1576
  # update settings from run_obj
1590
- self._settings._apply_run_start(message_to_dict(self._run_obj))
1591
- self._update_settings(self._settings)
1577
+ run_start_settings = message_to_dict(self._run_obj)
1578
+ param_map = {
1579
+ "run_id": "run_id",
1580
+ "entity": "entity",
1581
+ "project": "project",
1582
+ "run_group": "run_group",
1583
+ "job_type": "run_job_type",
1584
+ "display_name": "run_name",
1585
+ "notes": "run_notes",
1586
+ "tags": "run_tags",
1587
+ "sweep_id": "sweep_id",
1588
+ "host": "host",
1589
+ "resumed": "resumed",
1590
+ "git.remote_url": "git_remote_url",
1591
+ "git.commit": "git_commit",
1592
+ }
1593
+ run_settings = {
1594
+ name: reduce(lambda d, k: d.get(k, {}), attr.split("."), run_start_settings)
1595
+ for attr, name in param_map.items()
1596
+ }
1597
+ run_settings = {key: value for key, value in run_settings.items() if value}
1598
+
1599
+ if run_settings:
1600
+ self._settings.update_from_dict(run_settings)
1601
+ self._update_settings(self._settings)
1592
1602
 
1593
1603
  wandb._sentry.configure_scope(
1594
1604
  process_context="user",
@@ -2032,7 +2042,7 @@ class Run:
2032
2042
  policy: PolicyName,
2033
2043
  ) -> list[str]:
2034
2044
  # Can't use is_relative_to() because that's added in Python 3.9,
2035
- # but we support down to Python 3.7.
2045
+ # but we support down to Python 3.8.
2036
2046
  if not str(glob_path).startswith(str(base_path)):
2037
2047
  raise ValueError("Glob may not walk above the base path")
2038
2048
 
@@ -2076,12 +2086,7 @@ class Run:
2076
2086
  target_path.parent.mkdir(parents=True, exist_ok=True)
2077
2087
 
2078
2088
  # Delete the symlink if it exists.
2079
- try:
2080
- target_path.unlink()
2081
- except FileNotFoundError:
2082
- # In Python 3.8, we would pass missing_ok=True, but as of now
2083
- # we support down to Python 3.7.
2084
- pass
2089
+ target_path.unlink(missing_ok=True)
2085
2090
 
2086
2091
  target_path.symlink_to(source_path)
2087
2092
 
@@ -2126,30 +2131,45 @@ class Run:
2126
2131
 
2127
2132
  @_run_decorator._noop
2128
2133
  @_run_decorator._attach
2129
- def finish(self, exit_code: int | None = None, quiet: bool | None = None) -> None:
2130
- """Mark a run as finished, and finish uploading all data.
2134
+ def finish(
2135
+ self,
2136
+ exit_code: int | None = None,
2137
+ quiet: bool | None = None,
2138
+ ) -> None:
2139
+ """Finish a run and upload any remaining data.
2140
+
2141
+ Marks the completion of a W&B run and ensures all data is synced to the server.
2142
+ The run's final state is determined by its exit conditions and sync status.
2131
2143
 
2132
- This is used when creating multiple runs in the same process. We automatically
2133
- call this method when your script exits or if you use the run context manager.
2144
+ Run States:
2145
+ - Running: Active run that is logging data and/or sending heartbeats.
2146
+ - Crashed: Run that stopped sending heartbeats unexpectedly.
2147
+ - Finished: Run completed successfully (`exit_code=0`) with all data synced.
2148
+ - Failed: Run completed with errors (`exit_code!=0`).
2134
2149
 
2135
2150
  Args:
2136
- exit_code: Set to something other than 0 to mark a run as failed
2137
- quiet: Set to true to minimize log output
2151
+ exit_code: Integer indicating the run's exit status. Use 0 for success,
2152
+ any other value marks the run as failed.
2153
+ quiet: Deprecated. Configure logging verbosity using `wandb.Settings(quiet=...)`.
2138
2154
  """
2139
- return self._finish(exit_code, quiet)
2155
+ if quiet is not None:
2156
+ deprecate.deprecate(
2157
+ field_name=deprecate.Deprecated.run__finish_quiet,
2158
+ warning_message=(
2159
+ "The `quiet` argument to `wandb.run.finish()` is deprecated, "
2160
+ "use `wandb.Settings(quiet=...)` to set this instead."
2161
+ ),
2162
+ )
2163
+ return self._finish(exit_code)
2140
2164
 
2141
2165
  def _finish(
2142
2166
  self,
2143
2167
  exit_code: int | None = None,
2144
- quiet: bool | None = None,
2145
2168
  ) -> None:
2146
2169
  logger.info(f"finishing run {self._get_path()}")
2147
2170
  with telemetry.context(run=self) as tel:
2148
2171
  tel.feature.finish = True
2149
2172
 
2150
- if quiet is not None:
2151
- self._quiet = quiet
2152
-
2153
2173
  # Pop this run (hopefully) from the run stack, to support the "reinit"
2154
2174
  # functionality of wandb.init().
2155
2175
  #
@@ -2183,7 +2203,7 @@ class Run:
2183
2203
  #
2184
2204
  # TODO: Why not do this in _atexit_cleanup()?
2185
2205
  service = self._wl and self._wl.service
2186
- if service:
2206
+ if service and self._run_id:
2187
2207
  service.inform_finish(run_id=self._run_id)
2188
2208
 
2189
2209
  finally:
@@ -2228,31 +2248,6 @@ class Run:
2228
2248
  sync_time=sync_time,
2229
2249
  )
2230
2250
 
2231
- @staticmethod
2232
- def plot_table(
2233
- vega_spec_name: str,
2234
- data_table: Table,
2235
- fields: dict[str, Any],
2236
- string_fields: dict[str, Any] | None = None,
2237
- split_table: bool = False,
2238
- ) -> CustomChart:
2239
- """Create a custom plot on a table.
2240
-
2241
- Args:
2242
- vega_spec_name: the name of the spec for the plot
2243
- data_table: a wandb.Table object containing the data to
2244
- be used on the visualization
2245
- fields: a dict mapping from table keys to fields that the custom
2246
- visualization needs
2247
- string_fields: a dict that provides values for any string constants
2248
- the custom visualization needs
2249
- split_table: a boolean that indicates whether the table should be in
2250
- a separate section in the UI
2251
- """
2252
- return plot_table(
2253
- vega_spec_name, data_table, fields, string_fields or {}, split_table
2254
- )
2255
-
2256
2251
  def _add_panel(
2257
2252
  self, visualize_key: str, panel_type: str, panel_config: dict
2258
2253
  ) -> None:
@@ -2272,7 +2267,6 @@ class Run:
2272
2267
  use_artifact=self.use_artifact,
2273
2268
  log_artifact=self.log_artifact,
2274
2269
  define_metric=self.define_metric,
2275
- plot_table=self.plot_table,
2276
2270
  alert=self.alert,
2277
2271
  watch=self.watch,
2278
2272
  unwatch=self.unwatch,
@@ -2292,7 +2286,7 @@ class Run:
2292
2286
  console = self._settings.console
2293
2287
  # only use raw for service to minimize potential changes
2294
2288
  if console == "wrap":
2295
- if not self._settings._disable_service:
2289
+ if not self._settings.x_disable_service:
2296
2290
  console = "wrap_raw"
2297
2291
  else:
2298
2292
  console = "wrap_emu"
@@ -2441,8 +2435,6 @@ class Run:
2441
2435
  final_summary=self._final_summary,
2442
2436
  poll_exit_response=self._poll_exit_response,
2443
2437
  internal_messages_response=self._internal_messages_response,
2444
- reporter=self._reporter,
2445
- quiet=self._quiet,
2446
2438
  settings=self._settings,
2447
2439
  printer=self._printer,
2448
2440
  )
@@ -2481,7 +2473,7 @@ class Run:
2481
2473
  if self._settings.save_code and self._settings.code_dir is not None:
2482
2474
  self.log_code(self._settings.code_dir)
2483
2475
 
2484
- if self._settings._save_requirements:
2476
+ if self._settings.x_save_requirements:
2485
2477
  if self._backend and self._backend.interface:
2486
2478
  from wandb.util import working_set
2487
2479
 
@@ -2525,6 +2517,8 @@ class Run:
2525
2517
 
2526
2518
  import_telemetry_set = telemetry.list_telemetry_imports()
2527
2519
  import_hook_fn = functools.partial(_telemetry_import_hook, self)
2520
+ if not self._run_id:
2521
+ return
2528
2522
  for module_name in import_telemetry_set:
2529
2523
  register_post_import_hook(
2530
2524
  import_hook_fn,
@@ -2665,7 +2659,11 @@ class Run:
2665
2659
 
2666
2660
  assert self._backend and self._backend.interface
2667
2661
 
2668
- exit_handle = self._backend.interface.deliver_exit(self._exit_code)
2662
+ if self._settings.x_update_finish_state:
2663
+ exit_handle = self._backend.interface.deliver_exit(self._exit_code)
2664
+ else:
2665
+ exit_handle = self._backend.interface.deliver_finish_without_exit()
2666
+
2669
2667
  exit_handle.add_probe(on_probe=self._on_probe_exit)
2670
2668
 
2671
2669
  with progress.progress_printer(
@@ -2717,7 +2715,8 @@ class Run:
2717
2715
  if self._run_status_checker:
2718
2716
  self._run_status_checker.join()
2719
2717
 
2720
- self._unregister_telemetry_import_hooks(self._run_id)
2718
+ if self._run_id:
2719
+ self._unregister_telemetry_import_hooks(self._run_id)
2721
2720
 
2722
2721
  @staticmethod
2723
2722
  def _unregister_telemetry_import_hooks(run_id: str) -> None:
@@ -2870,7 +2869,7 @@ class Run:
2870
2869
  def watch(
2871
2870
  self,
2872
2871
  models: torch.nn.Module | Sequence[torch.nn.Module],
2873
- criterion: torch.F | None = None,
2872
+ criterion: torch.F | None = None, # type: ignore
2874
2873
  log: Literal["gradients", "parameters", "all"] | None = "gradients",
2875
2874
  log_freq: int = 1000,
2876
2875
  idx: int | None = None,
@@ -3350,7 +3349,7 @@ class Run:
3350
3349
  return artifact
3351
3350
 
3352
3351
  def _public_api(self, overrides: dict[str, str] | None = None) -> PublicApi:
3353
- overrides = {"run": self._run_id}
3352
+ overrides = {"run": self._run_id} # type: ignore
3354
3353
  if not (self._settings._offline or self._run_obj is None):
3355
3354
  overrides["entity"] = self._run_obj.entity
3356
3355
  overrides["project"] = self._run_obj.project
@@ -3688,9 +3687,10 @@ class Run:
3688
3687
  Returns:
3689
3688
  A dictionary of system metrics.
3690
3689
  """
3690
+ from wandb.proto import wandb_internal_pb2
3691
3691
 
3692
3692
  def pb_to_dict(
3693
- system_metrics_pb: wandb.proto.wandb_internal_pb2.GetSystemMetricsResponse,
3693
+ system_metrics_pb: wandb_internal_pb2.GetSystemMetricsResponse,
3694
3694
  ) -> dict[str, list[tuple[datetime, float]]]:
3695
3695
  res = {}
3696
3696
 
@@ -3852,8 +3852,6 @@ class Run:
3852
3852
  final_summary: GetSummaryResponse | None = None,
3853
3853
  poll_exit_response: PollExitResponse | None = None,
3854
3854
  internal_messages_response: InternalMessagesResponse | None = None,
3855
- reporter: Reporter | None = None,
3856
- quiet: bool | None = None,
3857
3855
  *,
3858
3856
  settings: Settings,
3859
3857
  printer: printer.Printer,
@@ -3861,37 +3859,29 @@ class Run:
3861
3859
  Run._footer_history_summary_info(
3862
3860
  history=sampled_history,
3863
3861
  summary=final_summary,
3864
- quiet=quiet,
3865
3862
  settings=settings,
3866
3863
  printer=printer,
3867
3864
  )
3868
3865
 
3869
3866
  Run._footer_sync_info(
3870
3867
  poll_exit_response=poll_exit_response,
3871
- quiet=quiet,
3872
3868
  settings=settings,
3873
3869
  printer=printer,
3874
3870
  )
3875
- Run._footer_log_dir_info(quiet=quiet, settings=settings, printer=printer)
3871
+ Run._footer_log_dir_info(settings=settings, printer=printer)
3876
3872
  Run._footer_notify_wandb_core(
3877
- quiet=quiet,
3878
3873
  settings=settings,
3879
3874
  printer=printer,
3880
3875
  )
3881
3876
  Run._footer_internal_messages(
3882
3877
  internal_messages_response=internal_messages_response,
3883
- quiet=quiet,
3884
3878
  settings=settings,
3885
3879
  printer=printer,
3886
3880
  )
3887
- Run._footer_reporter_warn_err(
3888
- reporter=reporter, quiet=quiet, settings=settings, printer=printer
3889
- )
3890
3881
 
3891
3882
  @staticmethod
3892
3883
  def _footer_sync_info(
3893
3884
  poll_exit_response: PollExitResponse | None = None,
3894
- quiet: bool | None = None,
3895
3885
  *,
3896
3886
  settings: Settings,
3897
3887
  printer: printer.Printer,
@@ -3900,7 +3890,7 @@ class Run:
3900
3890
  return
3901
3891
 
3902
3892
  if settings._offline:
3903
- if not quiet and not settings.quiet:
3893
+ if not settings.quiet:
3904
3894
  printer.display(
3905
3895
  [
3906
3896
  "You can sync this run to the cloud by running:",
@@ -3929,12 +3919,11 @@ class Run:
3929
3919
 
3930
3920
  @staticmethod
3931
3921
  def _footer_log_dir_info(
3932
- quiet: bool | None = None,
3933
3922
  *,
3934
3923
  settings: Settings,
3935
3924
  printer: printer.Printer,
3936
3925
  ) -> None:
3937
- if (quiet or settings.quiet) or settings.silent:
3926
+ if settings.quiet or settings.silent:
3938
3927
  return
3939
3928
 
3940
3929
  log_dir = settings.log_user or settings.log_internal
@@ -3948,12 +3937,11 @@ class Run:
3948
3937
  def _footer_history_summary_info(
3949
3938
  history: SampledHistoryResponse | None = None,
3950
3939
  summary: GetSummaryResponse | None = None,
3951
- quiet: bool | None = None,
3952
3940
  *,
3953
3941
  settings: Settings,
3954
3942
  printer: printer.Printer,
3955
3943
  ) -> None:
3956
- if (quiet or settings.quiet) or settings.silent:
3944
+ if settings.quiet or settings.silent:
3957
3945
  return
3958
3946
 
3959
3947
  panel = []
@@ -4018,12 +4006,11 @@ class Run:
4018
4006
  @staticmethod
4019
4007
  def _footer_internal_messages(
4020
4008
  internal_messages_response: InternalMessagesResponse | None = None,
4021
- quiet: bool | None = None,
4022
4009
  *,
4023
4010
  settings: Settings,
4024
4011
  printer: printer.Printer,
4025
4012
  ) -> None:
4026
- if (quiet or settings.quiet) or settings.silent:
4013
+ if settings.quiet or settings.silent:
4027
4014
  return
4028
4015
 
4029
4016
  if not internal_messages_response:
@@ -4035,12 +4022,11 @@ class Run:
4035
4022
  @staticmethod
4036
4023
  def _footer_notify_wandb_core(
4037
4024
  *,
4038
- quiet: bool | None = None,
4039
4025
  settings: Settings,
4040
4026
  printer: printer.Printer,
4041
4027
  ) -> None:
4042
4028
  """Prints a message advertising the upcoming core release."""
4043
- if quiet or not settings._require_legacy_service:
4029
+ if settings.quiet or not settings.x_require_legacy_service:
4044
4030
  return
4045
4031
 
4046
4032
  printer.display(
@@ -4050,34 +4036,6 @@ class Run:
4050
4036
  level="warn",
4051
4037
  )
4052
4038
 
4053
- @staticmethod
4054
- def _footer_reporter_warn_err(
4055
- reporter: Reporter | None = None,
4056
- quiet: bool | None = None,
4057
- *,
4058
- settings: Settings,
4059
- printer: printer.Printer,
4060
- ) -> None:
4061
- if (quiet or settings.quiet) or settings.silent:
4062
- return
4063
-
4064
- if not reporter:
4065
- return
4066
-
4067
- warning_lines = reporter.warning_lines
4068
- if warning_lines:
4069
- warnings = ["Warnings:"] + [f"{line}" for line in warning_lines]
4070
- if len(warning_lines) < reporter.warning_count:
4071
- warnings.append("More warnings...")
4072
- printer.display(warnings)
4073
-
4074
- error_lines = reporter.error_lines
4075
- if error_lines:
4076
- errors = ["Errors:"] + [f"{line}" for line in error_lines]
4077
- if len(error_lines) < reporter.error_count:
4078
- errors.append("More errors...")
4079
- printer.display(errors)
4080
-
4081
4039
 
4082
4040
  # We define this outside of the run context to support restoring before init
4083
4041
  def restore(
@@ -4143,15 +4101,25 @@ except AttributeError:
4143
4101
  pass
4144
4102
 
4145
4103
 
4146
- def finish(exit_code: int | None = None, quiet: bool | None = None) -> None:
4147
- """Mark a run as finished, and finish uploading all data.
4104
+ def finish(
4105
+ exit_code: int | None = None,
4106
+ quiet: bool | None = None,
4107
+ ) -> None:
4108
+ """Finish a run and upload any remaining data.
4109
+
4110
+ Marks the completion of a W&B run and ensures all data is synced to the server.
4111
+ The run's final state is determined by its exit conditions and sync status.
4148
4112
 
4149
- This is used when creating multiple runs in the same process.
4150
- We automatically call this method when your script exits.
4113
+ Run States:
4114
+ - Running: Active run that is logging data and/or sending heartbeats.
4115
+ - Crashed: Run that stopped sending heartbeats unexpectedly.
4116
+ - Finished: Run completed successfully (`exit_code=0`) with all data synced.
4117
+ - Failed: Run completed with errors (`exit_code!=0`).
4151
4118
 
4152
4119
  Args:
4153
- exit_code: Set to something other than 0 to mark a run as failed
4154
- quiet: Set to true to minimize log output
4120
+ exit_code: Integer indicating the run's exit status. Use 0 for success,
4121
+ any other value marks the run as failed.
4122
+ quiet: Deprecated. Configure logging verbosity using `wandb.Settings(quiet=...)`.
4155
4123
  """
4156
4124
  if wandb.run:
4157
4125
  wandb.run.finish(exit_code=exit_code, quiet=quiet)