wandb 0.13.10__py3-none-any.whl → 0.14.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- wandb/__init__.py +2 -3
- wandb/apis/__init__.py +1 -3
- wandb/apis/importers/__init__.py +4 -0
- wandb/apis/importers/base.py +312 -0
- wandb/apis/importers/mlflow.py +113 -0
- wandb/apis/internal.py +29 -2
- wandb/apis/normalize.py +6 -5
- wandb/apis/public.py +163 -180
- wandb/apis/reports/_templates.py +6 -12
- wandb/apis/reports/report.py +1 -1
- wandb/apis/reports/runset.py +1 -3
- wandb/apis/reports/util.py +12 -10
- wandb/beta/workflows.py +57 -34
- wandb/catboost/__init__.py +1 -2
- wandb/cli/cli.py +215 -133
- wandb/data_types.py +63 -56
- wandb/docker/__init__.py +78 -16
- wandb/docker/auth.py +21 -22
- wandb/env.py +0 -1
- wandb/errors/__init__.py +8 -116
- wandb/errors/term.py +1 -1
- wandb/fastai/__init__.py +1 -2
- wandb/filesync/dir_watcher.py +8 -5
- wandb/filesync/step_prepare.py +76 -75
- wandb/filesync/step_upload.py +1 -2
- wandb/integration/catboost/__init__.py +1 -3
- wandb/integration/catboost/catboost.py +8 -14
- wandb/integration/fastai/__init__.py +7 -13
- wandb/integration/gym/__init__.py +35 -4
- wandb/integration/keras/__init__.py +3 -3
- wandb/integration/keras/callbacks/metrics_logger.py +9 -8
- wandb/integration/keras/callbacks/model_checkpoint.py +9 -9
- wandb/integration/keras/callbacks/tables_builder.py +31 -19
- wandb/integration/kfp/kfp_patch.py +20 -17
- wandb/integration/kfp/wandb_logging.py +1 -2
- wandb/integration/lightgbm/__init__.py +21 -19
- wandb/integration/prodigy/prodigy.py +6 -7
- wandb/integration/sacred/__init__.py +9 -12
- wandb/integration/sagemaker/__init__.py +1 -3
- wandb/integration/sagemaker/auth.py +0 -1
- wandb/integration/sagemaker/config.py +1 -1
- wandb/integration/sagemaker/resources.py +1 -1
- wandb/integration/sb3/sb3.py +8 -4
- wandb/integration/tensorboard/__init__.py +1 -3
- wandb/integration/tensorboard/log.py +8 -8
- wandb/integration/tensorboard/monkeypatch.py +11 -9
- wandb/integration/tensorflow/__init__.py +1 -3
- wandb/integration/xgboost/__init__.py +4 -6
- wandb/integration/yolov8/__init__.py +7 -0
- wandb/integration/yolov8/yolov8.py +250 -0
- wandb/jupyter.py +31 -35
- wandb/lightgbm/__init__.py +1 -2
- wandb/old/settings.py +2 -2
- wandb/plot/bar.py +1 -2
- wandb/plot/confusion_matrix.py +1 -3
- wandb/plot/histogram.py +1 -2
- wandb/plot/line.py +1 -2
- wandb/plot/line_series.py +4 -4
- wandb/plot/pr_curve.py +17 -20
- wandb/plot/roc_curve.py +1 -3
- wandb/plot/scatter.py +1 -2
- wandb/proto/v3/wandb_server_pb2.py +85 -39
- wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
- wandb/proto/v4/wandb_server_pb2.py +51 -39
- wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
- wandb/sdk/__init__.py +1 -3
- wandb/sdk/backend/backend.py +1 -1
- wandb/sdk/data_types/_dtypes.py +38 -30
- wandb/sdk/data_types/base_types/json_metadata.py +1 -3
- wandb/sdk/data_types/base_types/media.py +17 -17
- wandb/sdk/data_types/base_types/wb_value.py +33 -26
- wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +91 -125
- wandb/sdk/data_types/helper_types/classes.py +1 -1
- wandb/sdk/data_types/helper_types/image_mask.py +12 -12
- wandb/sdk/data_types/histogram.py +5 -4
- wandb/sdk/data_types/html.py +1 -2
- wandb/sdk/data_types/image.py +11 -11
- wandb/sdk/data_types/molecule.py +3 -6
- wandb/sdk/data_types/object_3d.py +1 -2
- wandb/sdk/data_types/plotly.py +1 -2
- wandb/sdk/data_types/saved_model.py +10 -8
- wandb/sdk/data_types/video.py +1 -1
- wandb/sdk/integration_utils/data_logging.py +5 -5
- wandb/sdk/interface/artifacts.py +288 -266
- wandb/sdk/interface/interface.py +2 -3
- wandb/sdk/interface/interface_grpc.py +1 -1
- wandb/sdk/interface/interface_queue.py +1 -1
- wandb/sdk/interface/interface_relay.py +1 -1
- wandb/sdk/interface/interface_shared.py +1 -2
- wandb/sdk/interface/interface_sock.py +1 -1
- wandb/sdk/interface/message_future.py +1 -1
- wandb/sdk/interface/message_future_poll.py +1 -1
- wandb/sdk/interface/router.py +1 -1
- wandb/sdk/interface/router_queue.py +1 -1
- wandb/sdk/interface/router_relay.py +1 -1
- wandb/sdk/interface/router_sock.py +1 -1
- wandb/sdk/interface/summary_record.py +1 -1
- wandb/sdk/internal/artifacts.py +1 -1
- wandb/sdk/internal/datastore.py +2 -3
- wandb/sdk/internal/file_pusher.py +5 -3
- wandb/sdk/internal/file_stream.py +22 -19
- wandb/sdk/internal/handler.py +5 -4
- wandb/sdk/internal/internal.py +1 -1
- wandb/sdk/internal/internal_api.py +115 -55
- wandb/sdk/internal/job_builder.py +1 -3
- wandb/sdk/internal/profiler.py +1 -1
- wandb/sdk/internal/progress.py +4 -6
- wandb/sdk/internal/sample.py +1 -3
- wandb/sdk/internal/sender.py +28 -16
- wandb/sdk/internal/settings_static.py +5 -5
- wandb/sdk/internal/system/assets/__init__.py +1 -0
- wandb/sdk/internal/system/assets/cpu.py +3 -9
- wandb/sdk/internal/system/assets/disk.py +2 -4
- wandb/sdk/internal/system/assets/gpu.py +6 -18
- wandb/sdk/internal/system/assets/gpu_apple.py +2 -4
- wandb/sdk/internal/system/assets/interfaces.py +50 -22
- wandb/sdk/internal/system/assets/ipu.py +1 -3
- wandb/sdk/internal/system/assets/memory.py +7 -13
- wandb/sdk/internal/system/assets/network.py +4 -8
- wandb/sdk/internal/system/assets/open_metrics.py +283 -0
- wandb/sdk/internal/system/assets/tpu.py +1 -4
- wandb/sdk/internal/system/assets/trainium.py +26 -14
- wandb/sdk/internal/system/system_info.py +2 -3
- wandb/sdk/internal/system/system_monitor.py +52 -20
- wandb/sdk/internal/tb_watcher.py +12 -13
- wandb/sdk/launch/_project_spec.py +54 -65
- wandb/sdk/launch/agent/agent.py +374 -90
- wandb/sdk/launch/builder/abstract.py +61 -7
- wandb/sdk/launch/builder/build.py +81 -110
- wandb/sdk/launch/builder/docker_builder.py +181 -0
- wandb/sdk/launch/builder/kaniko_builder.py +419 -0
- wandb/sdk/launch/builder/noop.py +31 -12
- wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +70 -20
- wandb/sdk/launch/environment/abstract.py +28 -0
- wandb/sdk/launch/environment/aws_environment.py +276 -0
- wandb/sdk/launch/environment/gcp_environment.py +271 -0
- wandb/sdk/launch/environment/local_environment.py +65 -0
- wandb/sdk/launch/github_reference.py +3 -8
- wandb/sdk/launch/launch.py +38 -29
- wandb/sdk/launch/launch_add.py +6 -8
- wandb/sdk/launch/loader.py +230 -0
- wandb/sdk/launch/registry/abstract.py +54 -0
- wandb/sdk/launch/registry/elastic_container_registry.py +163 -0
- wandb/sdk/launch/registry/google_artifact_registry.py +203 -0
- wandb/sdk/launch/registry/local_registry.py +62 -0
- wandb/sdk/launch/runner/abstract.py +1 -16
- wandb/sdk/launch/runner/{kubernetes.py → kubernetes_runner.py} +83 -95
- wandb/sdk/launch/runner/local_container.py +46 -22
- wandb/sdk/launch/runner/local_process.py +1 -4
- wandb/sdk/launch/runner/{aws.py → sagemaker_runner.py} +53 -212
- wandb/sdk/launch/runner/{gcp_vertex.py → vertex_runner.py} +38 -55
- wandb/sdk/launch/sweeps/__init__.py +3 -2
- wandb/sdk/launch/sweeps/scheduler.py +132 -39
- wandb/sdk/launch/sweeps/scheduler_sweep.py +80 -89
- wandb/sdk/launch/utils.py +101 -30
- wandb/sdk/launch/wandb_reference.py +2 -7
- wandb/sdk/lib/_settings_toposort_generate.py +166 -0
- wandb/sdk/lib/_settings_toposort_generated.py +201 -0
- wandb/sdk/lib/apikey.py +2 -4
- wandb/sdk/lib/config_util.py +4 -1
- wandb/sdk/lib/console.py +1 -3
- wandb/sdk/lib/deprecate.py +3 -3
- wandb/sdk/lib/file_stream_utils.py +7 -5
- wandb/sdk/lib/filenames.py +1 -1
- wandb/sdk/lib/filesystem.py +61 -5
- wandb/sdk/lib/git.py +1 -3
- wandb/sdk/lib/import_hooks.py +4 -7
- wandb/sdk/lib/ipython.py +8 -5
- wandb/sdk/lib/lazyloader.py +1 -3
- wandb/sdk/lib/mailbox.py +14 -4
- wandb/sdk/lib/proto_util.py +10 -5
- wandb/sdk/lib/redirect.py +15 -22
- wandb/sdk/lib/reporting.py +1 -3
- wandb/sdk/lib/retry.py +4 -5
- wandb/sdk/lib/runid.py +1 -3
- wandb/sdk/lib/server.py +15 -9
- wandb/sdk/lib/sock_client.py +1 -1
- wandb/sdk/lib/sparkline.py +1 -1
- wandb/sdk/lib/wburls.py +1 -1
- wandb/sdk/service/port_file.py +1 -2
- wandb/sdk/service/service.py +36 -13
- wandb/sdk/service/service_base.py +12 -1
- wandb/sdk/verify/verify.py +5 -7
- wandb/sdk/wandb_artifacts.py +142 -177
- wandb/sdk/wandb_config.py +5 -8
- wandb/sdk/wandb_helper.py +1 -1
- wandb/sdk/wandb_init.py +24 -13
- wandb/sdk/wandb_login.py +9 -9
- wandb/sdk/wandb_manager.py +39 -4
- wandb/sdk/wandb_metric.py +2 -6
- wandb/sdk/wandb_require.py +4 -15
- wandb/sdk/wandb_require_helpers.py +1 -9
- wandb/sdk/wandb_run.py +95 -141
- wandb/sdk/wandb_save.py +1 -3
- wandb/sdk/wandb_settings.py +149 -54
- wandb/sdk/wandb_setup.py +66 -46
- wandb/sdk/wandb_summary.py +13 -10
- wandb/sdk/wandb_sweep.py +6 -7
- wandb/sdk/wandb_watch.py +1 -1
- wandb/sklearn/calculate/confusion_matrix.py +1 -1
- wandb/sklearn/calculate/learning_curve.py +1 -1
- wandb/sklearn/calculate/summary_metrics.py +1 -3
- wandb/sklearn/plot/__init__.py +1 -1
- wandb/sklearn/plot/classifier.py +27 -18
- wandb/sklearn/plot/clusterer.py +4 -5
- wandb/sklearn/plot/regressor.py +4 -4
- wandb/sklearn/plot/shared.py +2 -2
- wandb/sync/__init__.py +1 -3
- wandb/sync/sync.py +4 -5
- wandb/testing/relay.py +11 -10
- wandb/trigger.py +1 -1
- wandb/util.py +106 -81
- wandb/viz.py +4 -4
- wandb/wandb_agent.py +50 -50
- wandb/wandb_controller.py +2 -3
- wandb/wandb_run.py +1 -2
- wandb/wandb_torch.py +1 -1
- wandb/xgboost/__init__.py +1 -2
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/METADATA +6 -2
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/RECORD +224 -209
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/WHEEL +1 -1
- wandb/sdk/launch/builder/docker.py +0 -80
- wandb/sdk/launch/builder/kaniko.py +0 -393
- wandb/sdk/launch/builder/loader.py +0 -32
- wandb/sdk/launch/runner/loader.py +0 -50
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/LICENSE +0 -0
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/entry_points.txt +0 -0
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/top_level.txt +0 -0
wandb/sdk/wandb_setup.py
CHANGED
@@ -15,18 +15,25 @@ import logging
|
|
15
15
|
import os
|
16
16
|
import sys
|
17
17
|
import threading
|
18
|
-
from typing import Any, Dict, List, Optional, Union
|
18
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
19
19
|
|
20
20
|
import wandb
|
21
21
|
|
22
22
|
from . import wandb_manager, wandb_settings
|
23
23
|
from .lib import config_util, server, tracelog
|
24
24
|
|
25
|
+
Settings = Union["wandb.sdk.wandb_settings.Settings", Dict[str, Any]]
|
26
|
+
|
27
|
+
Logger = Union[logging.Logger, "_EarlyLogger"]
|
28
|
+
|
29
|
+
if TYPE_CHECKING:
|
30
|
+
from . import wandb_run
|
31
|
+
|
25
32
|
# logger will be configured to be either a standard logger instance or _EarlyLogger
|
26
|
-
logger = None
|
33
|
+
logger: Optional[Logger] = None
|
27
34
|
|
28
35
|
|
29
|
-
def _set_logger(log_object):
|
36
|
+
def _set_logger(log_object: Logger) -> None:
|
30
37
|
"""Configure module logger."""
|
31
38
|
global logger
|
32
39
|
logger = log_object
|
@@ -35,35 +42,36 @@ def _set_logger(log_object):
|
|
35
42
|
class _EarlyLogger:
|
36
43
|
"""Early logger which captures logs in memory until logging can be configured."""
|
37
44
|
|
38
|
-
def __init__(self):
|
39
|
-
self._log = []
|
40
|
-
self._exception = []
|
45
|
+
def __init__(self) -> None:
|
46
|
+
self._log: List[tuple] = []
|
47
|
+
self._exception: List[tuple] = []
|
41
48
|
# support old warn() as alias of warning()
|
42
49
|
self.warn = self.warning
|
43
50
|
|
44
|
-
def debug(self, msg, *args, **kwargs):
|
51
|
+
def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
45
52
|
self._log.append((logging.DEBUG, msg, args, kwargs))
|
46
53
|
|
47
|
-
def info(self, msg, *args, **kwargs):
|
54
|
+
def info(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
48
55
|
self._log.append((logging.INFO, msg, args, kwargs))
|
49
56
|
|
50
|
-
def warning(self, msg, *args, **kwargs):
|
57
|
+
def warning(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
51
58
|
self._log.append((logging.WARNING, msg, args, kwargs))
|
52
59
|
|
53
|
-
def error(self, msg, *args, **kwargs):
|
60
|
+
def error(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
54
61
|
self._log.append((logging.ERROR, msg, args, kwargs))
|
55
62
|
|
56
|
-
def critical(self, msg, *args, **kwargs):
|
63
|
+
def critical(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
57
64
|
self._log.append((logging.CRITICAL, msg, args, kwargs))
|
58
65
|
|
59
|
-
def exception(self, msg, *args, **kwargs):
|
60
|
-
self._exception.append(msg, args, kwargs)
|
66
|
+
def exception(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
67
|
+
self._exception.append((msg, args, kwargs))
|
61
68
|
|
62
|
-
def log(self, level, msg, *args, **kwargs):
|
63
|
-
self._log.append(level, msg, args, kwargs)
|
69
|
+
def log(self, level: str, msg: str, *args: Any, **kwargs: Any) -> None:
|
70
|
+
self._log.append((level, msg, args, kwargs))
|
64
71
|
|
65
|
-
def _flush(self):
|
72
|
+
def _flush(self) -> None:
|
66
73
|
assert self is not logger
|
74
|
+
assert logger is not None
|
67
75
|
for level, msg, args, kwargs in self._log:
|
68
76
|
logger.log(level, msg, *args, **kwargs)
|
69
77
|
for msg, args, kwargs in self._exception:
|
@@ -79,18 +87,18 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
79
87
|
def __init__(
|
80
88
|
self,
|
81
89
|
pid: int,
|
82
|
-
settings:
|
90
|
+
settings: Optional[Settings] = None,
|
83
91
|
environ: Optional[Dict[str, Any]] = None,
|
84
|
-
):
|
92
|
+
) -> None:
|
85
93
|
self._environ = environ or dict(os.environ)
|
86
|
-
self._sweep_config = None
|
87
|
-
self._config = None
|
88
|
-
self._server = None
|
89
|
-
self._manager = None
|
94
|
+
self._sweep_config: Optional[Dict[str, Any]] = None
|
95
|
+
self._config: Optional[Dict[str, Any]] = None
|
96
|
+
self._server: Optional[server.Server] = None
|
97
|
+
self._manager: Optional[wandb_manager._Manager] = None
|
90
98
|
self._pid = pid
|
91
99
|
|
92
100
|
# keep track of multiple runs, so we can unwind with join()s
|
93
|
-
self._global_run_stack = []
|
101
|
+
self._global_run_stack: List["wandb_run.Run"] = []
|
94
102
|
|
95
103
|
# TODO(jhr): defer strict checks until settings are fully initialized
|
96
104
|
# and logging is ready
|
@@ -111,9 +119,9 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
111
119
|
|
112
120
|
def _settings_setup(
|
113
121
|
self,
|
114
|
-
settings:
|
122
|
+
settings: Optional[Settings] = None,
|
115
123
|
early_logger: Optional[_EarlyLogger] = None,
|
116
|
-
):
|
124
|
+
) -> "wandb_settings.Settings":
|
117
125
|
s = wandb_settings.Settings()
|
118
126
|
s._apply_base(pid=self._pid, _logger=early_logger)
|
119
127
|
s._apply_config_files(_logger=early_logger)
|
@@ -132,7 +140,8 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
132
140
|
return s
|
133
141
|
|
134
142
|
def _update(
|
135
|
-
self,
|
143
|
+
self,
|
144
|
+
settings: Optional[Settings] = None,
|
136
145
|
) -> None:
|
137
146
|
if settings is None:
|
138
147
|
return
|
@@ -145,7 +154,7 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
145
154
|
self._settings.update(settings, source=wandb_settings.Source.SETUP)
|
146
155
|
# self._settings.freeze()
|
147
156
|
|
148
|
-
def _update_user_settings(self, settings=None):
|
157
|
+
def _update_user_settings(self, settings: Optional[Settings] = None) -> None:
|
149
158
|
settings = settings or self._settings
|
150
159
|
# Get rid of cached results to force a refresh.
|
151
160
|
self._server = None
|
@@ -155,18 +164,18 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
155
164
|
self._settings._apply_user(user_settings)
|
156
165
|
# self._settings.freeze()
|
157
166
|
|
158
|
-
def _early_logger_flush(self, new_logger):
|
167
|
+
def _early_logger_flush(self, new_logger: Logger) -> None:
|
159
168
|
if not self._early_logger:
|
160
169
|
return
|
161
170
|
_set_logger(new_logger)
|
162
171
|
# self._settings._clear_early_logger()
|
163
172
|
self._early_logger._flush()
|
164
173
|
|
165
|
-
def _get_logger(self):
|
174
|
+
def _get_logger(self) -> Optional[Logger]:
|
166
175
|
return logger
|
167
176
|
|
168
177
|
@property
|
169
|
-
def settings(self):
|
178
|
+
def settings(self) -> "wandb_settings.Settings":
|
170
179
|
return self._settings
|
171
180
|
|
172
181
|
def _get_entity(self) -> Optional[str]:
|
@@ -174,6 +183,7 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
174
183
|
return None
|
175
184
|
if self._server is None:
|
176
185
|
self._load_viewer()
|
186
|
+
assert self._server is not None
|
177
187
|
entity = self._server._viewer.get("entity")
|
178
188
|
return entity
|
179
189
|
|
@@ -182,27 +192,33 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
182
192
|
return None
|
183
193
|
if self._server is None:
|
184
194
|
self._load_viewer()
|
195
|
+
assert self._server is not None
|
185
196
|
username = self._server._viewer.get("username")
|
186
197
|
return username
|
187
198
|
|
188
199
|
def _get_teams(self) -> List[str]:
|
189
200
|
if self._settings and self._settings._offline:
|
190
|
-
return
|
201
|
+
return []
|
191
202
|
if self._server is None:
|
192
203
|
self._load_viewer()
|
204
|
+
assert self._server is not None
|
193
205
|
teams = self._server._viewer.get("teams")
|
194
206
|
if teams:
|
195
207
|
teams = [team["node"]["name"] for team in teams["edges"]]
|
196
208
|
return teams or []
|
197
209
|
|
198
|
-
def _load_viewer(self, settings=None) -> None:
|
210
|
+
def _load_viewer(self, settings: Optional[Settings] = None) -> None:
|
199
211
|
if self._settings and self._settings._offline:
|
200
212
|
return
|
213
|
+
if isinstance(settings, dict):
|
214
|
+
settings = wandb_settings.Settings(**settings)
|
201
215
|
s = server.Server(settings=settings)
|
202
216
|
s.query_with_timeout()
|
203
217
|
self._server = s
|
204
218
|
|
205
|
-
def _load_user_settings(
|
219
|
+
def _load_user_settings(
|
220
|
+
self, settings: Optional[Settings] = None
|
221
|
+
) -> Optional[Dict[str, Any]]:
|
206
222
|
if self._server is None:
|
207
223
|
self._load_viewer(settings=settings)
|
208
224
|
|
@@ -221,7 +237,7 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
221
237
|
|
222
238
|
return user_settings
|
223
239
|
|
224
|
-
def _check(self):
|
240
|
+
def _check(self) -> None:
|
225
241
|
if hasattr(threading, "main_thread"):
|
226
242
|
if threading.current_thread() is not threading.main_thread():
|
227
243
|
pass
|
@@ -230,7 +246,7 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
230
246
|
if getattr(sys, "frozen", False):
|
231
247
|
print("frozen, could be trouble")
|
232
248
|
|
233
|
-
def _setup(self):
|
249
|
+
def _setup(self) -> None:
|
234
250
|
self._setup_manager()
|
235
251
|
|
236
252
|
sweep_path = self._settings.sweep_param_path
|
@@ -242,8 +258,7 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
242
258
|
# if config_paths was set, read in config dict
|
243
259
|
if self._settings.config_paths:
|
244
260
|
# TODO(jhr): handle load errors, handle list of files
|
245
|
-
|
246
|
-
for config_path in config_paths:
|
261
|
+
for config_path in self._settings.config_paths:
|
247
262
|
config_dict = config_util.dict_from_config_file(config_path)
|
248
263
|
if config_dict is None:
|
249
264
|
continue
|
@@ -252,12 +267,12 @@ class _WandbSetup__WandbSetup: # noqa: N801
|
|
252
267
|
else:
|
253
268
|
self._config = config_dict
|
254
269
|
|
255
|
-
def _teardown(self, exit_code: Optional[int] = None):
|
270
|
+
def _teardown(self, exit_code: Optional[int] = None) -> None:
|
256
271
|
exit_code = exit_code or 0
|
257
272
|
self._teardown_manager(exit_code=exit_code)
|
258
273
|
|
259
274
|
def _setup_manager(self) -> None:
|
260
|
-
if
|
275
|
+
if self._settings._disable_service:
|
261
276
|
return
|
262
277
|
self._manager = wandb_manager._Manager(settings=self._settings)
|
263
278
|
|
@@ -280,35 +295,40 @@ class _WandbSetup:
|
|
280
295
|
|
281
296
|
_instance: Optional["_WandbSetup__WandbSetup"] = None
|
282
297
|
|
283
|
-
def __init__(self, settings=None) -> None:
|
298
|
+
def __init__(self, settings: Optional[Settings] = None) -> None:
|
284
299
|
pid = os.getpid()
|
285
300
|
if _WandbSetup._instance and _WandbSetup._instance._pid == pid:
|
286
301
|
_WandbSetup._instance._update(settings=settings)
|
287
302
|
return
|
288
303
|
_WandbSetup._instance = _WandbSetup__WandbSetup(settings=settings, pid=pid)
|
289
304
|
|
290
|
-
def __getattr__(self, name):
|
305
|
+
def __getattr__(self, name: str) -> Any:
|
291
306
|
return getattr(self._instance, name)
|
292
307
|
|
293
308
|
|
294
|
-
def _setup(
|
295
|
-
|
309
|
+
def _setup(
|
310
|
+
settings: Optional[Settings] = None,
|
311
|
+
_reset: bool = False,
|
312
|
+
) -> Optional["_WandbSetup"]:
|
313
|
+
"""Set up library context."""
|
296
314
|
if _reset:
|
297
315
|
setup_instance = _WandbSetup._instance
|
298
316
|
if setup_instance:
|
299
317
|
setup_instance._teardown()
|
300
318
|
_WandbSetup._instance = None
|
301
|
-
return
|
319
|
+
return None
|
302
320
|
wl = _WandbSetup(settings=settings)
|
303
321
|
return wl
|
304
322
|
|
305
323
|
|
306
|
-
def setup(
|
324
|
+
def setup(
|
325
|
+
settings: Optional[Settings] = None,
|
326
|
+
) -> Optional["_WandbSetup"]:
|
307
327
|
ret = _setup(settings=settings)
|
308
328
|
return ret
|
309
329
|
|
310
330
|
|
311
|
-
def teardown(exit_code=None):
|
331
|
+
def teardown(exit_code: Optional[int] = None) -> None:
|
312
332
|
setup_instance = _WandbSetup._instance
|
313
333
|
if setup_instance:
|
314
334
|
setup_instance._teardown(exit_code=exit_code)
|
wandb/sdk/wandb_summary.py
CHANGED
@@ -12,8 +12,10 @@ def _get_dict(d):
|
|
12
12
|
|
13
13
|
|
14
14
|
class SummaryDict(metaclass=abc.ABCMeta):
|
15
|
-
"""dict-like
|
16
|
-
|
15
|
+
"""dict-like wrapper for the nested dictionaries in a SummarySubDict.
|
16
|
+
|
17
|
+
Triggers self._root._callback on property changes.
|
18
|
+
"""
|
17
19
|
|
18
20
|
@abc.abstractmethod
|
19
21
|
def _as_dict(self):
|
@@ -73,8 +75,7 @@ class SummaryDict(metaclass=abc.ABCMeta):
|
|
73
75
|
|
74
76
|
|
75
77
|
class Summary(SummaryDict):
|
76
|
-
"""
|
77
|
-
Tracks single values for each metric for each run.
|
78
|
+
"""Track single values for each metric for each run.
|
78
79
|
|
79
80
|
By default, a metric's summary is the last value of its History.
|
80
81
|
|
@@ -99,10 +100,10 @@ class Summary(SummaryDict):
|
|
99
100
|
|
100
101
|
best_accuracy = 0
|
101
102
|
for epoch in range(1, args.epochs + 1):
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
103
|
+
test_loss, test_accuracy = test()
|
104
|
+
if test_accuracy > best_accuracy:
|
105
|
+
wandb.run.summary["best_accuracy"] = test_accuracy
|
106
|
+
best_accuracy = test_accuracy
|
106
107
|
```
|
107
108
|
"""
|
108
109
|
|
@@ -128,8 +129,10 @@ class Summary(SummaryDict):
|
|
128
129
|
|
129
130
|
|
130
131
|
class SummarySubDict(SummaryDict):
|
131
|
-
"""Non-root node of the summary data structure.
|
132
|
-
|
132
|
+
"""Non-root node of the summary data structure.
|
133
|
+
|
134
|
+
Contains a path to itself from the root.
|
135
|
+
"""
|
133
136
|
|
134
137
|
_items: t.Dict
|
135
138
|
_parent: SummaryDict
|
wandb/sdk/wandb_sweep.py
CHANGED
@@ -44,7 +44,7 @@ def sweep(
|
|
44
44
|
sweep: dict, SweepConfig, or callable. The sweep configuration
|
45
45
|
(or configuration generator). If a dict or SweepConfig,
|
46
46
|
should conform to the W&B sweep config specification
|
47
|
-
(https://docs.wandb.ai/guides/sweeps/configuration). If a
|
47
|
+
(https://docs.wandb.ai/guides/sweeps/define-sweep-configuration). If a
|
48
48
|
callable, should take no arguments and return a dict that
|
49
49
|
conforms to the W&B sweep config spec.
|
50
50
|
entity: str (optional). An entity is a username or team name
|
@@ -67,17 +67,15 @@ def sweep(
|
|
67
67
|
<!--yeadoc-test:one-parameter-sweep-->
|
68
68
|
```python
|
69
69
|
import wandb
|
70
|
+
|
70
71
|
sweep_configuration = {
|
71
72
|
"name": "my-awesome-sweep",
|
72
73
|
"metric": {"name": "accuracy", "goal": "maximize"},
|
73
74
|
"method": "grid",
|
74
|
-
"parameters": {
|
75
|
-
"a": {
|
76
|
-
"values": [1, 2, 3, 4]
|
77
|
-
}
|
78
|
-
}
|
75
|
+
"parameters": {"a": {"values": [1, 2, 3, 4]}},
|
79
76
|
}
|
80
77
|
|
78
|
+
|
81
79
|
def my_train_func():
|
82
80
|
# read the current value of parameter "a" from wandb.config
|
83
81
|
wandb.init()
|
@@ -85,13 +83,13 @@ def sweep(
|
|
85
83
|
|
86
84
|
wandb.log({"a": a, "accuracy": a + 1})
|
87
85
|
|
86
|
+
|
88
87
|
sweep_id = wandb.sweep(sweep_configuration)
|
89
88
|
|
90
89
|
# run the sweep
|
91
90
|
wandb.agent(sweep_id, function=my_train_func)
|
92
91
|
```
|
93
92
|
"""
|
94
|
-
|
95
93
|
if callable(sweep):
|
96
94
|
sweep = sweep()
|
97
95
|
"""Sweep create for controller api and jupyter (eventually for cli)."""
|
@@ -128,6 +126,7 @@ def controller(
|
|
128
126
|
Usage:
|
129
127
|
```python
|
130
128
|
import wandb
|
129
|
+
|
131
130
|
tuner = wandb.controller(...)
|
132
131
|
print(tuner.sweep_config)
|
133
132
|
print(tuner.sweep_id)
|
wandb/sdk/wandb_watch.py
CHANGED
@@ -25,7 +25,7 @@ def watch(
|
|
25
25
|
idx: Optional[int] = None,
|
26
26
|
log_graph: bool = False,
|
27
27
|
):
|
28
|
-
"""
|
28
|
+
"""Hook into the torch model to collect gradients and the topology.
|
29
29
|
|
30
30
|
Should be extended to accept arbitrary ML models.
|
31
31
|
|
@@ -24,7 +24,7 @@ def confusion_matrix(
|
|
24
24
|
pred_labels=None,
|
25
25
|
normalize=False,
|
26
26
|
):
|
27
|
-
"""
|
27
|
+
"""Compute the confusion matrix to evaluate the performance of a classification.
|
28
28
|
|
29
29
|
Called by plot_confusion_matrix to visualize roc curves. Please use the function
|
30
30
|
plot_confusion_matrix() if you wish to visualize your confusion matrix.
|
@@ -21,7 +21,7 @@ def learning_curve(
|
|
21
21
|
n_jobs=1,
|
22
22
|
scoring=None,
|
23
23
|
):
|
24
|
-
"""
|
24
|
+
"""Train model on datasets of varying size and generates plot of score vs size.
|
25
25
|
|
26
26
|
Called by plot_learning_curve to visualize learning curve. Please use the function
|
27
27
|
plot_learning_curve() if you wish to visualize your learning curves.
|
@@ -11,7 +11,7 @@ simplefilter(action="ignore", category=FutureWarning)
|
|
11
11
|
|
12
12
|
|
13
13
|
def summary_metrics(model=None, X=None, y=None, X_test=None, y_test=None):
|
14
|
-
"""
|
14
|
+
"""Calculate summary metrics for both regressors and classifiers.
|
15
15
|
|
16
16
|
Called by plot_summary_metrics to visualize metrics. Please use the function
|
17
17
|
plot_summary_metrics() if you wish to visualize your summary metrics.
|
@@ -23,7 +23,6 @@ def summary_metrics(model=None, X=None, y=None, X_test=None, y_test=None):
|
|
23
23
|
y_pred = model.predict(X_test)
|
24
24
|
|
25
25
|
if sklearn.base.is_classifier(model):
|
26
|
-
|
27
26
|
accuracy_score = sklearn.metrics.accuracy_score(y_test, y_pred)
|
28
27
|
metrics["accuracy_score"] = accuracy_score
|
29
28
|
|
@@ -37,7 +36,6 @@ def summary_metrics(model=None, X=None, y=None, X_test=None, y_test=None):
|
|
37
36
|
metrics["f1_score"] = f1_score
|
38
37
|
|
39
38
|
elif sklearn.base.is_regressor(model):
|
40
|
-
|
41
39
|
mae = sklearn.metrics.mean_absolute_error(y_test, y_pred)
|
42
40
|
metrics["mae"] = mae
|
43
41
|
|
wandb/sklearn/plot/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Create and logs charts introspecting models built with scikit-learn to W&B."""
|
2
2
|
from .classifier import calibration_curve as plot_calibration_curve
|
3
3
|
from .classifier import class_proportions as plot_class_proportions
|
4
4
|
from .classifier import classifier as plot_classifier
|
wandb/sklearn/plot/classifier.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Define plots for classification models built with scikit-learn."""
|
2
2
|
from warnings import simplefilter
|
3
3
|
|
4
4
|
import numpy as np
|
@@ -28,7 +28,7 @@ def classifier(
|
|
28
28
|
feature_names=None,
|
29
29
|
log_learning_curve=False,
|
30
30
|
):
|
31
|
-
"""
|
31
|
+
"""Generate all sklearn classifier plots supported by W&B.
|
32
32
|
|
33
33
|
The following plots are generated:
|
34
34
|
feature importances, confusion matrix, summary metrics,
|
@@ -61,9 +61,19 @@ def classifier(
|
|
61
61
|
|
62
62
|
Example:
|
63
63
|
```python
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
wandb.sklearn.plot_classifier(
|
65
|
+
model,
|
66
|
+
X_train,
|
67
|
+
X_test,
|
68
|
+
y_train,
|
69
|
+
y_test,
|
70
|
+
y_pred,
|
71
|
+
y_probas,
|
72
|
+
["cat", "dog"],
|
73
|
+
False,
|
74
|
+
"RandomForest",
|
75
|
+
["barks", "drools", "plays_fetch", "breed"],
|
76
|
+
)
|
67
77
|
```
|
68
78
|
"""
|
69
79
|
wandb.termlog("\nPlotting %s." % model_name)
|
@@ -104,7 +114,7 @@ def roc(
|
|
104
114
|
plot_macro=True,
|
105
115
|
classes_to_plot=None,
|
106
116
|
):
|
107
|
-
"""
|
117
|
+
"""Log the receiver-operating characteristic curve.
|
108
118
|
|
109
119
|
Arguments:
|
110
120
|
y_true: (arr) Test set labels.
|
@@ -120,7 +130,7 @@ def roc(
|
|
120
130
|
|
121
131
|
Example:
|
122
132
|
```python
|
123
|
-
|
133
|
+
wandb.sklearn.plot_roc(y_true, y_probas, labels)
|
124
134
|
```
|
125
135
|
"""
|
126
136
|
roc_chart = wandb.plots.roc.roc(
|
@@ -137,7 +147,7 @@ def confusion_matrix(
|
|
137
147
|
pred_labels=None,
|
138
148
|
normalize=False,
|
139
149
|
):
|
140
|
-
"""
|
150
|
+
"""Log a confusion matrix to W&B.
|
141
151
|
|
142
152
|
Confusion matrices depict the pattern of misclassifications by a model.
|
143
153
|
|
@@ -155,7 +165,7 @@ def confusion_matrix(
|
|
155
165
|
|
156
166
|
Example:
|
157
167
|
```python
|
158
|
-
|
168
|
+
wandb.sklearn.plot_confusion_matrix(y_true, y_probas, labels)
|
159
169
|
```
|
160
170
|
"""
|
161
171
|
y_true = np.asarray(y_true)
|
@@ -180,7 +190,7 @@ def confusion_matrix(
|
|
180
190
|
def precision_recall(
|
181
191
|
y_true=None, y_probas=None, labels=None, plot_micro=True, classes_to_plot=None
|
182
192
|
):
|
183
|
-
"""
|
193
|
+
"""Log a precision-recall curve to W&B.
|
184
194
|
|
185
195
|
Precision-recall curves depict the tradeoff between positive predictive value (precision)
|
186
196
|
and true positive rate (recall) as the threshold of a classifier is shifted.
|
@@ -199,7 +209,7 @@ def precision_recall(
|
|
199
209
|
|
200
210
|
Example:
|
201
211
|
```python
|
202
|
-
|
212
|
+
wandb.sklearn.plot_precision_recall(y_true, y_probas, labels)
|
203
213
|
```
|
204
214
|
"""
|
205
215
|
precision_recall_chart = wandb.plots.precision_recall(
|
@@ -212,7 +222,7 @@ def precision_recall(
|
|
212
222
|
def feature_importances(
|
213
223
|
model=None, feature_names=None, title="Feature Importance", max_num_features=50
|
214
224
|
):
|
215
|
-
"""
|
225
|
+
"""Log a plot depicting the relative importance of each feature for a classifier's decisions.
|
216
226
|
|
217
227
|
Should only be called with a fitted classifer (otherwise an error is thrown).
|
218
228
|
Only works with classifiers that have a feature_importances_ attribute, like trees.
|
@@ -228,7 +238,7 @@ def feature_importances(
|
|
228
238
|
|
229
239
|
Example:
|
230
240
|
```python
|
231
|
-
|
241
|
+
wandb.sklearn.plot_feature_importances(model, ["width", "height", "length"])
|
232
242
|
```
|
233
243
|
"""
|
234
244
|
not_missing = utils.test_missing(model=model)
|
@@ -241,7 +251,7 @@ def feature_importances(
|
|
241
251
|
|
242
252
|
|
243
253
|
def class_proportions(y_train=None, y_test=None, labels=None):
|
244
|
-
"""
|
254
|
+
"""Plot the distribution of target classses in training and test sets.
|
245
255
|
|
246
256
|
Useful for detecting imbalanced classes.
|
247
257
|
|
@@ -259,13 +269,12 @@ def class_proportions(y_train=None, y_test=None, labels=None):
|
|
259
269
|
|
260
270
|
Example:
|
261
271
|
```python
|
262
|
-
|
272
|
+
wandb.sklearn.plot_class_proportions(y_train, y_test, ["dog", "cat", "owl"])
|
263
273
|
```
|
264
274
|
"""
|
265
275
|
not_missing = utils.test_missing(y_train=y_train, y_test=y_test)
|
266
276
|
correct_types = utils.test_types(y_train=y_train, y_test=y_test)
|
267
277
|
if not_missing and correct_types:
|
268
|
-
|
269
278
|
y_train, y_test = np.array(y_train), np.array(y_test)
|
270
279
|
class_proportions_chart = calculate.class_proportions(y_train, y_test, labels)
|
271
280
|
|
@@ -273,7 +282,7 @@ def class_proportions(y_train=None, y_test=None, labels=None):
|
|
273
282
|
|
274
283
|
|
275
284
|
def calibration_curve(clf=None, X=None, y=None, clf_name="Classifier"):
|
276
|
-
"""
|
285
|
+
"""Log a plot depicting how well-calibrated the predicted probabilities of a classifier are.
|
277
286
|
|
278
287
|
Also suggests how to calibrate an uncalibrated classifier. Compares estimated predicted
|
279
288
|
probabilities by a baseline logistic regression model, the model passed as
|
@@ -302,7 +311,7 @@ def calibration_curve(clf=None, X=None, y=None, clf_name="Classifier"):
|
|
302
311
|
|
303
312
|
Example:
|
304
313
|
```python
|
305
|
-
|
314
|
+
wandb.sklearn.plot_calibration_curve(clf, X, y, "RandomForestClassifier")
|
306
315
|
```
|
307
316
|
"""
|
308
317
|
not_missing = utils.test_missing(clf=clf, X=X, y=y)
|
wandb/sklearn/plot/clusterer.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Define plots for clustering models built with scikit-learn."""
|
2
2
|
from warnings import simplefilter
|
3
3
|
|
4
4
|
import pandas as pd
|
@@ -36,7 +36,7 @@ def clusterer(model, X_train, cluster_labels, labels=None, model_name="Clusterer
|
|
36
36
|
|
37
37
|
Example:
|
38
38
|
```python
|
39
|
-
|
39
|
+
wandb.sklearn.plot_clusterer(kmeans, X, cluster_labels, labels, "KMeans")
|
40
40
|
```
|
41
41
|
"""
|
42
42
|
wandb.termlog("\nPlotting %s." % model_name)
|
@@ -73,7 +73,7 @@ def elbow_curve(
|
|
73
73
|
|
74
74
|
Example:
|
75
75
|
```python
|
76
|
-
|
76
|
+
wandb.sklearn.plot_elbow_curve(model, X_train)
|
77
77
|
```
|
78
78
|
"""
|
79
79
|
if not hasattr(clusterer, "n_clusters"):
|
@@ -87,7 +87,6 @@ def elbow_curve(
|
|
87
87
|
is_fitted = utils.test_fitted(clusterer)
|
88
88
|
|
89
89
|
if not_missing and correct_types and is_fitted:
|
90
|
-
|
91
90
|
elbow_curve_chart = calculate.elbow_curve(
|
92
91
|
clusterer, X, cluster_ranges, n_jobs, show_cluster_time
|
93
92
|
)
|
@@ -126,7 +125,7 @@ def silhouette(
|
|
126
125
|
|
127
126
|
Example:
|
128
127
|
```python
|
129
|
-
|
128
|
+
wandb.sklearn.plot_silhouette(model, X_train, ["spam", "not spam"])
|
130
129
|
```
|
131
130
|
"""
|
132
131
|
not_missing = utils.test_missing(clusterer=clusterer)
|
wandb/sklearn/plot/regressor.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Define plots for regression models built with scikit-learn."""
|
2
2
|
from warnings import simplefilter
|
3
3
|
|
4
4
|
import numpy as np
|
@@ -34,7 +34,7 @@ def regressor(model, X_train, X_test, y_train, y_test, model_name="Regressor"):
|
|
34
34
|
|
35
35
|
Example:
|
36
36
|
```python
|
37
|
-
|
37
|
+
wandb.sklearn.plot_regressor(reg, X_train, X_test, y_train, y_test, "Ridge")
|
38
38
|
```
|
39
39
|
"""
|
40
40
|
wandb.termlog("\nPlotting %s." % model_name)
|
@@ -72,7 +72,7 @@ def outlier_candidates(regressor=None, X=None, y=None):
|
|
72
72
|
|
73
73
|
Example:
|
74
74
|
```python
|
75
|
-
|
75
|
+
wandb.sklearn.plot_outlier_candidates(model, X, y)
|
76
76
|
```
|
77
77
|
"""
|
78
78
|
is_missing = utils.test_missing(regressor=regressor, X=X, y=y)
|
@@ -106,7 +106,7 @@ def residuals(regressor=None, X=None, y=None):
|
|
106
106
|
|
107
107
|
Example:
|
108
108
|
```python
|
109
|
-
|
109
|
+
wandb.sklearn.plot_residuals(model, X, y)
|
110
110
|
```
|
111
111
|
"""
|
112
112
|
not_missing = utils.test_missing(regressor=regressor, X=X, y=y)
|