wandb 0.19.3__py3-none-win32.whl → 0.19.4__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.
wandb/__init__.py CHANGED
@@ -10,7 +10,7 @@ For reference documentation, see https://docs.wandb.com/ref/python.
10
10
  """
11
11
  from __future__ import annotations
12
12
 
13
- __version__ = "0.19.3"
13
+ __version__ = "0.19.4"
14
14
 
15
15
 
16
16
  from wandb.errors import Error
wandb/__init__.pyi CHANGED
@@ -103,7 +103,7 @@ if TYPE_CHECKING:
103
103
  import wandb
104
104
  from wandb.plot import CustomChart
105
105
 
106
- __version__: str = "0.19.3"
106
+ __version__: str = "0.19.4"
107
107
 
108
108
  run: Run | None
109
109
  config: wandb_config.Config
wandb/bin/gpu_stats.exe CHANGED
Binary file
wandb/bin/wandb-core CHANGED
Binary file
@@ -25,8 +25,6 @@ if TYPE_CHECKING:
25
25
  from wandb.proto.wandb_internal_pb2 import Record, Result
26
26
  from wandb.sdk.lib import service_connection
27
27
 
28
- from ..wandb_run import Run
29
-
30
28
  RecordQueue = Union["queue.Queue[Record]", multiprocessing.Queue[Record]]
31
29
  ResultQueue = Union["queue.Queue[Result]", multiprocessing.Queue[Result]]
32
30
 
@@ -54,7 +52,7 @@ class Backend:
54
52
  interface: Optional[InterfaceBase]
55
53
  _internal_pid: Optional[int]
56
54
  wandb_process: Optional[multiprocessing.process.BaseProcess]
57
- _settings: Optional[Settings]
55
+ _settings: Settings
58
56
  record_q: Optional["RecordQueue"]
59
57
  result_q: Optional["ResultQueue"]
60
58
  _mailbox: Mailbox
@@ -62,7 +60,7 @@ class Backend:
62
60
  def __init__(
63
61
  self,
64
62
  mailbox: Mailbox,
65
- settings: Optional[Settings] = None,
63
+ settings: Settings,
66
64
  log_level: Optional[int] = None,
67
65
  service: "Optional[service_connection.ServiceConnection]" = None,
68
66
  ) -> None:
@@ -84,12 +82,7 @@ class Backend:
84
82
  self._save_mod_path: Optional[str] = None
85
83
  self._save_mod_spec = None
86
84
 
87
- def _hack_set_run(self, run: "Run") -> None:
88
- assert self.interface
89
- self.interface._hack_set_run(run)
90
-
91
85
  def _multiprocessing_setup(self) -> None:
92
- assert self._settings
93
86
  if self._settings.start_method == "thread":
94
87
  return
95
88
 
@@ -141,10 +134,13 @@ class Backend:
141
134
  def ensure_launched(self) -> None:
142
135
  """Launch backend worker if not running."""
143
136
  if self._service:
144
- self.interface = self._service.make_interface(self._mailbox)
137
+ assert self._settings.run_id
138
+ self.interface = self._service.make_interface(
139
+ self._mailbox,
140
+ stream_id=self._settings.run_id,
141
+ )
145
142
  return
146
143
 
147
- assert self._settings
148
144
  settings = self._settings.model_copy()
149
145
  settings.x_log_level = self._log_level or logging.DEBUG
150
146
 
@@ -10,7 +10,6 @@ InterfaceRelay: Responses are routed to a relay queue (not matching uuids)
10
10
 
11
11
  import gzip
12
12
  import logging
13
- import os
14
13
  import time
15
14
  from abc import abstractmethod
16
15
  from pathlib import Path
@@ -91,18 +90,11 @@ def file_enum_to_policy(enum: "pb.FilesItem.PolicyType.V") -> "PolicyName":
91
90
 
92
91
 
93
92
  class InterfaceBase:
94
- _run: Optional["Run"]
95
93
  _drop: bool
96
94
 
97
95
  def __init__(self) -> None:
98
- self._run = None
99
96
  self._drop = False
100
97
 
101
- def _hack_set_run(self, run: "Run") -> None:
102
- self._run = run
103
- current_pid = os.getpid()
104
- self._run._set_iface_pid(current_pid)
105
-
106
98
  def publish_header(self) -> None:
107
99
  header = pb.HeaderRecord()
108
100
  self._publish_header(header)
@@ -235,7 +227,12 @@ class InterfaceBase:
235
227
  update.value_json = json.dumps(v)
236
228
  return summary
237
229
 
238
- def _summary_encode(self, value: Any, path_from_root: str) -> dict:
230
+ def _summary_encode(
231
+ self,
232
+ value: Any,
233
+ path_from_root: str,
234
+ run: "Run",
235
+ ) -> dict:
239
236
  """Normalize, compress, and encode sub-objects for backend storage.
240
237
 
241
238
  value: Object to encode.
@@ -253,12 +250,14 @@ class InterfaceBase:
253
250
  json_value = {}
254
251
  for key, value in value.items(): # noqa: B020
255
252
  json_value[key] = self._summary_encode(
256
- value, path_from_root + "." + key
253
+ value,
254
+ path_from_root + "." + key,
255
+ run=run,
257
256
  )
258
257
  return json_value
259
258
  else:
260
259
  friendly_value, converted = json_friendly(
261
- val_to_json(self._run, path_from_root, value, namespace="summary")
260
+ val_to_json(run, path_from_root, value, namespace="summary")
262
261
  )
