wandb 0.20.2rc20250616__py3-none-win32.whl → 0.21.1__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 +16 -14
- wandb/__init__.pyi +450 -472
- wandb/agents/pyagent.py +41 -12
- wandb/analytics/sentry.py +7 -2
- wandb/apis/importers/mlflow.py +1 -1
- wandb/apis/internal.py +3 -0
- wandb/apis/paginator.py +17 -4
- wandb/apis/public/__init__.py +1 -1
- wandb/apis/public/api.py +606 -359
- wandb/apis/public/artifacts.py +214 -16
- wandb/apis/public/automations.py +19 -3
- wandb/apis/public/files.py +177 -38
- wandb/apis/public/history.py +67 -15
- wandb/apis/public/integrations.py +25 -2
- wandb/apis/public/jobs.py +90 -2
- wandb/apis/public/projects.py +161 -69
- wandb/apis/public/query_generator.py +11 -1
- wandb/apis/public/registries/registries_search.py +7 -15
- wandb/apis/public/reports.py +147 -13
- wandb/apis/public/runs.py +315 -128
- wandb/apis/public/sweeps.py +222 -22
- wandb/apis/public/teams.py +41 -4
- wandb/apis/public/users.py +45 -4
- wandb/automations/__init__.py +10 -10
- wandb/automations/_filters/run_metrics.py +0 -2
- wandb/automations/_utils.py +0 -2
- wandb/automations/actions.py +0 -2
- wandb/automations/automations.py +0 -2
- wandb/automations/events.py +0 -2
- wandb/beta/workflows.py +66 -30
- wandb/bin/gpu_stats.exe +0 -0
- wandb/bin/wandb-core +0 -0
- wandb/cli/cli.py +80 -1
- wandb/env.py +8 -0
- wandb/errors/errors.py +4 -1
- wandb/integration/catboost/catboost.py +6 -2
- wandb/integration/kfp/kfp_patch.py +3 -1
- wandb/integration/lightning/fabric/logger.py +3 -4
- wandb/integration/metaflow/__init__.py +6 -0
- wandb/integration/metaflow/data_pandas.py +74 -0
- wandb/integration/metaflow/errors.py +13 -0
- wandb/integration/metaflow/metaflow.py +205 -190
- wandb/integration/openai/fine_tuning.py +1 -2
- wandb/integration/sb3/sb3.py +3 -3
- wandb/integration/ultralytics/callback.py +6 -2
- wandb/jupyter.py +5 -5
- wandb/plot/__init__.py +2 -0
- wandb/plot/bar.py +30 -29
- wandb/plot/confusion_matrix.py +75 -71
- wandb/plot/custom_chart.py +30 -7
- wandb/plot/histogram.py +26 -25
- wandb/plot/line.py +33 -32
- wandb/plot/line_series.py +100 -103
- wandb/plot/pr_curve.py +33 -32
- wandb/plot/roc_curve.py +38 -38
- wandb/plot/scatter.py +27 -27
- wandb/proto/v3/wandb_internal_pb2.py +366 -385
- wandb/proto/v3/wandb_settings_pb2.py +2 -2
- wandb/proto/v3/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v4/wandb_internal_pb2.py +352 -356
- wandb/proto/v4/wandb_settings_pb2.py +2 -2
- wandb/proto/v4/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v5/wandb_internal_pb2.py +352 -356
- wandb/proto/v5/wandb_settings_pb2.py +2 -2
- wandb/proto/v5/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v6/wandb_internal_pb2.py +352 -356
- wandb/proto/v6/wandb_settings_pb2.py +2 -2
- wandb/proto/v6/wandb_telemetry_pb2.py +4 -4
- wandb/proto/wandb_deprecated.py +6 -0
- wandb/sdk/artifacts/_generated/__init__.py +12 -1
- wandb/sdk/artifacts/_generated/input_types.py +20 -2
- wandb/sdk/artifacts/_generated/link_artifact.py +21 -0
- wandb/sdk/artifacts/_generated/operations.py +9 -0
- wandb/sdk/artifacts/_internal_artifact.py +19 -8
- wandb/sdk/artifacts/_validators.py +48 -2
- wandb/sdk/artifacts/artifact.py +269 -96
- wandb/sdk/data_types/audio.py +38 -10
- wandb/sdk/data_types/base_types/media.py +15 -63
- wandb/sdk/data_types/base_types/wb_value.py +6 -6
- wandb/sdk/data_types/graph.py +48 -14
- wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +1 -3
- wandb/sdk/data_types/helper_types/image_mask.py +1 -3
- wandb/sdk/data_types/histogram.py +34 -21
- wandb/sdk/data_types/html.py +35 -12
- wandb/sdk/data_types/image.py +104 -68
- wandb/sdk/data_types/molecule.py +32 -19
- wandb/sdk/data_types/object_3d.py +36 -17
- wandb/sdk/data_types/plotly.py +18 -5
- wandb/sdk/data_types/saved_model.py +7 -9
- wandb/sdk/data_types/table.py +99 -70
- wandb/sdk/data_types/trace_tree.py +12 -12
- wandb/sdk/data_types/video.py +53 -26
- wandb/sdk/integration_utils/auto_logging.py +2 -2
- wandb/sdk/interface/interface.py +8 -19
- wandb/sdk/interface/interface_shared.py +7 -16
- wandb/sdk/internal/datastore.py +18 -18
- wandb/sdk/internal/handler.py +3 -5
- wandb/sdk/internal/internal_api.py +60 -0
- wandb/sdk/internal/job_builder.py +6 -0
- wandb/sdk/internal/sender.py +23 -3
- wandb/sdk/internal/sender_config.py +9 -0
- wandb/sdk/launch/_project_spec.py +3 -3
- wandb/sdk/launch/agent/agent.py +11 -4
- wandb/sdk/launch/agent/job_status_tracker.py +3 -1
- wandb/sdk/launch/agent/run_queue_item_file_saver.py +2 -2
- wandb/sdk/launch/create_job.py +3 -1
- wandb/sdk/launch/inputs/internal.py +3 -4
- wandb/sdk/launch/inputs/schema.py +1 -0
- wandb/sdk/launch/runner/kubernetes_monitor.py +1 -0
- wandb/sdk/launch/runner/kubernetes_runner.py +328 -1
- wandb/sdk/launch/sweeps/scheduler.py +2 -3
- wandb/sdk/launch/utils.py +3 -3
- wandb/sdk/lib/asyncio_compat.py +3 -0
- wandb/sdk/lib/console_capture.py +66 -19
- wandb/sdk/lib/deprecate.py +1 -7
- wandb/sdk/lib/disabled.py +1 -1
- wandb/sdk/lib/hashutil.py +14 -1
- wandb/sdk/lib/module.py +7 -13
- wandb/sdk/lib/progress.py +0 -19
- wandb/sdk/lib/sock_client.py +0 -4
- wandb/sdk/wandb_init.py +67 -93
- wandb/sdk/wandb_login.py +18 -14
- wandb/sdk/wandb_metric.py +2 -0
- wandb/sdk/wandb_require.py +0 -1
- wandb/sdk/wandb_run.py +429 -527
- wandb/sdk/wandb_settings.py +364 -74
- wandb/sdk/wandb_setup.py +28 -28
- wandb/sdk/wandb_sweep.py +14 -13
- wandb/sdk/wandb_watch.py +4 -6
- wandb/sync/sync.py +10 -0
- wandb/util.py +57 -0
- wandb/wandb_run.py +1 -2
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/METADATA +1 -1
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/RECORD +137 -137
- wandb/sdk/wandb_metadata.py +0 -623
- wandb/vendor/pynvml/__init__.py +0 -0
- wandb/vendor/pynvml/pynvml.py +0 -4779
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/WHEEL +0 -0
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/entry_points.txt +0 -0
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/licenses/LICENSE +0 -0
wandb/__init__.pyi
CHANGED
@@ -12,20 +12,20 @@ For reference documentation, see https://docs.wandb.com/ref/python.
|
|
12
12
|
from __future__ import annotations
|
13
13
|
|
14
14
|
__all__ = (
|
15
|
-
"__version__",
|
15
|
+
"__version__", # doc:exclude
|
16
16
|
"init",
|
17
17
|
"finish",
|
18
18
|
"setup",
|
19
19
|
"login",
|
20
|
-
"save",
|
20
|
+
"save", # doc:exclude
|
21
21
|
"sweep",
|
22
22
|
"controller",
|
23
23
|
"agent",
|
24
|
-
"config",
|
25
|
-
"log",
|
26
|
-
"summary",
|
24
|
+
"config", # doc:exclude
|
25
|
+
"log", # doc:exclude
|
26
|
+
"summary", # doc:exclude
|
27
27
|
"Api",
|
28
|
-
"Graph",
|
28
|
+
"Graph", # doc:exclude
|
29
29
|
"Image",
|
30
30
|
"Plotly",
|
31
31
|
"Video",
|
@@ -36,26 +36,27 @@ __all__ = (
|
|
36
36
|
"Object3D",
|
37
37
|
"Molecule",
|
38
38
|
"Histogram",
|
39
|
-
"ArtifactTTL",
|
40
|
-
"log_artifact",
|
41
|
-
"use_artifact",
|
42
|
-
"log_model",
|
43
|
-
"use_model",
|
44
|
-
"link_model",
|
45
|
-
"define_metric",
|
46
|
-
"Error",
|
47
|
-
"termsetup",
|
48
|
-
"termlog",
|
49
|
-
"termerror",
|
50
|
-
"termwarn",
|
39
|
+
"ArtifactTTL", # doc:exclude
|
40
|
+
"log_artifact", # doc:exclude
|
41
|
+
"use_artifact", # doc:exclude
|
42
|
+
"log_model", # doc:exclude
|
43
|
+
"use_model", # doc:exclude
|
44
|
+
"link_model", # doc:exclude
|
45
|
+
"define_metric", # doc:exclude
|
46
|
+
"Error", # doc:exclude
|
47
|
+
"termsetup", # doc:exclude
|
48
|
+
"termlog", # doc:exclude
|
49
|
+
"termerror", # doc:exclude
|
50
|
+
"termwarn", # doc:exclude
|
51
51
|
"Artifact",
|
52
52
|
"Settings",
|
53
53
|
"teardown",
|
54
|
-
"watch",
|
55
|
-
"unwatch",
|
56
|
-
"plot",
|
54
|
+
"watch", # doc:exclude
|
55
|
+
"unwatch", # doc:exclude
|
56
|
+
"plot", # doc:exclude
|
57
57
|
"plot_table",
|
58
58
|
"restore",
|
59
|
+
"Run",
|
59
60
|
)
|
60
61
|
|
61
62
|
import os
|
@@ -106,7 +107,7 @@ if TYPE_CHECKING:
|
|
106
107
|
import wandb
|
107
108
|
from wandb.plot import CustomChart
|
108
109
|
|
109
|
-
__version__: str = "0.
|
110
|
+
__version__: str = "0.21.1"
|
110
111
|
|
111
112
|
run: Run | None
|
112
113
|
config: wandb_config.Config
|
@@ -155,45 +156,45 @@ def setup(settings: Settings | None = None) -> _WandbSetup:
|
|
155
156
|
overridden by subsequent `wandb.init()` calls.
|
156
157
|
|
157
158
|
Example:
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
159
|
+
```python
|
160
|
+
import multiprocessing
|
161
|
+
|
162
|
+
import wandb
|
163
|
+
|
164
|
+
def run_experiment(params):
|
165
|
+
with wandb.init(config=params):
|
166
|
+
# Run experiment
|
167
|
+
pass
|
168
|
+
|
169
|
+
if __name__ == "__main__":
|
170
|
+
# Start backend and set global config
|
171
|
+
wandb.setup(settings={"project": "my_project"})
|
172
|
+
|
173
|
+
# Define experiment parameters
|
174
|
+
experiment_params = [
|
175
|
+
{"learning_rate": 0.01, "epochs": 10},
|
176
|
+
{"learning_rate": 0.001, "epochs": 20},
|
177
|
+
]
|
178
|
+
|
179
|
+
# Start multiple processes, each running a separate experiment
|
180
|
+
processes = []
|
181
|
+
for params in experiment_params:
|
182
|
+
p = multiprocessing.Process(target=run_experiment, args=(params,))
|
183
|
+
p.start()
|
184
|
+
processes.append(p)
|
185
|
+
|
186
|
+
# Wait for all processes to complete
|
187
|
+
for p in processes:
|
188
|
+
p.join()
|
189
|
+
|
190
|
+
# Optional: Explicitly shut down the backend
|
191
|
+
wandb.teardown()
|
192
|
+
```
|
192
193
|
"""
|
193
194
|
...
|
194
195
|
|
195
196
|
def teardown(exit_code: int | None = None) -> None:
|
196
|
-
"""Waits for
|
197
|
+
"""Waits for W&B to finish and frees resources.
|
197
198
|
|
198
199
|
Completes any runs that were not explicitly finished
|
199
200
|
using `run.finish()` and waits for all data to be uploaded.
|
@@ -219,7 +220,7 @@ def init(
|
|
219
220
|
allow_val_change: bool | None = None,
|
220
221
|
group: str | None = None,
|
221
222
|
job_type: str | None = None,
|
222
|
-
mode: Literal["online", "offline", "disabled"] | None = None,
|
223
|
+
mode: Literal["online", "offline", "disabled", "shared"] | None = None,
|
223
224
|
force: bool | None = None,
|
224
225
|
anonymous: Literal["never", "allow", "must"] | None = None,
|
225
226
|
reinit: (
|
@@ -249,53 +250,17 @@ def init(
|
|
249
250
|
|
250
251
|
`wandb.init()` spawns a new background process to log data to a run, and it
|
251
252
|
also syncs data to https://wandb.ai by default, so you can see your results
|
252
|
-
in real-time.
|
253
|
-
|
254
|
-
Call `wandb.init()` to start a run before logging data with `wandb.log()`.
|
255
|
-
When you're done logging data, call `wandb.finish()` to end the run. If you
|
256
|
-
don't call `wandb.finish()`, the run will end when your script exits.
|
257
|
-
|
258
|
-
For more on using `wandb.init()`, including detailed examples, check out our
|
259
|
-
[guide and FAQs](https://docs.wandb.ai/guides/track/launch).
|
260
|
-
|
261
|
-
Examples:
|
262
|
-
### Explicitly set the entity and project and choose a name for the run:
|
263
|
-
|
264
|
-
```python
|
265
|
-
import wandb
|
266
|
-
|
267
|
-
run = wandb.init(
|
268
|
-
entity="geoff",
|
269
|
-
project="capsules",
|
270
|
-
name="experiment-2021-10-31",
|
271
|
-
)
|
272
|
-
|
273
|
-
# ... your training code here ...
|
274
|
-
|
275
|
-
run.finish()
|
276
|
-
```
|
277
|
-
|
278
|
-
### Add metadata about the run using the `config` argument:
|
253
|
+
in real-time. When you're done logging data, call `wandb.Run.finish()` to end the run.
|
254
|
+
If you don't call `run.finish()`, the run will end when your script exits.
|
279
255
|
|
280
|
-
|
281
|
-
import wandb
|
282
|
-
|
283
|
-
config = {"lr": 0.01, "batch_size": 32}
|
284
|
-
with wandb.init(config=config) as run:
|
285
|
-
run.config.update({"architecture": "resnet", "depth": 34})
|
286
|
-
|
287
|
-
# ... your training code here ...
|
288
|
-
```
|
289
|
-
|
290
|
-
Note that you can use `wandb.init()` as a context manager to automatically
|
291
|
-
call `wandb.finish()` at the end of the block.
|
256
|
+
Run IDs must not contain any of the following special characters `/ \ # ? % :`
|
292
257
|
|
293
258
|
Args:
|
294
|
-
entity: The username or team name
|
295
|
-
The entity must already exist, so ensure you
|
259
|
+
entity: The username or team name the runs are logged to.
|
260
|
+
The entity must already exist, so ensure you create your account
|
296
261
|
or team in the UI before starting to log runs. If not specified, the
|
297
262
|
run will default your default entity. To change the default entity,
|
298
|
-
go to
|
263
|
+
go to your settings and update the
|
299
264
|
"Default location to create new projects" under "Default team".
|
300
265
|
project: The name of the project under which this run will be logged.
|
301
266
|
If not specified, we use a heuristic to infer the project name based
|
@@ -307,9 +272,8 @@ def init(
|
|
307
272
|
to the `./wandb` directory. Note that this does not affect the
|
308
273
|
location where artifacts are stored when calling `download()`.
|
309
274
|
id: A unique identifier for this run, used for resuming. It must be unique
|
310
|
-
within the project and cannot be reused once a run is deleted.
|
311
|
-
|
312
|
-
`/ \ # ? % :`. For a short descriptive name, use the `name` field,
|
275
|
+
within the project and cannot be reused once a run is deleted. For
|
276
|
+
a short descriptive name, use the `name` field,
|
313
277
|
or for saving hyperparameters to compare across runs, use `config`.
|
314
278
|
name: A short display name for this run, which appears in the UI to help
|
315
279
|
you identify it. By default, we generate a random two-word name
|
@@ -325,7 +289,7 @@ def init(
|
|
325
289
|
the UI.
|
326
290
|
If resuming a run, the tags provided here will replace any existing
|
327
291
|
tags. To add tags to a resumed run without overwriting the current
|
328
|
-
tags, use `run.tags +=
|
292
|
+
tags, use `run.tags += ("new_tag",)` after calling `run = wandb.init()`.
|
329
293
|
config: Sets `wandb.config`, a dictionary-like object for storing input
|
330
294
|
parameters to your run, such as model hyperparameters or data
|
331
295
|
preprocessing settings.
|
@@ -350,54 +314,56 @@ def init(
|
|
350
314
|
multiple jobs that train and evaluate a model on different test sets.
|
351
315
|
Grouping allows you to manage related runs collectively in the UI,
|
352
316
|
making it easy to toggle and review results as a unified experiment.
|
353
|
-
For more information, refer to our
|
354
|
-
[guide to grouping runs](https://docs.wandb.com/guides/runs/grouping).
|
355
317
|
job_type: Specify the type of run, especially helpful when organizing runs
|
356
318
|
within a group as part of a larger experiment. For example, in a group,
|
357
319
|
you might label runs with job types such as "train" and "eval".
|
358
320
|
Defining job types enables you to easily filter and group similar runs
|
359
321
|
in the UI, facilitating direct comparisons.
|
360
322
|
mode: Specifies how run data is managed, with the following options:
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
323
|
+
- `"online"` (default): Enables live syncing with W&B when a network
|
324
|
+
connection is available, with real-time updates to visualizations.
|
325
|
+
- `"offline"`: Suitable for air-gapped or offline environments; data
|
326
|
+
is saved locally and can be synced later. Ensure the run folder
|
327
|
+
is preserved to enable future syncing.
|
328
|
+
- `"disabled"`: Disables all W&B functionality, making the run’s methods
|
329
|
+
no-ops. Typically used in testing to bypass W&B operations.
|
330
|
+
- `"shared"`: (This is an experimental feature). Allows multiple processes,
|
331
|
+
possibly on different machines, to simultaneously log to the same run.
|
332
|
+
In this approach you use a primary node and one or more worker nodes
|
333
|
+
to log data to the same run. Within the primary node you
|
334
|
+
initialize a run. For each worker node, initialize a run
|
335
|
+
using the run ID used by the primary node.
|
368
336
|
force: Determines if a W&B login is required to run the script. If `True`,
|
369
337
|
the user must be logged in to W&B; otherwise, the script will not
|
370
338
|
proceed. If `False` (default), the script can proceed without a login,
|
371
339
|
switching to offline mode if the user is not logged in.
|
372
340
|
anonymous: Specifies the level of control over anonymous data logging.
|
373
341
|
Available options are:
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
342
|
+
- `"never"` (default): Requires you to link your W&B account before
|
343
|
+
tracking the run. This prevents unintentional creation of anonymous
|
344
|
+
runs by ensuring each run is associated with an account.
|
345
|
+
- `"allow"`: Enables a logged-in user to track runs with their account,
|
346
|
+
but also allows someone running the script without a W&B account
|
347
|
+
to view the charts and data in the UI.
|
348
|
+
- `"must"`: Forces the run to be logged to an anonymous account, even
|
349
|
+
if the user is logged in.
|
382
350
|
reinit: Shorthand for the "reinit" setting. Determines the behavior of
|
383
351
|
`wandb.init()` when a run is active.
|
384
352
|
resume: Controls the behavior when resuming a run with the specified `id`.
|
385
353
|
Available options are:
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
354
|
+
- `"allow"`: If a run with the specified `id` exists, it will resume
|
355
|
+
from the last step; otherwise, a new run will be created.
|
356
|
+
- `"never"`: If a run with the specified `id` exists, an error will
|
357
|
+
be raised. If no such run is found, a new run will be created.
|
358
|
+
- `"must"`: If a run with the specified `id` exists, it will resume
|
359
|
+
from the last step. If no run is found, an error will be raised.
|
360
|
+
- `"auto"`: Automatically resumes the previous run if it crashed on
|
361
|
+
this machine; otherwise, starts a new run.
|
362
|
+
- `True`: Deprecated. Use `"auto"` instead.
|
363
|
+
- `False`: Deprecated. Use the default behavior (leaving `resume`
|
364
|
+
unset) to always start a new run.
|
365
|
+
If `resume` is set, `fork_from` and `resume_from` cannot be
|
398
366
|
used. When `resume` is unset, the system will always start a new run.
|
399
|
-
For more details, see our
|
400
|
-
[guide to resuming runs](https://docs.wandb.com/guides/runs/resuming).
|
401
367
|
resume_from: Specifies a moment in a previous run to resume a run from,
|
402
368
|
using the format `{run_id}?_step={step}`. This allows users to truncate
|
403
369
|
the history logged to a run at an intermediate step and resume logging
|
@@ -406,7 +372,7 @@ def init(
|
|
406
372
|
take precedence.
|
407
373
|
`resume`, `resume_from` and `fork_from` cannot be used together, only
|
408
374
|
one of them can be used at a time.
|
409
|
-
Note
|
375
|
+
Note that this feature is in beta and may change in the future.
|
410
376
|
fork_from: Specifies a point in a previous run from which to fork a new
|
411
377
|
run, using the format `{id}?_step={step}`. This creates a new run that
|
412
378
|
resumes logging from the specified step in the target run’s history.
|
@@ -415,35 +381,45 @@ def init(
|
|
415
381
|
`fork_from` argument, an error will be raised if they are the same.
|
416
382
|
`resume`, `resume_from` and `fork_from` cannot be used together, only
|
417
383
|
one of them can be used at a time.
|
418
|
-
Note
|
384
|
+
Note that this feature is in beta and may change in the future.
|
419
385
|
save_code: Enables saving the main script or notebook to W&B, aiding in
|
420
386
|
experiment reproducibility and allowing code comparisons across runs in
|
421
387
|
the UI. By default, this is disabled, but you can change the default to
|
422
|
-
enable on your
|
388
|
+
enable on your settings page.
|
423
389
|
tensorboard: Deprecated. Use `sync_tensorboard` instead.
|
424
390
|
sync_tensorboard: Enables automatic syncing of W&B logs from TensorBoard
|
425
391
|
or TensorBoardX, saving relevant event files for viewing in the W&B UI.
|
426
392
|
saving relevant event files for viewing in the W&B UI. (Default: `False`)
|
427
393
|
monitor_gym: Enables automatic logging of videos of the environment when
|
428
|
-
using OpenAI Gym.
|
429
|
-
[guide for gym integration](https://docs.wandb.com/guides/integrations/openai-gym).
|
394
|
+
using OpenAI Gym.
|
430
395
|
settings: Specifies a dictionary or `wandb.Settings` object with advanced
|
431
396
|
settings for the run.
|
432
397
|
|
433
398
|
Returns:
|
434
|
-
A `Run` object
|
435
|
-
to perform operations like logging data, saving files, and finishing
|
436
|
-
the run. See the [Run API](https://docs.wandb.ai/ref/python/run) for
|
437
|
-
more details.
|
399
|
+
A `Run` object.
|
438
400
|
|
439
401
|
Raises:
|
440
402
|
Error: If some unknown or internal error happened during the run
|
441
403
|
initialization.
|
442
404
|
AuthenticationError: If the user failed to provide valid credentials.
|
443
|
-
CommError: If there was a problem communicating with the
|
444
|
-
UsageError: If the user provided invalid arguments
|
445
|
-
KeyboardInterrupt: If
|
446
|
-
|
405
|
+
CommError: If there was a problem communicating with the WandB server.
|
406
|
+
UsageError: If the user provided invalid arguments.
|
407
|
+
KeyboardInterrupt: If user interrupts the run.
|
408
|
+
|
409
|
+
Examples:
|
410
|
+
`wandb.init()` returns a `Run` object. Use the run object to log data,
|
411
|
+
save artifacts, and manage the run lifecycle.
|
412
|
+
|
413
|
+
```python
|
414
|
+
import wandb
|
415
|
+
|
416
|
+
config = {"lr": 0.01, "batch_size": 32}
|
417
|
+
with wandb.init(config=config) as run:
|
418
|
+
# Log accuracy and loss to the run
|
419
|
+
acc = 0.95 # Example accuracy
|
420
|
+
loss = 0.05 # Example loss
|
421
|
+
run.log({"accuracy": acc, "loss": loss})
|
422
|
+
```
|
447
423
|
"""
|
448
424
|
...
|
449
425
|
|
@@ -486,25 +462,26 @@ def login(
|
|
486
462
|
`verify=True`.
|
487
463
|
|
488
464
|
Args:
|
489
|
-
anonymous:
|
465
|
+
anonymous: Set to "must", "allow", or "never".
|
490
466
|
If set to "must", always log a user in anonymously. If set to
|
491
467
|
"allow", only create an anonymous user if the user
|
492
468
|
isn't already logged in. If set to "never", never log a
|
493
|
-
user anonymously. Default set to "never".
|
494
|
-
key:
|
495
|
-
relogin:
|
496
|
-
host:
|
497
|
-
force:
|
498
|
-
timeout:
|
499
|
-
verify:
|
500
|
-
referrer:
|
469
|
+
user anonymously. Default set to "never". Defaults to `None`.
|
470
|
+
key: The API key to use.
|
471
|
+
relogin: If true, will re-prompt for API key.
|
472
|
+
host: The host to connect to.
|
473
|
+
force: If true, will force a relogin.
|
474
|
+
timeout: Number of seconds to wait for user input.
|
475
|
+
verify: Verify the credentials with the W&B server.
|
476
|
+
referrer: The referrer to use in the URL login request.
|
477
|
+
|
501
478
|
|
502
479
|
Returns:
|
503
|
-
bool:
|
480
|
+
bool: If `key` is configured.
|
504
481
|
|
505
482
|
Raises:
|
506
|
-
AuthenticationError
|
507
|
-
UsageError
|
483
|
+
AuthenticationError: If `api_key` fails verification with the server.
|
484
|
+
UsageError: If `api_key` cannot be configured and no tty.
|
508
485
|
"""
|
509
486
|
...
|
510
487
|
|
@@ -516,91 +493,94 @@ def log(
|
|
516
493
|
"""Upload run data.
|
517
494
|
|
518
495
|
Use `log` to log data from runs, such as scalars, images, video,
|
519
|
-
histograms, plots, and tables.
|
496
|
+
histograms, plots, and tables. See [Log objects and media](https://docs.wandb.ai/guides/track/log) for
|
497
|
+
code snippets, best practices, and more.
|
520
498
|
|
521
|
-
|
522
|
-
live examples, code snippets, best practices, and more.
|
499
|
+
Basic usage:
|
523
500
|
|
524
|
-
|
525
|
-
|
526
|
-
|
501
|
+
```python
|
502
|
+
import wandb
|
503
|
+
|
504
|
+
with wandb.init() as run:
|
505
|
+
run.log({"train-loss": 0.5, "accuracy": 0.9})
|
506
|
+
```
|
527
507
|
|
528
|
-
|
508
|
+
The previous code snippet saves the loss and accuracy to the run's
|
509
|
+
history and updates the summary values for these metrics.
|
510
|
+
|
511
|
+
Visualize logged data in a workspace at [wandb.ai](https://wandb.ai),
|
529
512
|
or locally on a [self-hosted instance](https://docs.wandb.ai/guides/hosting)
|
530
|
-
of the W&B app, or export data to visualize and explore locally,
|
531
|
-
Jupyter
|
532
|
-
|
533
|
-
Logged values don't have to be scalars.
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
[guide to logging tables](https://docs.wandb.ai/guides/models/tables/tables-walkthrough)
|
542
|
-
for details.
|
543
|
-
|
544
|
-
The W&B UI organizes metrics with a forward slash (`/`) in their name
|
513
|
+
of the W&B app, or export data to visualize and explore locally, such as in a
|
514
|
+
Jupyter notebook, with the [Public API](https://docs.wandb.ai/guides/track/public-api-guide).
|
515
|
+
|
516
|
+
Logged values don't have to be scalars. You can log any
|
517
|
+
[W&B supported Data Type](https://docs.wandb.ai/ref/python/data-types/)
|
518
|
+
such as images, audio, video, and more. For example, you can use
|
519
|
+
`wandb.Table` to log structured data. See
|
520
|
+
[Log tables, visualize and query data](https://docs.wandb.ai/guides/models/tables/tables-walkthrough)
|
521
|
+
tutorial for more details.
|
522
|
+
|
523
|
+
W&B organizes metrics with a forward slash (`/`) in their name
|
545
524
|
into sections named using the text before the final slash. For example,
|
546
525
|
the following results in two sections named "train" and "validate":
|
547
526
|
|
548
|
-
```
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
527
|
+
```python
|
528
|
+
with wandb.init() as run:
|
529
|
+
# Log metrics in the "train" section.
|
530
|
+
run.log(
|
531
|
+
{
|
532
|
+
"train/accuracy": 0.9,
|
533
|
+
"train/loss": 30,
|
534
|
+
"validate/accuracy": 0.8,
|
535
|
+
"validate/loss": 20,
|
536
|
+
}
|
537
|
+
)
|
557
538
|
```
|
558
539
|
|
559
540
|
Only one level of nesting is supported; `run.log({"a/b/c": 1})`
|
560
541
|
produces a section named "a/b".
|
561
542
|
|
562
|
-
`run.log` is not intended to be called more than a few times per second.
|
543
|
+
`run.log()` is not intended to be called more than a few times per second.
|
563
544
|
For optimal performance, limit your logging to once every N iterations,
|
564
545
|
or collect data over multiple iterations and log it in a single step.
|
565
546
|
|
566
|
-
|
567
|
-
|
568
|
-
With basic usage, each call to `log` creates a new "step".
|
547
|
+
By default, each call to `log` creates a new "step".
|
569
548
|
The step must always increase, and it is not possible to log
|
570
|
-
to a previous step.
|
549
|
+
to a previous step. You can use any metric as the X axis in charts.
|
550
|
+
See [Custom log axes](https://docs.wandb.ai/guides/track/log/customize-logging-axes/)
|
551
|
+
for more details.
|
571
552
|
|
572
|
-
Note that you can use any metric as the X axis in charts.
|
573
553
|
In many cases, it is better to treat the W&B step like
|
574
554
|
you'd treat a timestamp rather than a training step.
|
575
555
|
|
556
|
+
```python
|
557
|
+
with wandb.init() as run:
|
558
|
+
# Example: log an "epoch" metric for use as an X axis.
|
559
|
+
run.log({"epoch": 40, "train-loss": 0.5})
|
576
560
|
```
|
577
|
-
# Example: log an "epoch" metric for use as an X axis.
|
578
|
-
run.log({"epoch": 40, "train-loss": 0.5})
|
579
|
-
```
|
580
|
-
|
581
|
-
See also [define_metric](https://docs.wandb.ai/ref/python/run#define_metric).
|
582
561
|
|
583
|
-
It is possible to use multiple `log` invocations to log to
|
562
|
+
It is possible to use multiple `wandb.Run.log()` invocations to log to
|
584
563
|
the same step with the `step` and `commit` parameters.
|
585
564
|
The following are all equivalent:
|
586
565
|
|
587
|
-
```
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
566
|
+
```python
|
567
|
+
with wandb.init() as run:
|
568
|
+
# Normal usage:
|
569
|
+
run.log({"train-loss": 0.5, "accuracy": 0.8})
|
570
|
+
run.log({"train-loss": 0.4, "accuracy": 0.9})
|
571
|
+
|
572
|
+
# Implicit step without auto-incrementing:
|
573
|
+
run.log({"train-loss": 0.5}, commit=False)
|
574
|
+
run.log({"accuracy": 0.8})
|
575
|
+
run.log({"train-loss": 0.4}, commit=False)
|
576
|
+
run.log({"accuracy": 0.9})
|
577
|
+
|
578
|
+
# Explicit step:
|
579
|
+
run.log({"train-loss": 0.5}, step=current_step)
|
580
|
+
run.log({"accuracy": 0.8}, step=current_step)
|
581
|
+
current_step += 1
|
582
|
+
run.log({"train-loss": 0.4}, step=current_step)
|
583
|
+
run.log({"accuracy": 0.9}, step=current_step)
|
604
584
|
```
|
605
585
|
|
606
586
|
Args:
|
@@ -618,59 +598,64 @@ def log(
|
|
618
598
|
otherwise, the default is `commit=False`.
|
619
599
|
|
620
600
|
Examples:
|
621
|
-
|
622
|
-
|
601
|
+
For more and more detailed examples, see
|
602
|
+
[our guides to logging](https://docs.wandb.com/guides/track/log).
|
603
|
+
|
604
|
+
Basic usage
|
605
|
+
|
606
|
+
```python
|
607
|
+
import wandb
|
623
608
|
|
624
|
-
|
625
|
-
|
626
|
-
|
609
|
+
with wandb.init() as run:
|
610
|
+
run.log({"train-loss": 0.5, "accuracy": 0.9
|
611
|
+
```
|
627
612
|
|
628
|
-
|
629
|
-
run.log({"accuracy": 0.9, "epoch": 5})
|
630
|
-
```
|
613
|
+
Incremental logging
|
631
614
|
|
632
|
-
|
633
|
-
|
634
|
-
import wandb
|
615
|
+
```python
|
616
|
+
import wandb
|
635
617
|
|
636
|
-
|
618
|
+
with wandb.init() as run:
|
637
619
|
run.log({"loss": 0.2}, commit=False)
|
638
620
|
# Somewhere else when I'm ready to report this step:
|
639
621
|
run.log({"accuracy": 0.8})
|
640
|
-
|
622
|
+
```
|
623
|
+
|
624
|
+
Histogram
|
641
625
|
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
import wandb
|
626
|
+
```python
|
627
|
+
import numpy as np
|
628
|
+
import wandb
|
646
629
|
|
647
|
-
|
648
|
-
|
649
|
-
|
630
|
+
# sample gradients at random from normal distribution
|
631
|
+
gradients = np.random.randn(100, 100)
|
632
|
+
with wandb.init() as run:
|
650
633
|
run.log({"gradients": wandb.Histogram(gradients)})
|
651
|
-
|
634
|
+
```
|
652
635
|
|
653
|
-
|
654
|
-
```python
|
655
|
-
import numpy as np
|
656
|
-
import wandb
|
636
|
+
Image from NumPy
|
657
637
|
|
658
|
-
|
638
|
+
```python
|
639
|
+
import numpy as np
|
640
|
+
import wandb
|
641
|
+
|
642
|
+
with wandb.init() as run:
|
659
643
|
examples = []
|
660
644
|
for i in range(3):
|
661
645
|
pixels = np.random.randint(low=0, high=256, size=(100, 100, 3))
|
662
646
|
image = wandb.Image(pixels, caption=f"random field {i}")
|
663
647
|
examples.append(image)
|
664
648
|
run.log({"examples": examples})
|
665
|
-
|
649
|
+
```
|
666
650
|
|
667
|
-
|
668
|
-
```python
|
669
|
-
import numpy as np
|
670
|
-
from PIL import Image as PILImage
|
671
|
-
import wandb
|
651
|
+
Image from PIL
|
672
652
|
|
673
|
-
|
653
|
+
```python
|
654
|
+
import numpy as np
|
655
|
+
from PIL import Image as PILImage
|
656
|
+
import wandb
|
657
|
+
|
658
|
+
with wandb.init() as run:
|
674
659
|
examples = []
|
675
660
|
for i in range(3):
|
676
661
|
pixels = np.random.randint(
|
@@ -683,14 +668,15 @@ def log(
|
|
683
668
|
image = wandb.Image(pil_image, caption=f"random field {i}")
|
684
669
|
examples.append(image)
|
685
670
|
run.log({"examples": examples})
|
686
|
-
|
671
|
+
```
|
687
672
|
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
673
|
+
Video from NumPy
|
674
|
+
|
675
|
+
```python
|
676
|
+
import numpy as np
|
677
|
+
import wandb
|
692
678
|
|
693
|
-
|
679
|
+
with wandb.init() as run:
|
694
680
|
# axes are (time, channel, height, width)
|
695
681
|
frames = np.random.randint(
|
696
682
|
low=0,
|
@@ -699,35 +685,38 @@ def log(
|
|
699
685
|
dtype=np.uint8,
|
700
686
|
)
|
701
687
|
run.log({"video": wandb.Video(frames, fps=4)})
|
702
|
-
|
688
|
+
```
|
689
|
+
|
690
|
+
Matplotlib plot
|
703
691
|
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
import wandb
|
692
|
+
```python
|
693
|
+
from matplotlib import pyplot as plt
|
694
|
+
import numpy as np
|
695
|
+
import wandb
|
709
696
|
|
710
|
-
|
697
|
+
with wandb.init() as run:
|
711
698
|
fig, ax = plt.subplots()
|
712
699
|
x = np.linspace(0, 10)
|
713
700
|
y = x * x
|
714
701
|
ax.plot(x, y) # plot y = x^2
|
715
702
|
run.log({"chart": fig})
|
716
|
-
|
703
|
+
```
|
704
|
+
|
705
|
+
PR Curve
|
717
706
|
|
718
|
-
|
719
|
-
|
720
|
-
import wandb
|
707
|
+
```python
|
708
|
+
import wandb
|
721
709
|
|
722
|
-
|
710
|
+
with wandb.init() as run:
|
723
711
|
run.log({"pr": wandb.plot.pr_curve(y_test, y_probas, labels)})
|
724
|
-
|
712
|
+
```
|
725
713
|
|
726
|
-
|
727
|
-
```python
|
728
|
-
import wandb
|
714
|
+
3D Object
|
729
715
|
|
730
|
-
|
716
|
+
```python
|
717
|
+
import wandb
|
718
|
+
|
719
|
+
with wandb.init() as run:
|
731
720
|
run.log(
|
732
721
|
{
|
733
722
|
"generated_samples": [
|
@@ -737,11 +726,11 @@ def log(
|
|
737
726
|
]
|
738
727
|
}
|
739
728
|
)
|
740
|
-
|
729
|
+
```
|
741
730
|
|
742
731
|
Raises:
|
743
|
-
wandb.Error:
|
744
|
-
ValueError:
|
732
|
+
wandb.Error: If called before `wandb.init()`.
|
733
|
+
ValueError: If invalid data is passed.
|
745
734
|
"""
|
746
735
|
...
|
747
736
|
|
@@ -760,42 +749,48 @@ def save(
|
|
760
749
|
|
761
750
|
A `base_path` may be provided to control the directory structure of
|
762
751
|
uploaded files. It should be a prefix of `glob_str`, and the directory
|
763
|
-
structure beneath it is preserved.
|
764
|
-
examples:
|
765
|
-
|
766
|
-
```
|
767
|
-
wandb.save("these/are/myfiles/*")
|
768
|
-
# => Saves files in a "these/are/myfiles/" folder in the run.
|
769
|
-
|
770
|
-
wandb.save("these/are/myfiles/*", base_path="these")
|
771
|
-
# => Saves files in an "are/myfiles/" folder in the run.
|
752
|
+
structure beneath it is preserved.
|
772
753
|
|
773
|
-
|
774
|
-
# => Saves files in a "run123/" folder in the run. See note below.
|
775
|
-
|
776
|
-
wandb.save("/User/username/Documents/run123/*.txt", base_path="/User")
|
777
|
-
# => Saves files in a "username/Documents/run123/" folder in the run.
|
778
|
-
|
779
|
-
wandb.save("files/*/saveme.txt")
|
780
|
-
# => Saves each "saveme.txt" file in an appropriate subdirectory
|
781
|
-
# of "files/".
|
782
|
-
```
|
783
|
-
|
784
|
-
Note: when given an absolute path or glob and no `base_path`, one
|
754
|
+
When given an absolute path or glob and no `base_path`, one
|
785
755
|
directory level is preserved as in the example above.
|
786
756
|
|
787
757
|
Args:
|
788
758
|
glob_str: A relative or absolute path or Unix glob.
|
789
759
|
base_path: A path to use to infer a directory structure; see examples.
|
790
760
|
policy: One of `live`, `now`, or `end`.
|
791
|
-
|
792
|
-
|
793
|
-
|
761
|
+
- live: upload the file as it changes, overwriting the previous version
|
762
|
+
- now: upload the file once now
|
763
|
+
- end: upload file when the run ends
|
794
764
|
|
795
765
|
Returns:
|
796
766
|
Paths to the symlinks created for the matched files.
|
797
767
|
|
798
768
|
For historical reasons, this may return a boolean in legacy code.
|
769
|
+
|
770
|
+
```python
|
771
|
+
import wandb
|
772
|
+
|
773
|
+
run = wandb.init()
|
774
|
+
|
775
|
+
run.save("these/are/myfiles/*")
|
776
|
+
# => Saves files in a "these/are/myfiles/" folder in the run.
|
777
|
+
|
778
|
+
run.save("these/are/myfiles/*", base_path="these")
|
779
|
+
# => Saves files in an "are/myfiles/" folder in the run.
|
780
|
+
|
781
|
+
run.save("/User/username/Documents/run123/*.txt")
|
782
|
+
# => Saves files in a "run123/" folder in the run. See note below.
|
783
|
+
|
784
|
+
run.save("/User/username/Documents/run123/*.txt", base_path="/User")
|
785
|
+
# => Saves files in a "username/Documents/run123/" folder in the run.
|
786
|
+
|
787
|
+
run.save("files/*/saveme.txt")
|
788
|
+
# => Saves each "saveme.txt" file in an appropriate subdirectory
|
789
|
+
# of "files/".
|
790
|
+
|
791
|
+
# Explicitly finish the run since a context manager is not used.
|
792
|
+
run.finish()
|
793
|
+
```
|
799
794
|
"""
|
800
795
|
...
|
801
796
|
|
@@ -813,11 +808,12 @@ def sweep(
|
|
813
808
|
Make note the unique identifier, `sweep_id`, that is returned.
|
814
809
|
At a later step provide the `sweep_id` to a sweep agent.
|
815
810
|
|
811
|
+
See [Sweep configuration structure](https://docs.wandb.ai/guides/sweeps/define-sweep-configuration)
|
812
|
+
for information on how to define your sweep.
|
813
|
+
|
816
814
|
Args:
|
817
815
|
sweep: The configuration of a hyperparameter search.
|
818
|
-
(or configuration generator).
|
819
|
-
[Sweep configuration structure](https://docs.wandb.ai/guides/sweeps/define-sweep-configuration)
|
820
|
-
for information on how to define your sweep.
|
816
|
+
(or configuration generator).
|
821
817
|
If you provide a callable, ensure that the callable does
|
822
818
|
not take arguments and that it returns a dictionary that
|
823
819
|
conforms to the W&B sweep config spec.
|
@@ -832,7 +828,7 @@ def sweep(
|
|
832
828
|
prior_runs: The run IDs of existing runs to add to this sweep.
|
833
829
|
|
834
830
|
Returns:
|
835
|
-
|
831
|
+
str: A unique identifier for the sweep.
|
836
832
|
"""
|
837
833
|
...
|
838
834
|
|
@@ -843,16 +839,16 @@ def controller(
|
|
843
839
|
) -> _WandbController:
|
844
840
|
"""Public sweep controller constructor.
|
845
841
|
|
846
|
-
|
847
|
-
|
848
|
-
|
842
|
+
Examples:
|
843
|
+
```python
|
844
|
+
import wandb
|
849
845
|
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
846
|
+
tuner = wandb.controller(...)
|
847
|
+
print(tuner.sweep_config)
|
848
|
+
print(tuner.sweep_id)
|
849
|
+
tuner.configure_search(...)
|
850
|
+
tuner.configure_stopping(...)
|
851
|
+
```
|
856
852
|
"""
|
857
853
|
...
|
858
854
|
|
@@ -895,23 +891,26 @@ def define_metric(
|
|
895
891
|
goal: str | None = None,
|
896
892
|
overwrite: bool | None = None,
|
897
893
|
) -> wandb_metric.Metric:
|
898
|
-
"""Customize metrics logged with `wandb.log()`.
|
894
|
+
"""Customize metrics logged with `wandb.Run.log()`.
|
899
895
|
|
900
896
|
Args:
|
901
897
|
name: The name of the metric to customize.
|
902
898
|
step_metric: The name of another metric to serve as the X-axis
|
903
899
|
for this metric in automatically generated charts.
|
904
900
|
step_sync: Automatically insert the last value of step_metric into
|
905
|
-
`
|
901
|
+
`wandb.Run.log()` if it is not provided explicitly. Defaults to True
|
906
902
|
if step_metric is specified.
|
907
903
|
hidden: Hide this metric from automatic plots.
|
908
904
|
summary: Specify aggregate metrics added to summary.
|
909
905
|
Supported aggregations include "min", "max", "mean", "last",
|
910
|
-
"best", "copy" and "none". "
|
911
|
-
|
912
|
-
"
|
906
|
+
"first", "best", "copy" and "none". "none" prevents a summary
|
907
|
+
from being generated. "best" is used together with the goal
|
908
|
+
parameter, "best" is deprecated and should not be used, use
|
909
|
+
"min" or "max" instead. "copy" is deprecated and should not be
|
910
|
+
used.
|
913
911
|
goal: Specify how to interpret the "best" summary type.
|
914
|
-
Supported options are "minimize" and "maximize".
|
912
|
+
Supported options are "minimize" and "maximize". "goal" is
|
913
|
+
deprecated and should not be used, use "min" or "max" instead.
|
915
914
|
overwrite: If false, then this call is merged with previous
|
916
915
|
`define_metric` calls for the same metric by using their
|
917
916
|
values for any unspecified parameters. If true, then
|
@@ -967,19 +966,43 @@ def use_artifact(
|
|
967
966
|
Call `download` or `file` on the returned object to get the contents locally.
|
968
967
|
|
969
968
|
Args:
|
970
|
-
artifact_or_name:
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
type:
|
978
|
-
aliases:
|
969
|
+
artifact_or_name: The name of the artifact to use. May be prefixed
|
970
|
+
with the name of the project the artifact was logged to
|
971
|
+
("<entity>" or "<entity>/<project>"). If no
|
972
|
+
entity is specified in the name, the Run or API setting's entity is used.
|
973
|
+
Valid names can be in the following forms
|
974
|
+
- name:version
|
975
|
+
- name:alias
|
976
|
+
type: The type of artifact to use.
|
977
|
+
aliases: Aliases to apply to this artifact
|
979
978
|
use_as: This argument is deprecated and does nothing.
|
980
979
|
|
981
980
|
Returns:
|
982
981
|
An `Artifact` object.
|
982
|
+
|
983
|
+
Examples:
|
984
|
+
```python
|
985
|
+
import wandb
|
986
|
+
|
987
|
+
run = wandb.init(project="<example>")
|
988
|
+
|
989
|
+
# Use an artifact by name and alias
|
990
|
+
artifact_a = run.use_artifact(artifact_or_name="<name>:<alias>")
|
991
|
+
|
992
|
+
# Use an artifact by name and version
|
993
|
+
artifact_b = run.use_artifact(artifact_or_name="<name>:v<version>")
|
994
|
+
|
995
|
+
# Use an artifact by entity/project/name:alias
|
996
|
+
artifact_c = run.use_artifact(artifact_or_name="<entity>/<project>/<name>:<alias>")
|
997
|
+
|
998
|
+
# Use an artifact by entity/project/name:version
|
999
|
+
artifact_d = run.use_artifact(
|
1000
|
+
artifact_or_name="<entity>/<project>/<name>:v<version>"
|
1001
|
+
)
|
1002
|
+
|
1003
|
+
# Explicitly finish the run since a context manager is not used.
|
1004
|
+
run.finish()
|
1005
|
+
```
|
983
1006
|
"""
|
984
1007
|
...
|
985
1008
|
|
@@ -990,39 +1013,24 @@ def log_model(
|
|
990
1013
|
) -> None:
|
991
1014
|
"""Logs a model artifact containing the contents inside the 'path' to a run and marks it as an output to this run.
|
992
1015
|
|
1016
|
+
The name of model artifact can only contain alphanumeric characters,
|
1017
|
+
underscores, and hyphens.
|
1018
|
+
|
993
1019
|
Args:
|
994
1020
|
path: (str) A path to the contents of this model,
|
995
1021
|
can be in the following forms:
|
996
1022
|
- `/local/directory`
|
997
1023
|
- `/local/directory/file.txt`
|
998
1024
|
- `s3://bucket/path`
|
999
|
-
name:
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
aliases:
|
1025
|
+
name: A name to assign to the model artifact that
|
1026
|
+
the file contents will be added to. This will default to the
|
1027
|
+
basename of the path prepended with the current run id if
|
1028
|
+
not specified.
|
1029
|
+
aliases: Aliases to apply to the created model artifact,
|
1004
1030
|
defaults to `["latest"]`
|
1005
1031
|
|
1006
|
-
Examples:
|
1007
|
-
```python
|
1008
|
-
run.log_model(
|
1009
|
-
path="/local/directory",
|
1010
|
-
name="my_model_artifact",
|
1011
|
-
aliases=["production"],
|
1012
|
-
)
|
1013
|
-
```
|
1014
|
-
|
1015
|
-
Invalid usage
|
1016
|
-
```python
|
1017
|
-
run.log_model(
|
1018
|
-
path="/local/directory",
|
1019
|
-
name="my_entity/my_project/my_model_artifact",
|
1020
|
-
aliases=["production"],
|
1021
|
-
)
|
1022
|
-
```
|
1023
|
-
|
1024
1032
|
Raises:
|
1025
|
-
ValueError:
|
1033
|
+
ValueError: If name has invalid special characters.
|
1026
1034
|
|
1027
1035
|
Returns:
|
1028
1036
|
None
|
@@ -1033,40 +1041,18 @@ def use_model(name: str) -> FilePathStr:
|
|
1033
1041
|
"""Download the files logged in a model artifact 'name'.
|
1034
1042
|
|
1035
1043
|
Args:
|
1036
|
-
name:
|
1037
|
-
model artifact.
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
- model_artifact_name:alias
|
1042
|
-
|
1043
|
-
Examples:
|
1044
|
-
```python
|
1045
|
-
run.use_model(
|
1046
|
-
name="my_model_artifact:latest",
|
1047
|
-
)
|
1048
|
-
|
1049
|
-
run.use_model(
|
1050
|
-
name="my_project/my_model_artifact:v0",
|
1051
|
-
)
|
1052
|
-
|
1053
|
-
run.use_model(
|
1054
|
-
name="my_entity/my_project/my_model_artifact:<digest>",
|
1055
|
-
)
|
1056
|
-
```
|
1044
|
+
name: A model artifact name. 'name' must match the name of an existing logged
|
1045
|
+
model artifact. May be prefixed with `entity/project/`. Valid names
|
1046
|
+
can be in the following forms
|
1047
|
+
- model_artifact_name:version
|
1048
|
+
- model_artifact_name:alias
|
1057
1049
|
|
1058
|
-
|
1059
|
-
|
1060
|
-
run.use_model(
|
1061
|
-
name="my_entity/my_project/my_model_artifact",
|
1062
|
-
)
|
1063
|
-
```
|
1050
|
+
Returns:
|
1051
|
+
path (str): Path to downloaded model artifact file(s).
|
1064
1052
|
|
1065
1053
|
Raises:
|
1066
|
-
AssertionError:
|
1067
|
-
|
1068
|
-
Returns:
|
1069
|
-
path: (str) path to downloaded model artifact file(s).
|
1054
|
+
AssertionError: If model artifact 'name' is of a type that does
|
1055
|
+
not contain the substring 'model'.
|
1070
1056
|
"""
|
1071
1057
|
...
|
1072
1058
|
|
@@ -1078,66 +1064,43 @@ def link_model(
|
|
1078
1064
|
) -> Artifact | None:
|
1079
1065
|
"""Log a model artifact version and link it to a registered model in the model registry.
|
1080
1066
|
|
1081
|
-
|
1067
|
+
Linked model versions are visible in the UI for the specified registered model.
|
1082
1068
|
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1069
|
+
This method will:
|
1070
|
+
- Check if 'name' model artifact has been logged. If so, use the artifact version that matches the files
|
1071
|
+
located at 'path' or log a new version. Otherwise log files under 'path' as a new model artifact, 'name'
|
1072
|
+
of type 'model'.
|
1073
|
+
- Check if registered model with name 'registered_model_name' exists in the 'model-registry' project.
|
1074
|
+
If not, create a new registered model with name 'registered_model_name'.
|
1075
|
+
- Link version of model artifact 'name' to registered model, 'registered_model_name'.
|
1076
|
+
- Attach aliases from 'aliases' list to the newly linked model artifact version.
|
1091
1077
|
|
1092
1078
|
Args:
|
1093
|
-
path: (str) A path to the contents of this model,
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
registered_model_name:
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
run.link_model(
|
1110
|
-
path="/local/directory",
|
1111
|
-
registered_model_name="my_reg_model",
|
1112
|
-
name="my_model_artifact",
|
1113
|
-
aliases=["production"],
|
1114
|
-
)
|
1115
|
-
```
|
1116
|
-
|
1117
|
-
Invalid usage
|
1118
|
-
```python
|
1119
|
-
run.link_model(
|
1120
|
-
path="/local/directory",
|
1121
|
-
registered_model_name="my_entity/my_project/my_reg_model",
|
1122
|
-
name="my_model_artifact",
|
1123
|
-
aliases=["production"],
|
1124
|
-
)
|
1125
|
-
|
1126
|
-
run.link_model(
|
1127
|
-
path="/local/directory",
|
1128
|
-
registered_model_name="my_reg_model",
|
1129
|
-
name="my_entity/my_project/my_model_artifact",
|
1130
|
-
aliases=["production"],
|
1131
|
-
)
|
1132
|
-
```
|
1079
|
+
path: (str) A path to the contents of this model, can be in the
|
1080
|
+
following forms:
|
1081
|
+
- `/local/directory`
|
1082
|
+
- `/local/directory/file.txt`
|
1083
|
+
- `s3://bucket/path`
|
1084
|
+
registered_model_name: The name of the registered model that the
|
1085
|
+
model is to be linked to. A registered model is a collection of
|
1086
|
+
model versions linked to the model registry, typically
|
1087
|
+
representing a team's specific ML Task. The entity that this
|
1088
|
+
registered model belongs to will be derived from the run.
|
1089
|
+
name: The name of the model artifact that files in 'path' will be
|
1090
|
+
logged to. This will default to the basename of the path
|
1091
|
+
prepended with the current run id if not specified.
|
1092
|
+
aliases: Aliases that will only be applied on this linked artifact
|
1093
|
+
inside the registered model. The alias "latest" will always be
|
1094
|
+
applied to the latest version of an artifact that is linked.
|
1133
1095
|
|
1134
1096
|
Raises:
|
1135
|
-
AssertionError:
|
1136
|
-
if model artifact 'name' is of a type that does not contain
|
1137
|
-
|
1097
|
+
AssertionError: If registered_model_name is a path or
|
1098
|
+
if model artifact 'name' is of a type that does not contain
|
1099
|
+
the substring 'model'.
|
1100
|
+
ValueError: If name has invalid special characters.
|
1138
1101
|
|
1139
1102
|
Returns:
|
1140
|
-
The linked artifact if linking was successful, otherwise None
|
1103
|
+
The linked artifact if linking was successful, otherwise `None`.
|
1141
1104
|
"""
|
1142
1105
|
...
|
1143
1106
|
|
@@ -1153,27 +1116,50 @@ def plot_table(
|
|
1153
1116
|
This function creates a custom chart based on a Vega-Lite specification and
|
1154
1117
|
a data table represented by a `wandb.Table` object. The specification needs
|
1155
1118
|
to be predefined and stored in the W&B backend. The function returns a custom
|
1156
|
-
chart object that can be logged to W&B using `wandb.log()`.
|
1119
|
+
chart object that can be logged to W&B using `wandb.Run.log()`.
|
1157
1120
|
|
1158
1121
|
Args:
|
1159
|
-
vega_spec_name
|
1122
|
+
vega_spec_name: The name or identifier of the Vega-Lite spec
|
1160
1123
|
that defines the visualization structure.
|
1161
|
-
data_table
|
1124
|
+
data_table: A `wandb.Table` object containing the data to be
|
1162
1125
|
visualized.
|
1163
|
-
fields
|
1126
|
+
fields: A mapping between the fields in the Vega-Lite spec and the
|
1164
1127
|
corresponding columns in the data table to be visualized.
|
1165
|
-
string_fields
|
1128
|
+
string_fields: A dictionary for providing values for any string constants
|
1166
1129
|
required by the custom visualization.
|
1167
|
-
split_table
|
1130
|
+
split_table: Whether the table should be split into a separate section
|
1168
1131
|
in the W&B UI. If `True`, the table will be displayed in a section named
|
1169
1132
|
"Custom Chart Tables". Default is `False`.
|
1170
1133
|
|
1171
1134
|
Returns:
|
1172
1135
|
CustomChart: A custom chart object that can be logged to W&B. To log the
|
1173
|
-
chart, pass
|
1136
|
+
chart, pass the chart object as argument to `wandb.Run.log()`.
|
1174
1137
|
|
1175
1138
|
Raises:
|
1176
1139
|
wandb.Error: If `data_table` is not a `wandb.Table` object.
|
1140
|
+
|
1141
|
+
Example:
|
1142
|
+
```python
|
1143
|
+
# Create a custom chart using a Vega-Lite spec and the data table.
|
1144
|
+
import wandb
|
1145
|
+
|
1146
|
+
data = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]
|
1147
|
+
table = wandb.Table(data=data, columns=["x", "y"])
|
1148
|
+
fields = {"x": "x", "y": "y", "title": "MY TITLE"}
|
1149
|
+
|
1150
|
+
with wandb.init() as run:
|
1151
|
+
# Training code goes here
|
1152
|
+
|
1153
|
+
# Create a custom title with `string_fields`.
|
1154
|
+
my_custom_chart = wandb.plot_table(
|
1155
|
+
vega_spec_name="wandb/line/v0",
|
1156
|
+
data_table=table,
|
1157
|
+
fields=fields,
|
1158
|
+
string_fields={"title": "Title"},
|
1159
|
+
)
|
1160
|
+
|
1161
|
+
run.log({"custom_chart": my_custom_chart})
|
1162
|
+
```
|
1177
1163
|
"""
|
1178
1164
|
...
|
1179
1165
|
|
@@ -1185,29 +1171,22 @@ def watch(
|
|
1185
1171
|
idx: int | None = None,
|
1186
1172
|
log_graph: bool = False,
|
1187
1173
|
) -> None:
|
1188
|
-
"""
|
1174
|
+
"""Hook into given PyTorch model to monitor gradients and the model's computational graph.
|
1189
1175
|
|
1190
|
-
This function can track parameters, gradients, or both during training.
|
1191
|
-
extended to support arbitrary machine learning models in the future.
|
1176
|
+
This function can track parameters, gradients, or both during training.
|
1192
1177
|
|
1193
1178
|
Args:
|
1194
|
-
models
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
log
|
1199
|
-
|
1200
|
-
|
1201
|
-
log_freq (int):
|
1202
|
-
Frequency (in batches) to log gradients and parameters. (default=1000)
|
1203
|
-
idx (Optional[int]):
|
1204
|
-
Index used when tracking multiple models with `wandb.watch`. (default=None)
|
1205
|
-
log_graph (bool):
|
1206
|
-
Whether to log the model's computational graph. (default=False)
|
1179
|
+
models: A single model or a sequence of models to be monitored.
|
1180
|
+
criterion: The loss function being optimized (optional).
|
1181
|
+
log: Specifies whether to log "gradients", "parameters", or "all".
|
1182
|
+
Set to None to disable logging. (default="gradients").
|
1183
|
+
log_freq: Frequency (in batches) to log gradients and parameters. (default=1000)
|
1184
|
+
idx: Index used when tracking multiple models with `wandb.watch`. (default=None)
|
1185
|
+
log_graph: Whether to log the model's computational graph. (default=False)
|
1207
1186
|
|
1208
1187
|
Raises:
|
1209
1188
|
ValueError:
|
1210
|
-
If `wandb.init` has not been called or if any of the models are not instances
|
1189
|
+
If `wandb.init()` has not been called or if any of the models are not instances
|
1211
1190
|
of `torch.nn.Module`.
|
1212
1191
|
"""
|
1213
1192
|
...
|
@@ -1218,8 +1197,7 @@ def unwatch(
|
|
1218
1197
|
"""Remove pytorch model topology, gradient and parameter hooks.
|
1219
1198
|
|
1220
1199
|
Args:
|
1221
|
-
models
|
1222
|
-
Optional list of pytorch models that have had watch called on them
|
1200
|
+
models: Optional list of pytorch models that have had watch called on them.
|
1223
1201
|
"""
|
1224
1202
|
...
|
1225
1203
|
|
@@ -1235,18 +1213,18 @@ def restore(
|
|
1235
1213
|
By default, will only download the file if it doesn't already exist.
|
1236
1214
|
|
1237
1215
|
Args:
|
1238
|
-
name:
|
1239
|
-
run_path:
|
1216
|
+
name: The name of the file.
|
1217
|
+
run_path: Optional path to a run to pull files from, i.e. `username/project_name/run_id`
|
1240
1218
|
if wandb.init has not been called, this is required.
|
1241
|
-
replace:
|
1242
|
-
root:
|
1219
|
+
replace: Whether to download the file even if it already exists locally
|
1220
|
+
root: The directory to download the file to. Defaults to the current
|
1243
1221
|
directory or the run directory if wandb.init was called.
|
1244
1222
|
|
1245
1223
|
Returns:
|
1246
|
-
None if it can't find the file, otherwise a file object open for reading
|
1224
|
+
None if it can't find the file, otherwise a file object open for reading.
|
1247
1225
|
|
1248
1226
|
Raises:
|
1249
|
-
|
1250
|
-
ValueError:
|
1227
|
+
CommError: If W&B can't connect to the W&B backend.
|
1228
|
+
ValueError: If the file is not found or can't find run_path.
|
1251
1229
|
"""
|
1252
1230
|
...
|