wandb 0.19.0rc1__py3-none-win32.whl → 0.19.1rc1__py3-none-win32.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. wandb/__init__.py +1 -1
  2. wandb/__init__.pyi +211 -209
  3. wandb/apis/attrs.py +15 -4
  4. wandb/apis/public/api.py +8 -4
  5. wandb/apis/public/files.py +65 -12
  6. wandb/apis/public/runs.py +52 -7
  7. wandb/apis/public/sweeps.py +1 -1
  8. wandb/bin/gpu_stats.exe +0 -0
  9. wandb/bin/wandb-core +0 -0
  10. wandb/cli/cli.py +2 -1
  11. wandb/env.py +1 -1
  12. wandb/errors/term.py +60 -1
  13. wandb/integration/keras/callbacks/tables_builder.py +3 -1
  14. wandb/integration/kfp/kfp_patch.py +25 -15
  15. wandb/integration/lightning/fabric/logger.py +3 -1
  16. wandb/integration/tensorboard/monkeypatch.py +3 -2
  17. wandb/jupyter.py +4 -5
  18. wandb/plot/bar.py +5 -6
  19. wandb/plot/histogram.py +1 -1
  20. wandb/plot/line_series.py +3 -3
  21. wandb/plot/pr_curve.py +7 -3
  22. wandb/plot/scatter.py +2 -1
  23. wandb/proto/v3/wandb_settings_pb2.py +25 -15
  24. wandb/proto/v4/wandb_settings_pb2.py +17 -15
  25. wandb/proto/v5/wandb_settings_pb2.py +17 -15
  26. wandb/sdk/artifacts/_validators.py +1 -3
  27. wandb/sdk/artifacts/artifact_manifest_entry.py +1 -1
  28. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +12 -2
  29. wandb/sdk/data_types/helper_types/image_mask.py +8 -2
  30. wandb/sdk/data_types/histogram.py +3 -3
  31. wandb/sdk/data_types/image.py +3 -1
  32. wandb/sdk/interface/interface.py +34 -5
  33. wandb/sdk/interface/interface_sock.py +2 -2
  34. wandb/sdk/internal/file_stream.py +4 -1
  35. wandb/sdk/internal/sender.py +4 -1
  36. wandb/sdk/internal/settings_static.py +17 -4
  37. wandb/sdk/launch/utils.py +1 -0
  38. wandb/sdk/lib/ipython.py +5 -27
  39. wandb/sdk/lib/printer.py +33 -20
  40. wandb/sdk/lib/sparkline.py +1 -2
  41. wandb/sdk/wandb_config.py +2 -2
  42. wandb/sdk/wandb_init.py +236 -243
  43. wandb/sdk/wandb_run.py +172 -231
  44. wandb/sdk/wandb_settings.py +103 -14
  45. {wandb-0.19.0rc1.dist-info → wandb-0.19.1rc1.dist-info}/METADATA +1 -1
  46. {wandb-0.19.0rc1.dist-info → wandb-0.19.1rc1.dist-info}/RECORD +49 -49
  47. {wandb-0.19.0rc1.dist-info → wandb-0.19.1rc1.dist-info}/WHEEL +0 -0
  48. {wandb-0.19.0rc1.dist-info → wandb-0.19.1rc1.dist-info}/entry_points.txt +0 -0
  49. {wandb-0.19.0rc1.dist-info → wandb-0.19.1rc1.dist-info}/licenses/LICENSE +0 -0
wandb/sdk/wandb_init.py CHANGED
@@ -18,7 +18,7 @@ import platform
18
18
  import sys
19
19
  import tempfile
20
20
  import time
21
- from typing import TYPE_CHECKING, Any, Sequence
21
+ from typing import TYPE_CHECKING, Any, Literal, Sequence
22
22
 
23
23
  if sys.version_info >= (3, 11):
24
24
  from typing import Self
@@ -38,7 +38,7 @@ from wandb.util import _is_artifact_representation
38
38
 
39
39
  from . import wandb_login, wandb_setup
40
40
  from .backend.backend import Backend
41
- from .lib import SummaryDisabled, filesystem, ipython, module, printer, telemetry
41
+ from .lib import SummaryDisabled, filesystem, module, printer, telemetry
42
42
  from .lib.deprecate import Deprecated, deprecate
