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_config.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
"""
|
2
|
-
config.
|
3
|
-
"""
|
1
|
+
"""config."""
|
4
2
|
|
5
3
|
import logging
|
6
4
|
from typing import Optional
|
@@ -22,8 +20,7 @@ logger = logging.getLogger("wandb")
|
|
22
20
|
# if this is done right we might make sure this is pickle-able
|
23
21
|
# we might be able to do this on other objects like Run?
|
24
22
|
class Config:
|
25
|
-
"""
|
26
|
-
Config object
|
23
|
+
"""Config object.
|
27
24
|
|
28
25
|
Config objects are intended to hold all of the hyperparameters associated with
|
29
26
|
a wandb run and are saved with the run object when `wandb.init` is called.
|
@@ -32,11 +29,11 @@ class Config:
|
|
32
29
|
setting the config as a parameter to init, ie. `wandb.init(config=my_config_dict)`
|
33
30
|
|
34
31
|
You can create a file called `config-defaults.yaml`, and it will automatically be
|
35
|
-
loaded into `wandb.config`. See https://docs.wandb.com/
|
32
|
+
loaded into `wandb.config`. See https://docs.wandb.com/guides/track/config#file-based-configs.
|
36
33
|
|
37
34
|
You can also load a config YAML file with your custom name and pass the filename
|
38
35
|
into `wandb.init(config="special_config.yaml")`.
|
39
|
-
See https://docs.wandb.com/
|
36
|
+
See https://docs.wandb.com/guides/track/config#file-based-configs.
|
40
37
|
|
41
38
|
Examples:
|
42
39
|
Basic usage
|
@@ -193,7 +190,7 @@ class Config:
|
|
193
190
|
return self._items.get(*args)
|
194
191
|
|
195
192
|
def persist(self):
|
196
|
-
"""
|
193
|
+
"""Call the callback if it's set."""
|
197
194
|
if self._callback:
|
198
195
|
self._callback(data=self._as_dict())
|
199
196
|
|
wandb/sdk/wandb_helper.py
CHANGED
@@ -29,7 +29,7 @@ def _to_dict(params):
|
|
29
29
|
if meta:
|
30
30
|
is_tf_flags_module = (
|
31
31
|
isinstance(params, types.ModuleType)
|
32
|
-
and meta.__name__ == "tensorflow.python.platform.flags"
|
32
|
+
and meta.__name__ == "tensorflow.python.platform.flags"
|
33
33
|
)
|
34
34
|
if is_tf_flags_module or meta.__name__ == "absl.flags":
|
35
35
|
params = params.FLAGS
|
wandb/sdk/wandb_init.py
CHANGED
@@ -124,7 +124,7 @@ class _WandbInit:
|
|
124
124
|
self.printer = get_printer(settings._jupyter)
|
125
125
|
|
126
126
|
def setup(self, kwargs: Any) -> None: # noqa: C901
|
127
|
-
"""
|
127
|
+
"""Complete setup for `wandb.init()`.
|
128
128
|
|
129
129
|
This includes parsing all arguments, applying them with settings and enabling logging.
|
130
130
|
"""
|
@@ -161,13 +161,27 @@ class _WandbInit:
|
|
161
161
|
)
|
162
162
|
self.printer.display(line, level="warn")
|
163
163
|
|
164
|
-
|
164
|
+
# we add this logic to be backward compatible with the old behavior of disable
|
165
|
+
# where it would disable the service if the mode was set to disabled
|
166
|
+
mode = kwargs.get("mode")
|
167
|
+
settings_mode = (kwargs.get("settings") or {}).get("mode")
|
168
|
+
_disable_service = mode == "disabled" or settings_mode == "disabled"
|
169
|
+
setup_settings = {"_disable_service": _disable_service}
|
170
|
+
|
171
|
+
self._wl = wandb_setup.setup(settings=setup_settings)
|
165
172
|
# Make sure we have a logger setup (might be an early logger)
|
166
173
|
assert self._wl is not None
|
167
174
|
_set_logger(self._wl._get_logger())
|
168
175
|
|
169
176
|
# Start with settings from wandb library singleton
|
170
177
|
settings: Settings = self._wl.settings.copy()
|
178
|
+
|
179
|
+
# when using launch, we don't want to reuse the same run id from the singleton
|
180
|
+
# since users might launch multiple runs in the same process
|
181
|
+
# TODO(kdg): allow users to control this via launch settings
|
182
|
+
if settings.launch and singleton is not None:
|
183
|
+
settings.update({"run_id": None}, source=Source.INIT)
|
184
|
+
|
171
185
|
settings_param = kwargs.pop("settings", None)
|
172
186
|
if settings_param is not None and isinstance(settings_param, (Settings, dict)):
|
173
187
|
settings.update(settings_param, source=Source.INIT)
|
@@ -329,7 +343,7 @@ class _WandbInit:
|
|
329
343
|
config_target.setdefault(k, v)
|
330
344
|
|
331
345
|
def _enable_logging(self, log_fname: str, run_id: Optional[str] = None) -> None:
|
332
|
-
"""
|
346
|
+
"""Enable logging to the global debug log.
|
333
347
|
|
334
348
|
This adds a run_id to the log, in case of multiple processes on the same machine.
|
335
349
|
Currently, there is no way to disable logging after it's enabled.
|
@@ -455,7 +469,7 @@ class _WandbInit:
|
|
455
469
|
ipython.display_pub.publish = publish
|
456
470
|
|
457
471
|
def _log_setup(self, settings: Settings) -> None:
|
458
|
-
"""
|
472
|
+
"""Set up logging from settings."""
|
459
473
|
filesystem.mkdir_exists_ok(os.path.dirname(settings.log_user))
|
460
474
|
filesystem.mkdir_exists_ok(os.path.dirname(settings.log_internal))
|
461
475
|
filesystem.mkdir_exists_ok(os.path.dirname(settings.sync_file))
|
@@ -547,7 +561,7 @@ class _WandbInit:
|
|
547
561
|
if len(self._wl._global_run_stack) > 1:
|
548
562
|
wandb.termwarn(
|
549
563
|
"If you want to track multiple runs concurrently in wandb, "
|
550
|
-
"you should use multi-processing not threads"
|
564
|
+
"you should use multi-processing not threads"
|
551
565
|
)
|
552
566
|
|
553
567
|
last_id = self._wl._global_run_stack[-1]._run_id
|
@@ -929,7 +943,7 @@ def init(
|
|
929
943
|
id: Optional[str] = None,
|
930
944
|
settings: Union[Settings, Dict[str, Any], None] = None,
|
931
945
|
) -> Union[Run, RunDisabled, None]:
|
932
|
-
r"""
|
946
|
+
r"""Start a new run to track and log to W&B.
|
933
947
|
|
934
948
|
In an ML training pipeline, you could add `wandb.init()`
|
935
949
|
to the beginning of your training script as well as your evaluation
|
@@ -1000,7 +1014,7 @@ def init(
|
|
1000
1014
|
a model against different test sets. Group gives you a way to
|
1001
1015
|
organize runs together into a larger whole, and you can toggle this
|
1002
1016
|
on and off in the UI. For more details, see our
|
1003
|
-
[guide to grouping runs](https://docs.wandb.com/
|
1017
|
+
[guide to grouping runs](https://docs.wandb.com/guides/runs/grouping).
|
1004
1018
|
job_type: (str, optional) Specify the type of run, which is useful when
|
1005
1019
|
you're grouping runs together into larger experiments using group.
|
1006
1020
|
For example, you might have multiple jobs in a group, with job types
|
@@ -1042,7 +1056,7 @@ def init(
|
|
1042
1056
|
`WANDB_RUN_ID="UNIQUE_ID"` and it is identical to a previous run,
|
1043
1057
|
wandb will automatically resume the run with the id. Otherwise,
|
1044
1058
|
wandb will crash.
|
1045
|
-
See [our guide to resuming runs](https://docs.wandb.com/
|
1059
|
+
See [our guide to resuming runs](https://docs.wandb.com/guides/runs/resuming)
|
1046
1060
|
for more.
|
1047
1061
|
reinit: (bool, optional) Allow multiple `wandb.init()` calls in the same
|
1048
1062
|
process. (default: `False`)
|
@@ -1077,13 +1091,13 @@ def init(
|
|
1077
1091
|
tensorboardX and save the relevant events file. (default: `False`)
|
1078
1092
|
monitor_gym: (bool, optional) Automatically log videos of environment when
|
1079
1093
|
using OpenAI Gym. (default: `False`)
|
1080
|
-
See [our guide to this integration](https://docs.wandb.com/
|
1094
|
+
See [our guide to this integration](https://docs.wandb.com/guides/integrations/openai-gym).
|
1081
1095
|
id: (str, optional) A unique ID for this run, used for resuming. It must
|
1082
1096
|
be unique in the project, and if you delete a run you can't reuse
|
1083
1097
|
the ID. Use the `name` field for a short descriptive name, or `config`
|
1084
1098
|
for saving hyperparameters to compare across runs. The ID cannot
|
1085
1099
|
contain the following special characters: `/\#?%:`.
|
1086
|
-
See [our guide to resuming runs](https://docs.wandb.com/
|
1100
|
+
See [our guide to resuming runs](https://docs.wandb.com/guides/runs/resuming).
|
1087
1101
|
|
1088
1102
|
Examples:
|
1089
1103
|
### Set where the run is logged
|
@@ -1113,9 +1127,6 @@ def init(
|
|
1113
1127
|
wandb.init(config=config)
|
1114
1128
|
```
|
1115
1129
|
|
1116
|
-
Raises:
|
1117
|
-
Exception: if problem.
|
1118
|
-
|
1119
1130
|
Returns:
|
1120
1131
|
A `Run` object.
|
1121
1132
|
"""
|
wandb/sdk/wandb_login.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
"""
|
2
|
-
|
3
|
-
account.
|
1
|
+
"""Log in to Weights & Biases.
|
2
|
+
|
3
|
+
This authenticates your machine to log data to your account.
|
4
4
|
"""
|
5
5
|
|
6
6
|
import enum
|
@@ -26,9 +26,11 @@ from .wandb_settings import Settings, Source
|
|
26
26
|
|
27
27
|
|
28
28
|
def _handle_host_wandb_setting(host: Optional[str], cloud: bool = False) -> None:
|
29
|
-
"""Write the host parameter
|
30
|
-
|
31
|
-
the
|
29
|
+
"""Write the host parameter to the global settings file.
|
30
|
+
|
31
|
+
This takes the parameter from wandb.login or wandb login for use by the
|
32
|
+
application's APIs.
|
33
|
+
"""
|
32
34
|
_api = InternalApi()
|
33
35
|
if host == "https://api.wandb.ai" or (host is None and cloud):
|
34
36
|
_api.clear_setting("base_url", globally=True, persist=True)
|
@@ -49,8 +51,7 @@ def login(
|
|
49
51
|
force: Optional[bool] = None,
|
50
52
|
timeout: Optional[int] = None,
|
51
53
|
) -> bool:
|
52
|
-
"""
|
53
|
-
Log in to W&B.
|
54
|
+
"""Log in to W&B.
|
54
55
|
|
55
56
|
Arguments:
|
56
57
|
anonymous: (string, optional) Can be "must", "allow", or "never".
|
@@ -69,7 +70,6 @@ def login(
|
|
69
70
|
Raises:
|
70
71
|
UsageError - if api_key cannot be configured and no tty
|
71
72
|
"""
|
72
|
-
|
73
73
|
_handle_host_wandb_setting(host)
|
74
74
|
if wandb.setup()._settings._noop:
|
75
75
|
return True
|
wandb/sdk/wandb_manager.py
CHANGED
@@ -7,11 +7,15 @@ import atexit
|
|
7
7
|
import os
|
8
8
|
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional
|
9
9
|
|
10
|
+
import psutil
|
11
|
+
|
10
12
|
import wandb
|
11
13
|
from wandb import env, trigger
|
14
|
+
from wandb.errors import Error
|
12
15
|
from wandb.sdk.lib.exit_hooks import ExitHooks
|
13
16
|
from wandb.sdk.lib.import_hooks import unregister_all_post_import_hooks
|
14
17
|
from wandb.sdk.lib.proto_util import settings_dict_from_pbmap
|
18
|
+
from wandb.util import sentry_reraise
|
15
19
|
|
16
20
|
if TYPE_CHECKING:
|
17
21
|
from wandb.sdk.service import service
|
@@ -19,6 +23,18 @@ if TYPE_CHECKING:
|
|
19
23
|
from wandb.sdk.wandb_settings import Settings
|
20
24
|
|
21
25
|
|
26
|
+
class ManagerConnectionError(Error):
|
27
|
+
"""Raised when service process is not running."""
|
28
|
+
|
29
|
+
pass
|
30
|
+
|
31
|
+
|
32
|
+
class ManagerConnectionRefusedError(ManagerConnectionError):
|
33
|
+
"""Raised when service process is not running."""
|
34
|
+
|
35
|
+
pass
|
36
|
+
|
37
|
+
|
22
38
|
class _ManagerToken:
|
23
39
|
_version = "2"
|
24
40
|
_supported_transports = {"grpc", "tcp"}
|
@@ -93,8 +109,26 @@ class _Manager:
|
|
93
109
|
_settings: "Settings"
|
94
110
|
_service: "service._Service"
|
95
111
|
|
112
|
+
def _service_connect(self) -> None:
|
113
|
+
port = self._token.port
|
114
|
+
svc_iface = self._get_service_interface()
|
115
|
+
|
116
|
+
try:
|
117
|
+
svc_iface._svc_connect(port=port)
|
118
|
+
except ConnectionRefusedError as e:
|
119
|
+
if not psutil.pid_exists(self._token.pid):
|
120
|
+
message = (
|
121
|
+
"Connection to wandb service failed "
|
122
|
+
"since the process is not available. "
|
123
|
+
)
|
124
|
+
else:
|
125
|
+
message = f"Connection to wandb service failed: {e}. "
|
126
|
+
raise ManagerConnectionRefusedError(message)
|
127
|
+
except Exception as e:
|
128
|
+
raise ManagerConnectionError(f"Connection to wandb service failed: {e}")
|
129
|
+
|
96
130
|
def __init__(self, settings: "Settings") -> None:
|
97
|
-
# TODO: warn if user
|
131
|
+
# TODO: warn if user doesn't have grpc installed
|
98
132
|
from wandb.sdk.service import service
|
99
133
|
|
100
134
|
self._settings = settings
|
@@ -124,9 +158,10 @@ class _Manager:
|
|
124
158
|
|
125
159
|
self._token = token
|
126
160
|
|
127
|
-
|
128
|
-
|
129
|
-
|
161
|
+
try:
|
162
|
+
self._service_connect()
|
163
|
+
except ManagerConnectionError as e:
|
164
|
+
sentry_reraise(e, delay=True)
|
130
165
|
|
131
166
|
def _atexit_setup(self) -> None:
|
132
167
|
self._atexit_lambda = lambda: self._atexit_teardown()
|
wandb/sdk/wandb_metric.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
"""
|
2
|
-
metric.
|
3
|
-
"""
|
1
|
+
"""metric."""
|
4
2
|
|
5
3
|
import logging
|
6
4
|
from typing import Callable, Optional, Sequence, Tuple
|
@@ -11,9 +9,7 @@ logger = logging.getLogger("wandb")
|
|
11
9
|
|
12
10
|
|
13
11
|
class Metric:
|
14
|
-
"""
|
15
|
-
Metric object
|
16
|
-
"""
|
12
|
+
"""Metric object."""
|
17
13
|
|
18
14
|
_callback: Optional[Callable[[pb.MetricRecord], None]]
|
19
15
|
_name: str
|
wandb/sdk/wandb_require.py
CHANGED
@@ -9,12 +9,10 @@ Example:
|
|
9
9
|
wandb.require("incremental-artifacts@beta")
|
10
10
|
"""
|
11
11
|
|
12
|
-
import os
|
13
12
|
from typing import Optional, Sequence, Union
|
14
13
|
|
15
14
|
import wandb
|
16
|
-
from wandb.
|
17
|
-
from wandb.errors import RequireError
|
15
|
+
from wandb.errors import UnsupportedError
|
18
16
|
from wandb.sdk import wandb_run
|
19
17
|
from wandb.sdk.lib.wburls import wburls
|
20
18
|
|
@@ -33,18 +31,11 @@ class _Requires:
|
|
33
31
|
pass
|
34
32
|
|
35
33
|
def _require_service(self) -> None:
|
36
|
-
os.environ[REQUIRE_SERVICE] = "True"
|
37
34
|
wandb.teardown = wandb._teardown # type: ignore
|
38
35
|
wandb.attach = wandb._attach # type: ignore
|
39
36
|
wandb_run.Run.detach = wandb_run.Run._detach # type: ignore
|
40
37
|
|
41
38
|
def require_service(self) -> None:
|
42
|
-
disable_service = os.environ.get(_DISABLE_SERVICE)
|
43
|
-
if disable_service:
|
44
|
-
if REQUIRE_SERVICE in os.environ:
|
45
|
-
del os.environ[REQUIRE_SERVICE]
|
46
|
-
return
|
47
|
-
|
48
39
|
self._require_service()
|
49
40
|
|
50
41
|
def apply(self) -> None:
|
@@ -65,7 +56,7 @@ class _Requires:
|
|
65
56
|
wandb.termerror(
|
66
57
|
f"Supported wandb.require() features can be found at: {wburls.get('doc_require')}"
|
67
58
|
)
|
68
|
-
raise
|
59
|
+
raise UnsupportedError(last_message)
|
69
60
|
|
70
61
|
|
71
62
|
def require(
|
@@ -79,7 +70,7 @@ def require(
|
|
79
70
|
experiment: (str or list) Features to require
|
80
71
|
|
81
72
|
Raises:
|
82
|
-
wandb.errors.
|
73
|
+
wandb.errors.UnsupportedError: if not supported
|
83
74
|
"""
|
84
75
|
features = requirement or experiment
|
85
76
|
if not features:
|
@@ -93,6 +84,4 @@ def _import_module_hook() -> None:
|
|
93
84
|
"""On wandb import, setup anything needed based on parent process require calls."""
|
94
85
|
# TODO: optimize by caching which pids this has been done for or use real import hooks
|
95
86
|
# TODO: make this more generic, but for now this works
|
96
|
-
|
97
|
-
if req_service:
|
98
|
-
require("service")
|
87
|
+
require("service")
|
@@ -10,9 +10,7 @@ requirement_env_var_mapping: Dict[str, str] = {
|
|
10
10
|
|
11
11
|
|
12
12
|
def requires(requirement: str) -> FuncT: # type: ignore
|
13
|
-
"""
|
14
|
-
The decorator for gating features.
|
15
|
-
"""
|
13
|
+
"""Decorate functions to gate features with wandb.require."""
|
16
14
|
env_var = requirement_env_var_mapping[requirement]
|
17
15
|
|
18
16
|
def deco(func: FuncT) -> FuncT:
|
@@ -33,15 +31,9 @@ class RequiresMixin:
|
|
33
31
|
requirement = ""
|
34
32
|
|
35
33
|
def __init__(self) -> None:
|
36
|
-
"""
|
37
|
-
This hook for normal classes
|
38
|
-
"""
|
39
34
|
self._check_if_requirements_met()
|
40
35
|
|
41
36
|
def __post_init__(self) -> None:
|
42
|
-
"""
|
43
|
-
This hook added for dataclasses
|
44
|
-
"""
|
45
37
|
self._check_if_requirements_met()
|
46
38
|
|
47
39
|
def _check_if_requirements_met(self) -> None:
|