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.
Files changed (228) hide show
  1. wandb/__init__.py +2 -3
  2. wandb/apis/__init__.py +1 -3
  3. wandb/apis/importers/__init__.py +4 -0
  4. wandb/apis/importers/base.py +312 -0
  5. wandb/apis/importers/mlflow.py +113 -0
  6. wandb/apis/internal.py +29 -2
  7. wandb/apis/normalize.py +6 -5
  8. wandb/apis/public.py +163 -180
  9. wandb/apis/reports/_templates.py +6 -12
  10. wandb/apis/reports/report.py +1 -1
  11. wandb/apis/reports/runset.py +1 -3
  12. wandb/apis/reports/util.py +12 -10
  13. wandb/beta/workflows.py +57 -34
  14. wandb/catboost/__init__.py +1 -2
  15. wandb/cli/cli.py +215 -133
  16. wandb/data_types.py +63 -56
  17. wandb/docker/__init__.py +78 -16
  18. wandb/docker/auth.py +21 -22
  19. wandb/env.py +0 -1
  20. wandb/errors/__init__.py +8 -116
  21. wandb/errors/term.py +1 -1
  22. wandb/fastai/__init__.py +1 -2
  23. wandb/filesync/dir_watcher.py +8 -5
  24. wandb/filesync/step_prepare.py +76 -75
  25. wandb/filesync/step_upload.py +1 -2
  26. wandb/integration/catboost/__init__.py +1 -3
  27. wandb/integration/catboost/catboost.py +8 -14
  28. wandb/integration/fastai/__init__.py +7 -13
  29. wandb/integration/gym/__init__.py +35 -4
  30. wandb/integration/keras/__init__.py +3 -3
  31. wandb/integration/keras/callbacks/metrics_logger.py +9 -8
  32. wandb/integration/keras/callbacks/model_checkpoint.py +9 -9
  33. wandb/integration/keras/callbacks/tables_builder.py +31 -19
  34. wandb/integration/kfp/kfp_patch.py +20 -17
  35. wandb/integration/kfp/wandb_logging.py +1 -2
  36. wandb/integration/lightgbm/__init__.py +21 -19
  37. wandb/integration/prodigy/prodigy.py +6 -7
  38. wandb/integration/sacred/__init__.py +9 -12
  39. wandb/integration/sagemaker/__init__.py +1 -3
  40. wandb/integration/sagemaker/auth.py +0 -1
  41. wandb/integration/sagemaker/config.py +1 -1
  42. wandb/integration/sagemaker/resources.py +1 -1
  43. wandb/integration/sb3/sb3.py +8 -4
  44. wandb/integration/tensorboard/__init__.py +1 -3
  45. wandb/integration/tensorboard/log.py +8 -8
  46. wandb/integration/tensorboard/monkeypatch.py +11 -9
  47. wandb/integration/tensorflow/__init__.py +1 -3
  48. wandb/integration/xgboost/__init__.py +4 -6
  49. wandb/integration/yolov8/__init__.py +7 -0
  50. wandb/integration/yolov8/yolov8.py +250 -0
  51. wandb/jupyter.py +31 -35
  52. wandb/lightgbm/__init__.py +1 -2
  53. wandb/old/settings.py +2 -2
  54. wandb/plot/bar.py +1 -2
  55. wandb/plot/confusion_matrix.py +1 -3
  56. wandb/plot/histogram.py +1 -2
  57. wandb/plot/line.py +1 -2
  58. wandb/plot/line_series.py +4 -4
  59. wandb/plot/pr_curve.py +17 -20
  60. wandb/plot/roc_curve.py +1 -3
  61. wandb/plot/scatter.py +1 -2
  62. wandb/proto/v3/wandb_server_pb2.py +85 -39
  63. wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
  64. wandb/proto/v4/wandb_server_pb2.py +51 -39
  65. wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
  66. wandb/sdk/__init__.py +1 -3
  67. wandb/sdk/backend/backend.py +1 -1
  68. wandb/sdk/data_types/_dtypes.py +38 -30
  69. wandb/sdk/data_types/base_types/json_metadata.py +1 -3
  70. wandb/sdk/data_types/base_types/media.py +17 -17
  71. wandb/sdk/data_types/base_types/wb_value.py +33 -26
  72. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +91 -125
  73. wandb/sdk/data_types/helper_types/classes.py +1 -1
  74. wandb/sdk/data_types/helper_types/image_mask.py +12 -12
  75. wandb/sdk/data_types/histogram.py +5 -4
  76. wandb/sdk/data_types/html.py +1 -2
  77. wandb/sdk/data_types/image.py +11 -11
  78. wandb/sdk/data_types/molecule.py +3 -6
  79. wandb/sdk/data_types/object_3d.py +1 -2
  80. wandb/sdk/data_types/plotly.py +1 -2
  81. wandb/sdk/data_types/saved_model.py +10 -8
  82. wandb/sdk/data_types/video.py +1 -1
  83. wandb/sdk/integration_utils/data_logging.py +5 -5
  84. wandb/sdk/interface/artifacts.py +288 -266
  85. wandb/sdk/interface/interface.py +2 -3
  86. wandb/sdk/interface/interface_grpc.py +1 -1
  87. wandb/sdk/interface/interface_queue.py +1 -1
  88. wandb/sdk/interface/interface_relay.py +1 -1
  89. wandb/sdk/interface/interface_shared.py +1 -2
  90. wandb/sdk/interface/interface_sock.py +1 -1
  91. wandb/sdk/interface/message_future.py +1 -1
  92. wandb/sdk/interface/message_future_poll.py +1 -1
  93. wandb/sdk/interface/router.py +1 -1
  94. wandb/sdk/interface/router_queue.py +1 -1
  95. wandb/sdk/interface/router_relay.py +1 -1
  96. wandb/sdk/interface/router_sock.py +1 -1
  97. wandb/sdk/interface/summary_record.py +1 -1
  98. wandb/sdk/internal/artifacts.py +1 -1
  99. wandb/sdk/internal/datastore.py +2 -3
  100. wandb/sdk/internal/file_pusher.py +5 -3
  101. wandb/sdk/internal/file_stream.py +22 -19
  102. wandb/sdk/internal/handler.py +5 -4
  103. wandb/sdk/internal/internal.py +1 -1
  104. wandb/sdk/internal/internal_api.py +115 -55
  105. wandb/sdk/internal/job_builder.py +1 -3
  106. wandb/sdk/internal/profiler.py +1 -1
  107. wandb/sdk/internal/progress.py +4 -6
  108. wandb/sdk/internal/sample.py +1 -3
  109. wandb/sdk/internal/sender.py +28 -16
  110. wandb/sdk/internal/settings_static.py +5 -5
  111. wandb/sdk/internal/system/assets/__init__.py +1 -0
  112. wandb/sdk/internal/system/assets/cpu.py +3 -9
  113. wandb/sdk/internal/system/assets/disk.py +2 -4
  114. wandb/sdk/internal/system/assets/gpu.py +6 -18
  115. wandb/sdk/internal/system/assets/gpu_apple.py +2 -4
  116. wandb/sdk/internal/system/assets/interfaces.py +50 -22
  117. wandb/sdk/internal/system/assets/ipu.py +1 -3
  118. wandb/sdk/internal/system/assets/memory.py +7 -13
  119. wandb/sdk/internal/system/assets/network.py +4 -8
  120. wandb/sdk/internal/system/assets/open_metrics.py +283 -0
  121. wandb/sdk/internal/system/assets/tpu.py +1 -4
  122. wandb/sdk/internal/system/assets/trainium.py +26 -14
  123. wandb/sdk/internal/system/system_info.py +2 -3
  124. wandb/sdk/internal/system/system_monitor.py +52 -20
  125. wandb/sdk/internal/tb_watcher.py +12 -13
  126. wandb/sdk/launch/_project_spec.py +54 -65
  127. wandb/sdk/launch/agent/agent.py +374 -90
  128. wandb/sdk/launch/builder/abstract.py +61 -7
  129. wandb/sdk/launch/builder/build.py +81 -110
  130. wandb/sdk/launch/builder/docker_builder.py +181 -0
  131. wandb/sdk/launch/builder/kaniko_builder.py +419 -0
  132. wandb/sdk/launch/builder/noop.py +31 -12
  133. wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +70 -20
  134. wandb/sdk/launch/environment/abstract.py +28 -0
  135. wandb/sdk/launch/environment/aws_environment.py +276 -0
  136. wandb/sdk/launch/environment/gcp_environment.py +271 -0
  137. wandb/sdk/launch/environment/local_environment.py +65 -0
  138. wandb/sdk/launch/github_reference.py +3 -8
  139. wandb/sdk/launch/launch.py +38 -29
  140. wandb/sdk/launch/launch_add.py +6 -8
  141. wandb/sdk/launch/loader.py +230 -0
  142. wandb/sdk/launch/registry/abstract.py +54 -0
  143. wandb/sdk/launch/registry/elastic_container_registry.py +163 -0
  144. wandb/sdk/launch/registry/google_artifact_registry.py +203 -0
  145. wandb/sdk/launch/registry/local_registry.py +62 -0
  146. wandb/sdk/launch/runner/abstract.py +1 -16
  147. wandb/sdk/launch/runner/{kubernetes.py → kubernetes_runner.py} +83 -95
  148. wandb/sdk/launch/runner/local_container.py +46 -22
  149. wandb/sdk/launch/runner/local_process.py +1 -4
  150. wandb/sdk/launch/runner/{aws.py → sagemaker_runner.py} +53 -212
  151. wandb/sdk/launch/runner/{gcp_vertex.py → vertex_runner.py} +38 -55
  152. wandb/sdk/launch/sweeps/__init__.py +3 -2
  153. wandb/sdk/launch/sweeps/scheduler.py +132 -39
  154. wandb/sdk/launch/sweeps/scheduler_sweep.py +80 -89
  155. wandb/sdk/launch/utils.py +101 -30
  156. wandb/sdk/launch/wandb_reference.py +2 -7
  157. wandb/sdk/lib/_settings_toposort_generate.py +166 -0
  158. wandb/sdk/lib/_settings_toposort_generated.py +201 -0
  159. wandb/sdk/lib/apikey.py +2 -4
  160. wandb/sdk/lib/config_util.py +4 -1
  161. wandb/sdk/lib/console.py +1 -3
  162. wandb/sdk/lib/deprecate.py +3 -3
  163. wandb/sdk/lib/file_stream_utils.py +7 -5
  164. wandb/sdk/lib/filenames.py +1 -1
  165. wandb/sdk/lib/filesystem.py +61 -5
  166. wandb/sdk/lib/git.py +1 -3
  167. wandb/sdk/lib/import_hooks.py +4 -7
  168. wandb/sdk/lib/ipython.py +8 -5
  169. wandb/sdk/lib/lazyloader.py +1 -3
  170. wandb/sdk/lib/mailbox.py +14 -4
  171. wandb/sdk/lib/proto_util.py +10 -5
  172. wandb/sdk/lib/redirect.py +15 -22
  173. wandb/sdk/lib/reporting.py +1 -3
  174. wandb/sdk/lib/retry.py +4 -5
  175. wandb/sdk/lib/runid.py +1 -3
  176. wandb/sdk/lib/server.py +15 -9
  177. wandb/sdk/lib/sock_client.py +1 -1
  178. wandb/sdk/lib/sparkline.py +1 -1
  179. wandb/sdk/lib/wburls.py +1 -1
  180. wandb/sdk/service/port_file.py +1 -2
  181. wandb/sdk/service/service.py +36 -13
  182. wandb/sdk/service/service_base.py +12 -1
  183. wandb/sdk/verify/verify.py +5 -7
  184. wandb/sdk/wandb_artifacts.py +142 -177
  185. wandb/sdk/wandb_config.py +5 -8
  186. wandb/sdk/wandb_helper.py +1 -1
  187. wandb/sdk/wandb_init.py +24 -13
  188. wandb/sdk/wandb_login.py +9 -9
  189. wandb/sdk/wandb_manager.py +39 -4
  190. wandb/sdk/wandb_metric.py +2 -6
  191. wandb/sdk/wandb_require.py +4 -15
  192. wandb/sdk/wandb_require_helpers.py +1 -9
  193. wandb/sdk/wandb_run.py +95 -141
  194. wandb/sdk/wandb_save.py +1 -3
  195. wandb/sdk/wandb_settings.py +149 -54
  196. wandb/sdk/wandb_setup.py +66 -46
  197. wandb/sdk/wandb_summary.py +13 -10
  198. wandb/sdk/wandb_sweep.py +6 -7
  199. wandb/sdk/wandb_watch.py +1 -1
  200. wandb/sklearn/calculate/confusion_matrix.py +1 -1
  201. wandb/sklearn/calculate/learning_curve.py +1 -1
  202. wandb/sklearn/calculate/summary_metrics.py +1 -3
  203. wandb/sklearn/plot/__init__.py +1 -1
  204. wandb/sklearn/plot/classifier.py +27 -18
  205. wandb/sklearn/plot/clusterer.py +4 -5
  206. wandb/sklearn/plot/regressor.py +4 -4
  207. wandb/sklearn/plot/shared.py +2 -2
  208. wandb/sync/__init__.py +1 -3
  209. wandb/sync/sync.py +4 -5
  210. wandb/testing/relay.py +11 -10
  211. wandb/trigger.py +1 -1
  212. wandb/util.py +106 -81
  213. wandb/viz.py +4 -4
  214. wandb/wandb_agent.py +50 -50
  215. wandb/wandb_controller.py +2 -3
  216. wandb/wandb_run.py +1 -2
  217. wandb/wandb_torch.py +1 -1
  218. wandb/xgboost/__init__.py +1 -2
  219. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/METADATA +6 -2
  220. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/RECORD +224 -209
  221. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/WHEEL +1 -1
  222. wandb/sdk/launch/builder/docker.py +0 -80
  223. wandb/sdk/launch/builder/kaniko.py +0 -393
  224. wandb/sdk/launch/builder/loader.py +0 -32
  225. wandb/sdk/launch/runner/loader.py +0 -50
  226. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/LICENSE +0 -0
  227. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/entry_points.txt +0 -0
  228. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/top_level.txt +0 -0
