wandb 0.19.9__py3-none-any.whl → 0.19.10__py3-none-any.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 +1 -1
- wandb/__init__.pyi +4 -1
- wandb/_pydantic/__init__.py +14 -7
- wandb/_pydantic/base.py +44 -9
- wandb/_pydantic/utils.py +66 -0
- wandb/_pydantic/v1_compat.py +78 -56
- wandb/apis/public/__init__.py +2 -2
- wandb/apis/public/api.py +114 -2
- wandb/apis/public/artifacts.py +365 -673
- wandb/apis/public/automations.py +69 -0
- wandb/apis/public/integrations.py +168 -0
- wandb/apis/public/projects.py +29 -0
- wandb/apis/public/utils.py +107 -1
- wandb/automations/__init__.py +81 -0
- wandb/automations/_filters/__init__.py +40 -0
- wandb/automations/_filters/expressions.py +179 -0
- wandb/automations/_filters/operators.py +267 -0
- wandb/automations/_filters/run_metrics.py +183 -0
- wandb/automations/_generated/__init__.py +184 -0
- wandb/automations/_generated/create_filter_trigger.py +21 -0
- wandb/automations/_generated/create_generic_webhook_integration.py +43 -0
- wandb/automations/_generated/delete_trigger.py +19 -0
- wandb/automations/_generated/enums.py +33 -0
- wandb/automations/_generated/fragments.py +343 -0
- wandb/automations/_generated/generic_webhook_integrations_by_entity.py +22 -0
- wandb/automations/_generated/get_triggers.py +24 -0
- wandb/automations/_generated/get_triggers_by_entity.py +24 -0
- wandb/automations/_generated/input_types.py +104 -0
- wandb/automations/_generated/integrations_by_entity.py +22 -0
- wandb/automations/_generated/operations.py +710 -0
- wandb/automations/_generated/slack_integrations_by_entity.py +22 -0
- wandb/automations/_generated/update_filter_trigger.py +21 -0
- wandb/automations/_utils.py +123 -0
- wandb/automations/_validators.py +73 -0
- wandb/automations/actions.py +205 -0
- wandb/automations/automations.py +109 -0
- wandb/automations/events.py +235 -0
- wandb/automations/integrations.py +26 -0
- wandb/automations/scopes.py +76 -0
- wandb/beta/workflows.py +9 -10
- wandb/bin/gpu_stats +0 -0
- wandb/cli/cli.py +3 -3
- wandb/integration/keras/keras.py +2 -1
- wandb/integration/langchain/wandb_tracer.py +2 -1
- wandb/jupyter.py +137 -118
- wandb/old/summary.py +0 -2
- wandb/proto/v3/wandb_internal_pb2.py +293 -292
- wandb/proto/v3/wandb_settings_pb2.py +2 -2
- wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
- wandb/proto/v4/wandb_internal_pb2.py +292 -292
- wandb/proto/v4/wandb_settings_pb2.py +2 -2
- wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
- wandb/proto/v5/wandb_internal_pb2.py +292 -292
- wandb/proto/v5/wandb_settings_pb2.py +2 -2
- wandb/proto/v5/wandb_telemetry_pb2.py +10 -10
- wandb/proto/v6/wandb_base_pb2.py +41 -0
- wandb/proto/v6/wandb_internal_pb2.py +393 -0
- wandb/proto/v6/wandb_server_pb2.py +78 -0
- wandb/proto/v6/wandb_settings_pb2.py +58 -0
- wandb/proto/v6/wandb_telemetry_pb2.py +52 -0
- wandb/proto/wandb_base_pb2.py +2 -0
- wandb/proto/wandb_deprecated.py +8 -0
- wandb/proto/wandb_internal_pb2.py +3 -1
- wandb/proto/wandb_server_pb2.py +2 -0
- wandb/proto/wandb_settings_pb2.py +2 -0
- wandb/proto/wandb_telemetry_pb2.py +2 -0
- wandb/sdk/artifacts/_generated/__init__.py +248 -0
- wandb/sdk/artifacts/_generated/artifact_collection_membership_files.py +43 -0
- wandb/sdk/artifacts/_generated/artifact_version_files.py +36 -0
- wandb/sdk/artifacts/_generated/create_artifact_collection_tag_assignments.py +36 -0
- wandb/sdk/artifacts/_generated/delete_artifact_collection_tag_assignments.py +25 -0
- wandb/sdk/artifacts/_generated/delete_artifact_portfolio.py +35 -0
- wandb/sdk/artifacts/_generated/delete_artifact_sequence.py +35 -0
- wandb/sdk/artifacts/_generated/enums.py +17 -0
- wandb/sdk/artifacts/_generated/fragments.py +186 -0
- wandb/sdk/artifacts/_generated/input_types.py +16 -0
- wandb/sdk/artifacts/_generated/move_artifact_collection.py +35 -0
- wandb/sdk/artifacts/_generated/operations.py +510 -0
- wandb/sdk/artifacts/_generated/project_artifact_collection.py +101 -0
- wandb/sdk/artifacts/_generated/project_artifact_collections.py +33 -0
- wandb/sdk/artifacts/_generated/project_artifact_type.py +24 -0
- wandb/sdk/artifacts/_generated/project_artifact_types.py +24 -0
- wandb/sdk/artifacts/_generated/project_artifacts.py +42 -0
- wandb/sdk/artifacts/_generated/run_input_artifacts.py +51 -0
- wandb/sdk/artifacts/_generated/run_output_artifacts.py +51 -0
- wandb/sdk/artifacts/_generated/update_artifact_portfolio.py +35 -0
- wandb/sdk/artifacts/_generated/update_artifact_sequence.py +35 -0
- wandb/sdk/artifacts/_graphql_fragments.py +56 -79
- wandb/sdk/artifacts/artifact.py +40 -13
- wandb/sdk/artifacts/artifact_manifest_entry.py +2 -1
- wandb/sdk/artifacts/storage_handlers/azure_handler.py +1 -0
- wandb/sdk/data_types/base_types/media.py +2 -3
- wandb/sdk/data_types/base_types/wb_value.py +34 -11
- wandb/sdk/data_types/html.py +36 -9
- wandb/sdk/data_types/image.py +12 -12
- wandb/sdk/data_types/table.py +5 -0
- wandb/sdk/data_types/trace_tree.py +2 -0
- wandb/sdk/data_types/utils.py +1 -1
- wandb/sdk/data_types/video.py +14 -26
- wandb/sdk/interface/interface.py +2 -0
- wandb/sdk/internal/profiler.py +6 -5
- wandb/sdk/internal/run.py +13 -6
- wandb/sdk/lib/apikey.py +25 -4
- wandb/sdk/lib/asyncio_compat.py +1 -1
- wandb/sdk/lib/deprecate.py +13 -22
- wandb/sdk/lib/disabled.py +2 -1
- wandb/sdk/lib/printer.py +37 -8
- wandb/sdk/lib/printer_asyncio.py +46 -0
- wandb/sdk/lib/redirect.py +10 -5
- wandb/sdk/service/server_sock.py +19 -14
- wandb/sdk/service/service.py +9 -7
- wandb/sdk/service/streams.py +5 -0
- wandb/sdk/verify/verify.py +6 -3
- wandb/sdk/wandb_init.py +185 -65
- wandb/sdk/wandb_login.py +13 -4
- wandb/sdk/wandb_run.py +382 -286
- wandb/sdk/wandb_settings.py +21 -3
- wandb/sdk/wandb_setup.py +49 -0
- wandb/util.py +29 -29
- {wandb-0.19.9.dist-info → wandb-0.19.10.dist-info}/METADATA +5 -5
- {wandb-0.19.9.dist-info → wandb-0.19.10.dist-info}/RECORD +124 -71
- wandb/_globals.py +0 -19
- wandb/sdk/internal/_generated/base.py +0 -226
- wandb/sdk/internal/_generated/typing_compat.py +0 -14
- {wandb-0.19.9.dist-info → wandb-0.19.10.dist-info}/WHEEL +0 -0
- {wandb-0.19.9.dist-info → wandb-0.19.10.dist-info}/entry_points.txt +0 -0
- {wandb-0.19.9.dist-info → wandb-0.19.10.dist-info}/licenses/LICENSE +0 -0
wandb/jupyter.py
CHANGED
@@ -1,160 +1,171 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import json
|
2
4
|
import logging
|
3
5
|
import os
|
4
6
|
import re
|
5
7
|
import shutil
|
6
8
|
import sys
|
9
|
+
import traceback
|
7
10
|
from base64 import b64encode
|
8
|
-
from typing import
|
11
|
+
from typing import Any
|
9
12
|
|
13
|
+
import IPython
|
14
|
+
import IPython.display
|
10
15
|
import requests
|
16
|
+
from IPython.core.magic import Magics, line_cell_magic, magics_class
|
17
|
+
from IPython.core.magic_arguments import argument, magic_arguments, parse_argstring
|
11
18
|
from requests.compat import urljoin
|
12
19
|
|
13
20
|
import wandb
|
14
21
|
import wandb.util
|
22
|
+
from wandb.sdk import wandb_run, wandb_setup
|
15
23
|
from wandb.sdk.lib import filesystem
|
16
24
|
|
17
|
-
|
18
|
-
import IPython
|
19
|
-
from IPython.core.magic import Magics, line_cell_magic, magics_class
|
20
|
-
from IPython.core.magic_arguments import argument, magic_arguments, parse_argstring
|
21
|
-
except ImportError:
|
22
|
-
wandb.termwarn("ipython is not supported in python 2.7, upgrade to 3.x")
|
25
|
+
logger = logging.getLogger(__name__)
|
23
26
|
|
24
|
-
class Magics:
|
25
|
-
pass
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
def display_if_magic_is_used(run: wandb_run.Run) -> bool:
|
29
|
+
"""Display a run's page if the cell has the %%wandb cell magic.
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
Args:
|
32
|
+
run: The run to display.
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
Returns:
|
35
|
+
Whether the %%wandb cell magic was present.
|
36
|
+
"""
|
37
|
+
if not _current_cell_wandb_magic:
|
38
|
+
return False
|
35
39
|
|
36
|
-
|
37
|
-
|
40
|
+
_current_cell_wandb_magic.display_if_allowed(run)
|
41
|
+
return True
|
38
42
|
|
39
43
|
|
40
|
-
|
44
|
+
class _WandbCellMagicState:
|
45
|
+
"""State for a cell with the %%wandb cell magic."""
|
41
46
|
|
42
|
-
|
47
|
+
def __init__(self, *, height: int) -> None:
|
48
|
+
"""Initializes the %%wandb cell magic state.
|
43
49
|
|
50
|
+
Args:
|
51
|
+
height: The desired height for displayed iframes.
|
52
|
+
"""
|
53
|
+
self._height = height
|
54
|
+
self._already_displayed = False
|
44
55
|
|
45
|
-
def
|
46
|
-
|
47
|
-
if __IFrame is not None:
|
48
|
-
return __IFrame.maybe_display()
|
49
|
-
return False
|
56
|
+
def display_if_allowed(self, run: wandb_run.Run) -> None:
|
57
|
+
"""Display a run's iframe if one is not already displayed.
|
50
58
|
|
59
|
+
Args:
|
60
|
+
run: The run to display.
|
61
|
+
"""
|
62
|
+
if self._already_displayed:
|
63
|
+
return
|
64
|
+
self._already_displayed = True
|
51
65
|
|
52
|
-
|
53
|
-
if __IFrame is not None:
|
54
|
-
return __IFrame.opts.get("quiet")
|
55
|
-
return False
|
66
|
+
_display_wandb_run(run, height=self._height)
|
56
67
|
|
57
68
|
|
58
|
-
|
59
|
-
def __init__(self, path=None, opts=None):
|
60
|
-
self.path = path
|
61
|
-
self.api = wandb.Api()
|
62
|
-
self.opts = opts or {}
|
63
|
-
self.displayed = False
|
64
|
-
self.height = self.opts.get("height", 420)
|
69
|
+
_current_cell_wandb_magic: _WandbCellMagicState | None = None
|
65
70
|
|
66
|
-
def maybe_display(self) -> bool:
|
67
|
-
if not self.displayed and (self.path or wandb.run):
|
68
|
-
IPython.display.display(self)
|
69
|
-
return self.displayed
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
72
|
+
def _display_by_wandb_path(path: str, *, height: int) -> None:
|
73
|
+
"""Display a wandb object (usually in an iframe) given its URI.
|
74
|
+
|
75
|
+
Args:
|
76
|
+
path: A path to a run, sweep, project, report, etc.
|
77
|
+
height: Height of the iframe in pixels.
|
78
|
+
"""
|
79
|
+
api = wandb.Api()
|
80
|
+
|
81
|
+
try:
|
82
|
+
obj = api.from_path(path)
|
83
|
+
|
84
|
+
IPython.display.display_html(
|
85
|
+
obj.to_html(height=height),
|
86
|
+
raw=True,
|
87
|
+
)
|
88
|
+
except wandb.Error:
|
89
|
+
traceback.print_exc()
|
90
|
+
IPython.display.display_html(
|
91
|
+
f"Path {path!r} does not refer to a W&B object you can access.",
|
92
|
+
raw=True,
|
93
|
+
)
|
94
|
+
|
95
|
+
|
96
|
+
def _display_wandb_run(run: wandb_run.Run, *, height: int) -> None:
|
97
|
+
"""Display a run (usually in an iframe).
|
98
|
+
|
99
|
+
Args:
|
100
|
+
run: The run to display.
|
101
|
+
height: Height of the iframe in pixels.
|
102
|
+
"""
|
103
|
+
IPython.display.display_html(
|
104
|
+
run.to_html(height=height),
|
105
|
+
raw=True,
|
106
|
+
)
|
96
107
|
|
97
108
|
|
98
109
|
@magics_class
|
99
110
|
class WandBMagics(Magics):
|
100
|
-
def __init__(self, shell
|
111
|
+
def __init__(self, shell):
|
101
112
|
super().__init__(shell)
|
102
|
-
self.options = {}
|
103
113
|
|
104
114
|
@magic_arguments()
|
105
115
|
@argument(
|
106
116
|
"path",
|
107
117
|
default=None,
|
108
118
|
nargs="?",
|
109
|
-
help="
|
110
|
-
)
|
111
|
-
@argument(
|
112
|
-
"-w",
|
113
|
-
"--workspace",
|
114
|
-
default=False,
|
115
|
-
action="store_true",
|
116
|
-
help="Display the entire run project workspace",
|
117
|
-
)
|
118
|
-
@argument(
|
119
|
-
"-q",
|
120
|
-
"--quiet",
|
121
|
-
default=False,
|
122
|
-
action="store_true",
|
123
|
-
help="Display the minimal amount of output",
|
119
|
+
help="The path to a resource you want to display.",
|
124
120
|
)
|
125
121
|
@argument(
|
126
122
|
"-h",
|
127
123
|
"--height",
|
128
124
|
default=420,
|
129
125
|
type=int,
|
130
|
-
help="The height of the iframe in pixels",
|
126
|
+
help="The height of the iframe in pixels.",
|
131
127
|
)
|
132
128
|
@line_cell_magic
|
133
|
-
def wandb(self, line, cell=None):
|
134
|
-
"""Display wandb resources in
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
129
|
+
def wandb(self, line: str, cell: str | None = None) -> None:
|
130
|
+
"""Display wandb resources in Jupyter.
|
131
|
+
|
132
|
+
This can be used as a line magic:
|
133
|
+
|
134
|
+
%wandb USERNAME/PROJECT/runs/RUN_ID
|
135
|
+
|
136
|
+
Or as a cell magic:
|
137
|
+
|
138
|
+
%%wandb -h 1024
|
139
|
+
with wandb.init() as run:
|
140
|
+
run.log({"loss": 1})
|
141
141
|
"""
|
142
|
-
|
142
|
+
global _current_cell_wandb_magic
|
143
|
+
|
143
144
|
args = parse_argstring(self.wandb, line)
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
145
|
+
path: str | None = args.path
|
146
|
+
height: int = args.height
|
147
|
+
|
148
|
+
if path:
|
149
|
+
_display_by_wandb_path(path, height=height)
|
150
|
+
displayed = True
|
151
|
+
elif run := wandb_setup._setup(start_service=False).most_recent_active_run:
|
152
|
+
_display_wandb_run(run, height=height)
|
153
|
+
displayed = True
|
154
|
+
else:
|
155
|
+
displayed = False
|
156
|
+
|
157
|
+
# If this is being used as a line magic ("%wandb"), we are done.
|
158
|
+
# When used as a cell magic ("%%wandb"), we must run the cell.
|
159
|
+
if cell is None:
|
160
|
+
return
|
161
|
+
|
162
|
+
if not displayed:
|
163
|
+
_current_cell_wandb_magic = _WandbCellMagicState(height=height)
|
164
|
+
|
165
|
+
try:
|
157
166
|
IPython.get_ipython().run_cell(cell)
|
167
|
+
finally:
|
168
|
+
_current_cell_wandb_magic = None
|
158
169
|
|
159
170
|
|
160
171
|
def notebook_metadata_from_jupyter_servers_and_kernel_id():
|
@@ -193,7 +204,7 @@ def notebook_metadata_from_jupyter_servers_and_kernel_id():
|
|
193
204
|
return None
|
194
205
|
|
195
206
|
|
196
|
-
def notebook_metadata(silent: bool) ->
|
207
|
+
def notebook_metadata(silent: bool) -> dict[str, str]:
|
197
208
|
"""Attempt to query jupyter for the path and name of the notebook file.
|
198
209
|
|
199
210
|
This can handle different jupyter environments, specifically:
|
@@ -249,7 +260,7 @@ def jupyter_servers_and_kernel_id():
|
|
249
260
|
Used to query for the name of the notebook.
|
250
261
|
"""
|
251
262
|
try:
|
252
|
-
import ipykernel
|
263
|
+
import ipykernel # type: ignore
|
253
264
|
|
254
265
|
kernel_id = re.search(
|
255
266
|
"kernel-(.*).json", ipykernel.connect.get_connection_file()
|
@@ -291,10 +302,13 @@ def attempt_kaggle_load_ipynb():
|
|
291
302
|
return None
|
292
303
|
|
293
304
|
|
294
|
-
def attempt_colab_login(
|
305
|
+
def attempt_colab_login(
|
306
|
+
app_url: str,
|
307
|
+
referrer: str | None = None,
|
308
|
+
):
|
295
309
|
"""This renders an iframe to wandb in the hopes it posts back an api key."""
|
296
|
-
from google.colab import output
|
297
|
-
from google.colab._message import MessageError
|
310
|
+
from google.colab import output # type: ignore
|
311
|
+
from google.colab._message import MessageError # type: ignore
|
298
312
|
from IPython import display
|
299
313
|
|
300
314
|
display.display(
|
@@ -316,7 +330,7 @@ def attempt_colab_login(app_url):
|
|
316
330
|
document.body.appendChild(iframe)
|
317
331
|
const handshake = new Postmate({{
|
318
332
|
container: iframe,
|
319
|
-
url: '{}/authorize'
|
333
|
+
url: '{}/authorize{}'
|
320
334
|
}});
|
321
335
|
const timeout = setTimeout(() => reject("Couldn't auto authenticate"), 5000)
|
322
336
|
handshake.then(function(child) {{
|
@@ -327,7 +341,10 @@ def attempt_colab_login(app_url):
|
|
327
341
|
}});
|
328
342
|
}})
|
329
343
|
}});
|
330
|
-
""".format(
|
344
|
+
""".format(
|
345
|
+
app_url.replace("http:", "https:"),
|
346
|
+
f"?ref={referrer}" if referrer else "",
|
347
|
+
)
|
331
348
|
)
|
332
349
|
)
|
333
350
|
try:
|
@@ -337,8 +354,8 @@ def attempt_colab_login(app_url):
|
|
337
354
|
|
338
355
|
|
339
356
|
class Notebook:
|
340
|
-
def __init__(self, settings):
|
341
|
-
self.outputs = {}
|
357
|
+
def __init__(self, settings: wandb.Settings) -> None:
|
358
|
+
self.outputs: dict[int, Any] = {}
|
342
359
|
self.settings = settings
|
343
360
|
self.shell = IPython.get_ipython()
|
344
361
|
|
@@ -441,10 +458,10 @@ class Notebook:
|
|
441
458
|
|
442
459
|
return False
|
443
460
|
|
444
|
-
def save_history(self):
|
461
|
+
def save_history(self, run: wandb_run.Run):
|
445
462
|
"""This saves all cell executions in the current session as a new notebook."""
|
446
463
|
try:
|
447
|
-
from nbformat import v4, validator, write
|
464
|
+
from nbformat import v4, validator, write # type: ignore
|
448
465
|
except ImportError:
|
449
466
|
wandb.termerror(
|
450
467
|
"The nbformat package was not found."
|
@@ -499,8 +516,8 @@ class Notebook:
|
|
499
516
|
},
|
500
517
|
)
|
501
518
|
state_path = os.path.join("code", "_session_history.ipynb")
|
502
|
-
|
503
|
-
filesystem.mkdir_exists_ok(os.path.join(
|
519
|
+
run._set_config_wandb("session_history", state_path)
|
520
|
+
filesystem.mkdir_exists_ok(os.path.join(self.settings.files_dir, "code"))
|
504
521
|
with open(
|
505
522
|
os.path.join(self.settings._tmp_code_dir, "_session_history.ipynb"),
|
506
523
|
"w",
|
@@ -508,7 +525,9 @@ class Notebook:
|
|
508
525
|
) as f:
|
509
526
|
write(nb, f, version=4)
|
510
527
|
with open(
|
511
|
-
os.path.join(
|
528
|
+
os.path.join(self.settings.files_dir, state_path),
|
529
|
+
"w",
|
530
|
+
encoding="utf-8",
|
512
531
|
) as f:
|
513
532
|
write(nb, f, version=4)
|
514
533
|
except (OSError, validator.NotebookValidationError):
|