wandb 0.17.0rc2__py3-none-win32.whl → 0.17.1__py3-none-win32.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. wandb/__init__.py +1 -2
  2. wandb/apis/importers/internals/internal.py +0 -1
  3. wandb/apis/importers/wandb.py +12 -7
  4. wandb/apis/internal.py +0 -3
  5. wandb/apis/public/api.py +213 -79
  6. wandb/apis/public/artifacts.py +335 -100
  7. wandb/apis/public/files.py +9 -9
  8. wandb/apis/public/jobs.py +16 -4
  9. wandb/apis/public/projects.py +26 -28
  10. wandb/apis/public/query_generator.py +1 -1
  11. wandb/apis/public/runs.py +163 -65
  12. wandb/apis/public/sweeps.py +2 -2
  13. wandb/apis/reports/__init__.py +1 -7
  14. wandb/apis/reports/v1/__init__.py +5 -27
  15. wandb/apis/reports/v2/__init__.py +7 -19
  16. wandb/apis/workspaces/__init__.py +8 -0
  17. wandb/beta/workflows.py +8 -3
  18. wandb/bin/wandb-core +0 -0
  19. wandb/cli/cli.py +131 -59
  20. wandb/docker/__init__.py +1 -1
  21. wandb/errors/term.py +10 -2
  22. wandb/filesync/step_checksum.py +1 -4
  23. wandb/filesync/step_prepare.py +4 -24
  24. wandb/filesync/step_upload.py +5 -107
  25. wandb/filesync/upload_job.py +0 -76
  26. wandb/integration/gym/__init__.py +35 -15
  27. wandb/integration/openai/fine_tuning.py +21 -3
  28. wandb/integration/prodigy/prodigy.py +1 -1
  29. wandb/jupyter.py +16 -17
  30. wandb/plot/pr_curve.py +2 -1
  31. wandb/plot/roc_curve.py +2 -1
  32. wandb/{plots → plot}/utils.py +13 -25
  33. wandb/proto/v3/wandb_internal_pb2.py +54 -54
  34. wandb/proto/v3/wandb_settings_pb2.py +2 -2
  35. wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
  36. wandb/proto/v4/wandb_internal_pb2.py +54 -54
  37. wandb/proto/v4/wandb_settings_pb2.py +2 -2
  38. wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
  39. wandb/proto/v5/wandb_base_pb2.py +30 -0
  40. wandb/proto/v5/wandb_internal_pb2.py +355 -0
  41. wandb/proto/v5/wandb_server_pb2.py +63 -0
  42. wandb/proto/v5/wandb_settings_pb2.py +45 -0
  43. wandb/proto/v5/wandb_telemetry_pb2.py +41 -0
  44. wandb/proto/wandb_base_pb2.py +2 -0
  45. wandb/proto/wandb_deprecated.py +9 -1
  46. wandb/proto/wandb_generate_deprecated.py +34 -0
  47. wandb/proto/{wandb_internal_codegen.py → wandb_generate_proto.py} +1 -35
  48. wandb/proto/wandb_internal_pb2.py +2 -0
  49. wandb/proto/wandb_server_pb2.py +2 -0
  50. wandb/proto/wandb_settings_pb2.py +2 -0
  51. wandb/proto/wandb_telemetry_pb2.py +2 -0
  52. wandb/sdk/artifacts/artifact.py +68 -22
  53. wandb/sdk/artifacts/artifact_manifest.py +1 -1
  54. wandb/sdk/artifacts/artifact_manifest_entry.py +6 -3
  55. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +1 -1
  56. wandb/sdk/artifacts/artifact_saver.py +1 -10
  57. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +6 -2
  58. wandb/sdk/artifacts/storage_handlers/multi_handler.py +1 -1
  59. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +6 -4
  60. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +2 -42
  61. wandb/sdk/artifacts/storage_policy.py +1 -12
  62. wandb/sdk/data_types/image.py +1 -1
  63. wandb/sdk/data_types/video.py +4 -2
  64. wandb/sdk/interface/interface.py +13 -0
  65. wandb/sdk/interface/interface_shared.py +1 -1
  66. wandb/sdk/internal/file_pusher.py +2 -5
  67. wandb/sdk/internal/file_stream.py +6 -19
  68. wandb/sdk/internal/internal_api.py +148 -136
  69. wandb/sdk/internal/job_builder.py +207 -135
  70. wandb/sdk/internal/progress.py +0 -28
  71. wandb/sdk/internal/sender.py +102 -39
  72. wandb/sdk/internal/settings_static.py +8 -1
  73. wandb/sdk/internal/system/assets/trainium.py +3 -3
  74. wandb/sdk/internal/system/system_info.py +4 -2
  75. wandb/sdk/internal/update.py +1 -1
  76. wandb/sdk/launch/__init__.py +9 -1
  77. wandb/sdk/launch/_launch.py +4 -24
  78. wandb/sdk/launch/_launch_add.py +1 -3
  79. wandb/sdk/launch/_project_spec.py +184 -224
  80. wandb/sdk/launch/agent/agent.py +58 -18
  81. wandb/sdk/launch/agent/config.py +0 -3
  82. wandb/sdk/launch/builder/abstract.py +67 -0
  83. wandb/sdk/launch/builder/build.py +165 -576
  84. wandb/sdk/launch/builder/context_manager.py +235 -0
  85. wandb/sdk/launch/builder/docker_builder.py +7 -23
  86. wandb/sdk/launch/builder/kaniko_builder.py +10 -23
  87. wandb/sdk/launch/builder/templates/dockerfile.py +92 -0
  88. wandb/sdk/launch/create_job.py +51 -45
  89. wandb/sdk/launch/environment/aws_environment.py +26 -1
  90. wandb/sdk/launch/inputs/files.py +148 -0
  91. wandb/sdk/launch/inputs/internal.py +224 -0
  92. wandb/sdk/launch/inputs/manage.py +95 -0
  93. wandb/sdk/launch/runner/abstract.py +2 -2
  94. wandb/sdk/launch/runner/kubernetes_monitor.py +45 -12
  95. wandb/sdk/launch/runner/kubernetes_runner.py +6 -8
  96. wandb/sdk/launch/runner/local_container.py +2 -3
  97. wandb/sdk/launch/runner/local_process.py +8 -29
  98. wandb/sdk/launch/runner/sagemaker_runner.py +20 -14
  99. wandb/sdk/launch/runner/vertex_runner.py +8 -7
  100. wandb/sdk/launch/sweeps/scheduler.py +2 -0
  101. wandb/sdk/launch/sweeps/utils.py +2 -2
  102. wandb/sdk/launch/utils.py +16 -138
  103. wandb/sdk/lib/_settings_toposort_generated.py +2 -5
  104. wandb/sdk/lib/apikey.py +4 -2
  105. wandb/sdk/lib/config_util.py +3 -3
  106. wandb/sdk/lib/proto_util.py +22 -1
  107. wandb/sdk/lib/redirect.py +1 -1
  108. wandb/sdk/service/service.py +2 -1
  109. wandb/sdk/service/streams.py +5 -5
  110. wandb/sdk/wandb_init.py +25 -59
  111. wandb/sdk/wandb_login.py +28 -25
  112. wandb/sdk/wandb_run.py +112 -45
  113. wandb/sdk/wandb_settings.py +33 -64
  114. wandb/sdk/wandb_watch.py +1 -1
  115. wandb/sklearn/plot/classifier.py +4 -6
  116. wandb/sync/sync.py +2 -2
  117. wandb/testing/relay.py +32 -17
  118. wandb/util.py +36 -37
  119. wandb/wandb_agent.py +3 -3
  120. wandb/wandb_controller.py +3 -2
  121. {wandb-0.17.0rc2.dist-info → wandb-0.17.1.dist-info}/METADATA +7 -9
  122. {wandb-0.17.0rc2.dist-info → wandb-0.17.1.dist-info}/RECORD +125 -147
  123. wandb/apis/reports/v1/_blocks.py +0 -1406
  124. wandb/apis/reports/v1/_helpers.py +0 -70
  125. wandb/apis/reports/v1/_panels.py +0 -1282
  126. wandb/apis/reports/v1/_templates.py +0 -478
  127. wandb/apis/reports/v1/blocks.py +0 -27
  128. wandb/apis/reports/v1/helpers.py +0 -2
  129. wandb/apis/reports/v1/mutations.py +0 -66
  130. wandb/apis/reports/v1/panels.py +0 -17
  131. wandb/apis/reports/v1/report.py +0 -268
  132. wandb/apis/reports/v1/runset.py +0 -144
  133. wandb/apis/reports/v1/templates.py +0 -7
  134. wandb/apis/reports/v1/util.py +0 -406
  135. wandb/apis/reports/v1/validators.py +0 -131
  136. wandb/apis/reports/v2/blocks.py +0 -25
  137. wandb/apis/reports/v2/expr_parsing.py +0 -257
  138. wandb/apis/reports/v2/gql.py +0 -68
  139. wandb/apis/reports/v2/interface.py +0 -1911
  140. wandb/apis/reports/v2/internal.py +0 -867
  141. wandb/apis/reports/v2/metrics.py +0 -6
  142. wandb/apis/reports/v2/panels.py +0 -15
  143. wandb/catboost/__init__.py +0 -9
  144. wandb/fastai/__init__.py +0 -9
  145. wandb/keras/__init__.py +0 -19
  146. wandb/lightgbm/__init__.py +0 -9
  147. wandb/plots/__init__.py +0 -6
  148. wandb/plots/explain_text.py +0 -36
  149. wandb/plots/heatmap.py +0 -81
  150. wandb/plots/named_entity.py +0 -43
  151. wandb/plots/part_of_speech.py +0 -50
  152. wandb/plots/plot_definitions.py +0 -768
  153. wandb/plots/precision_recall.py +0 -121
  154. wandb/plots/roc.py +0 -103
  155. wandb/sacred/__init__.py +0 -3
  156. wandb/xgboost/__init__.py +0 -9
  157. {wandb-0.17.0rc2.dist-info → wandb-0.17.1.dist-info}/WHEEL +0 -0
  158. {wandb-0.17.0rc2.dist-info → wandb-0.17.1.dist-info}/entry_points.txt +0 -0
  159. {wandb-0.17.0rc2.dist-info → wandb-0.17.1.dist-info}/licenses/LICENSE +0 -0