@@ -57,51 +57,34 @@ class BoundingBoxes2D(JSONMetadata):
57
57
  wandb.init()
58
58
  image = np.random.randint(low=0, high=256, size=(200, 300, 3))
59
59
 
60
- class_labels = {
61
- 0: "person",
62
- 1: "car",
63
- 2: "road",
64
- 3: "building"
65
- }
66
-
67
- img = wandb.Image(image, boxes={
68
- "predictions": {
69
- "box_data": [
70
- {
71
- # one box expressed in the default relative/fractional domain
72
- "position": {
73
- "minX": 0.1,
74
- "maxX": 0.2,
75
- "minY": 0.3,
76
- "maxY": 0.4
60
+ class_labels = {0: "person", 1: "car", 2: "road", 3: "building"}
61
+
62
+ img = wandb.Image(
63
+ image,
64
+ boxes={
65
+ "predictions": {
66
+ "box_data": [
67
+ {
68
+ # one box expressed in the default relative/fractional domain
69
+ "position": {"minX": 0.1, "maxX": 0.2, "minY": 0.3, "maxY": 0.4},
70
+ "class_id": 1,
71
+ "box_caption": class_labels[1],
72
+ "scores": {"acc": 0.2, "loss": 1.2},
77
73
  },
78
- "class_id" : 1,
79
- "box_caption": class_labels[1],
80
- "scores" : {
81
- "acc": 0.2,
82
- "loss": 1.2
83
- }
84
- },
85
- {
86
- # another box expressed in the pixel domain
87
- "position": {
88
- "middle": [150, 20],
89
- "width": 68,
90
- "height": 112
74
+ {
75
+ # another box expressed in the pixel domain
76
+ "position": {"middle": [150, 20], "width": 68, "height": 112},
77
+ "domain": "pixel",
78
+ "class_id": 3,
79
+ "box_caption": "a building",
80
+ "scores": {"acc": 0.5, "loss": 0.7},
91
81
  },
92
- "domain" : "pixel",
93
- "class_id" : 3,
94
- "box_caption": "a building",
95
- "scores" : {
96
- "acc": 0.5,
97
- "loss": 0.7
98
- }
99
- },
100
- # Log as many boxes an as needed
101
- ],
102
- "class_labels": class_labels
103
- }
104
- })
82
+ # Log as many boxes an as needed
83
+ ],
84
+ "class_labels": class_labels,
85
+ }
86
+ },
87
+ )
105
88
 
106
89
  wandb.log({"driving_scene": img})
107
90
  ```
@@ -109,65 +92,50 @@ class BoundingBoxes2D(JSONMetadata):
109
92
  ### Log a bounding box overlay to a Table
110
93
  <!--yeadoc-test:bb2d-image-with-labels-->
111
94
  ```python
112
-
113
95
  import numpy as np
114
96
  import wandb
115
97
 
116
98
  wandb.init()
117
99
  image = np.random.randint(low=0, high=256, size=(200, 300, 3))
118
100
 
119
- class_labels = {
120
- 0: "person",
121
- 1: "car",
122
- 2: "road",
123
- 3: "building"
124
- }
125
-
126
- class_set = wandb.Classes([
127
- {"name" : "person", "id" : 0},
128
- {"name" : "car", "id" : 1},
129
- {"name" : "road", "id" : 2},
130
- {"name" : "building", "id" : 3}
131
- ])
132
-
133
- img = wandb.Image(image, boxes={
134
- "predictions": {
135
- "box_data": [
136
- {
137
- # one box expressed in the default relative/fractional domain
138
- "position": {
139
- "minX": 0.1,
140
- "maxX": 0.2,
141
- "minY": 0.3,
142
- "maxY": 0.4
101
+ class_labels = {0: "person", 1: "car", 2: "road", 3: "building"}
102
+
103
+ class_set = wandb.Classes(
104
+ [
105
+ {"name": "person", "id": 0},
106
+ {"name": "car", "id": 1},
107
+ {"name": "road", "id": 2},
108
+ {"name": "building", "id": 3},
109
+ ]
110
+ )
111
+
112
+ img = wandb.Image(
113
+ image,
114
+ boxes={
115
+ "predictions": {
116
+ "box_data": [
117
+ {
118
+ # one box expressed in the default relative/fractional domain
119
+ "position": {"minX": 0.1, "maxX": 0.2, "minY": 0.3, "maxY": 0.4},
120
+ "class_id": 1,
121
+ "box_caption": class_labels[1],
122
+ "scores": {"acc": 0.2, "loss": 1.2},
143
123
  },
144
- "class_id" : 1,
145
- "box_caption": class_labels[1],
146
- "scores" : {
147
- "acc": 0.2,
148
- "loss": 1.2
149
- }
150
- },
151
- {
152
- # another box expressed in the pixel domain
153
- "position": {
154
- "middle": [150, 20],
155
- "width": 68,
156
- "height": 112
124
+ {
125
+ # another box expressed in the pixel domain
126
+ "position": {"middle": [150, 20], "width": 68, "height": 112},
127
+ "domain": "pixel",
128
+ "class_id": 3,
129
+ "box_caption": "a building",
130
+ "scores": {"acc": 0.5, "loss": 0.7},
157
131
  },
158
- "domain" : "pixel",
159
- "class_id" : 3,
160
- "box_caption": "a building",
161
- "scores" : {
162
- "acc": 0.5,
163
- "loss": 0.7
164
- }
165
- },
166
- # Log as many boxes an as needed
167
- ],
168
- "class_labels": class_labels
169
- }
170
- }, classes=class_set)
132
+ # Log as many boxes an as needed
133
+ ],
134
+ "class_labels": class_labels,
135
+ }
136
+ },
137
+ classes=class_set,
138
+ )
171
139
 
172
140
  table = wandb.Table(columns=["image"])
173
141
  table.add_data(img)
@@ -180,36 +148,35 @@ class BoundingBoxes2D(JSONMetadata):
180
148
  # it here as _log_type, associate it in to_json
181
149
 
182
150
  def __init__(self, val: dict, key: str) -> None:
183
- """
184
- Arguments:
185
- val: (dictionary) A dictionary of the following form:
186
- box_data: (list of dictionaries) One dictionary for each bounding box, containing:
187
- position: (dictionary) the position and size of the bounding box, in one of two formats
188
- Note that boxes need not all use the same format.
189
- {"minX", "minY", "maxX", "maxY"}: (dictionary) A set of coordinates defining
190
- the upper and lower bounds of the box (the bottom left and top right corners)
191
- {"middle", "width", "height"}: (dictionary) A set of coordinates defining the
192
- center and dimensions of the box, with "middle" as a list [x, y] for the
193
- center point and "width" and "height" as numbers
194
- domain: (string) One of two options for the bounding box coordinate domain
195
- null: By default, or if no argument is passed, the coordinate domain
196
- is assumed to be relative to the original image, expressing this box as a fraction
197
- or percentage of the original image. This means all coordinates and dimensions
198
- passed into the "position" argument are floating point numbers between 0 and 1.
199
- "pixel": (string literal) The coordinate domain is set to the pixel space. This means all
200
- coordinates and dimensions passed into "position" are integers within the bounds
201
- of the image dimensions.
202
- class_id: (integer) The class label id for this box
203
- scores: (dictionary of string to number, optional) A mapping of named fields
204
- to numerical values (float or int), can be used for filtering boxes in the UI
205
- based on a range of values for the corresponding field
206
- box_caption: (string, optional) A string to be displayed as the label text above this
207
- box in the UI, often composed of the class label, class name, and/or scores
208
-
209
- class_labels: (dictionary, optional) A map of integer class labels to their readable class names
210
-
211
- key: (string)
212
- The readable name or id for this set of bounding boxes (e.g. predictions, ground_truth)
151
+ """Initialize a BoundingBoxes object.
152
+
153
+ The input dictionary `val` should contain the keys:
154
+ box_data: a list of dictionaries, each of which describes a bounding box.
155
+ class_labels: (optional) A map of integer class labels to their readable
156
+ class names.
157
+
158
+ Each bounding box dictionary should contain the following keys:
159
+ position: (dictionary) the position and size of the bounding box.
160
+ domain: (string) One of two options for the bounding box coordinate domain.
161
+ class_id: (integer) The class label id for this box.
162
+ scores: (dictionary of string to number, optional) A mapping of named fields
163
+ to numerical values (float or int).
164
+ box_caption: (optional) The label text, often composed of the class label,
165
+ class name, and/or scores.
166
+
167
+ The position dictionary should be in one of two formats:
168
+ {"minX", "minY", "maxX", "maxY"}: (dictionary) A set of coordinates defining
169
+ the upper and lower bounds of the box (the bottom left and top right
170
+ corners).
171
+ {"middle", "width", "height"}: (dictionary) A set of coordinates defining
172
+ the center and dimensions of the box, with "middle" as a list [x, y] for
173
+ the center point and "width" and "height" as numbers.
174
+ Note that boxes need not all use the same format.
175
+
176
+ Args:
177
+ val: (dictionary) A dictionary containing the bounding box data.
178
+ key: (string) The readable name or id for this set of bounding boxes (e.g.
179
+ predictions, ground_truth)
213
180
  """
214
181
  super().__init__(val)
215
182
  self._val = val["box_data"]
@@ -308,7 +275,6 @@ class BoundingBoxes2D(JSONMetadata):
308
275
  return True
309
276
 
310
277
  def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
311
-
312
278
  if isinstance(run_or_artifact, wandb.wandb_sdk.wandb_run.Run):
313
279
  return super().to_json(run_or_artifact)
314
280
  elif isinstance(run_or_artifact, wandb.wandb_sdk.wandb_artifacts.Artifact):
@@ -17,7 +17,7 @@ class Classes(Media):
17
17
  _class_set: Sequence[dict]
18
18
 
19
19
  def __init__(self, class_set: Sequence[dict]) -> None:
20
- """Classes is holds class metadata intended to be used in concert with other objects when visualizing artifacts
20
+ """Classes is holds class metadata intended to be used in concert with other objects when visualizing artifacts.
21
21
 
22
22
  Args:
23
23
  class_set (list): list of dicts in the form of {"id":int|str, "name":str}
@@ -116,19 +116,19 @@ class ImageMask(Media):
116
116
  _log_type = "mask"
117
117
 
118
118
  def __init__(self, val: dict, key: str) -> None:
119
- """
119
+ """Initialize an ImageMask object.
120
+
120
121
  Arguments:
121
- val: (dictionary)
122
- One of these two keys to represent the image:
123
- mask_data : (2D numpy array) The mask containing an integer class label
124
- for each pixel in the image
125
- path : (string) The path to a saved image file of the mask
126
- class_labels : (dictionary of integers to strings, optional) A mapping of the
127
- integer class labels in the mask to readable class names. These will default
128
- to class_0, class_1, class_2, etc.
129
-
130
- key: (string)
131
- The readable name or id for this mask type (e.g. predictions, ground_truth)
122
+ val: (dictionary) One of these two keys to represent the image:
123
+ mask_data : (2D numpy array) The mask containing an integer class label
124
+ for each pixel in the image
125
+ path : (string) The path to a saved image file of the mask
126
+ class_labels : (dictionary of integers to strings, optional) A mapping
127
+ of the integer class labels in the mask to readable class names.
128
+ These will default to class_0, class_1, class_2, etc.
129
+
130
+ key: (string)
131
+ The readable name or id for this mask type (e.g. predictions, ground_truth)
132
132
  """
133
133
  super().__init__()
134
134
 
@@ -23,7 +23,7 @@ class Histogram(WBValue):
23
23
  Examples:
24
24
  Generate histogram from a sequence
25
25
  ```python
26
- wandb.Histogram([1,2,3])
26
+ wandb.Histogram([1, 2, 3])
27
27
  ```
28
28
 
29
29
  Efficiently initialize from np.histogram.
@@ -52,7 +52,6 @@ class Histogram(WBValue):
52
52
  np_histogram: Optional["NumpyHistogram"] = None,
53
53
  num_bins: int = 64,
54
54
  ) -> None:
55
-
56
55
  if np_histogram:
57
56
  if len(np_histogram) == 2:
58
57
  self.histogram = (
@@ -88,7 +87,9 @@ class Histogram(WBValue):
88
87
  return {"_type": self._log_type, "values": self.histogram, "bins": self.bins}
89
88
 
90
89
  def __sizeof__(self) -> int:
91
- """This returns an estimated size in bytes, currently the factor of 1.7
92
- is used to account for the JSON encoding. We use this in tb_watcher.TBHistory
90
+ """Estimated size in bytes.
91
+
92
+ Currently the factor of 1.7 is used to account for the JSON encoding. We use
93
+ this in tb_watcher.TBHistory.
93
94
  """
94
95
  return int((sys.getsizeof(self.histogram) + sys.getsizeof(self.bins)) * 1.7)
@@ -17,8 +17,7 @@ if TYPE_CHECKING: # pragma: no cover
17
17
 
18
18
 
19
19
  class Html(BatchableMedia):
20
- """
21
- Wandb class for arbitrary html
20
+ """Wandb class for arbitrary html.
22
21
 
23
22
  Arguments:
24
23
  data: (string or io object) HTML to display in wandb
@@ -34,13 +34,16 @@ if TYPE_CHECKING: # pragma: no cover
34
34
 
35
35
 
36
36
  def _server_accepts_image_filenames() -> bool:
37
- from pkg_resources import parse_version
37
+ if util._is_offline():
38
+ return True
38
39
 
39
40
  # Newer versions of wandb accept large image filenames arrays
40
41
  # but older versions would have issues with this.
41
42
  max_cli_version = util._get_max_cli_version()
42
43
  if max_cli_version is None:
43
44
  return False
45
+ from pkg_resources import parse_version
46
+
44
47
  accepts_image_filenames: bool = parse_version("0.12.10") <= parse_version(
45
48
  max_cli_version
46
49
  )
@@ -435,9 +438,7 @@ class Image(BatchableMedia):
435
438
  return json_dict
436
439
 
437
440
  def guess_mode(self, data: "np.ndarray") -> str:
438
- """
439
- Guess what type of image the np.array is representing
440
- """
441
+ """Guess what type of image the np.array is representing."""
441
442
  # TODO: do we want to support dimensions being at the beginning of the array?
442
443
  if data.ndim == 2:
443
444
  return "L"
@@ -452,9 +453,10 @@ class Image(BatchableMedia):
452
453
 
453
454
  @classmethod
454
455
  def to_uint8(cls, data: "np.ndarray") -> "np.ndarray":
455
- """
456
- Converts floating point image on the range [0,1] and integer images
457
- on the range [0,255] to uint8, clipping if necessary.
456
+ """Convert image data to uint8.
457
+
458
+ Convert floating point image on the range [0,1] and integer images on the range
459
+ [0,255] to uint8, clipping if necessary.
458
460
  """
459
461
  np = util.get_module(
460
462
  "numpy",
@@ -482,9 +484,7 @@ class Image(BatchableMedia):
482
484
  key: str,
483
485
  step: Union[int, str],
484
486
  ) -> dict:
485
- """
486
- Combines a list of images into a meta dictionary object describing the child images.
487
- """
487
+ """Combine a list of images into a meta dictionary object describing the child images."""
488
488
  if TYPE_CHECKING:
489
489
  seq = cast(Sequence["Image"], seq)
490
490
 
@@ -528,7 +528,7 @@ class Image(BatchableMedia):
528
528
  ]
529
529
  else:
530
530
  wandb.termwarn(
531
- "Unable to log image array filenames. In some cases, this can prevent images from being"
531
+ "Unable to log image array filenames. In some cases, this can prevent images from being "
532
532
  "viewed in the UI. Please upgrade your wandb server",
533
533
  repeat=False,
534
534
  )
@@ -21,8 +21,7 @@ if TYPE_CHECKING: # pragma: no cover
21
21
 
22
22
 
23
23
  class Molecule(BatchableMedia):
24
- """
25
- Wandb class for 3D Molecular data
24
+ """Wandb class for 3D Molecular data.
26
25
 
27
26
  Arguments:
28
27
  data_or_path: (string, io)
@@ -103,8 +102,7 @@ class Molecule(BatchableMedia):
103
102
  convert_to_3d_and_optimize: bool = True,
104
103
  mmff_optimize_molecule_max_iterations: int = 200,
105
104
  ) -> "Molecule":
106
- """
107
- Convert RDKit-supported file/object types to wandb.Molecule
105
+ """Convert RDKit-supported file/object types to wandb.Molecule.
108
106
 
109
107
  Arguments:
110
108
  data_or_path: (string, rdkit.Chem.rdchem.Mol)
@@ -171,8 +169,7 @@ class Molecule(BatchableMedia):
171
169
  convert_to_3d_and_optimize: bool = True,
172
170
  mmff_optimize_molecule_max_iterations: int = 200,
173
171
  ) -> "Molecule":
174
- """
175
- Convert SMILES string to wandb.Molecule
172
+ """Convert SMILES string to wandb.Molecule.
176
173
 
177
174
  Arguments:
178
175
  data: (string)
@@ -75,8 +75,7 @@ if TYPE_CHECKING: # pragma: no cover
75
75
 
76
76
 
77
77
  class Object3D(BatchableMedia):
78
- """
79
- Wandb class for 3D point clouds.
78
+ """Wandb class for 3D point clouds.
80
79
 
81
80
  Arguments:
82
81
  data_or_path: (numpy array, string, io)
@@ -30,8 +30,7 @@ if TYPE_CHECKING: # pragma: no cover
30
30
 
31
31
 
32
32
  class Plotly(Media):
33
- """
34
- Wandb class for plotly plots.
33
+ """Wandb class for plotly plots.
35
34
 
36
35
  Arguments:
37
36
  val: matplotlib or plotly figure
@@ -71,8 +71,7 @@ SavedModelObjType = TypeVar("SavedModelObjType")
71
71
 
72
72
 
73
73
  class _SavedModel(WBValue, Generic[SavedModelObjType]):
74
- """SavedModel is a private data type that can be used to store a model object
75
- inside of a W&B Artifact.
74
+ """Internal W&B Artifact model storage.
76
75
 
77
76
  _model_type_id: (str) The id of the SavedModel subclass used to serialize the model.
78
77
  """
@@ -184,7 +183,7 @@ class _SavedModel(WBValue, Generic[SavedModelObjType]):
184
183
  return json_obj
185
184
 
186
185
  def model_obj(self) -> SavedModelObjType:
187
- """Returns the model object."""
186
+ """Return the model object."""
188
187
  if self._model_obj is None:
189
188
  assert self._path is not None, "Cannot load model object without path"
190
189
  self._set_obj(self._deserialize(self._path))
@@ -195,19 +194,22 @@ class _SavedModel(WBValue, Generic[SavedModelObjType]):
195
194
  # Methods to be implemented by subclasses
196
195
  @staticmethod
197
196
  def _deserialize(path: str) -> SavedModelObjType:
198
- """Returns the model object from a path. Allowed to throw errors"""
197
+ """Return the model object from a path. Allowed to throw errors."""
199
198
  raise NotImplementedError
200
199
 
201
200
  @staticmethod
202
201
  def _validate_obj(obj: Any) -> bool:
203
- """Validates the model object. Allowed to throw errors"""
202
+ """Validate the model object. Allowed to throw errors."""
204
203
  raise NotImplementedError
205
204
 
206
205
  @staticmethod
207
206
  def _serialize(obj: SavedModelObjType, dir_or_file_path: str) -> None:
208
- """Save the model to disk. The method will receive a directory path which all
209
- files needed for deserialization should be saved. A directory will always be passed if
210
- _path_extension is an empty string, else a single file will be passed. Allowed to throw errors
207
+ """Save the model to disk.
208
+
209
+ The method will receive a directory path which all files needed for
210
+ deserialization should be saved. A directory will always be passed if
211
+ _path_extension is an empty string, else a single file will be passed. Allowed
212
+ to throw errors.
211
213
  """
212
214
  raise NotImplementedError
213
215
 
@@ -183,7 +183,7 @@ class Video(BatchableMedia):
183
183
  return json_dict
184
184
 
185
185
  def _prepare_video(self, video: "np.ndarray") -> "np.ndarray":
186
- """This logic was mostly taken from tensorboardX"""
186
+ """This logic was mostly taken from tensorboardX."""
187
187
  np = util.get_module(
188
188
  "numpy",
189
189
  required='wandb.Video requires numpy when passing raw data. To get it, run "pip install numpy".',
@@ -44,7 +44,7 @@ class ValidationDataLogger:
44
44
  class_labels: Optional[List[str]] = None,
45
45
  infer_missing_processors: bool = True,
46
46
  ) -> None:
47
- """Initializes a new ValidationDataLogger.
47
+ """Initialize a new ValidationDataLogger.
48
48
 
49
49
  Args:
50
50
  inputs: A list of input vectors or dictionary of lists of input vectors
@@ -143,7 +143,7 @@ class ValidationDataLogger:
143
143
  def make_predictions(
144
144
  self, predict_fn: Callable
145
145
  ) -> Union[Sequence, Dict[str, Sequence]]:
146
- """Produces predictions by passing `validation_inputs` to `predict_fn`.
146
+ """Produce predictions by passing `validation_inputs` to `predict_fn`.
147
147
 
148
148
  Args:
149
149
  predict_fn (Callable): Any function which can accept `validation_inputs` and produce
@@ -162,7 +162,7 @@ class ValidationDataLogger:
162
162
  table_name: str = "validation_predictions",
163
163
  commit: bool = True,
164
164
  ) -> wandb.data_types.Table:
165
- """Logs a set of predictions.
165
+ """Log a set of predictions.
166
166
 
167
167
  Intended usage:
168
168
 
@@ -221,7 +221,7 @@ def _make_example(data: Any) -> Optional[Union[Dict, Sequence, Any]]:
221
221
 
222
222
 
223
223
  def _get_example_shape(example: Union[Sequence, Any]):
224
- """Gets the shape of an object if applicable."""
224
+ """Get the shape of an object if applicable."""
225
225
  shape = []
226
226
  if type(example) is not str and hasattr(example, "__len__"):
227
227
  length = len(example)
@@ -232,7 +232,7 @@ def _get_example_shape(example: Union[Sequence, Any]):
232
232
 
233
233
 
234
234
  def _bind(lambda_fn: Callable, **closure_kwargs: Any) -> Callable:
235
- """Creates a closure around a lambda function by binding `closure_kwargs` to the function."""
235
+ """Create a closure around a lambda function by binding `closure_kwargs` to the function."""
236
236
 
237
237
  def closure(*args: Any, **kwargs: Any) -> Any:
238
238
  _k = {}