43
43
  from .lib.mailbox import Mailbox, MailboxProgress
44
44
  from .wandb_helper import parse_config
@@ -538,8 +538,19 @@ class _WandbInit:
538
538
  The returned Run object has all expected attributes and methods, but they are
539
539
  no-op versions that don't perform any actual logging or communication.
540
540
  """
541
+ run_id = runid.generate_id()
541
542
  drun = Run(
542
- settings=Settings(mode="disabled", x_files_dir=tempfile.gettempdir())
543
+ settings=Settings(
544
+ mode="disabled",
545
+ x_files_dir=tempfile.gettempdir(),
546
+ run_id=run_id,
547
+ run_tags=tuple(),
548
+ run_notes=None,
549
+ run_group=None,
550
+ run_name=f"dummy-{run_id}",
551
+ project="dummy",
552
+ entity="dummy",
553
+ )
543
554
  )
544
555
  # config and summary objects
545
556
  drun._config = wandb.sdk.wandb_config.Config()
@@ -600,19 +611,13 @@ class _WandbInit:
600
611
 
601
612
  drun.log_artifact = _ChainableNoOpField()
602
613
  # attributes
603
- drun._backend = None
604
- drun._step = 0
605
- drun._attach_id = None
606
- drun._run_obj = None
607
- drun._run_id = runid.generate_id()
608
- drun._name = "dummy-" + drun.id
609
- drun._project = "dummy"
610
- drun._entity = "dummy"
611
- drun._tags = tuple()
612
- drun._notes = None
613
- drun._group = None
614
614
  drun._start_time = time.time()
615
615
  drun._starting_step = 0
616
+ drun._step = 0
617
+ drun._attach_id = None
618
+ drun._backend = None
619
+
620
+ # set the disabled run as the global run
616
621
  module.set_global(
617
622
  run=drun,
618
623
  config=drun.config,
@@ -648,34 +653,21 @@ class _WandbInit:
648
653
 
649
654
  if self.settings._noop:
650
655
  return self._make_run_disabled()
651
- if self.settings.reinit or (
652
- self.settings._jupyter and self.settings.reinit is not False
653
- ):
654
- if len(self._wl._global_run_stack) > 0:
655
- if len(self._wl._global_run_stack) > 1:
656
- wandb.termwarn(
657
- "If you want to track multiple runs concurrently in wandb, "
658
- "you should use multi-processing not threads"
659
- )
660
-
661
- latest_run = self._wl._global_run_stack[-1]
662
-
663
- logger.info(
664
- f"re-initializing run, found existing run on stack: {latest_run._run_id}"
656
+ if (
657
+ self.settings.reinit
658
+ or (self.settings._jupyter and self.settings.reinit is not False)
659
+ ) and len(self._wl._global_run_stack) > 0:
660
+ if len(self._wl._global_run_stack) > 1:
661
+ wandb.termwarn(
662
+ "Launching multiple wandb runs using Python's threading"
663
+ " module is not well-supported."
664
+ " Please use multiprocessing instead."
665
+ " Finishing previous run before initializing another."
665
666
  )
666
667
 
667
- jupyter = self.settings._jupyter
668
- if jupyter and not self.settings.silent:
669
- ipython.display_html(
670
- f"Finishing last run (ID:{latest_run._run_id}) before initializing another..."
671
- )
672
-
673
- latest_run.finish()
674
-
675
- if jupyter and not self.settings.silent:
676
- ipython.display_html(
677
- f"Successfully finished last run (ID:{latest_run._run_id}). Initializing new run:<br/>"
678
- )
668
+ latest_run = self._wl._global_run_stack[-1]
669
+ logger.info(f"found existing run on stack: {latest_run._run_id}")
670
+ latest_run.finish()
679
671
  elif isinstance(wandb.run, Run):
680
672
  service = self._wl.service
681
673
  # We shouldn't return a stale global run if we are in a new pid
@@ -890,9 +882,8 @@ class _WandbInit:
890
882
  )
891
883
 
892
884
  assert backend.interface
893
- assert run._run_obj
894
885
 
895
- run_start_handle = backend.interface.deliver_run_start(run._run_obj)
886
+ run_start_handle = backend.interface.deliver_run_start(run)
896
887
  # TODO: add progress to let user know we are doing something
897
888
  run_start_result = run_start_handle.wait(timeout=30)
898
889
  if run_start_result is None:
@@ -1011,237 +1002,239 @@ def _attach(
1011
1002
 
1012
1003
 
1013
1004
  def init( # noqa: C901
1014
- job_type: str | None = None,
1015
- dir: StrPath | None = None,
1016
- config: dict | str | None = None,
1017
- project: str | None = None,
1018
1005
  entity: str | None = None,
1019
- reinit: bool | None = None,
1020
- tags: Sequence[str] | None = None,
1021
- group: str | None = None,
1006
+ project: str | None = None,
1007
+ dir: StrPath | None = None,
1008
+ id: str | None = None,
1022
1009
  name: str | None = None,
1023
1010
  notes: str | None = None,
1011
+ tags: Sequence[str] | None = None,
1012
+ config: dict[str, Any] | str | None = None,
1024
1013
  config_exclude_keys: list[str] | None = None,
1025
1014
  config_include_keys: list[str] | None = None,
1026
- anonymous: str | None = None,
1027
- mode: str | None = None,
1028
1015
  allow_val_change: bool | None = None,
1029
- resume: bool | str | None = None,
1016
+ group: str | None = None,
1017
+ job_type: str | None = None,
1018
+ mode: Literal["online", "offline", "disabled"] | None = None,
1030
1019
  force: bool | None = None,
1031
- tensorboard: bool | None = None, # alias for sync_tensorboard
1020
+ anonymous: Literal["never", "allow", "must"] | None = None,
1021
+ reinit: bool | None = None,
1022
+ resume: bool | Literal["allow", "never", "must", "auto"] | None = None,
1023
+ resume_from: str | None = None,
1024
+ fork_from: str | None = None,
1025
+ save_code: bool | None = None,
1026
+ tensorboard: bool | None = None,
1032
1027
  sync_tensorboard: bool | None = None,
1033
1028
  monitor_gym: bool | None = None,
1034
- save_code: bool | None = None,
1035
- id: str | None = None,
1036
- fork_from: str | None = None,
1037
- resume_from: str | None = None,
1038
1029
  settings: Settings | dict[str, Any] | None = None,
1039
1030
  ) -> Run:
1040
1031
  r"""Start a new run to track and log to W&B.