@@ -22,23 +22,22 @@ class Projects(Paginator):
22
22
 
23
23
  QUERY = gql(
24
24
  """
25
- query Projects($entity: String, $cursor: String, $perPage: Int = 50) {
26
- models(entityName: $entity, after: $cursor, first: $perPage) {
27
- edges {
28
- node {
25
+ query Projects($entity: String, $cursor: String, $perPage: Int = 50) {{
26
+ models(entityName: $entity, after: $cursor, first: $perPage) {{
27
+ edges {{
28
+ node {{
29
29
  ...ProjectFragment
30
- }
30
+ }}
31
31
  cursor
32
- }
33
- pageInfo {
32
+ }}
33
+ pageInfo {{
34
34
  endCursor
35
35
  hasNextPage
36
- }
37
- }
38
- }
39
- %s
40
- """
41
- % PROJECT_FRAGMENT
36
+ }}
37
+ }}
38
+ }}
39
+ {}
40
+ """.format(PROJECT_FRAGMENT)
42
41
  )
43
42
 
44
43
  def __init__(self, client, entity, per_page=50):
@@ -118,26 +117,25 @@ class Project(Attrs):
118
117
  def sweeps(self):
119
118
  query = gql(
120
119
  """
121
- query GetSweeps($project: String!, $entity: String!) {
122
- project(name: $project, entityName: $entity) {
120
+ query GetSweeps($project: String!, $entity: String!) {{
121
+ project(name: $project, entityName: $entity) {{
123
122
  totalSweeps
124
- sweeps {
125
- edges {
126
- node {
123
+ sweeps {{
124
+ edges {{
125
+ node {{
127
126
  ...SweepFragment
128
- }
127
+ }}
129
128
  cursor
130
- }
131
- pageInfo {
129
+ }}
130
+ pageInfo {{
132
131
  endCursor
133
132
  hasNextPage
134
- }
135
- }
136
- }
137
- }
138
- %s
139
- """
140
- % public.SWEEP_FRAGMENT
133
+ }}
134
+ }}
135
+ }}
136
+ }}
137
+ {}
138
+ """.format(public.SWEEP_FRAGMENT)
141
139
  )
142
140
  variable_values = {"project": self.name, "entity": self.entity}
143
141
  ret = self.client.execute(query, variable_values)
@@ -60,7 +60,7 @@ class QueryGenerator:
60
60
  return key["name"]
61
61
  elif key["section"] == "tags":
62
62
  return "tags." + key["name"]
63
- raise ValueError("Invalid key: %s" % key)
63
+ raise ValueError("Invalid key: {}".format(key))
64
64
 
65
65
  def server_path_to_key(self, path):
66
66
  if path.startswith("config."):
wandb/apis/public/runs.py CHANGED
@@ -2,10 +2,16 @@
2
2
 
3
3
  import json
4
4
  import os
5
+ import sys
5
6
  import tempfile
6
7
  import time
7
8
  import urllib
8
- from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional
9
+ from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional
10
+
11
+ if sys.version_info >= (3, 8):
12
+ from typing import Literal
13
+ else:
14
+ from typing_extensions import Literal
9
15
 
10
16
  from wandb_gql import gql
11
17
 
@@ -60,27 +66,26 @@ class Runs(Paginator):
60
66
 
61
67
  QUERY = gql(
62
68
  """
63
- query Runs($project: String!, $entity: String!, $cursor: String, $perPage: Int = 50, $order: String, $filters: JSONString) {
64
- project(name: $project, entityName: $entity) {
69
+ query Runs($project: String!, $entity: String!, $cursor: String, $perPage: Int = 50, $order: String, $filters: JSONString) {{
70
+ project(name: $project, entityName: $entity) {{
65
71
  runCount(filters: $filters)
66
72
  readOnly
67
- runs(filters: $filters, after: $cursor, first: $perPage, order: $order) {
68
- edges {
69
- node {
73
+ runs(filters: $filters, after: $cursor, first: $perPage, order: $order) {{
74
+ edges {{
75
+ node {{
70
76
  ...RunFragment
71
- }
77
+ }}
72
78
  cursor
73
- }
74
- pageInfo {
79
+ }}
80
+ pageInfo {{
75
81
  endCursor
76
82
  hasNextPage
77
- }
78
- }
79
- }
80
- }
81
- %s
82
- """
83
- % RUN_FRAGMENT
83
+ }}
84
+ }}
85
+ }}
86
+ }}
87
+ {}
88
+ """.format(RUN_FRAGMENT)
84
89
  )
85
90
 
86
91
  def __init__(
@@ -131,7 +136,7 @@ class Runs(Paginator):
131
136
  def convert_objects(self):
132
137
  objs = []
133
138
  if self.last_response is None or self.last_response.get("project") is None:
134
- raise ValueError("Could not find project %s" % self.project)
139
+ raise ValueError("Could not find project {}".format(self.project))
135
140
  for run_response in self.last_response["project"]["runs"]["edges"]:
136
141
  run = Run(
137
142
  self.client,
@@ -162,6 +167,104 @@ class Runs(Paginator):
162
167
 
163
168
  return objs
164
169
 
170
+ @normalize_exceptions
171
+ def histories(
172
+ self,
173
+ samples: int = 500,
174
+ keys: Optional[List[str]] = None,
175
+ x_axis: str = "_step",
176
+ format: Literal["default", "pandas", "polars"] = "default",
177
+ stream: Literal["default", "system"] = "default",
178
+ ):
179
+ """Return sampled history metrics for all runs that fit the filters conditions.
180
+
181
+ Arguments:
182
+ samples : (int, optional) The number of samples to return per run
183
+ keys : (list[str], optional) Only return metrics for specific keys
184
+ x_axis : (str, optional) Use this metric as the xAxis defaults to _step
185
+ format : (Literal, optional) Format to return data in, options are "default", "pandas", "polars"
186
+ stream : (Literal, optional) "default" for metrics, "system" for machine metrics
187
+ Returns:
188
+ pandas.DataFrame: If format="pandas", returns a `pandas.DataFrame` of history metrics.
189
+ polars.DataFrame: If format="polars", returns a `polars.DataFrame` of history metrics.
190
+ list of dicts: If format="default", returns a list of dicts containing history metrics with a run_id key.
191
+ """
192
+ if format not in ("default", "pandas", "polars"):
193
+ raise ValueError(
194
+ f"Invalid format: {format}. Must be one of 'default', 'pandas', 'polars'"
195
+ )
196
+
197
+ histories = []
198
+
199
+ if format == "default":
200
+ for run in self:
201
+ history_data = run.history(
202
+ samples=samples,
203
+ keys=keys,
204
+ x_axis=x_axis,
205
+ pandas=False,
206
+ stream=stream,
207
+ )
208
+ if not history_data:
209
+ continue
210
+ for entry in history_data:
211
+ entry["run_id"] = run.id
212
+ histories.extend(history_data)
213
+
214
+ return histories
215
+
216
+ if format == "pandas":
217
+ pd = util.get_module(
218
+ "pandas", required="Exporting pandas DataFrame requires pandas"
219
+ )
220
+ for run in self:
221
+ history_data = run.history(
222
+ samples=samples,
223
+ keys=keys,
224
+ x_axis=x_axis,
225
+ pandas=False,
226
+ stream=stream,
227
+ )
228
+ if not history_data:
229
+ continue
230
+ df = pd.DataFrame.from_records(history_data)
231
+ df["run_id"] = run.id
232
+ histories.append(df)
233
+ if not histories:
234
+ return pd.DataFrame()
235
+ combined_df = pd.concat(histories)
236
+ combined_df.sort_values("run_id", inplace=True)
237
+ combined_df.reset_index(drop=True, inplace=True)
238
+ # sort columns for consistency
239
+ combined_df = combined_df[(sorted(combined_df.columns))]
240
+
241
+ return combined_df
242
+
243
+ if format == "polars":
244
+ pl = util.get_module(
245
+ "polars", required="Exporting polars DataFrame requires polars"
246
+ )
247
+ for run in self:
248
+ history_data = run.history(
249
+ samples=samples,
250
+ keys=keys,
251
+ x_axis=x_axis,
252
+ pandas=False,
253
+ stream=stream,
254
+ )
255
+ if not history_data:
256
+ continue
257
+ df = pl.from_records(history_data)
258
+ df = df.with_columns(pl.lit(run.id).alias("run_id"))
259
+ histories.append(df)
260
+ if not histories:
261
+ return pl.DataFrame()
262
+ combined_df = pl.concat(histories, how="align")
263
+ # sort columns for consistency
264
+ combined_df = combined_df.select(sorted(combined_df.columns)).sort("run_id")
265
+
266
+ return combined_df
267
+
165
268
  def __repr__(self):
166
269
  return f"<Runs {self.entity}/{self.project}>"
167
270
 
@@ -310,16 +413,15 @@ class Run(Attrs):
310
413
  def load(self, force=False):
311
414
  query = gql(
312
415
  """
