wandb 0.21.0__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 +427 -450
- wandb/agents/pyagent.py +41 -12
- wandb/analytics/sentry.py +7 -2
- wandb/apis/importers/mlflow.py +1 -1
- wandb/apis/public/__init__.py +1 -1
- wandb/apis/public/api.py +526 -360
- wandb/apis/public/artifacts.py +204 -8
- wandb/apis/public/automations.py +19 -3
- wandb/apis/public/files.py +172 -33
- 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 +130 -79
- wandb/apis/public/query_generator.py +11 -1
- wandb/apis/public/registries/registries_search.py +7 -15
- wandb/apis/public/reports.py +83 -5
- wandb/apis/public/runs.py +299 -105
- wandb/apis/public/sweeps.py +222 -22
- wandb/apis/public/teams.py +41 -4
- wandb/apis/public/users.py +45 -4
- 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/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/jupyter.py +5 -5
- wandb/plot/custom_chart.py +30 -7
- wandb/proto/v3/wandb_internal_pb2.py +280 -280
- wandb/proto/v3/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v4/wandb_internal_pb2.py +280 -280
- wandb/proto/v4/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v5/wandb_internal_pb2.py +280 -280
- wandb/proto/v5/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v6/wandb_internal_pb2.py +280 -280
- wandb/proto/v6/wandb_telemetry_pb2.py +4 -4
- wandb/proto/wandb_deprecated.py +6 -0
- wandb/sdk/artifacts/_internal_artifact.py +19 -8
- wandb/sdk/artifacts/_validators.py +8 -0
- wandb/sdk/artifacts/artifact.py +106 -75
- wandb/sdk/data_types/audio.py +38 -10
- wandb/sdk/data_types/base_types/media.py +6 -56
- 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 +4 -6
- wandb/sdk/data_types/table.py +59 -30
- wandb/sdk/data_types/video.py +53 -26
- wandb/sdk/integration_utils/auto_logging.py +2 -2
- wandb/sdk/internal/internal_api.py +6 -0
- wandb/sdk/internal/job_builder.py +6 -0
- wandb/sdk/launch/agent/agent.py +8 -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/lib/asyncio_compat.py +3 -0
- 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 +66 -91
- wandb/sdk/wandb_login.py +18 -14
- wandb/sdk/wandb_metric.py +2 -0
- wandb/sdk/wandb_run.py +406 -414
- wandb/sdk/wandb_settings.py +130 -2
- 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.21.0.dist-info → wandb-0.21.1.dist-info}/METADATA +1 -1
- {wandb-0.21.0.dist-info → wandb-0.21.1.dist-info}/RECORD +95 -95
- wandb/vendor/pynvml/__init__.py +0 -0
- wandb/vendor/pynvml/pynvml.py +0 -4779
- {wandb-0.21.0.dist-info → wandb-0.21.1.dist-info}/WHEEL +0 -0
- {wandb-0.21.0.dist-info → wandb-0.21.1.dist-info}/entry_points.txt +0 -0
- {wandb-0.21.0.dist-info → wandb-0.21.1.dist-info}/licenses/LICENSE +0 -0
wandb/__init__.pyi
CHANGED
@@ -107,7 +107,7 @@ if TYPE_CHECKING:
|
|
107
107
|
import wandb
|
108
108
|
from wandb.plot import CustomChart
|
109
109
|
|
110
|
-
__version__: str = "0.21.
|
110
|
+
__version__: str = "0.21.1"
|
111
111
|
|
112
112
|
run: Run | None
|
113
113
|
config: wandb_config.Config
|
@@ -156,45 +156,45 @@ def setup(settings: Settings | None = None) -> _WandbSetup:
|
|
156
156
|
overridden by subsequent `wandb.init()` calls.
|
157
157
|
|
158
158
|
Example:
|
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
|
-
|
192
|
-
|
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
|
+
```
|
193
193
|
"""
|
194
194
|
...
|
195
195
|
|
196
196
|
def teardown(exit_code: int | None = None) -> None:
|
197
|
-
"""Waits for
|
197
|
+
"""Waits for W&B to finish and frees resources.
|
198
198
|
|
199
199
|
Completes any runs that were not explicitly finished
|
200
200
|
using `run.finish()` and waits for all data to be uploaded.
|
@@ -220,7 +220,7 @@ def init(
|
|
220
220
|
allow_val_change: bool | None = None,
|
221
221
|
group: str | None = None,
|
222
222
|
job_type: str | None = None,
|
223
|
-
mode: Literal["online", "offline", "disabled"] | None = None,
|
223
|
+
mode: Literal["online", "offline", "disabled", "shared"] | None = None,
|
224
224
|
force: bool | None = None,
|
225
225
|
anonymous: Literal["never", "allow", "must"] | None = None,
|
226
226
|
reinit: (
|
@@ -250,53 +250,17 @@ def init(
|
|
250
250
|
|
251
251
|
`wandb.init()` spawns a new background process to log data to a run, and it
|
252
252
|
also syncs data to https://wandb.ai by default, so you can see your results
|
253
|
-
in real-time.
|
254
|
-
|
255
|
-
Call `wandb.init()` to start a run before logging data with `wandb.log()`.
|
256
|
-
When you're done logging data, call `wandb.finish()` to end the run. If you
|
257
|
-
don't call `wandb.finish()`, the run will end when your script exits.
|
258
|
-
|
259
|
-
For more on using `wandb.init()`, including detailed examples, check out our
|
260
|
-
[guide and FAQs](https://docs.wandb.ai/guides/track/launch).
|
261
|
-
|
262
|
-
Examples:
|
263
|
-
### Explicitly set the entity and project and choose a name for the run:
|
264
|
-
|
265
|
-
```python
|
266
|
-
import wandb
|
267
|
-
|
268
|
-
run = wandb.init(
|
269
|
-
entity="geoff",
|
270
|
-
project="capsules",
|
271
|
-
name="experiment-2021-10-31",
|
272
|
-
)
|
273
|
-
|
274
|
-
# ... your training code here ...
|
275
|
-
|
276
|
-
run.finish()
|
277
|
-
```
|
278
|
-
|
279
|
-
### 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.
|
280
255
|
|
281
|
-
|
282
|
-
import wandb
|
283
|
-
|
284
|
-
config = {"lr": 0.01, "batch_size": 32}
|
285
|
-
with wandb.init(config=config) as run:
|
286
|
-
run.config.update({"architecture": "resnet", "depth": 34})
|
287
|
-
|
288
|
-
# ... your training code here ...
|
289
|
-
```
|
290
|
-
|
291
|
-
Note that you can use `wandb.init()` as a context manager to automatically
|
292
|
-
call `wandb.finish()` at the end of the block.
|
256
|
+
Run IDs must not contain any of the following special characters `/ \ # ? % :`
|
293
257
|
|
294
258
|
Args:
|
295
|
-
entity: The username or team name
|
296
|
-
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
|
297
261
|
or team in the UI before starting to log runs. If not specified, the
|
298
262
|
run will default your default entity. To change the default entity,
|
299
|
-
go to
|
263
|
+
go to your settings and update the
|
300
264
|
"Default location to create new projects" under "Default team".
|
301
265
|
project: The name of the project under which this run will be logged.
|
302
266
|
If not specified, we use a heuristic to infer the project name based
|
@@ -308,9 +272,8 @@ def init(
|
|
308
272
|
to the `./wandb` directory. Note that this does not affect the
|
309
273
|
location where artifacts are stored when calling `download()`.
|
310
274
|
id: A unique identifier for this run, used for resuming. It must be unique
|
311
|
-
within the project and cannot be reused once a run is deleted.
|
312
|
-
|
313
|
-
`/ \ # ? % :`. 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,
|
314
277
|
or for saving hyperparameters to compare across runs, use `config`.
|
315
278
|
name: A short display name for this run, which appears in the UI to help
|
316
279
|
you identify it. By default, we generate a random two-word name
|
@@ -351,54 +314,56 @@ def init(
|
|
351
314
|
multiple jobs that train and evaluate a model on different test sets.
|
352
315
|
Grouping allows you to manage related runs collectively in the UI,
|
353
316
|
making it easy to toggle and review results as a unified experiment.
|
354
|
-
For more information, refer to our
|
355
|
-
[guide to grouping runs](https://docs.wandb.com/guides/runs/grouping).
|
356
317
|
job_type: Specify the type of run, especially helpful when organizing runs
|
357
318
|
within a group as part of a larger experiment. For example, in a group,
|
358
319
|
you might label runs with job types such as "train" and "eval".
|
359
320
|
Defining job types enables you to easily filter and group similar runs
|
360
321
|
in the UI, facilitating direct comparisons.
|
361
322
|
mode: Specifies how run data is managed, with the following options:
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
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.
|
369
336
|
force: Determines if a W&B login is required to run the script. If `True`,
|
370
337
|
the user must be logged in to W&B; otherwise, the script will not
|
371
338
|
proceed. If `False` (default), the script can proceed without a login,
|
372
339
|
switching to offline mode if the user is not logged in.
|
373
340
|
anonymous: Specifies the level of control over anonymous data logging.
|
374
341
|
Available options are:
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
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.
|
383
350
|
reinit: Shorthand for the "reinit" setting. Determines the behavior of
|
384
351
|
`wandb.init()` when a run is active.
|
385
352
|
resume: Controls the behavior when resuming a run with the specified `id`.
|
386
353
|
Available options are:
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
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
|
399
366
|
used. When `resume` is unset, the system will always start a new run.
|
400
|
-
For more details, see our
|
401
|
-
[guide to resuming runs](https://docs.wandb.com/guides/runs/resuming).
|
402
367
|
resume_from: Specifies a moment in a previous run to resume a run from,
|
403
368
|
using the format `{run_id}?_step={step}`. This allows users to truncate
|
404
369
|
the history logged to a run at an intermediate step and resume logging
|
@@ -407,7 +372,7 @@ def init(
|
|
407
372
|
take precedence.
|
408
373
|
`resume`, `resume_from` and `fork_from` cannot be used together, only
|
409
374
|
one of them can be used at a time.
|
410
|
-
Note
|
375
|
+
Note that this feature is in beta and may change in the future.
|
411
376
|
fork_from: Specifies a point in a previous run from which to fork a new
|
412
377
|
run, using the format `{id}?_step={step}`. This creates a new run that
|
413
378
|
resumes logging from the specified step in the target run’s history.
|
@@ -416,35 +381,45 @@ def init(
|
|
416
381
|
`fork_from` argument, an error will be raised if they are the same.
|
417
382
|
`resume`, `resume_from` and `fork_from` cannot be used together, only
|
418
383
|
one of them can be used at a time.
|
419
|
-
Note
|
384
|
+
Note that this feature is in beta and may change in the future.
|
420
385
|
save_code: Enables saving the main script or notebook to W&B, aiding in
|
421
386
|
experiment reproducibility and allowing code comparisons across runs in
|
422
387
|
the UI. By default, this is disabled, but you can change the default to
|
423
|
-
enable on your
|
388
|
+
enable on your settings page.
|
424
389
|
tensorboard: Deprecated. Use `sync_tensorboard` instead.
|
425
390
|
sync_tensorboard: Enables automatic syncing of W&B logs from TensorBoard
|
426
391
|
or TensorBoardX, saving relevant event files for viewing in the W&B UI.
|
427
392
|
saving relevant event files for viewing in the W&B UI. (Default: `False`)
|
428
393
|
monitor_gym: Enables automatic logging of videos of the environment when
|
429
|
-
using OpenAI Gym.
|
430
|
-
[guide for gym integration](https://docs.wandb.com/guides/integrations/openai-gym).
|
394
|
+
using OpenAI Gym.
|
431
395
|
settings: Specifies a dictionary or `wandb.Settings` object with advanced
|
432
396
|
settings for the run.
|
433
397
|
|
434
398
|
Returns:
|
435
|
-
A `Run` object
|
436
|
-
to perform operations like logging data, saving files, and finishing
|
437
|
-
the run. See the [Run API](https://docs.wandb.ai/ref/python/run) for
|
438
|
-
more details.
|
399
|
+
A `Run` object.
|
439
400
|
|
440
401
|
Raises:
|
441
402
|
Error: If some unknown or internal error happened during the run
|
442
403
|
initialization.
|
443
404
|
AuthenticationError: If the user failed to provide valid credentials.
|
444
|
-
CommError: If there was a problem communicating with the
|
445
|
-
UsageError: If the user provided invalid arguments
|
446
|
-
KeyboardInterrupt: If
|
447
|
-
|
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
|
+
```
|
448
423
|
"""
|
449
424
|
...
|
450
425
|
|
@@ -487,25 +462,26 @@ def login(
|
|
487
462
|
`verify=True`.
|
488
463
|
|
489
464
|
Args:
|
490
|
-
anonymous:
|
465
|
+
anonymous: Set to "must", "allow", or "never".
|
491
466
|
If set to "must", always log a user in anonymously. If set to
|
492
467
|
"allow", only create an anonymous user if the user
|
493
468
|
isn't already logged in. If set to "never", never log a
|
494
|
-
user anonymously. Default set to "never".
|
495
|
-
key:
|
496
|
-
relogin:
|
497
|
-
host:
|
498
|
-
force:
|
499
|
-
timeout:
|
500
|
-
verify:
|
501
|
-
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
|
+
|
502
478
|
|
503
479
|
Returns:
|
504
|
-
bool:
|
480
|
+
bool: If `key` is configured.
|
505
481
|
|
506
482
|
Raises:
|
507
|
-
AuthenticationError
|
508
|
-
UsageError
|
483
|
+
AuthenticationError: If `api_key` fails verification with the server.
|
484
|
+
UsageError: If `api_key` cannot be configured and no tty.
|
509
485
|
"""
|
510
486
|
...
|
511
487
|
|
@@ -517,91 +493,94 @@ def log(
|
|
517
493
|
"""Upload run data.
|
518
494
|
|
519
495
|
Use `log` to log data from runs, such as scalars, images, video,
|
520
|
-
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.
|
521
498
|
|
522
|
-
|
523
|
-
live examples, code snippets, best practices, and more.
|
499
|
+
Basic usage:
|
524
500
|
|
525
|
-
|
526
|
-
|
527
|
-
|
501
|
+
```python
|
502
|
+
import wandb
|
503
|
+
|
504
|
+
with wandb.init() as run:
|
505
|
+
run.log({"train-loss": 0.5, "accuracy": 0.9})
|
506
|
+
```
|
528
507
|
|
529
|
-
|
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),
|
530
512
|
or locally on a [self-hosted instance](https://docs.wandb.ai/guides/hosting)
|
531
|
-
of the W&B app, or export data to visualize and explore locally,
|
532
|
-
Jupyter
|
533
|
-
|
534
|
-
Logged values don't have to be scalars.
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
[guide to logging tables](https://docs.wandb.ai/guides/models/tables/tables-walkthrough)
|
543
|
-
for details.
|
544
|
-
|
545
|
-
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
|
546
524
|
into sections named using the text before the final slash. For example,
|
547
525
|
the following results in two sections named "train" and "validate":
|
548
526
|
|
549
|
-
```
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
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
|
+
)
|
558
538
|
```
|
559
539
|
|
560
540
|
Only one level of nesting is supported; `run.log({"a/b/c": 1})`
|
561
541
|
produces a section named "a/b".
|
562
542
|
|
563
|
-
`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.
|
564
544
|
For optimal performance, limit your logging to once every N iterations,
|
565
545
|
or collect data over multiple iterations and log it in a single step.
|
566
546
|
|
567
|
-
|
568
|
-
|
569
|
-
With basic usage, each call to `log` creates a new "step".
|
547
|
+
By default, each call to `log` creates a new "step".
|
570
548
|
The step must always increase, and it is not possible to log
|
571
|
-
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.
|
572
552
|
|
573
|
-
Note that you can use any metric as the X axis in charts.
|
574
553
|
In many cases, it is better to treat the W&B step like
|
575
554
|
you'd treat a timestamp rather than a training step.
|
576
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})
|
577
560
|
```
|
578
|
-
# Example: log an "epoch" metric for use as an X axis.
|
579
|
-
run.log({"epoch": 40, "train-loss": 0.5})
|
580
|
-
```
|
581
|
-
|
582
|
-
See also [define_metric](https://docs.wandb.ai/ref/python/run#define_metric).
|
583
561
|
|
584
|
-
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
|
585
563
|
the same step with the `step` and `commit` parameters.
|
586
564
|
The following are all equivalent:
|
587
565
|
|
588
|
-
```
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
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)
|
605
584
|
```
|
606
585
|
|
607
586
|
Args:
|
@@ -619,59 +598,64 @@ def log(
|
|
619
598
|
otherwise, the default is `commit=False`.
|
620
599
|
|
621
600
|
Examples:
|
622
|
-
|
623
|
-
|
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
|
624
608
|
|
625
|
-
|
626
|
-
|
627
|
-
|
609
|
+
with wandb.init() as run:
|
610
|
+
run.log({"train-loss": 0.5, "accuracy": 0.9
|
611
|
+
```
|
628
612
|
|
629
|
-
|
630
|
-
run.log({"accuracy": 0.9, "epoch": 5})
|
631
|
-
```
|
613
|
+
Incremental logging
|
632
614
|
|
633
|
-
|
634
|
-
|
635
|
-
import wandb
|
615
|
+
```python
|
616
|
+
import wandb
|
636
617
|
|
637
|
-
|
618
|
+
with wandb.init() as run:
|
638
619
|
run.log({"loss": 0.2}, commit=False)
|
639
620
|
# Somewhere else when I'm ready to report this step:
|
640
621
|
run.log({"accuracy": 0.8})
|
641
|
-
|
622
|
+
```
|
623
|
+
|
624
|
+
Histogram
|
642
625
|
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
import wandb
|
626
|
+
```python
|
627
|
+
import numpy as np
|
628
|
+
import wandb
|
647
629
|
|
648
|
-
|
649
|
-
|
650
|
-
|
630
|
+
# sample gradients at random from normal distribution
|
631
|
+
gradients = np.random.randn(100, 100)
|
632
|
+
with wandb.init() as run:
|
651
633
|
run.log({"gradients": wandb.Histogram(gradients)})
|
652
|
-
|
634
|
+
```
|
653
635
|
|
654
|
-
|
655
|
-
```python
|
656
|
-
import numpy as np
|
657
|
-
import wandb
|
636
|
+
Image from NumPy
|
658
637
|
|
659
|
-
|
638
|
+
```python
|
639
|
+
import numpy as np
|
640
|
+
import wandb
|
641
|
+
|
642
|
+
with wandb.init() as run:
|
660
643
|
examples = []
|
661
644
|
for i in range(3):
|
662
645
|
pixels = np.random.randint(low=0, high=256, size=(100, 100, 3))
|
663
646
|
image = wandb.Image(pixels, caption=f"random field {i}")
|
664
647
|
examples.append(image)
|
665
648
|
run.log({"examples": examples})
|
666
|
-
|
649
|
+
```
|
667
650
|
|
668
|
-
|
669
|
-
```python
|
670
|
-
import numpy as np
|
671
|
-
from PIL import Image as PILImage
|
672
|
-
import wandb
|
651
|
+
Image from PIL
|
673
652
|
|
674
|
-
|
653
|
+
```python
|
654
|
+
import numpy as np
|
655
|
+
from PIL import Image as PILImage
|
656
|
+
import wandb
|
657
|
+
|
658
|
+
with wandb.init() as run:
|
675
659
|
examples = []
|
676
660
|
for i in range(3):
|
677
661
|
pixels = np.random.randint(
|
@@ -684,14 +668,15 @@ def log(
|
|
684
668
|
image = wandb.Image(pil_image, caption=f"random field {i}")
|
685
669
|
examples.append(image)
|
686
670
|
run.log({"examples": examples})
|
687
|
-
|
671
|
+
```
|
688
672
|
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
673
|
+
Video from NumPy
|
674
|
+
|
675
|
+
```python
|
676
|
+
import numpy as np
|
677
|
+
import wandb
|
693
678
|
|
694
|
-
|
679
|
+
with wandb.init() as run:
|
695
680
|
# axes are (time, channel, height, width)
|
696
681
|
frames = np.random.randint(
|
697
682
|
low=0,
|
@@ -700,35 +685,38 @@ def log(
|
|
700
685
|
dtype=np.uint8,
|
701
686
|
)
|
702
687
|
run.log({"video": wandb.Video(frames, fps=4)})
|
703
|
-
|
688
|
+
```
|
689
|
+
|
690
|
+
Matplotlib plot
|
704
691
|
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
import wandb
|
692
|
+
```python
|
693
|
+
from matplotlib import pyplot as plt
|
694
|
+
import numpy as np
|
695
|
+
import wandb
|
710
696
|
|
711
|
-
|
697
|
+
with wandb.init() as run:
|
712
698
|
fig, ax = plt.subplots()
|
713
699
|
x = np.linspace(0, 10)
|
714
700
|
y = x * x
|
715
701
|
ax.plot(x, y) # plot y = x^2
|
716
702
|
run.log({"chart": fig})
|
717
|
-
|
703
|
+
```
|
704
|
+
|
705
|
+
PR Curve
|
718
706
|
|
719
|
-
|
720
|
-
|
721
|
-
import wandb
|
707
|
+
```python
|
708
|
+
import wandb
|
722
709
|
|
723
|
-
|
710
|
+
with wandb.init() as run:
|
724
711
|
run.log({"pr": wandb.plot.pr_curve(y_test, y_probas, labels)})
|
725
|
-
|
712
|
+
```
|
726
713
|
|
727
|
-
|
728
|
-
```python
|
729
|
-
import wandb
|
714
|
+
3D Object
|
730
715
|
|
731
|
-
|
716
|
+
```python
|
717
|
+
import wandb
|
718
|
+
|
719
|
+
with wandb.init() as run:
|
732
720
|
run.log(
|
733
721
|
{
|
734
722
|
"generated_samples": [
|
@@ -738,11 +726,11 @@ def log(
|
|
738
726
|
]
|
739
727
|
}
|
740
728
|
)
|
741
|
-
|
729
|
+
```
|
742
730
|
|
743
731
|
Raises:
|
744
|
-
wandb.Error:
|
745
|
-
ValueError:
|
732
|
+
wandb.Error: If called before `wandb.init()`.
|
733
|
+
ValueError: If invalid data is passed.
|
746
734
|
"""
|
747
735
|
...
|
748
736
|
|
@@ -761,42 +749,48 @@ def save(
|
|
761
749
|
|
762
750
|
A `base_path` may be provided to control the directory structure of
|
763
751
|
uploaded files. It should be a prefix of `glob_str`, and the directory
|
764
|
-
structure beneath it is preserved.
|
765
|
-
examples:
|
766
|
-
|
767
|
-
```
|
768
|
-
wandb.save("these/are/myfiles/*")
|
769
|
-
# => Saves files in a "these/are/myfiles/" folder in the run.
|
770
|
-
|
771
|
-
wandb.save("these/are/myfiles/*", base_path="these")
|
772
|
-
# => Saves files in an "are/myfiles/" folder in the run.
|
752
|
+
structure beneath it is preserved.
|
773
753
|
|
774
|
-
|
775
|
-
# => Saves files in a "run123/" folder in the run. See note below.
|
776
|
-
|
777
|
-
wandb.save("/User/username/Documents/run123/*.txt", base_path="/User")
|
778
|
-
# => Saves files in a "username/Documents/run123/" folder in the run.
|
779
|
-
|
780
|
-
wandb.save("files/*/saveme.txt")
|
781
|
-
# => Saves each "saveme.txt" file in an appropriate subdirectory
|
782
|
-
# of "files/".
|
783
|
-
```
|
784
|
-
|
785
|
-
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
|
786
755
|
directory level is preserved as in the example above.
|
787
756
|
|
788
757
|
Args:
|
789
758
|
glob_str: A relative or absolute path or Unix glob.
|
790
759
|
base_path: A path to use to infer a directory structure; see examples.
|
791
760
|
policy: One of `live`, `now`, or `end`.
|
792
|
-
|
793
|
-
|
794
|
-
|
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
|
795
764
|
|
796
765
|
Returns:
|
797
766
|
Paths to the symlinks created for the matched files.
|
798
767
|
|
799
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
|
+
```
|
800
794
|
"""
|
801
795
|
...
|
802
796
|
|
@@ -814,11 +808,12 @@ def sweep(
|
|
814
808
|
Make note the unique identifier, `sweep_id`, that is returned.
|
815
809
|
At a later step provide the `sweep_id` to a sweep agent.
|
816
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
|
+
|
817
814
|
Args:
|
818
815
|
sweep: The configuration of a hyperparameter search.
|
819
|
-
(or configuration generator).
|
820
|
-
[Sweep configuration structure](https://docs.wandb.ai/guides/sweeps/define-sweep-configuration)
|
821
|
-
for information on how to define your sweep.
|
816
|
+
(or configuration generator).
|
822
817
|
If you provide a callable, ensure that the callable does
|
823
818
|
not take arguments and that it returns a dictionary that
|
824
819
|
conforms to the W&B sweep config spec.
|
@@ -833,7 +828,7 @@ def sweep(
|
|
833
828
|
prior_runs: The run IDs of existing runs to add to this sweep.
|
834
829
|
|
835
830
|
Returns:
|
836
|
-
|
831
|
+
str: A unique identifier for the sweep.
|
837
832
|
"""
|
838
833
|
...
|
839
834
|
|
@@ -844,16 +839,16 @@ def controller(
|
|
844
839
|
) -> _WandbController:
|
845
840
|
"""Public sweep controller constructor.
|
846
841
|
|
847
|
-
|
848
|
-
|
849
|
-
|
842
|
+
Examples:
|
843
|
+
```python
|
844
|
+
import wandb
|
850
845
|
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
846
|
+
tuner = wandb.controller(...)
|
847
|
+
print(tuner.sweep_config)
|
848
|
+
print(tuner.sweep_id)
|
849
|
+
tuner.configure_search(...)
|
850
|
+
tuner.configure_stopping(...)
|
851
|
+
```
|
857
852
|
"""
|
858
853
|
...
|
859
854
|
|
@@ -896,23 +891,26 @@ def define_metric(
|
|
896
891
|
goal: str | None = None,
|
897
892
|
overwrite: bool | None = None,
|
898
893
|
) -> wandb_metric.Metric:
|
899
|
-
"""Customize metrics logged with `wandb.log()`.
|
894
|
+
"""Customize metrics logged with `wandb.Run.log()`.
|
900
895
|
|
901
896
|
Args:
|
902
897
|
name: The name of the metric to customize.
|
903
898
|
step_metric: The name of another metric to serve as the X-axis
|
904
899
|
for this metric in automatically generated charts.
|
905
900
|
step_sync: Automatically insert the last value of step_metric into
|
906
|
-
`
|
901
|
+
`wandb.Run.log()` if it is not provided explicitly. Defaults to True
|
907
902
|
if step_metric is specified.
|
908
903
|
hidden: Hide this metric from automatic plots.
|
909
904
|
summary: Specify aggregate metrics added to summary.
|
910
905
|
Supported aggregations include "min", "max", "mean", "last",
|
911
|
-
"best", "copy" and "none". "
|
912
|
-
|
913
|
-
"
|
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.
|
914
911
|
goal: Specify how to interpret the "best" summary type.
|
915
|
-
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.
|
916
914
|
overwrite: If false, then this call is merged with previous
|
917
915
|
`define_metric` calls for the same metric by using their
|
918
916
|
values for any unspecified parameters. If true, then
|
@@ -968,19 +966,43 @@ def use_artifact(
|
|
968
966
|
Call `download` or `file` on the returned object to get the contents locally.
|
969
967
|
|
970
968
|
Args:
|
971
|
-
artifact_or_name:
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
type:
|
979
|
-
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
|
980
978
|
use_as: This argument is deprecated and does nothing.
|
981
979
|
|
982
980
|
Returns:
|
983
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
|
+
```
|
984
1006
|
"""
|
985
1007
|
...
|
986
1008
|
|
@@ -991,39 +1013,24 @@ def log_model(
|
|
991
1013
|
) -> None:
|
992
1014
|
"""Logs a model artifact containing the contents inside the 'path' to a run and marks it as an output to this run.
|
993
1015
|
|
1016
|
+
The name of model artifact can only contain alphanumeric characters,
|
1017
|
+
underscores, and hyphens.
|
1018
|
+
|
994
1019
|
Args:
|
995
1020
|
path: (str) A path to the contents of this model,
|
996
1021
|
can be in the following forms:
|
997
1022
|
- `/local/directory`
|
998
1023
|
- `/local/directory/file.txt`
|
999
1024
|
- `s3://bucket/path`
|
1000
|
-
name:
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
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,
|
1005
1030
|
defaults to `["latest"]`
|
1006
1031
|
|
1007
|
-
Examples:
|
1008
|
-
```python
|
1009
|
-
run.log_model(
|
1010
|
-
path="/local/directory",
|
1011
|
-
name="my_model_artifact",
|
1012
|
-
aliases=["production"],
|
1013
|
-
)
|
1014
|
-
```
|
1015
|
-
|
1016
|
-
Invalid usage
|
1017
|
-
```python
|
1018
|
-
run.log_model(
|
1019
|
-
path="/local/directory",
|
1020
|
-
name="my_entity/my_project/my_model_artifact",
|
1021
|
-
aliases=["production"],
|
1022
|
-
)
|
1023
|
-
```
|
1024
|
-
|
1025
1032
|
Raises:
|
1026
|
-
ValueError:
|
1033
|
+
ValueError: If name has invalid special characters.
|
1027
1034
|
|
1028
1035
|
Returns:
|
1029
1036
|
None
|
@@ -1034,40 +1041,18 @@ def use_model(name: str) -> FilePathStr:
|
|
1034
1041
|
"""Download the files logged in a model artifact 'name'.
|
1035
1042
|
|
1036
1043
|
Args:
|
1037
|
-
name:
|
1038
|
-
model artifact.
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
- model_artifact_name:alias
|
1043
|
-
|
1044
|
-
Examples:
|
1045
|
-
```python
|
1046
|
-
run.use_model(
|
1047
|
-
name="my_model_artifact:latest",
|
1048
|
-
)
|
1049
|
-
|
1050
|
-
run.use_model(
|
1051
|
-
name="my_project/my_model_artifact:v0",
|
1052
|
-
)
|
1053
|
-
|
1054
|
-
run.use_model(
|
1055
|
-
name="my_entity/my_project/my_model_artifact:<digest>",
|
1056
|
-
)
|
1057
|
-
```
|
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
|
1058
1049
|
|
1059
|
-
|
1060
|
-
|
1061
|
-
run.use_model(
|
1062
|
-
name="my_entity/my_project/my_model_artifact",
|
1063
|
-
)
|
1064
|
-
```
|
1050
|
+
Returns:
|
1051
|
+
path (str): Path to downloaded model artifact file(s).
|
1065
1052
|
|
1066
1053
|
Raises:
|
1067
|
-
AssertionError:
|
1068
|
-
|
1069
|
-
Returns:
|
1070
|
-
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'.
|
1071
1056
|
"""
|
1072
1057
|
...
|
1073
1058
|
|
@@ -1079,66 +1064,43 @@ def link_model(
|
|
1079
1064
|
) -> Artifact | None:
|
1080
1065
|
"""Log a model artifact version and link it to a registered model in the model registry.
|
1081
1066
|
|
1082
|
-
|
1067
|
+
Linked model versions are visible in the UI for the specified registered model.
|
1083
1068
|
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
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.
|
1092
1077
|
|
1093
1078
|
Args:
|
1094
|
-
path: (str) A path to the contents of this model,
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
registered_model_name:
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
run.link_model(
|
1111
|
-
path="/local/directory",
|
1112
|
-
registered_model_name="my_reg_model",
|
1113
|
-
name="my_model_artifact",
|
1114
|
-
aliases=["production"],
|
1115
|
-
)
|
1116
|
-
```
|
1117
|
-
|
1118
|
-
Invalid usage
|
1119
|
-
```python
|
1120
|
-
run.link_model(
|
1121
|
-
path="/local/directory",
|
1122
|
-
registered_model_name="my_entity/my_project/my_reg_model",
|
1123
|
-
name="my_model_artifact",
|
1124
|
-
aliases=["production"],
|
1125
|
-
)
|
1126
|
-
|
1127
|
-
run.link_model(
|
1128
|
-
path="/local/directory",
|
1129
|
-
registered_model_name="my_reg_model",
|
1130
|
-
name="my_entity/my_project/my_model_artifact",
|
1131
|
-
aliases=["production"],
|
1132
|
-
)
|
1133
|
-
```
|
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.
|
1134
1095
|
|
1135
1096
|
Raises:
|
1136
|
-
AssertionError:
|
1137
|
-
if model artifact 'name' is of a type that does not contain
|
1138
|
-
|
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.
|
1139
1101
|
|
1140
1102
|
Returns:
|
1141
|
-
The linked artifact if linking was successful, otherwise None
|
1103
|
+
The linked artifact if linking was successful, otherwise `None`.
|
1142
1104
|
"""
|
1143
1105
|
...
|
1144
1106
|
|
@@ -1154,27 +1116,50 @@ def plot_table(
|
|
1154
1116
|
This function creates a custom chart based on a Vega-Lite specification and
|
1155
1117
|
a data table represented by a `wandb.Table` object. The specification needs
|
1156
1118
|
to be predefined and stored in the W&B backend. The function returns a custom
|
1157
|
-
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()`.
|
1158
1120
|
|
1159
1121
|
Args:
|
1160
|
-
vega_spec_name
|
1122
|
+
vega_spec_name: The name or identifier of the Vega-Lite spec
|
1161
1123
|
that defines the visualization structure.
|
1162
|
-
data_table
|
1124
|
+
data_table: A `wandb.Table` object containing the data to be
|
1163
1125
|
visualized.
|
1164
|
-
fields
|
1126
|
+
fields: A mapping between the fields in the Vega-Lite spec and the
|
1165
1127
|
corresponding columns in the data table to be visualized.
|
1166
|
-
string_fields
|
1128
|
+
string_fields: A dictionary for providing values for any string constants
|
1167
1129
|
required by the custom visualization.
|
1168
|
-
split_table
|
1130
|
+
split_table: Whether the table should be split into a separate section
|
1169
1131
|
in the W&B UI. If `True`, the table will be displayed in a section named
|
1170
1132
|
"Custom Chart Tables". Default is `False`.
|
1171
1133
|
|
1172
1134
|
Returns:
|
1173
1135
|
CustomChart: A custom chart object that can be logged to W&B. To log the
|
1174
|
-
chart, pass
|
1136
|
+
chart, pass the chart object as argument to `wandb.Run.log()`.
|
1175
1137
|
|
1176
1138
|
Raises:
|
1177
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
|
+
```
|
1178
1163
|
"""
|
1179
1164
|
...
|
1180
1165
|
|
@@ -1186,29 +1171,22 @@ def watch(
|
|
1186
1171
|
idx: int | None = None,
|
1187
1172
|
log_graph: bool = False,
|
1188
1173
|
) -> None:
|
1189
|
-
"""
|
1174
|
+
"""Hook into given PyTorch model to monitor gradients and the model's computational graph.
|
1190
1175
|
|
1191
|
-
This function can track parameters, gradients, or both during training.
|
1192
|
-
extended to support arbitrary machine learning models in the future.
|
1176
|
+
This function can track parameters, gradients, or both during training.
|
1193
1177
|
|
1194
1178
|
Args:
|
1195
|
-
models
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
log
|
1200
|
-
|
1201
|
-
|
1202
|
-
log_freq (int):
|
1203
|
-
Frequency (in batches) to log gradients and parameters. (default=1000)
|
1204
|
-
idx (Optional[int]):
|
1205
|
-
Index used when tracking multiple models with `wandb.watch`. (default=None)
|
1206
|
-
log_graph (bool):
|
1207
|
-
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)
|
1208
1186
|
|
1209
1187
|
Raises:
|
1210
1188
|
ValueError:
|
1211
|
-
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
|
1212
1190
|
of `torch.nn.Module`.
|
1213
1191
|
"""
|
1214
1192
|
...
|
@@ -1219,8 +1197,7 @@ def unwatch(
|
|
1219
1197
|
"""Remove pytorch model topology, gradient and parameter hooks.
|
1220
1198
|
|
1221
1199
|
Args:
|
1222
|
-
models
|
1223
|
-
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.
|
1224
1201
|
"""
|
1225
1202
|
...
|
1226
1203
|
|
@@ -1236,18 +1213,18 @@ def restore(
|
|
1236
1213
|
By default, will only download the file if it doesn't already exist.
|
1237
1214
|
|
1238
1215
|
Args:
|
1239
|
-
name:
|
1240
|
-
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`
|
1241
1218
|
if wandb.init has not been called, this is required.
|
1242
|
-
replace:
|
1243
|
-
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
|
1244
1221
|
directory or the run directory if wandb.init was called.
|
1245
1222
|
|
1246
1223
|
Returns:
|
1247
|
-
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.
|
1248
1225
|
|
1249
1226
|
Raises:
|
1250
|
-
|
1251
|
-
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.
|
1252
1229
|
"""
|
1253
1230
|
...
|