1041
1032
 
1042
- In an ML training pipeline, you could add `wandb.init()`
1043
- to the beginning of your training script as well as your evaluation
1044
- script, and each piece would be tracked as a run in W&B.
1033
+ In an ML training pipeline, you could add `wandb.init()` to the beginning of
1034
+ your training script as well as your evaluation script, and each piece would
1035
+ be tracked as a run in W&B.
1045
1036
 
1046
1037
  `wandb.init()` spawns a new background process to log data to a run, and it
1047
- also syncs data to wandb.ai by default, so you can see live visualizations.
1048
-
1049
- Call `wandb.init()` to start a run before logging data with `wandb.log()`:
1050
- <!--yeadoc-test:init-method-log-->
1051
- ```python
1052
- import wandb
1038
+ also syncs data to https://wandb.ai by default, so you can see your results
1039
+ in real-time.
1053
1040
 
1054
- wandb.init()
1055
- # ... calculate metrics, generate media
1056
- wandb.log({"accuracy": 0.9})
1057
- ```
1041
+ Call `wandb.init()` to start a run before logging data with `wandb.log()`.
1042
+ When you're done logging data, call `wandb.finish()` to end the run. If you
1043
+ don't call `wandb.finish()`, the run will end when your script exits.
1058
1044
 
1059
- `wandb.init()` returns a run object, and you can also access the run object
1060
- via `wandb.run`:
1061
- <!--yeadoc-test:init-and-assert-global-->
1062
- ```python
1063
- import wandb
1045
+ For more on using `wandb.init()`, including detailed examples, check out our
1046
+ [guide and FAQs](https://docs.wandb.ai/guides/track/launch).
1064
1047
 
1065
- run = wandb.init()
1048
+ Examples:
1049
+ ### Explicitly set the entity and project and choose a name for the run:
1066
1050
 
1067
- assert run is wandb.run
1068
- ```
1051
+ ```python
1052
+ import wandb
1069
1053
 
1070
- At the end of your script, we will automatically call `wandb.finish` to
1071
- finalize and cleanup the run. However, if you call `wandb.init` from a
1072
- child process, you must explicitly call `wandb.finish` at the end of the
1073
- child process.
1054
+ run = wandb.init(
1055
+ entity="geoff",
1056
+ project="capsules",
1057
+ name="experiment-2021-10-31",
1058
+ )
1074
1059
 
1075
- For more on using `wandb.init()`, including detailed examples, check out our
1076
- [guide and FAQs](https://docs.wandb.ai/guides/track/launch).
1060
+ # ... your training code here ...
1077
1061
 
1078
- Args:
1079
- project: (str, optional) The name of the project where you're sending
1080
- the new run. If the project is not specified, we will try to infer
1081
- the project name from git root or the current program file. If we
1082
- can't infer the project name, we will default to `"uncategorized"`.
1083
- entity: (str, optional) An entity is a username or team name where
1084
- you're sending runs. This entity must exist before you can send runs
1085
- there, so make sure to create your account or team in the UI before
1086
- starting to log runs.
1087
- If you don't specify an entity, the run will be sent to your default
1088
- entity. Change your default entity
1089
- in [your settings](https://wandb.ai/settings) under "default location
1090
- to create new projects".
1091
- config: (dict, argparse, absl.flags, str, optional)
1092
- This sets `wandb.config`, a dictionary-like object for saving inputs
1093
- to your job, like hyperparameters for a model or settings for a data
1094
- preprocessing job. The config will show up in a table in the UI that
1095
- you can use to group, filter, and sort runs. Keys should not contain
1096
- `.` in their names, and values should be under 10 MB.
1097
- If dict, argparse or absl.flags: will load the key value pairs into
1098
- the `wandb.config` object.
1099
- If str: will look for a yaml file by that name, and load config from
1100
- that file into the `wandb.config` object.
1101
- save_code: (bool, optional) Turn this on to save the main script or
1102
- notebook to W&B. This is valuable for improving experiment
1103
- reproducibility and to diff code across experiments in the UI. By
1104
- default this is off, but you can flip the default behavior to on
1105
- in [your settings page](https://wandb.ai/settings).
1106
- group: (str, optional) Specify a group to organize individual runs into
1107
- a larger experiment. For example, you might be doing cross
1108
- validation, or you might have multiple jobs that train and evaluate
1109
- a model against different test sets. Group gives you a way to
1110
- organize runs together into a larger whole, and you can toggle this
1111
- on and off in the UI. For more details, see our
1112
- [guide to grouping runs](https://docs.wandb.com/guides/runs/grouping).
1113
- job_type: (str, optional) Specify the type of run, which is useful when
1114
- you're grouping runs together into larger experiments using group.
1115
- For example, you might have multiple jobs in a group, with job types
1116
- like train and eval. Setting this makes it easy to filter and group
1117
- similar runs together in the UI so you can compare apples to apples.
1118
- tags: (list, optional) A list of strings, which will populate the list
1119
- of tags on this run in the UI. Tags are useful for organizing runs
1120
- together, or applying temporary labels like "baseline" or
1121
- "production". It's easy to add and remove tags in the UI, or filter
1122
- down to just runs with a specific tag.
1123
- If you are resuming a run, its tags will be overwritten by the tags
1124
- you pass to `wandb.init()`. If you want to add tags to a resumed run
1125
- without overwriting its existing tags, use `run.tags += ["new_tag"]`
1126
- after `wandb.init()`.
1127
- name: (str, optional) A short display name for this run, which is how
1128
- you'll identify this run in the UI. By default, we generate a random
1129
- two-word name that lets you easily cross-reference runs from the
1130
- table to charts. Keeping these run names short makes the chart
1131
- legends and tables easier to read. If you're looking for a place to
1132
- save your hyperparameters, we recommend saving those in config.
1133
- notes: (str, optional) A longer description of the run, like a `-m` commit
1134
- message in git. This helps you remember what you were doing when you
1135
- ran this run.
1136
- dir: (str or pathlib.Path, optional) An absolute path to a directory where
1137
- metadata will be stored. When you call `download()` on an artifact,
1138
- this is the directory where downloaded files will be saved. By default,
1139
- this is the `./wandb` directory.
1140
- resume: (bool, str, optional) Sets the resuming behavior. Options:
1141
- `"allow"`, `"must"`, `"never"`, `"auto"` or `None`. Defaults to `None`.
1142
- Cases:
1143
- - `None` (default): If the new run has the same ID as a previous run,
1144
- this run overwrites that data.
1145
- - `"auto"` (or `True`): if the previous run on this machine crashed,
1146
- automatically resume it. Otherwise, start a new run.
1147
- - `"allow"`: if id is set with `init(id="UNIQUE_ID")` or
1148
- `WANDB_RUN_ID="UNIQUE_ID"` and it is identical to a previous run,
1149
- wandb will automatically resume the run with that id. Otherwise,
1150
- wandb will start a new run.
1151
- - `"never"`: if id is set with `init(id="UNIQUE_ID")` or
1152
- `WANDB_RUN_ID="UNIQUE_ID"` and it is identical to a previous run,
1153
- wandb will crash.
1154
- - `"must"`: if id is set with `init(id="UNIQUE_ID")` or
1155
- `WANDB_RUN_ID="UNIQUE_ID"` and it is identical to a previous run,
1156
- wandb will automatically resume the run with the id. Otherwise,
1157
- wandb will crash.
1158
- See [our guide to resuming runs](https://docs.wandb.com/guides/runs/resuming)
1159
- for more.
1160
- reinit: (bool, optional) Allow multiple `wandb.init()` calls in the same
1161
- process. (default: `False`)
1162
- config_exclude_keys: (list, optional) string keys to exclude from
1163
- `wandb.config`.
1164
- config_include_keys: (list, optional) string keys to include in
1165
- `wandb.config`.
1166
- anonymous: (str, optional) Controls anonymous data logging. Options:
1167
- - `"never"` (default): requires you to link your W&B account before
1168
- tracking the run, so you don't accidentally create an anonymous
1169
- run.
1170
- - `"allow"`: lets a logged-in user track runs with their account, but
1171
- lets someone who is running the script without a W&B account see
1172
- the charts in the UI.
1173
- - `"must"`: sends the run to an anonymous account instead of to a
1174
- signed-up user account.
1175
- mode: (str, optional) Can be `"online"`, `"offline"` or `"disabled"`. Defaults to
1176
- online.
1177
- allow_val_change: (bool, optional) Whether to allow config values to
1178
- change after setting the keys once. By default, we throw an exception
1179
- if a config value is overwritten. If you want to track something
1180
- like a varying learning rate at multiple times during training, use
1181
- `wandb.log()` instead. (default: `False` in scripts, `True` in Jupyter)
1182
- force: (bool, optional) If `True`, this crashes the script if a user isn't
1183
- logged in to W&B. If `False`, this will let the script run in offline
1184
- mode if a user isn't logged in to W&B. (default: `False`)
1185
- sync_tensorboard: (bool, optional) Synchronize wandb logs from tensorboard or
1186
- tensorboardX and save the relevant events file. (default: `False`)
1187
- tensorboard: (bool, optional) Alias for `sync_tensorboard`, deprecated.
1188
- monitor_gym: (bool, optional) Automatically log videos of environment when
1189
- using OpenAI Gym. (default: `False`)
1190
- See [our guide to this integration](https://docs.wandb.com/guides/integrations/openai-gym).
1191
- id: (str, optional) A unique ID for this run, used for resuming. It must
1192
- be unique in the project, and if you delete a run you can't reuse
1193
- the ID. Use the `name` field for a short descriptive name, or `config`
1194
- for saving hyperparameters to compare across runs. The ID cannot
1195
- contain the following special characters: `/\#?%:`.
1196
- See [our guide to resuming runs](https://docs.wandb.com/guides/runs/resuming).
1197
- fork_from: (str, optional) A string with the format `{run_id}?_step={step}` describing
1198
- a moment in a previous run to fork a new run from. Creates a new run that picks up
1199
- logging history from the specified run at the specified moment. The target run must
1200
- be in the current project. Example: `fork_from="my-run-id?_step=1234"`.
1201
- resume_from: (str, optional) A string with the format `{run_id}?_step={step}` describing
1202
- a moment in a previous run to resume a run from. This allows users to truncate
1203
- the history logged to a run at an intermediate step and resume logging from that step.
1204
- It uses run forking under the hood. The target run must be in the
1205
- current project. Example: `resume_from="my-run-id?_step=1234"`.
1206
- settings: (dict, wandb.Settings, optional) Settings to use for this run. (default: None)
1062
+ run.finish()
1063
+ ```
1207
1064
 
1208
- Examples:
1209
- ### Set where the run is logged
1065
+ ### Add metadata about the run using the `config` argument:
1210
1066
 
1211
- You can change where the run is logged, just like changing
1212
- the organization, repository, and branch in git:
1213
- ```python
1214
- import wandb
1067
+ ```python
1068
+ import wandb
1215
1069
 
1216
- user = "geoff"
1217
- project = "capsules"
1218
- display_name = "experiment-2021-10-31"
1070
+ config = {"lr": 0.01, "batch_size": 32}
1071
+ with wandb.init(config=config) as run:
1072
+ run.config.update({"architecture": "resnet", "depth": 34})
1219
1073
 
1220
- wandb.init(entity=user, project=project, name=display_name)
1221
- ```
1074
+ # ... your training code here ...
1075
+ ```
1222
1076
 
1223
- ### Add metadata about the run to the config
1077
+ Note that you can use `wandb.init()` as a context manager to automatically
1078
+ call `wandb.finish()` at the end of the block.
1224
1079
 
1225
- Pass a dictionary-style object as the `config` keyword argument to add
1226
- metadata, like hyperparameters, to your run.
1227
- <!--yeadoc-test:init-set-config-->
1228
- ```python
1229
- import wandb
1080
+ Args:
1081
+ entity: The username or team name under which the runs will be logged.
1082
+ The entity must already exist, so ensure you’ve created your account
1083
+ or team in the UI before starting to log runs. If not specified, the
1084
+ run will default your defualt entity. To change the default entity,
1085
+ go to [your settings](https://wandb.ai/settings) and update the
1086
+ "Default location to create new projects" under "Default team".
1087
+ project: The name of the project under which this run will be logged.
1088
+ If not specified, we use a heuristic to infer the project name based
1089
+ on the system, such as checking the git root or the current program
1090
+ file. If we can't infer the project name, the project will default to
1091
+ `"uncategorized"`.
1092
+ dir: An absolute path to the directory where metadata and downloaded
1093
+ files will be stored. When calling `download()` on an artifact, files
1094
+ will be saved to this directory. If not specified, this defaults to
1095
+ the `./wandb` directory.
1096
+ id: A unique identifier for this run, used for resuming. It must be unique
1097
+ within the project and cannot be reused once a run is deleted. The
1098
+ identifier must not contain any of the following special characters:
1099
+ `/ \ # ? % :`. For a short descriptive name, use the `name` field,
1100
+ or for saving hyperparameters to compare across runs, use `config`.
1101
+ name: A short display name for this run, which appears in the UI to help
1102
+ you identify it. By default, we generate a random two-word name
1103
+ allowing easy cross-reference runs from table to charts. Keeping these
1104
+ run names brief enhances readability in chart legends and tables. For
1105
+ saving hyperparameters, we recommend using the `config` field.
1106
+ notes: A detailed description of the run, similar to a commit message in
1107
+ Git. Use this argument to capture any context or details that may
1108
+ help you recall the purpose or setup of this run in the future.
1109
+ tags: A list of tags to label this run in the UI. Tags are helpful for
1110
+ organizing runs or adding temporary identifiers like "baseline" or
1111
+ "production." You can easily add, remove tags, or filter by tags in
1112
+ the UI.
1113
+ If resuming a run, the tags provided here will replace any existing
1114
+ tags. To add tags to a resumed run without overwriting the current
1115
+ tags, use `run.tags += ["new_tag"]` after calling `run = wandb.init()`.
1116
+ config: Sets `wandb.config`, a dictionary-like object for storing input
1117
+ parameters to your run, such as model hyperparameters or data
1118
+ preprocessing settings.
1119
+ The config appears in the UI in an overview page, allowing you to
1120
+ group, filter, and sort runs based on these parameters.
1121
+ Keys should not contain periods (`.`), and values should be
1122
+ smaller than 10 MB.
1123
+ If a dictionary, `argparse.Namespace`, or `absl.flags.FLAGS` is
1124
+ provided, the key-value pairs will be loaded directly into
1125
+ `wandb.config`.
1126
+ If a string is provided, it is interpreted as a path to a YAML file,
1127
+ from which configuration values will be loaded into `wandb.config`.
1128
+ config_exclude_keys: A list of specific keys to exclude from `wandb.config`.
1129
+ config_include_keys: A list of specific keys to include in `wandb.config`.
1130
+ allow_val_change: Controls whether config values can be modified after their
1131
+ initial set. By default, an exception is raised if a config value is
1132
+ overwritten. For tracking variables that change during training, such as
1133
+ a learning rate, consider using `wandb.log()` instead. By default, this
1134
+ is `False` in scripts and `True` in Notebook environments.
1135
+ group: Specify a group name to organize individual runs as part of a larger
1136
+ experiment. This is useful for cases like cross-validation or running
1137
+ multiple jobs that train and evaluate a model on different test sets.
1138
+ Grouping allows you to manage related runs collectively in the UI,
1139
+ making it easy to toggle and review results as a unified experiment.
1140
+ For more information, refer to our
1141
+ [guide to grouping runs](https://docs.wandb.com/guides/runs/grouping).
1142
+ job_type: Specify the type of run, especially helpful when organizing runs
1143
+ within a group as part of a larger experiment. For example, in a group,
1144
+ you might label runs with job types such as "train" and "eval".
1145
+ Defining job types enables you to easily filter and group similar runs
1146
+ in the UI, facilitating direct comparisons.
1147
+ mode: Specifies how run data is managed, with the following options:
1148
+ - `"online"` (default): Enables live syncing with W&B when a network
1149
+ connection is available, with real-time updates to visualizations.
1150
+ - `"offline"`: Suitable for air-gapped or offline environments; data
1151
+ is saved locally and can be synced later. Ensure the run folder
1152
+ is preserved to enable future syncing.
1153
+ - `"disabled"`: Disables all W&B functionality, making the run’s methods
1154
+ no-ops. Typically used in testing to bypass W&B operations.
1155
+ force: Determines if a W&B login is required to run the script. If `True`,
1156
+ the user must be logged in to W&B; otherwise, the script will not
1157
+ proceed. If `False` (default), the script can proceed without a login,
1158
+ switching to offline mode if the user is not logged in.
1159
+ anonymous: Specifies the level of control over anonymous data logging.
1160
+ Available options are:
1161
+ - `"never"` (default): Requires you to link your W&B account before
1162
+ tracking the run. This prevents unintentional creation of anonymous
1163
+ runs by ensuring each run is associated with an account.
1164
+ - `"allow"`: Enables a logged-in user to track runs with their account,
1165
+ but also allows someone running the script without a W&B account
1166
+ to view the charts and data in the UI.
1167
+ - `"must"`: Forces the run to be logged to an anonymous account, even
1168
+ if the user is logged in.
1169
+ reinit: Determines if multiple `wandb.init()` calls can start new runs
1170
+ within the same process. By default (`False`), if an active run
1171
+ exists, calling `wandb.init()` returns the existing run instead of
1172
+ creating a new one. When `reinit=True`, the active run is finished
1173
+ before a new run is initialized. In notebook environments, runs are
1174
+ reinitialized by default unless `reinit` is explicitly set to `False`.
1175
+ resume: Controls the behavior when resuming a run with the specified `id`.
1176
+ Available options are:
1177
+ - `"allow"`: If a run with the specified `id` exists, it will resume
1178
+ from the last step; otherwise, a new run will be created.
1179
+ - `"never"`: If a run with the specified `id` exists, an error will
1180
+ be raised. If no such run is found, a new run will be created.
1181
+ - `"must"`: If a run with the specified `id` exists, it will resume
1182
+ from the last step. If no run is found, an error will be raised.
1183
+ - `"auto"`: Automatically resumes the previous run if it crashed on
1184
+ this machine; otherwise, starts a new run.
1185
+ - `True`: Deprecated. Use `"auto"` instead.
1186
+ - `False`: Deprecated. Use the default behavior (leaving `resume`
1187
+ unset) to always start a new run.
1188
+ Note: If `resume` is set, `fork_from` and `resume_from` cannot be
1189
+ used. When `resume` is unset, the system will always start a new run.
1190
+ For more details, see our
1191
+ [guide to resuming runs](https://docs.wandb.com/guides/runs/resuming).
1192
+ resume_from: Specifies a moment in a previous run to resume a run from,
1193
+ using the format `{run_id}?_step={step}`. This allows users to truncate
1194
+ the history logged to a run at an intermediate step and resume logging
1195
+ from that step. The target run must be in the same project.
1196
+ If an `id` argument is also provided, the `resume_from` argument will
1197
+ take precedence.
1198
+ `resume`, `resume_from` and `fork_from` cannot be used together, only
1199
+ one of them can be used at a time.
1200
+ Note: This feature is in beta and may change in the future.
1201
+ fork_from: Specifies a point in a previous run from which to fork a new
1202
+ run, using the format `{id}?_step={step}`. This creates a new run that
1203
+ resumes logging from the specified step in the target run’s history.
1204
+ The target run must be part of the current project.
1205
+ If an `id` argument is also provided, it must be different from the
1206
+ `fork_from` argument, an error will be raised if they are the same.
1207
+ `resume`, `resume_from` and `fork_from` cannot be used together, only
1208
+ one of them can be used at a time.
1209
+ Note: This feature is in beta and may change in the future.
1210
+ save_code: Enables saving the main script or notebook to W&B, aiding in
1211
+ experiment reproducibility and allowing code comparisons across runs in
1212
+ the UI. By default, this is disabled, but you can change the default to
1213
+ enable on your [settings page](https://wandb.ai/settings).
1214
+ tensorboard: Deprecated. Use `sync_tensorboard` instead.
1215
+ sync_tensorboard: Enables automatic syncing of W&B logs from TensorBoard
1216
+ or TensorBoardX, saving relevant event files for viewing in the W&B UI.
1217
+ saving relevant event files for viewing in the W&B UI. (Default: `False`)
1218
+ monitor_gym: Enables automatic logging of videos of the environment when
1219
+ using OpenAI Gym. For additional details, see our
1220
+ [guide for gym integration](https://docs.wandb.com/guides/integrations/openai-gym).
1221
+ settings: Specifies a dictionary or `wandb.Settings` object with advanced
1222
+ settings for the run.
1230
1223
 
1231
- config = {"lr": 3e-4, "batch_size": 32}
1232
- config.update({"architecture": "resnet", "depth": 34})
1233
- wandb.init(config=config)
1234
- ```
1224
+ Returns:
1225
+ A `Run` object, which is a handle to the current run. Use this object
1226
+ to perform operations like logging data, saving files, and finishing
1227
+ the run. See the [Run API](https://docs.wandb.ai/ref/python/run) for
1228
+ more details.
1235
1229
 
1236
1230
  Raises:
1237
- Error: if some unknown or internal error happened during the run initialization.
1238
- AuthenticationError: if the user failed to provide valid credentials.
1239
- CommError: if there was a problem communicating with the WandB server.
1240
- UsageError: if the user provided invalid arguments.
1241
- KeyboardInterrupt: if user interrupts the run.
1242
-
1243
- Returns:
1244
- A `Run` object.
1231
+ Error: If some unknown or internal error happened during the run
1232
+ initialization.
1233
+ AuthenticationError: If the user failed to provide valid credentials.
1234
+ CommError: If there was a problem communicating with the W&B server.
1235
+ UsageError: If the user provided invalid arguments to the function.
1236
+ KeyboardInterrupt: If the user interrupts the run initialization process.
1237
+ If the user interrupts the run initialization process.
1245
1238
  """
1246
1239
  wandb._assert_is_user_process() # type: ignore
1247
1240
 
@@ -1317,4 +1310,4 @@ def init( # noqa: C901
1317
1310
  # Need to build delay into this sentry capture because our exit hooks
1318
1311
  # mess with sentry's ability to send out errors before the program ends.
1319
1312
  wandb._sentry.reraise(e)
1320
- raise AssertionError() # unreachable
1313
+ raise AssertionError() # should never get here