313
- query Run($project: String!, $entity: String!, $name: String!) {
314
- project(name: $project, entityName: $entity) {
315
- run(name: $name) {
416
+ query Run($project: String!, $entity: String!, $name: String!) {{
417
+ project(name: $project, entityName: $entity) {{
418
+ run(name: $name) {{
316
419
  ...RunFragment
317
- }
318
- }
319
- }
320
- %s
321
- """
322
- % RUN_FRAGMENT
420
+ }}
421
+ }}
422
+ }}
423
+ {}
424
+ """.format(RUN_FRAGMENT)
323
425
  )
324
426
  if force or not self._attrs:
325
427
  response = self._exec(query)
@@ -328,7 +430,7 @@ class Run(Attrs):
328
430
  or response.get("project") is None
329
431
  or response["project"].get("run") is None
330
432
  ):
331
- raise ValueError("Could not find run %s" % self)
433
+ raise ValueError("Could not find run {}".format(self))
332
434
  self._attrs = response["project"]["run"]
333
435
  self._state = self._attrs["state"]
334
436
 
@@ -402,16 +504,15 @@ class Run(Attrs):
402
504
  """Persist changes to the run object to the wandb backend."""
403
505
  mutation = gql(
404
506
  """
405
- mutation UpsertBucket($id: String!, $description: String, $display_name: String, $notes: String, $tags: [String!], $config: JSONString!, $groupName: String) {
406
- upsertBucket(input: {id: $id, description: $description, displayName: $display_name, notes: $notes, tags: $tags, config: $config, groupName: $groupName}) {
407
- bucket {
507
+ mutation UpsertBucket($id: String!, $description: String, $display_name: String, $notes: String, $tags: [String!], $config: JSONString!, $groupName: String) {{
508
+ upsertBucket(input: {{id: $id, description: $description, displayName: $display_name, notes: $notes, tags: $tags, config: $config, groupName: $groupName}}) {{
509
+ bucket {{
408
510
  ...RunFragment
409
- }
410
- }
411
- }
412
- %s
413
- """
414
- % RUN_FRAGMENT
511
+ }}
512
+ }}
513
+ }}
514
+ {}
515
+ """.format(RUN_FRAGMENT)
415
516
  )
416
517
  _ = self._exec(
417
518
  mutation,
@@ -491,13 +592,12 @@ class Run(Attrs):
491
592
  node = "history" if stream == "default" else "events"
492
593
  query = gql(
493
594
  """