263
262
  json_value, compressed = maybe_compress_summary(
264
263
  friendly_value, get_h5_typename(value)
@@ -270,7 +269,11 @@ class InterfaceBase:
270
269
 
271
270
  return json_value
272
271
 
273
- def _make_summary(self, summary_record: sr.SummaryRecord) -> pb.SummaryRecord:
272
+ def _make_summary(
273
+ self,
274
+ summary_record: sr.SummaryRecord,
275
+ run: "Run",
276
+ ) -> pb.SummaryRecord:
274
277
  pb_summary_record = pb.SummaryRecord()
275
278
 
276
279
  for item in summary_record.update:
@@ -285,7 +288,11 @@ class InterfaceBase:
285
288
  pb_summary_item.key = item.key[0]
286
289
 
287
290
  path_from_root = ".".join(item.key)
288
- json_value = self._summary_encode(item.value, path_from_root)
291
+ json_value = self._summary_encode(
292
+ item.value,
293
+ path_from_root,
294
+ run=run,
295
+ )
289
296
  json_value, _ = json_friendly(json_value) # type: ignore
290
297
 
291
298
  pb_summary_item.value_json = json.dumps(
@@ -306,8 +313,12 @@ class InterfaceBase:
306
313
 
307
314
  return pb_summary_record
308
315
 
309
- def publish_summary(self, summary_record: sr.SummaryRecord) -> None:
310
- pb_summary_record = self._make_summary(summary_record)
316
+ def publish_summary(
317
+ self,
318
+ run: "Run",
319
+ summary_record: sr.SummaryRecord,
320
+ ) -> None:
321
+ pb_summary_record = self._make_summary(summary_record, run=run)
311
322
  self._publish_summary(pb_summary_record)
312
323
 
313
324
  @abstractmethod
@@ -653,15 +664,13 @@ class InterfaceBase:
653
664
 
654
665
  def publish_partial_history(
655
666
  self,
667
+ run: "Run",
656
668
  data: dict,
657
669
  user_step: int,
658
670
  step: Optional[int] = None,
659
671
  flush: Optional[bool] = None,
660
672
  publish_step: bool = True,
661
- run: Optional["Run"] = None,
662
673
  ) -> None:
663
- run = run or self._run
664
-
665
674
  data = history_dict_to_json(run, data, step=user_step, ignore_copy_err=True)
666
675
  data.pop("_step", None)
667
676
 
@@ -688,12 +697,11 @@ class InterfaceBase:
688
697
 
689
698
  def publish_history(
690
699
  self,
700
+ run: "Run",
691
701
  data: dict,
692
702
  step: Optional[int] = None,
693
- run: Optional["Run"] = None,
694
703
  publish_step: bool = True,
695
704
  ) -> None:
696
- run = run or self._run
697
705
  data = history_dict_to_json(run, data, step=step)
698
706
  history = pb.HistoryRecord()
699
707
  if publish_step:
@@ -16,32 +16,28 @@ from .router_sock import MessageSockRouter
16
16
  if TYPE_CHECKING:
17
17
  from wandb.proto import wandb_internal_pb2 as pb
18
18
 
19
- from ..wandb_run import Run
20
-
21
19
 
22
20
  logger = logging.getLogger("wandb")
23
21
 
24
22
 
25
23
  class InterfaceSock(InterfaceShared):
26
- _stream_id: Optional[str]
27
- _sock_client: SockClient
28
24
  _mailbox: Mailbox
29
25
 
30
- def __init__(self, sock_client: SockClient, mailbox: Mailbox) -> None:
26
+ def __init__(
27
+ self,
28
+ sock_client: SockClient,
29
+ mailbox: Mailbox,
30
+ stream_id: str,
31
+ ) -> None:
31
32
  # _sock_client is used when abstract method _init_router() is called by constructor
32
33
  self._sock_client = sock_client
33
34
  super().__init__(mailbox=mailbox)
34
35
  self._process_check = False
35
- self._stream_id = None
36
+ self._stream_id = stream_id
36
37
 
37
38
  def _init_router(self) -> None:
38
39
  self._router = MessageSockRouter(self._sock_client, mailbox=self._mailbox)
39
40
 
40
- def _hack_set_run(self, run: "Run") -> None:
41
- super()._hack_set_run(run)
42
- assert run._settings.run_id
43
- self._stream_id = run._settings.run_id
44
-
45
41
  def _assign(self, record: Any) -> None:
46
42
  assert self._stream_id
47
43
  record._info.stream_id = self._stream_id
@@ -454,7 +454,9 @@ class TBEventConsumer:
454
454
  row[chart.spec.table_key] = chart.table
455
455
 
456
456
  self._tbwatcher._interface.publish_history(
457
- row, run=self._internal_run, publish_step=False
457
+ self._internal_run,
458
+ row,
459
+ publish_step=False,
458
460
  )
459
461
 
460
462
 
@@ -124,9 +124,9 @@ class ServiceConnection:
124
124
  self._torn_down = False
125
125
  self._cleanup = cleanup
126
126
 
127
- def make_interface(self, mailbox: Mailbox) -> InterfaceBase:
127
+ def make_interface(self, mailbox: Mailbox, stream_id: str) -> InterfaceBase:
128
128
  """Returns an interface for communicating with the service."""
129
- return InterfaceSock(self._client, mailbox)
129
+ return InterfaceSock(self._client, mailbox, stream_id=stream_id)
130
130
 
131
131
  def send_record(self, record: pb.Record) -> None:
132
132
  """Sends data to the service."""
wandb/sdk/wandb_init.py CHANGED
@@ -11,6 +11,7 @@ For more on using `wandb.init()`, including code snippets, check out our
11
11
  from __future__ import annotations
12
12
 
13
13
  import copy
14
+ import dataclasses
14
15
  import json
15
16
  import logging
16
17
  import os
@@ -105,16 +106,40 @@ def _handle_launch_config(settings: Settings) -> dict[str, Any]:
105
106
  return launch_run_config
106
107
 
107
108
 
108
- class _WandbInit:
109
- _init_telemetry_obj: telemetry.TelemetryRecord
109
+ @dataclasses.dataclass(frozen=True)
110
+ class _ConfigParts:
111
+ base_no_artifacts: dict[str, Any]
112
+ """The run config passed to `init()` minus any artifact-valued keys."""
113
+
114
+ sweep_no_artifacts: dict[str, Any]
115
+ """The config loaded as part of a sweep minus any artifact-valued keys."""
116
+
117
+ launch_no_artifacts: dict[str, Any]
118
+ """The config loaded as part of Launch minus any artifact-valued keys."""
119
+
120
+ artifacts: dict[str, Any]
121
+ """Artifact keys removed from config dictionaries.
122
+
123
+ Due to implementation details of how a Run is constructed,
124
+ artifacts must be inserted into its config after initialization.
125
+ """
126
+
110
127
 
111
- def __init__(self, wl: wandb_setup._WandbSetup) -> None:
128
+ class _WandbInit:
129
+ def __init__(
130
+ self,
131
+ wl: wandb_setup._WandbSetup,
132
+ telemetry: telemetry.TelemetryRecord,
133
+ ) -> None:
112
134
  self._wl = wl
113
135
 
136
+ self._telemetry = telemetry
137
+ """Telemetry gathered before creating a run.
138
+
139
+ After the run is created, `telemetry.context()` is used instead.
140
+ """
141
+
114
142
  self.kwargs = None
115
- self.sweep_config: dict[str, Any] = {}
116
- self.launch_config: dict[str, Any] = {}
117
- self.config: dict[str, Any] = {}
118
143
  self.run: Run | None = None
119
144
  self.backend: Backend | None = None
120
145
 
@@ -122,8 +147,6 @@ class _WandbInit:
122
147
  self.notebook: wandb.jupyter.Notebook | None = None # type: ignore
123
148
  self.printer = printer.new_printer()
124
149
 
125
- self._init_telemetry_obj = telemetry.TelemetryRecord()
126
-
127
150
  self.deprecated_features_used: dict[str, str] = dict()
128
151
 
129
152
  @property
@@ -229,7 +252,7 @@ class _WandbInit:
229
252
  warn("run_id", init_settings.run_id)
230
253
  init_settings.run_id = None
231
254
 
232
- def compute_run_settings(self, init_settings: Settings) -> Settings:
255
+ def make_run_settings(self, init_settings: Settings) -> Settings:
233
256
  """Returns the run's settings.
234
257
 
235
258
  Args:
@@ -250,8 +273,7 @@ class _WandbInit:
250
273
  if not settings.sagemaker_disable and sagemaker.is_using_sagemaker():
251
274
  if sagemaker.set_run_id(settings):
252
275
  self._logger.info("set run ID and group based on SageMaker")
253
- with telemetry.context(obj=self._init_telemetry_obj) as tel:
254
- tel.feature.sagemaker = True
276
+ self._telemetry.feature.sagemaker = True
255
277
 
256
278
  # get status of code saving before applying user settings
257
279
  save_code_pre_user_settings = settings.save_code
@@ -355,25 +377,24 @@ class _WandbInit:
355
377
  run_id=settings.run_id,
356
378
  )
357
379
 
358
- def setup(
380
+ def make_run_config(
359
381
  self,
360
382
  settings: Settings,
361
383
  config: dict | str | None = None,
362
384
  config_exclude_keys: list[str] | None = None,
363
385
  config_include_keys: list[str] | None = None,
364
- monitor_gym: bool | None = None,
365
- ) -> None:
366
- """Compute the run's config and some telemetry."""
367
- with telemetry.context(obj=self._init_telemetry_obj) as tel:
368
- if config is not None:
369
- tel.feature.set_init_config = True
370
- if settings.run_name is not None:
371
- tel.feature.set_init_name = True
372
- if settings.run_id is not None:
373
- tel.feature.set_init_id = True
374
- if settings.run_tags is not None:
375
- tel.feature.set_init_tags = True
386
+ ) -> _ConfigParts:
387
+ """Construct the run's config.
388
+
389
+ Args:
390
+ settings: The run's finalized settings.
391
+ config: The config passed to `init()`.
392
+ config_exclude_keys: Deprecated. Keys to filter out from `config`.
393
+ config_include_keys: Deprecated. Keys to include from `config`.
376
394
 
395
+ Returns:
396
+ Initial values for the run's config.
397
+ """
377
398
  # TODO: remove this once officially deprecated
378
399
  if config_exclude_keys:
379
400
  self.deprecated_features_used["config_exclude_keys"] = (
@@ -389,49 +410,51 @@ class _WandbInit:
389
410
  exclude=config_exclude_keys,
390
411
  )
391
412
 
392
- # Construct the run's config.
393
- self.config = dict()
394
- self.init_artifact_config: dict[str, Any] = dict()
413
+ result = _ConfigParts(
414
+ base_no_artifacts=dict(),
415
+ sweep_no_artifacts=dict(),
416
+ launch_no_artifacts=dict(),
417
+ artifacts=dict(),
418
+ )
395
419
 
396
420
  if not settings.sagemaker_disable and sagemaker.is_using_sagemaker():
397
421
  sagemaker_config = sagemaker.parse_sm_config()
398
- self._split_artifacts_from_config(sagemaker_config, self.config)
399
-
400
- with telemetry.context(obj=self._init_telemetry_obj) as tel:
401
- tel.feature.sagemaker = True
422
+ self._split_artifacts_from_config(
423
+ sagemaker_config,
424
+ config_target=result.base_no_artifacts,
425
+ artifacts=result.artifacts,
426
+ )
427
+ self._telemetry.feature.sagemaker = True
402
428
 
403
429
  if self._wl._config:
404
- self._split_artifacts_from_config(self._wl._config, self.config)
430
+ self._split_artifacts_from_config(
431
+ self._wl._config,
432
+ config_target=result.base_no_artifacts,
433
+ artifacts=result.artifacts,
434
+ )
405
435
 
406
436
  if config and isinstance(config, dict):
407
- self._split_artifacts_from_config(config, self.config)
408
-
409
- self.sweep_config = dict()
410
- sweep_config = self._wl._sweep_config or dict()
411
- if sweep_config:
412
- self._split_artifacts_from_config(sweep_config, self.sweep_config)
413
-
414
- if monitor_gym and len(wandb.patched["gym"]) == 0:
415
- wandb.gym.monitor() # type: ignore
416
-
417
- if wandb.patched["tensorboard"]:
418
- with telemetry.context(obj=self._init_telemetry_obj) as tel:
419
- tel.feature.tensorboard_patch = True
437
+ self._split_artifacts_from_config(
438
+ config,
439
+ config_target=result.base_no_artifacts,
440
+ artifacts=result.artifacts,
441
+ )
420
442
 
421
- if settings.sync_tensorboard:
422
- if len(wandb.patched["tensorboard"]) == 0:
423
- wandb.tensorboard.patch() # type: ignore
424
- with telemetry.context(obj=self._init_telemetry_obj) as tel:
425
- tel.feature.tensorboard_sync = True
443
+ if self._wl._sweep_config:
444
+ self._split_artifacts_from_config(
445
+ self._wl._sweep_config,
446
+ config_target=result.sweep_no_artifacts,
447
+ artifacts=result.artifacts,
448
+ )
426
449
 
427
- if not settings._noop:
428
- self._log_setup(settings)
450
+ if launch_config := _handle_launch_config(settings):
451
+ self._split_artifacts_from_config(
452
+ launch_config,
453
+ config_target=result.launch_no_artifacts,
454
+ artifacts=result.artifacts,
455
+ )
429
456
 
430
- if settings._jupyter:
431
- self._jupyter_setup(settings)
432
- launch_config = _handle_launch_config(settings)
433
- if launch_config:
434
- self._split_artifacts_from_config(launch_config, self.launch_config)
457
+ return result
435
458
 
436
459
  def teardown(self) -> None:
437
460
  # TODO: currently this is only called on failed wandb.init attempts
@@ -441,11 +464,14 @@ class _WandbInit:
441
464
  hook.call()
442
465
 
443
466
  def _split_artifacts_from_config(
444
- self, config_source: dict, config_target: dict
467
+ self,
468
+ config_source: dict,
469
+ config_target: dict,
470
+ artifacts: dict,
445
471
  ) -> None:
446
472
  for k, v in config_source.items():
447
473
  if _is_artifact_representation(v):
448
- self.init_artifact_config[k] = v
474
+ artifacts[k] = v
449
475
  else:
450
476
  config_target.setdefault(k, v)
451
477
 
@@ -540,7 +566,7 @@ class _WandbInit:
540
566
  ipython.display_pub.publish = ipython.display_pub._orig_publish
541
567
  del ipython.display_pub._orig_publish
542
568
 
543
- def _jupyter_setup(self, settings: Settings) -> None:
569
+ def monkeypatch_ipython(self, settings: Settings) -> None:
544
570
  """Add hooks, and session history saving."""
545
571
  self.notebook = wandb.jupyter.Notebook(settings) # type: ignore
546
572
  ipython = self.notebook.shell
@@ -566,7 +592,7 @@ class _WandbInit:
566
592
 
567
593
  ipython.display_pub.publish = publish
568
594
 
569
- def _log_setup(self, settings: Settings) -> None:
595
+ def setup_run_log_directory(self, settings: Settings) -> None:
570
596
  """Set up logging from settings."""
571
597
  filesystem.mkdir_exists_ok(os.path.dirname(settings.log_user))
572
598
  filesystem.mkdir_exists_ok(os.path.dirname(settings.log_internal))
@@ -598,15 +624,18 @@ class _WandbInit:
598
624
  self._logger.info(f"Logging user logs to {settings.log_user}")
599
625
  self._logger.info(f"Logging internal logs to {settings.log_internal}")
600
626
 
601
- def _make_run_disabled(self) -> Run:
627
+ def make_disabled_run(self, config: _ConfigParts) -> Run:
602
628
  """Returns a Run-like object where all methods are no-ops.
603
629
 
604
- This method is used when wandb.init(mode="disabled") is called or WANDB_MODE=disabled
605
- is set. It creates a Run object that mimics the behavior of a normal Run but doesn't
630
+ This method is used when the `mode` setting is set to "disabled", such as
631
+ by wandb.init(mode="disabled") or by setting the WANDB_MODE environment
632
+ variable to "disabled".
633
+
634
+ It creates a Run object that mimics the behavior of a normal Run but doesn't
606
635
  communicate with the W&B servers.
607
636
 
608
- The returned Run object has all expected attributes and methods, but they are
609
- no-op versions that don't perform any actual logging or communication.
637
+ The returned Run object has all expected attributes and methods, but they
638
+ are no-op versions that don't perform any actual logging or communication.
610
639
  """
611
640
  run_id = runid.generate_id()
612
641
  drun = Run(
@@ -624,8 +653,8 @@ class _WandbInit:
624
653
  )
625
654
  # config, summary, and metadata objects
626
655
  drun._config = wandb.sdk.wandb_config.Config()
627
- drun._config.update(self.sweep_config)
628
- drun._config.update(self.config)
656
+ drun._config.update(config.sweep_no_artifacts)
657
+ drun._config.update(config.base_no_artifacts)
629
658
  drun.summary = SummaryDisabled() # type: ignore
630
659
  drun._Run__metadata = wandb.sdk.wandb_metadata.Metadata()
631
660
 
@@ -710,18 +739,17 @@ class _WandbInit:
710
739
  percent_done = handle.percent_done
711
740
  self.printer.progress_update(line, percent_done=percent_done)
712
741
 
713
- def init(self, settings: Settings) -> Run: # noqa: C901
742
+ def init(self, settings: Settings, config: _ConfigParts) -> Run: # noqa: C901
714
743
  self._logger.info("calling init triggers")
715
744
  trigger.call("on_init")
716
745
 
717
746
  assert self._wl is not None
718
747
 
719
748
  self._logger.info(
720
- f"wandb.init called with sweep_config: {self.sweep_config}\nconfig: {self.config}"
749
+ f"wandb.init called with sweep_config: {config.sweep_no_artifacts}"
750
+ f"\nconfig: {config.base_no_artifacts}"
721
751
  )
722
752
 
723
- if settings._noop:
724
- return self._make_run_disabled()
725
753
  if (
726
754
  settings.reinit or (settings._jupyter and settings.reinit is not False)
727
755
  ) and len(self._wl._global_run_stack) > 0:
@@ -738,8 +766,11 @@ class _WandbInit:
738
766
  latest_run.finish()
739
767
  elif wandb.run is not None and os.getpid() == wandb.run._init_pid:
740
768
  self._logger.info("wandb.init() called when a run is still active")
769
+
770
+ # NOTE: Updates telemetry on the pre-existing run.
741
771
  with telemetry.context() as tel:
742
772
  tel.feature.init_return_run = True
773
+
743
774
  return wandb.run
744
775
 
745
776
  self._logger.info("starting backend")
@@ -765,14 +796,14 @@ class _WandbInit:
765
796
 
766
797
  # resuming needs access to the server, check server_status()?
767
798
  run = Run(
768
- config=self.config,
799
+ config=config.base_no_artifacts,
769
800
  settings=settings,
770
- sweep_config=self.sweep_config,
771
- launch_config=self.launch_config,
801
+ sweep_config=config.sweep_no_artifacts,
802
+ launch_config=config.launch_no_artifacts,
772
803
  )
773
804
 
774
805
  # Populate initial telemetry
775
- with telemetry.context(run=run, obj=self._init_telemetry_obj) as tel:
806
+ with telemetry.context(run=run, obj=self._telemetry) as tel:
776
807
  tel.cli_version = wandb.__version__
777
808
  tel.python_version = platform.python_version()
778
809
  tel.platform = f"{platform.system()}-{platform.machine()}".lower()
@@ -860,7 +891,6 @@ class _WandbInit:
860
891
  run._set_backend(backend)
861
892
  run._set_teardown_hooks(self._teardown_hooks)
862
893
 
863
- backend._hack_set_run(run)
864
894
  assert backend.interface
865
895
  mailbox.enable_keepalive()
866
896
  backend.interface.publish_header()
@@ -873,15 +903,11 @@ class _WandbInit:
873
903
 
874
904
  run_result: pb.RunUpdateResult | None = None
875
905
 
876
- if settings._offline:
877
- with telemetry.context(run=run) as tel:
878
- tel.feature.offline = True
879
-
880
- if settings.resume:
881
- wandb.termwarn(
882
- "`resume` will be ignored since W&B syncing is set to `offline`. "
883
- f"Starting a new run with run id {run.id}."
884
- )
906
+ if settings._offline and settings.resume:
907
+ wandb.termwarn(
908
+ "`resume` will be ignored since W&B syncing is set to `offline`. "
909
+ f"Starting a new run with run id {run.id}."
910
+ )
885
911
  error: wandb.Error | None = None
886
912
 
887
913
  timeout = settings.init_timeout
@@ -970,7 +996,7 @@ class _WandbInit:
970
996
  # put artifacts in run config here
971
997
  # since doing so earlier will cause an error
972
998
  # as the run is not upserted
973
- for k, v in self.init_artifact_config.items():
999
+ for k, v in config.artifacts.items():
974
1000
  run.config.update({k: v}, allow_val_change=True)
975
1001
  job_artifact = run._launch_artifact_mapping.get(
976
1002
  wandb.util.LAUNCH_JOB_ARTIFACT_SLOT_NAME
@@ -1042,7 +1068,6 @@ def _attach(
1042
1068
  run._init(settings=settings)
1043
1069
  run._set_library(_wl)
1044
1070
  run._set_backend(backend)
1045
- backend._hack_set_run(run)
1046
1071
  assert backend.interface
1047
1072
 
1048
1073
  mailbox.enable_keepalive()
@@ -1062,6 +1087,26 @@ def _attach(
1062
1087
  return run
1063
1088
 
1064
1089
 
1090
+ def _monkeypatch_openai_gym() -> None:
1091
+ """Patch OpenAI gym to log to the global `wandb.run`."""
1092
+ if len(wandb.patched["gym"]) > 0:
1093
+ return
1094
+
1095
+ from wandb.integration import gym
1096
+
1097
+ gym.monitor()
1098
+
1099
+
1100
+ def _monkeypatch_tensorboard() -> None:
1101
+ """Patch TensorBoard to log to the global `wandb.run`."""
1102
+ if len(wandb.patched["tensorboard"]) > 0:
1103
+ return
1104
+
1105
+ from wandb.integration import tensorboard as tb_module
1106
+
1107
+ tb_module.patch()
1108
+
1109
+
1065
1110
  def init( # noqa: C901
1066
1111
  entity: str | None = None,
1067
1112
  project: str | None = None,
@@ -1299,6 +1344,8 @@ def init( # noqa: C901
1299
1344
  """
1300
1345
  wandb._assert_is_user_process() # type: ignore
1301
1346
 
1347
+ init_telemetry = telemetry.TelemetryRecord()
1348
+
1302
1349
  init_settings = Settings()
1303
1350
  if isinstance(settings, dict):
1304
1351
  init_settings = Settings(**settings)
@@ -1346,26 +1393,55 @@ def init( # noqa: C901
1346
1393
  if resume_from is not None:
1347
1394
  init_settings.resume_from = resume_from # type: ignore
1348
1395
 
1396
+ if config is not None:
1397
+ init_telemetry.feature.set_init_config = True
1398
+
1349
1399
  wl: wandb_setup._WandbSetup | None = None
1350
1400
 
1351
1401
  try:
1352
1402
  wl = wandb.setup()
1353
1403
 
1354
- wi = _WandbInit(wl)
1404
+ wi = _WandbInit(wl, init_telemetry)
1355
1405
 
1356
1406
  wi.maybe_login(init_settings)
1357
- run_settings = wi.compute_run_settings(init_settings)
1407
+ run_settings = wi.make_run_settings(init_settings)
1408
+
1409
+ if run_settings.run_id is not None:
1410
+ init_telemetry.feature.set_init_id = True
1411
+ if run_settings.run_name is not None:
1412
+ init_telemetry.feature.set_init_name = True
1413
+ if run_settings.run_tags is not None:
1414
+ init_telemetry.feature.set_init_tags = True
1415
+ if run_settings._offline:
1416
+ init_telemetry.feature.offline = True
1417
+
1358
1418
  wi.set_run_id(run_settings)
1359
1419
 
1360
- wi.setup(
1420
+ run_config = wi.make_run_config(
1361
1421
  settings=run_settings,
1362
1422
  config=config,
1363
1423
  config_exclude_keys=config_exclude_keys,
1364
1424
  config_include_keys=config_include_keys,
1365
- monitor_gym=monitor_gym,
1366
1425
  )
1367
1426
 
1368
- return wi.init(run_settings)
1427
+ if run_settings._noop:
1428
+ return wi.make_disabled_run(run_config)
1429
+
1430
+ wi.setup_run_log_directory(run_settings)
1431
+ if run_settings._jupyter:
1432
+ wi.monkeypatch_ipython(run_settings)
1433
+
1434
+ if monitor_gym:
1435
+ _monkeypatch_openai_gym()
1436
+
1437
+ if wandb.patched["tensorboard"]:
1438
+ # NOTE: The user may have called the patch function directly.
1439
+ init_telemetry.feature.tensorboard_patch = True
1440
+ if run_settings.sync_tensorboard:
1441
+ _monkeypatch_tensorboard()
1442
+ init_telemetry.feature.tensorboard_sync = True
1443
+
1444
+ return wi.init(run_settings, run_config)
1369
1445
 
1370
1446
  except KeyboardInterrupt as e:
1371
1447
  if wl:
wandb/sdk/wandb_run.py CHANGED
@@ -547,8 +547,6 @@ class Run:
547
547
 
548
548
  _init_pid: int
549
549
  _attach_pid: int
550
- _iface_pid: int | None
551
- _iface_port: int | None
552
550
 
553
551
  _attach_id: str | None
554
552
  _is_attached: bool
@@ -707,10 +705,6 @@ class Run:
707
705
  if launch_trace_id:
708
706
  self._config[wandb_key]["launch_trace_id"] = launch_trace_id
709
707
 
710
- # interface pid and port configured when backend is configured (See _hack_set_run)
711
- # TODO: using pid isn't the best for windows as pid reuse can happen more often than unix
712
- self._iface_pid = None
713
- self._iface_port = None
714
708
  self._attach_id = None
715
709
  self._is_attached = False
716
710
  self._is_finished = False
@@ -721,12 +715,6 @@ class Run:
721
715
  if not self._settings.x_disable_service:
722
716
  self._attach_id = self._settings.run_id
723
717
 
724
- def _set_iface_pid(self, iface_pid: int) -> None:
725
- self._iface_pid = iface_pid
726
-
727
- def _set_iface_port(self, iface_port: int) -> None:
728
- self._iface_port = iface_port
729
-
730
718
  def _handle_launch_artifact_overrides(self) -> None:
731
719
  if self._settings.launch and (os.environ.get("WANDB_ARTIFACTS") is not None):
732
720
  try:
@@ -1327,7 +1315,7 @@ class Run:
1327
1315
  with telemetry.context(run=self) as tel:
1328
1316
  tel.feature.set_summary = True
1329
1317
  if self._backend and self._backend.interface:
1330
- self._backend.interface.publish_summary(summary_record)
1318
+ self._backend.interface.publish_summary(self, summary_record)
1331
1319
 
1332
1320
  def _on_progress_get_summary(self, handle: MailboxProgress) -> None:
1333
1321
  pass
@@ -1442,6 +1430,7 @@ class Run:
1442
1430
 
1443
1431
  not_using_tensorboard = len(wandb.patched["tensorboard"]) == 0
1444
1432
  self._backend.interface.publish_partial_history(
1433
+ self,
1445
1434
  data,
1446
1435
  user_step=self._step,
1447
1436
  step=step,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wandb
3
- Version: 0.19.3
3
+ Version: 0.19.4
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
@@ -1,6 +1,6 @@
1
1
  package_readme.md,sha256=XGlaq8rMFcoBb21rCr2d5qeSM79ZI4WslLmXqRimTGQ,4395
2
- wandb/__init__.py,sha256=6bfGa-Ok_bVjLxHb6qRt7k5PAIsE9vs23fgzlEMhcMo,7234
3
- wandb/__init__.pyi,sha256=hFQcodH9-eV92-XyoD3DAzwe4MWuOEWnNTRMgGAb1EA,48229
2
+ wandb/__init__.py,sha256=ZVmzUcZ962nd9h4fpfBUnSwssMkS66UsZK4HWbsahsQ,7234
3
+ wandb/__init__.pyi,sha256=Ai5J-LqGFb0ETs856XKkahDDnv9WCSsZWR4dCCJNkLc,48229
4
4
  wandb/__main__.py,sha256=uHY6OxHT6RtTH34zC8_UC1GsCTkndgbdsHXv-t7dOMI,67
5
5
  wandb/_globals.py,sha256=NwgYSB2tl2Z5t1Tn1xpLtfkcmPy_dF01u-xxgnCbzoc,721
6
6
  wandb/data_types.py,sha256=4zXwzPgwHuMjyxzNbVQZANnHM0FoqEOn1jlLvnkdPAc,2342
@@ -49,8 +49,8 @@ wandb/apis/reports/v1/__init__.py,sha256=nxs3gJlbvVc0b_pV5DUypk1amMkRSq_M-xUw7qP
49
49
  wandb/apis/reports/v2/__init__.py,sha256=vlF0ZRVHS-Qd7mBllcZri-gWE0TtjhiDSA6h5XPRVLU,271
50
50
  wandb/apis/workspaces/__init__.py,sha256=XsF4ccNRUCTmI9ANjlrj_dYU1OcOi5N354Wg2Qkkaqo,273
51
51
  wandb/beta/workflows.py,sha256=ENy_lmIyn3k_FHdD2ZO8HBaXdeoLrsPVbEfL_KYW8Ps,10527
52
- wandb/bin/gpu_stats.exe,sha256=zzNA92_Q82V4yzPtsVFSo6pO4pbeaIox8u6lmftIPNc,8208896
53
- wandb/bin/wandb-core,sha256=DKT4UChpAdWjIZI6-0sEHCciXO4eAvsGN2ingeOU5SE,47137792
52
+ wandb/bin/gpu_stats.exe,sha256=wJKvNTStr6_5syn7XCyxEm03CGMM3uxCgUYWATxCncg,8364032
53
+ wandb/bin/wandb-core,sha256=fHT6yuKqrxNZYFLwZHenr4CeNeyrnaMgrVQB3jJfNkU,47137792
54
54
  wandb/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  wandb/cli/beta.py,sha256=_wbqhk6J2yjnNuVQAGlYbYZ9-j0sFE73zMIXVkQYlXA,5619
56
56
  wandb/cli/cli.py,sha256=a3aXT1tAMH5v0_BW1r4Bo6AT2YZ7e1hTz6K4ZnEcz9k,95536
@@ -204,13 +204,13 @@ wandb/sdk/__init__.py,sha256=6lzqckLZUs7GpFZIwpgxGJwJDvhuyo-XCQnSrtZqE1c,850
204
204
  wandb/sdk/wandb_alerts.py,sha256=f6ygzuXTDT0IvMLcKlgatmXKx5HMPsm8sYwvPocl0Js,205
205
205
  wandb/sdk/wandb_config.py,sha256=TxH6SD8DCfFU3yhmy03yewXQ4Gvgn3avZ0qbwpZJKt8,11178
206
206
  wandb/sdk/wandb_helper.py,sha256=kc5Ib648to7cEGEwAuJus07rsHudL1Ux7FWPPSRnKy8,1878
207
- wandb/sdk/wandb_init.py,sha256=qP1D1HuG0WoEdR0FU34HQA6qNM9i6IPGhV0JeSJef8Q,57867
207
+ wandb/sdk/wandb_init.py,sha256=5gyJeRd4ya9nSd7LzdqmGnOOO_5ePwZASI1cyuZv-7M,59836
208
208
  wandb/sdk/wandb_login.py,sha256=OupHHFIAg-EwP-3jp67rR_dlcFoVd8Qu_J1gtC26p18,11305
209
209
  wandb/sdk/wandb_metadata.py,sha256=kcF7MhTM4Cnlw8d5rSp-WzKNDfy2NtUhd8FFuB2i3pY,20658
210
210
  wandb/sdk/wandb_metric.py,sha256=oI6NQJJ_tyZ3YcnO0Xg5avDVr3Dh6tpTvHuPEMda30A,3378
211
211
  wandb/sdk/wandb_require.py,sha256=06Mgqdd5r5u4UUpIU3T2JIAn0elkFfaWRtNwyaLu8jc,3044
212
212
  wandb/sdk/wandb_require_helpers.py,sha256=4PUXmVw86_XaKj3rn20s5DAjBMO8L0m26KqnTLaQJNc,1375
213
- wandb/sdk/wandb_run.py,sha256=p9uPY-nE6EFhBUsl0jU1xxNijeTSL_1yliDPThfHZNk,159829
213
+ wandb/sdk/wandb_run.py,sha256=N32b7eT3kn2wO4ERJ5-3KrWHLAzK6k5leWyharlrFX0,159349
214
214
  wandb/sdk/wandb_settings.py,sha256=vSRyZPLORsM7Gca-pgQEUNNyo5uNXbm07wkbiNZHGoU,48543
215
215
  wandb/sdk/wandb_setup.py,sha256=44YSZ2o_uFGN9cRQOcbwq25EFI5VC8EJOyOLOXGxubs,13417
216
216
  wandb/sdk/wandb_summary.py,sha256=eEV3hvHhbc1XQus0MUqFmvhXCzd3SPjvVVVg_fVZ1QM,4686
@@ -249,7 +249,7 @@ wandb/sdk/artifacts/storage_policies/__init__.py,sha256=G8quZY8-eynVVXmNBbiLGfUo
249
249
  wandb/sdk/artifacts/storage_policies/register.py,sha256=azfof-H42vIuvndo9hvN4cZ3UXWG-nZcrFQ1QFL9oIc,50
250
250
  wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py,sha256=4nQNkDfG_2Uq4ANOYZIaQVcPsZsUmhs6c2MdQBOqMSI,14380
251
251
  wandb/sdk/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
252
- wandb/sdk/backend/backend.py,sha256=1o4zCs8suzQsAzBhd-hWp0zTH8lzZ7hqZ-JT8Own1H0,7834
252
+ wandb/sdk/backend/backend.py,sha256=7xJvW0ZpIQkI1TkeO-K9b5kHIypQMjp8WNpS_8Nu0wM,7709
253
253
  wandb/sdk/data_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
254
254
  wandb/sdk/data_types/_dtypes.py,sha256=JYi0cqF2Lska0JF_gndyz-FfcS09Ozu735WIarU8HKo,31010
255
255
  wandb/sdk/data_types/_private.py,sha256=vpatnpMcuWUtpSI-dY-YXs9zmffAgEXCoViIGS4yVT8,309
@@ -280,11 +280,11 @@ wandb/sdk/integration_utils/auto_logging.py,sha256=143120qDwFrh7qsojhMvT4CddgHes
280
280
  wandb/sdk/integration_utils/data_logging.py,sha256=DtSEZB-TzxQKhjm9IXNxDeOAUZyDXGYrfRvVh2Cju54,20008
281
281
  wandb/sdk/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
282
282
  wandb/sdk/interface/constants.py,sha256=GKZ2hATTBCt7yU8kloafZR34yLChiI36O_VtxZZbQyg,64
283
- wandb/sdk/interface/interface.py,sha256=MfoJjLujxflUBIGQdfqaAGGLCxlk9PhguLIDgnm1QmE,37636
283
+ wandb/sdk/interface/interface.py,sha256=PW31FI6U735n55mLKHm0WAJ1EgUqQv56nSEvwEguyPo,37594
284
284
  wandb/sdk/interface/interface_queue.py,sha256=RG_FfjVt3arcNSRFXCiwjkleUkpUYJZfUdp5oV-68Is,1753
285
285
  wandb/sdk/interface/interface_relay.py,sha256=R28bIhebZux7PwFeJmO8wOOkm_uCjmQ2T5lKKy3sL-Y,1567
286
286
  wandb/sdk/interface/interface_shared.py,sha256=f3UH-u_5bI2t_J8EJw1JN8RuTQadLtg8rQafpZlWhq0,21838
287
- wandb/sdk/interface/interface_sock.py,sha256=Tle-Pu5Z1ECQnm47ra1DQ0mdxkqMmJ2atknvTlmqfnE,2063
287
+ wandb/sdk/interface/interface_sock.py,sha256=IQCznD4EH5tcGWPg0XUvFa67-N8AzUiqf6TEoXmQxfc,1859
288
288
  wandb/sdk/interface/message_future.py,sha256=SlMF8psfA1AW3iVuB_PVLo41bC4U-AAvek1Zlh31mdE,712
289
289
  wandb/sdk/interface/message_future_poll.py,sha256=8a7GcNtCyohHUnxoJ5sx6RRQa2Vu_hjiBqeQ-UQ0RTc,1460
290
290
  wandb/sdk/interface/router.py,sha256=ur0vqGqzUi-nafh-4KVHOk71DaqiHJnIWFUQjttQ724,3534
@@ -310,7 +310,7 @@ wandb/sdk/internal/sample.py,sha256=tVNzrLatHr8P1kbVzw8bWhLpqZxx7zdm4fgv7rv2hO0,
310
310
  wandb/sdk/internal/sender.py,sha256=0ZJ6iGjU1UYwCyQVNzdHU-wyNWbRYvSAZdzfF3RLl74,67023
311
311
  wandb/sdk/internal/sender_config.py,sha256=LZaQY4_bzb9003D2j6aynGqv-Mr2GwUGcNmnQrhJOJw,6964
312
312
  wandb/sdk/internal/settings_static.py,sha256=jGEP14enXA2A9YiA_EyFzn7OhVGavyuTbr-eVEl8tBk,3767
313
- wandb/sdk/internal/tb_watcher.py,sha256=FmfAW3TAdYkacgKrlasPnfTI0opOa5XKEC9ld9eg69k,19236
313
+ wandb/sdk/internal/tb_watcher.py,sha256=KRIGZA8gF3guuZm1ioUo8Uy4iOX2OZ3I_MkDW_znh-k,19259
314
314
  wandb/sdk/internal/thread_local_settings.py,sha256=f6uzjTa0d6twZ9aFHzdUlUqv3gy6AnbOZoWYm95DxKA,545
315
315
  wandb/sdk/internal/writer.py,sha256=D2vQe-2yEfUuGwqYxMvu7iZgo3rpsjUxCgrH8YwNSeA,7471
316
316
  wandb/sdk/internal/system/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -415,7 +415,7 @@ wandb/sdk/lib/retry.py,sha256=2h1AB9xzNth93ADYJ2g1zlUcmjcEd-bp6UoZAvs5_Yg,10381
415
415
  wandb/sdk/lib/run_moment.py,sha256=Bb45CL_loDGwoGkg550lFomDOKJog9CVpaZhqdmNgcc,2265
416
416
  wandb/sdk/lib/runid.py,sha256=rHYRTjJu8gTZ6Aoo0WZ5jQfAtNLXQo6aY6PD-i3Fh6I,404
417
417
  wandb/sdk/lib/server.py,sha256=ArqpZ-N7EWqNhkXE9E3IDe4N40oJBNwGXhHpI5yGcTs,1148
418
- wandb/sdk/lib/service_connection.py,sha256=NlyOKENZz6m4sSue76NjzYuuMcW0CHzh4BGyamICYvs,6683
418
+ wandb/sdk/lib/service_connection.py,sha256=BKEgLzFczBcrt0igWS7rf7StE4LcbREZPMuOAJsT7po,6720
419
419
  wandb/sdk/lib/service_token.py,sha256=GC8onzk44uphA5l5hHs8RZmQ7Auo7-Dx-KhCWOFYH9g,2565
420
420
  wandb/sdk/lib/sock_client.py,sha256=K0gIbhFkW7qkPuPDx-AG4cd08HnDCz9Bp_M99zI34BA,10641
421
421
  wandb/sdk/lib/sparkline.py,sha256=CivfHHGPrbnnacpfjsoYUrCtX6Xz7AHoybEeOuWeEI0,1407
@@ -817,8 +817,8 @@ wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/importlib2.py,sha256=kX0rdVmTDL
817
817
  wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/platform.py,sha256=7fpTDfxSYvSRtHvyog-plRdLR5A6k1QVY_AL0gVhhPM,1563
818
818
  wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/unicode_paths.py,sha256=xzyQmuba2gns1s3Qemu9SXaKV5zeTL3TP9--xOi541g,2254
819
819
  wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/win32stat.py,sha256=R48kuuEIi7XzCJBJ6Xo7v6DJIbOP5EwcsWaPf5Axn_g,3951
820
- wandb-0.19.3.dist-info/METADATA,sha256=e19bSAZtoEB6YW4CHgz1zBmQbw5uKTC88F-KZgBokLg,10282
821
- wandb-0.19.3.dist-info/WHEEL,sha256=F7luzo77gHneG2SMTaD6iIlqNT8oVz1uotn5Zigp4o8,89
822
- wandb-0.19.3.dist-info/entry_points.txt,sha256=v4FCOZ9gW7Pc6KLsmgQqpCiKTrA1wh2XHmNf-NUP1-I,67
823
- wandb-0.19.3.dist-info/licenses/LICENSE,sha256=rJ7p1acqNi17WFOAJ9WqsImXZtKZDA3i_gzdDVGRuFQ,1102
824
- wandb-0.19.3.dist-info/RECORD,,
820
+ wandb-0.19.4.dist-info/METADATA,sha256=10dH1p2yO5OYXIgbRV3xBDgpAsx6LOzXK0OfzrBIsBs,10282
821
+ wandb-0.19.4.dist-info/WHEEL,sha256=F7luzo77gHneG2SMTaD6iIlqNT8oVz1uotn5Zigp4o8,89
822
+ wandb-0.19.4.dist-info/entry_points.txt,sha256=v4FCOZ9gW7Pc6KLsmgQqpCiKTrA1wh2XHmNf-NUP1-I,67
823
+ wandb-0.19.4.dist-info/licenses/LICENSE,sha256=rJ7p1acqNi17WFOAJ9WqsImXZtKZDA3i_gzdDVGRuFQ,1102
824
+ wandb-0.19.4.dist-info/RECORD,,
File without changes