494
- query RunFullHistory($project: String!, $entity: String!, $name: String!, $samples: Int) {
495
- project(name: $project, entityName: $entity) {
496
- run(name: $name) { %s(samples: $samples) }
497
- }
498
- }
499
- """
500
- % node
595
+ query RunFullHistory($project: String!, $entity: String!, $name: String!, $samples: Int) {{
596
+ project(name: $project, entityName: $entity) {{
597
+ run(name: $name) {{ {}(samples: $samples) }}
598
+ }}
599
+ }}
600
+ """.format(node)
501
601
  )
502
602
 
503
603
  response = self._exec(query, samples=samples)
@@ -587,9 +687,9 @@ class Run(Attrs):
587
687
  else:
588
688
  lines = self._full_history(samples=samples, stream=stream)
589
689
  if pandas:
590
- pandas = util.get_module("pandas")
591
- if pandas:
592
- lines = pandas.DataFrame.from_records(lines)
690
+ pd = util.get_module("pandas")
691
+ if pd:
692
+ lines = pd.DataFrame.from_records(lines)
593
693
  else:
594
694
  print("Unable to load pandas, call history with pandas=False")
595
695
  return lines
@@ -607,10 +707,11 @@ class Run(Attrs):
607
707
  losses = [row["Loss"] for row in history]
608
708
  ```
609
709
 
610
-
611
710
  Arguments:
612
711
  keys ([str], optional): only fetch these keys, and only fetch rows that have all of keys defined.
613
- page_size (int, optional): size of pages to fetch from the api
712
+ page_size (int, optional): size of pages to fetch from the api.
713
+ min_step (int, optional): the minimum number of pages to scan at a time.
714
+ max_step (int, optional): the maximum number of pages to scan at a time.
614
715
 
615
716
  Returns:
616
717
  An iterable collection over history records (dict).
@@ -707,27 +808,24 @@ class Run(Attrs):
707
808
  )
708
809
  api.set_current_run_id(self.id)
709
810
 
710
- if isinstance(artifact, wandb.Artifact) and not artifact.is_draft():
711
- if (
712
- self.entity != artifact.source_entity
713
- or self.project != artifact.source_project
714
- ):
715
- raise ValueError("A run can't log an artifact to a different project.")
716
- artifact_collection_name = artifact.source_name.split(":")[0]
717
- api.create_artifact(
718
- artifact.type,
719
- artifact_collection_name,
720
- artifact.digest,
721
- aliases=aliases,
722
- )
723
- return artifact
724
- elif isinstance(artifact, wandb.Artifact) and artifact.is_draft():
811
+ if not isinstance(artifact, wandb.Artifact):
812
+ raise ValueError("You must pass a wandb.Api().artifact() to use_artifact")
813
+ if artifact.is_draft():
725
814
  raise ValueError(
726
815
  "Only existing artifacts are accepted by this api. "
727
816
  "Manually create one with `wandb artifact put`"
728
817
  )
729
- else:
730
- raise ValueError("You must pass a wandb.Api().artifact() to use_artifact")
818
+ if (
819
+ self.entity != artifact.source_entity
820
+ or self.project != artifact.source_project
821
+ ):
822
+ raise ValueError("A run can't log an artifact to a different project.")
823
+
824
+ artifact_collection_name = artifact.source_name.split(":")[0]
825
+ api.create_artifact(
826
+ artifact.type, artifact_collection_name, artifact.digest, aliases=aliases
827
+ )
828
+ return artifact
731
829
 
732
830
  @property
733
831
  def summary(self):
@@ -107,7 +107,7 @@ class Sweep(Attrs):
107
107
  if force or not self._attrs:
108
108
  sweep = self.get(self.client, self.entity, self.project, self.id)
109
109
  if sweep is None:
110
- raise ValueError("Could not find sweep %s" % self)
110
+ raise ValueError("Could not find sweep {}".format(self))
111
111
  self._attrs = sweep._attrs
112
112
  self.runs = sweep.runs
113
113
 
@@ -133,7 +133,7 @@ class Sweep(Attrs):
133
133
  "No order specified and couldn't find metric in sweep config, returning most recent run"
134
134
  )
135
135
  else:
136
- wandb.termlog("Sorting runs by %s" % order)
136
+ wandb.termlog("Sorting runs by {}".format(order))
137
137
  filters = {"$and": [{"sweep": self.id}]}
138
138
  try:
139
139
  return public.Runs(
@@ -1,7 +1 @@
1
- # flake8: noqa
2
- import os
3
-
4
- if os.getenv("WANDB_REPORT_API_ENABLE_V2"):
5
- from wandb.apis.reports.v2 import *
6
- else:
7
- from wandb.apis.reports.v1 import *
1
+ from .v2 import * # noqa: F403
@@ -1,30 +1,8 @@
1
- import os
2
- from inspect import cleandoc
3
-
4
1
  import wandb
5
2
 
6
- from . import blocks, helpers, panels, templates
7
- from .blocks import * # noqa: F403
8
- from .helpers import LineKey, PCColumn
9
- from .panels import * # noqa: F403
10
- from .report import Report
11
- from .runset import Runset
12
- from .templates import * # noqa: F403
13
- from .util import InlineCode, InlineLaTeX, Link
14
-
15
-
16
- def show_welcome_message():
17
- if os.getenv("WANDB_REPORT_API_DISABLE_MESSAGE"):
18
- return
19
-
20
- wandb.termwarn(
21
- cleandoc(
22
- """
23
- The v1 API is deprecated and will be removed in a future release. Please move to v2 by setting the env var WANDB_REPORT_API_ENABLE_V2=True. This will be on by default in a future release.
24
- You can disable this message by setting the env var WANDB_REPORT_API_DISABLE_MESSAGE=True
25
- """
26
- )
3
+ try:
4
+ from wandb_workspaces.reports.v1 import * # noqa: F403
5
+ except ImportError:
6
+ wandb.termerror(
7
+ "Failed to import wandb_workspaces. To edit reports programatically, please install it using `pip install wandb[workspaces]`."
27
8
  )
28
-
29
-
30
- show_welcome_message()
@@ -1,20 +1,8 @@
1
- import os
2
- from inspect import cleandoc
1
+ import wandb
3
2
 
4
- from .... import termlog
5
- from . import blocks, panels
6
- from .blocks import * # noqa
7
- from .interface import (
8
- GradientPoint,
9
- InlineCode,
10
- InlineLatex,
11
- Layout,
12
- Link,
13
- ParallelCoordinatesPlotColumn,
14
- Report,
15
- Runset,
16
- RunsetGroup,
17
- RunsetGroupKey,
18
- )
19
- from .metrics import * # noqa
20
- from .panels import * # noqa
3
+ try:
4
+ from wandb_workspaces.reports.v2 import * # noqa: F403
5
+ except ImportError:
6
+ wandb.termerror(
7
+ "Failed to import wandb_workspaces. To edit reports programatically, please install it using `pip install wandb[workspaces]`."
8
+ )
@@ -0,0 +1,8 @@
1
+ import wandb
2
+
3
+ try:
4
+ from wandb_workspaces.workspaces import * # noqa: F403
5
+ except ImportError:
6
+ wandb.termerror(
7
+ "Failed to import wandb_workspaces. To edit workspaces programatically, please install it using `pip install wandb[workspaces]`."
8
+ )
wandb/beta/workflows.py CHANGED
@@ -183,7 +183,7 @@ def log_model(
183
183
  return model
184
184
 
185
185
 
186
- def use_model(aliased_path: str) -> "_SavedModel":
186
+ def use_model(aliased_path: str, unsafe: bool = False) -> "_SavedModel":
187
187
  """Fetch a saved model from an alias.
188
188
 
189
189
  Under the hood, we use the alias to fetch the model artifact containing the
@@ -193,17 +193,22 @@ def use_model(aliased_path: str) -> "_SavedModel":
193
193
  Args:
194
194
  aliased_path: `str` - the following forms are valid: "name:version",
195
195
  "name:alias". May be prefixed with "entity/project".
196
+ unsafe: `bool` - must be True to indicate the user understands the risks
197
+ associated with loading external models.
196
198
 
197
199
  Returns:
198
200
  _SavedModel instance
199
201
 
200
202
  Example:
201
203
  ```python
202
- # Assuming you have previously logged a model with the name "my-simple-model":
203
- sm = use_model("my-simple-model:latest")
204
+ # Assuming the model with the name "my-simple-model" is trusted:
205
+ sm = use_model("my-simple-model:latest", unsafe=True)
204
206
  model = sm.model_obj()
205
207
  ```
206
208
  """
209
+ if not unsafe:
210
+ raise ValueError("The 'unsafe' parameter must be set to True to load a model.")
211
+
207
212
  if ":" not in aliased_path:
208
213
  raise ValueError(
209
214
  "aliased_path must be of the form 'name:alias' or 'name:version'."
wandb/bin/wandb-core CHANGED
Binary file