wandb 0.18.0rc1__py3-none-win_amd64.whl → 0.18.2__py3-none-win_amd64.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. wandb/__init__.py +4 -4
  2. wandb/__init__.pyi +67 -12
  3. wandb/apis/internal.py +3 -0
  4. wandb/apis/public/api.py +128 -2
  5. wandb/apis/public/artifacts.py +11 -7
  6. wandb/apis/public/jobs.py +8 -0
  7. wandb/apis/public/runs.py +18 -5
  8. wandb/bin/wandb-core +0 -0
  9. wandb/cli/cli.py +0 -5
  10. wandb/data_types.py +9 -2019
  11. wandb/env.py +0 -5
  12. wandb/errors/__init__.py +11 -40
  13. wandb/errors/errors.py +37 -0
  14. wandb/errors/warnings.py +2 -0
  15. wandb/{sklearn → integration/sklearn}/calculate/calibration_curves.py +7 -7
  16. wandb/{sklearn → integration/sklearn}/calculate/class_proportions.py +1 -1
  17. wandb/{sklearn → integration/sklearn}/calculate/confusion_matrix.py +3 -2
  18. wandb/{sklearn → integration/sklearn}/calculate/elbow_curve.py +6 -6
  19. wandb/{sklearn → integration/sklearn}/calculate/learning_curve.py +2 -2
  20. wandb/{sklearn → integration/sklearn}/calculate/outlier_candidates.py +2 -2
  21. wandb/{sklearn → integration/sklearn}/calculate/residuals.py +8 -8
  22. wandb/{sklearn → integration/sklearn}/calculate/silhouette.py +2 -2
  23. wandb/{sklearn → integration/sklearn}/calculate/summary_metrics.py +2 -2
  24. wandb/{sklearn → integration/sklearn}/plot/classifier.py +5 -5
  25. wandb/{sklearn → integration/sklearn}/plot/clusterer.py +10 -6
  26. wandb/{sklearn → integration/sklearn}/plot/regressor.py +5 -5
  27. wandb/{sklearn → integration/sklearn}/plot/shared.py +3 -3
  28. wandb/{sklearn → integration/sklearn}/utils.py +8 -8
  29. wandb/integration/tensorboard/log.py +1 -1
  30. wandb/{wandb_torch.py → integration/torch/wandb_torch.py} +36 -32
  31. wandb/old/core.py +2 -80
  32. wandb/plot/bar.py +7 -4
  33. wandb/plot/confusion_matrix.py +5 -4
  34. wandb/plot/histogram.py +7 -4
  35. wandb/plot/line.py +7 -4
  36. wandb/proto/v3/wandb_base_pb2.py +2 -1
  37. wandb/proto/v3/wandb_internal_pb2.py +2 -1
  38. wandb/proto/v3/wandb_server_pb2.py +2 -1
  39. wandb/proto/v3/wandb_settings_pb2.py +3 -2
  40. wandb/proto/v3/wandb_telemetry_pb2.py +2 -1
  41. wandb/proto/v4/wandb_base_pb2.py +2 -1
  42. wandb/proto/v4/wandb_internal_pb2.py +2 -1
  43. wandb/proto/v4/wandb_server_pb2.py +2 -1
  44. wandb/proto/v4/wandb_settings_pb2.py +3 -2
  45. wandb/proto/v4/wandb_telemetry_pb2.py +2 -1
  46. wandb/proto/v5/wandb_base_pb2.py +3 -2
  47. wandb/proto/v5/wandb_internal_pb2.py +3 -2
  48. wandb/proto/v5/wandb_server_pb2.py +3 -2
  49. wandb/proto/v5/wandb_settings_pb2.py +4 -3
  50. wandb/proto/v5/wandb_telemetry_pb2.py +3 -2
  51. wandb/sdk/artifacts/_validators.py +48 -3
  52. wandb/sdk/artifacts/artifact.py +157 -183
  53. wandb/sdk/artifacts/artifact_file_cache.py +13 -11
  54. wandb/sdk/artifacts/artifact_instance_cache.py +4 -2
  55. wandb/sdk/artifacts/artifact_manifest.py +13 -11
  56. wandb/sdk/artifacts/artifact_manifest_entry.py +24 -22
  57. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +9 -7
  58. wandb/sdk/artifacts/artifact_saver.py +27 -25
  59. wandb/sdk/artifacts/exceptions.py +26 -25
  60. wandb/sdk/artifacts/storage_handler.py +11 -9
  61. wandb/sdk/artifacts/storage_handlers/azure_handler.py +16 -14
  62. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +15 -13
  63. wandb/sdk/artifacts/storage_handlers/http_handler.py +15 -14
  64. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +10 -8
  65. wandb/sdk/artifacts/storage_handlers/multi_handler.py +14 -12
  66. wandb/sdk/artifacts/storage_handlers/s3_handler.py +19 -19
  67. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +10 -8
  68. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +12 -10
  69. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +9 -7
  70. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +31 -29
  71. wandb/sdk/artifacts/storage_policy.py +20 -20
  72. wandb/sdk/backend/backend.py +8 -26
  73. wandb/sdk/data_types/audio.py +165 -0
  74. wandb/sdk/data_types/base_types/wb_value.py +1 -3
  75. wandb/sdk/data_types/bokeh.py +70 -0
  76. wandb/sdk/data_types/graph.py +405 -0
  77. wandb/sdk/data_types/image.py +156 -0
  78. wandb/sdk/data_types/table.py +1204 -0
  79. wandb/sdk/data_types/trace_tree.py +2 -2
  80. wandb/sdk/data_types/utils.py +49 -0
  81. wandb/sdk/data_types/video.py +2 -2
  82. wandb/sdk/interface/interface.py +0 -24
  83. wandb/sdk/interface/interface_shared.py +0 -12
  84. wandb/sdk/internal/handler.py +0 -10
  85. wandb/sdk/internal/internal_api.py +71 -0
  86. wandb/sdk/internal/sender.py +0 -43
  87. wandb/sdk/internal/tb_watcher.py +1 -1
  88. wandb/sdk/lib/_settings_toposort_generated.py +1 -0
  89. wandb/sdk/lib/hashutil.py +34 -12
  90. wandb/sdk/lib/service_connection.py +216 -0
  91. wandb/sdk/lib/service_token.py +94 -0
  92. wandb/sdk/lib/sock_client.py +7 -3
  93. wandb/sdk/service/server.py +2 -5
  94. wandb/sdk/service/service.py +2 -31
  95. wandb/sdk/service/streams.py +0 -7
  96. wandb/sdk/wandb_init.py +42 -25
  97. wandb/sdk/wandb_run.py +18 -159
  98. wandb/sdk/wandb_settings.py +2 -0
  99. wandb/sdk/wandb_setup.py +25 -16
  100. wandb/sdk/wandb_sync.py +9 -3
  101. wandb/sdk/wandb_watch.py +31 -15
  102. wandb/sklearn.py +35 -0
  103. wandb/util.py +14 -3
  104. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/METADATA +6 -5
  105. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/RECORD +114 -110
  106. wandb/sdk/internal/update.py +0 -113
  107. wandb/sdk/lib/console.py +0 -39
  108. wandb/sdk/service/service_base.py +0 -50
  109. wandb/sdk/service/service_sock.py +0 -70
  110. wandb/sdk/wandb_manager.py +0 -232
  111. /wandb/{sklearn → integration/sklearn}/__init__.py +0 -0
  112. /wandb/{sklearn → integration/sklearn}/calculate/__init__.py +0 -0
  113. /wandb/{sklearn → integration/sklearn}/calculate/decision_boundaries.py +0 -0
  114. /wandb/{sklearn → integration/sklearn}/calculate/feature_importances.py +0 -0
  115. /wandb/{sklearn → integration/sklearn}/plot/__init__.py +0 -0
  116. /wandb/{sdk/lib → plot}/viz.py +0 -0
  117. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/WHEEL +0 -0
  118. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/entry_points.txt +0 -0
  119. {wandb-0.18.0rc1.dist-info → wandb-0.18.2.dist-info}/licenses/LICENSE +0 -0
wandb/__init__.py CHANGED
@@ -8,7 +8,7 @@ For scripts and interactive notebooks, see https://github.com/wandb/examples.
8
8
 
9
9
  For reference documentation, see https://docs.wandb.com/ref/python.
10
10
  """
11
- __version__ = "0.18.0rc1"
11
+ __version__ = "0.18.2"
12
12
 
13
13
  from typing import Optional
14
14
 
@@ -51,7 +51,7 @@ _lazyloader = wandb.wandb_lib.lazyloader # type: ignore
51
51
  # Call import module hook to set up any needed require hooks
52
52
  wandb.sdk.wandb_require._import_module_hook()
53
53
 
54
- from wandb import wandb_torch
54
+ from wandb.integration.torch import wandb_torch
55
55
 
56
56
  # Move this (keras.__init__ expects it at top level)
57
57
  from wandb.sdk.data_types._private import _cleanup_media_tmp_dir
@@ -76,8 +76,7 @@ from wandb.data_types import JoinedTable
76
76
 
77
77
  from wandb.wandb_agent import agent
78
78
 
79
- from wandb.sdk.lib.viz import visualize
80
- from wandb import plot
79
+ from wandb.plot.viz import visualize
81
80
  from wandb.integration.sagemaker import sagemaker_auth
82
81
  from wandb.sdk.internal import profiler
83
82
 
@@ -242,4 +241,5 @@ __all__ = (
242
241
  "use_model",
243
242
  "link_model",
244
243
  "define_metric",
244
+ "watch",
245
245
  )
wandb/__init__.pyi CHANGED
@@ -9,6 +9,8 @@ For scripts and interactive notebooks, see https://github.com/wandb/examples.
9
9
  For reference documentation, see https://docs.wandb.com/ref/python.
10
10
  """
11
11
 
12
+ from __future__ import annotations
13
+
12
14
  __all__ = (
13
15
  "__version__",
14
16
  "init",
@@ -49,12 +51,23 @@ __all__ = (
49
51
  "Artifact",
50
52
  "Settings",
51
53
  "teardown",
54
+ "watch",
52
55
  )
53
56
 
54
57
  import os
55
- from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Union
58
+ from typing import (
59
+ TYPE_CHECKING,
60
+ Any,
61
+ Callable,
62
+ Dict,
63
+ List,
64
+ Literal,
65
+ Optional,
66
+ Sequence,
67
+ Union,
68
+ )
56
69
 
57
- from wandb.analytics import Sentry as _Sentry
70
+ from wandb.analytics import Sentry
58
71
  from wandb.apis import InternalApi, PublicApi
59
72
  from wandb.data_types import (
60
73
  Audio,
@@ -79,17 +92,20 @@ from wandb.sdk.wandb_run import Run
79
92
  from wandb.sdk.wandb_setup import _WandbSetup
80
93
  from wandb.wandb_controller import _WandbController
81
94
 
82
- __version__: str = "0.18.0rc1"
95
+ if TYPE_CHECKING:
96
+ import torch # type: ignore [import-not-found]
83
97
 
84
- run: Optional[Run] = None
85
- config = wandb_config.Config
86
- summary = wandb_summary.Summary
87
- Api = PublicApi
88
- api = InternalApi()
89
- _sentry = _Sentry()
98
+ __version__: str = "0.18.2"
90
99
 
91
- # record of patched libraries
92
- patched = {"tensorboard": [], "keras": [], "gym": []} # type: ignore
100
+ run: Run | None
101
+ config: wandb_config.Config
102
+ summary: wandb_summary.Summary
103
+ Api: PublicApi
104
+
105
+ # private attributes
106
+ _sentry: Sentry
107
+ api: InternalApi
108
+ patched: Dict[str, List[Callable]]
93
109
 
94
110
  def setup(
95
111
  settings: Optional[Settings] = None,
@@ -183,7 +199,7 @@ def init(
183
199
  allow_val_change: Optional[bool] = None,
184
200
  resume: Optional[Union[bool, str]] = None,
185
201
  force: Optional[bool] = None,
186
- tensorboard: Optional[bool] = None, # alias for sync_tensorboard
202
+ tensorboard: Optional[bool] = None,
187
203
  sync_tensorboard: Optional[bool] = None,
188
204
  monitor_gym: Optional[bool] = None,
189
205
  save_code: Optional[bool] = None,
@@ -1082,3 +1098,42 @@ def link_model(
1082
1098
  None
1083
1099
  """
1084
1100
  ...
1101
+
1102
+ def watch(
1103
+ models: torch.nn.Module | Sequence[torch.nn.Module],
1104
+ criterion: torch.F | None = None,
1105
+ log: Literal["gradients", "parameters", "all"] | None = "gradients",
1106
+ log_freq: int = 1000,
1107
+ idx: int | None = None,
1108
+ log_graph: bool = False,
1109
+ ) -> Graph:
1110
+ """Hooks into the given PyTorch model(s) to monitor gradients and the model's computational graph.
1111
+
1112
+ This function can track parameters, gradients, or both during training. It should be
1113
+ extended to support arbitrary machine learning models in the future.
1114
+
1115
+ Args:
1116
+ models (Union[torch.nn.Module, Sequence[torch.nn.Module]]):
1117
+ A single model or a sequence of models to be monitored.
1118
+ criterion (Optional[torch.F]):
1119
+ The loss function being optimized (optional).
1120
+ log (Optional[Literal["gradients", "parameters", "all"]]):
1121
+ Specifies whether to log "gradients", "parameters", or "all".
1122
+ Set to None to disable logging. (default="gradients")
1123
+ log_freq (int):
1124
+ Frequency (in batches) to log gradients and parameters. (default=1000)
1125
+ idx (Optional[int]):
1126
+ Index used when tracking multiple models with `wandb.watch`. (default=None)
1127
+ log_graph (bool):
1128
+ Whether to log the model's computational graph. (default=False)
1129
+
1130
+ Returns:
1131
+ wandb.Graph:
1132
+ The graph object, which will be populated after the first backward pass.
1133
+
1134
+ Raises:
1135
+ ValueError:
1136
+ If `wandb.init` has not been called or if any of the models are not instances
1137
+ of `torch.nn.Module`.
1138
+ """
1139
+ ...
wandb/apis/internal.py CHANGED
@@ -204,6 +204,9 @@ class Api:
204
204
  def create_run_queue(self, *args, **kwargs):
205
205
  return self.api.create_run_queue(*args, **kwargs)
206
206
 
207
+ def upsert_run_queue(self, *args, **kwargs):
208
+ return self.api.upsert_run_queue(*args, **kwargs)
209
+
207
210
  def update_launch_agent_status(self, *args, **kwargs):
208
211
  return self.api.update_launch_agent_status(*args, **kwargs)
209
212
 
wandb/apis/public/api.py CHANGED
@@ -421,6 +421,121 @@ class Api:
421
421
  _default_resource_config=config,
422
422
  )
423
423
 
424
+ def upsert_run_queue(
425
+ self,
426
+ name: str,
427
+ resource_config: dict,
428
+ resource_type: "public.RunQueueResourceType",
429
+ entity: Optional[str] = None,
430
+ template_variables: Optional[dict] = None,
431
+ external_links: Optional[dict] = None,
432
+ prioritization_mode: Optional["public.RunQueuePrioritizationMode"] = None,
433
+ ):
434
+ """Upsert a run queue (launch).
435
+
436
+ Arguments:
437
+ name: (str) Name of the queue to create
438
+ entity: (str) Optional name of the entity to create the queue. If None, will use the configured or default entity.
439
+ resource_config: (dict) Optional default resource configuration to be used for the queue. Use handlebars (eg. "{{var}}") to specify template variables.
440
+ resource_type: (str) Type of resource to be used for the queue. One of "local-container", "local-process", "kubernetes", "sagemaker", or "gcp-vertex".
441
+ template_variables: (dict) A dictionary of template variable schemas to be used with the config. Expected format of:
442
+ {
443
+ "var-name": {
444
+ "schema": {
445
+ "type": ("string", "number", or "integer"),
446
+ "default": (optional value),
447
+ "minimum": (optional minimum),
448
+ "maximum": (optional maximum),
449
+ "enum": [..."(options)"]
450
+ }
451
+ }
452
+ }
453
+ external_links: (dict) Optional dictionary of external links to be used with the queue. Expected format of:
454
+ {
455
+ "name": "url"
456
+ }
457
+ prioritization_mode: (str) Optional version of prioritization to use. Either "V0" or None
458
+
459
+ Returns:
460
+ The upserted `RunQueue`.
461
+
462
+ Raises:
463
+ ValueError if any of the parameters are invalid
464
+ wandb.Error on wandb API errors
465
+ """
466
+ if entity is None:
467
+ entity = self.settings["entity"] or self.default_entity
468
+ if entity is None:
469
+ raise ValueError(
470
+ "entity must be passed as a parameter, or set in settings"
471
+ )
472
+
473
+ if len(name) == 0:
474
+ raise ValueError("name must be non-empty")
475
+ if len(name) > 64:
476
+ raise ValueError("name must be less than 64 characters")
477
+
478
+ prioritization_mode = prioritization_mode or "DISABLED"
479
+ prioritization_mode = prioritization_mode.upper()
480
+ if prioritization_mode not in ["V0", "DISABLED"]:
481
+ raise ValueError(
482
+ "prioritization_mode must be 'V0' or 'DISABLED' if present"
483
+ )
484
+
485
+ if resource_type not in [
486
+ "local-container",
487
+ "local-process",
488
+ "kubernetes",
489
+ "sagemaker",
490
+ "gcp-vertex",
491
+ ]:
492
+ raise ValueError(
493
+ "resource_type must be one of 'local-container', 'local-process', 'kubernetes', 'sagemaker', or 'gcp-vertex'"
494
+ )
495
+
496
+ self.create_project(LAUNCH_DEFAULT_PROJECT, entity)
497
+ api = InternalApi(
498
+ default_settings={
499
+ "entity": entity,
500
+ "project": self.project(LAUNCH_DEFAULT_PROJECT),
501
+ },
502
+ retry_timedelta=RETRY_TIMEDELTA,
503
+ )
504
+ # User provides external_links as a dict with name: url format
505
+ # but backend stores it as a list of dicts with url and label keys.
506
+ external_links = external_links or {}
507
+ external_links = {
508
+ "links": [
509
+ {
510
+ "label": key,
511
+ "url": value,
512
+ }
513
+ for key, value in external_links.items()
514
+ ]
515
+ }
516
+ upsert_run_queue_result = api.upsert_run_queue(
517
+ name,
518
+ entity,
519
+ resource_type,
520
+ {"resource_args": {resource_type: resource_config}},
521
+ template_variables=template_variables,
522
+ external_links=external_links,
523
+ prioritization_mode=prioritization_mode,
524
+ )
525
+ if not upsert_run_queue_result["success"]:
526
+ raise wandb.Error("failed to create run queue")
527
+ schema_errors = (
528
+ upsert_run_queue_result.get("configSchemaValidationErrors") or []
529
+ )
530
+ for error in schema_errors:
531
+ wandb.termwarn(f"resource config validation: {error}")
532
+
533
+ return public.RunQueue(
534
+ client=self.client,
535
+ name=name,
536
+ entity=entity,
537
+ )
538
+
424
539
  def create_user(self, email, admin=False):
425
540
  """Create a new user.
426
541
 
@@ -996,7 +1111,11 @@ class Api:
996
1111
 
997
1112
  @normalize_exceptions
998
1113
  def artifacts(
999
- self, type_name: str, name: str, per_page: Optional[int] = 50
1114
+ self,
1115
+ type_name: str,
1116
+ name: str,
1117
+ per_page: Optional[int] = 50,
1118
+ tags: Optional[List[str]] = None,
1000
1119
  ) -> "public.Artifacts":
1001
1120
  """Return an `Artifacts` collection from the given parameters.
1002
1121
 
@@ -1005,13 +1124,20 @@ class Api:
1005
1124
  name: (str) An artifact collection name. May be prefixed with entity/project.
1006
1125
  per_page: (int, optional) Sets the page size for query pagination. None will use the default size.
1007
1126
  Usually there is no reason to change this.
1127
+ tags: (list[str], optional) Only return artifacts with all of these tags.
1008
1128
 
1009
1129
  Returns:
1010
1130
  An iterable `Artifacts` object.
1011
1131
  """
1012
1132
  entity, project, collection_name = self._parse_artifact_path(name)
1013
1133
  return public.Artifacts(
1014
- self.client, entity, project, collection_name, type_name, per_page=per_page
1134
+ self.client,
1135
+ entity,
1136
+ project,
1137
+ collection_name,
1138
+ type_name,
1139
+ per_page=per_page,
1140
+ tags=tags,
1015
1141
  )
1016
1142
 
1017
1143
  @normalize_exceptions
@@ -3,7 +3,7 @@
3
3
  import json
4
4
  import re
5
5
  from copy import copy
6
- from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Sequence
6
+ from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Sequence, Union
7
7
 
8
8
  from wandb_gql import Client, gql
9
9
 
@@ -757,12 +757,14 @@ class Artifacts(Paginator):
757
757
  filters: Optional[Mapping[str, Any]] = None,
758
758
  order: Optional[str] = None,
759
759
  per_page: int = 50,
760
+ tags: Optional[Union[str, List[str]]] = None,
760
761
  ):
761
762
  self.entity = entity
762
763
  self.collection_name = collection_name
763
764
  self.type = type
764
765
  self.project = project
765
766
  self.filters = {"state": "COMMITTED"} if filters is None else filters
767
+ self.tags = [tags] if isinstance(tags, str) else tags
766
768
  self.order = order
767
769
  variables = {
768
770
  "project": self.project,
@@ -835,9 +837,9 @@ class Artifacts(Paginator):
835
837
  return None
836
838
 
837
839
  def convert_objects(self):
838
- if self.last_response["project"]["artifactType"]["artifactCollection"] is None:
839
- return []
840
- return [
840
+ collection = self.last_response["project"]["artifactType"]["artifactCollection"]
841
+ artifact_edges = collection.get("artifacts", {}).get("edges", [])
842
+ artifacts = (
841
843
  wandb.Artifact._from_attrs(
842
844
  self.entity,
843
845
  self.project,
@@ -845,9 +847,11 @@ class Artifacts(Paginator):
845
847
  a["node"],
846
848
  self.client,
847
849
  )
848
- for a in self.last_response["project"]["artifactType"][
849
- "artifactCollection"
850
- ]["artifacts"]["edges"]
850
+ for a in artifact_edges
851
+ )
852
+ required_tags = set(self.tags or [])
853
+ return [
854
+ artifact for artifact in artifacts if required_tags.issubset(artifact.tags)
851
855
  ]
852
856
 
853
857
 
wandb/apis/public/jobs.py CHANGED
@@ -473,6 +473,12 @@ class RunQueue:
473
473
  self._get_metadata()
474
474
  return self._access
475
475
 
476
+ @property
477
+ def external_links(self) -> Dict[str, str]:
478
+ if self._external_links is None:
479
+ self._get_metadata()
480
+ return self._external_links
481
+
476
482
  @property
477
483
  def type(self) -> RunQueueResourceType:
478
484
  if self._type is None:
@@ -549,6 +555,7 @@ class RunQueue:
549
555
  access
550
556
  defaultResourceConfigID
551
557
  prioritizationMode
558
+ externalLinks
552
559
  }
553
560
  }
554
561
  }
@@ -565,6 +572,7 @@ class RunQueue:
565
572
  self._default_resource_config_id = res["project"]["runQueue"][
566
573
  "defaultResourceConfigID"
567
574
  ]
575
+ self._external_links = res["project"]["runQueue"]["externalLinks"]
568
576
  if self._default_resource_config_id is None:
569
577
  self._default_resource_config = {}
570
578
  self._prioritization_mode = res["project"]["runQueue"]["prioritizationMode"]
wandb/apis/public/runs.py CHANGED
@@ -6,7 +6,7 @@ import sys
6
6
  import tempfile
7
7
  import time
8
8
  import urllib
9
- from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional
9
+ from typing import TYPE_CHECKING, Any, Collection, Dict, List, Mapping, Optional
10
10
 
11
11
  if sys.version_info >= (3, 8):
12
12
  from typing import Literal
@@ -562,6 +562,8 @@ class Run(Attrs):
562
562
  @property
563
563
  def json_config(self):
564
564
  config = {}
565
+ if "_wandb" in self.rawconfig:
566
+ config["_wandb"] = {"value": self.rawconfig["_wandb"], "desc": None}
565
567
  for k, v in self.config.items():
566
568
  config[k] = {"value": v, "desc": None}
567
569
  return json.dumps(config)
@@ -792,13 +794,20 @@ class Run(Attrs):
792
794
  raise ValueError("You must pass a wandb.Api().artifact() to use_artifact")
793
795
 
794
796
  @normalize_exceptions
795
- def log_artifact(self, artifact, aliases=None):
797
+ def log_artifact(
798
+ self,
799
+ artifact: "wandb.Artifact",
800
+ aliases: Optional[Collection[str]] = None,
801
+ tags: Optional[Collection[str]] = None,
802
+ ):
796
803
  """Declare an artifact as output of a run.
797
804
 
798
805
  Arguments:
799
806
  artifact (`Artifact`): An artifact returned from
800
- `wandb.Api().artifact(name)`
801
- aliases (list, optional): Aliases to apply to this artifact
807
+ `wandb.Api().artifact(name)`.
808
+ aliases (list, optional): Aliases to apply to this artifact.
809
+ tags: (list, optional) Tags to apply to this artifact, if any.
810
+
802
811
  Returns:
803
812
  A `Artifact` object.
804
813
  """
@@ -823,7 +832,11 @@ class Run(Attrs):
823
832
 
824
833
  artifact_collection_name = artifact.source_name.split(":")[0]
825
834
  api.create_artifact(
826
- artifact.type, artifact_collection_name, artifact.digest, aliases=aliases
835
+ artifact.type,
836
+ artifact_collection_name,
837
+ artifact.digest,
838
+ aliases=aliases,
839
+ tags=tags,
827
840
  )
828
841
  return artifact
829
842
 
wandb/bin/wandb-core CHANGED
Binary file
wandb/cli/cli.py CHANGED
@@ -275,7 +275,6 @@ def login(key, host, cloud, relogin, anonymously, verify, no_offline=False):
275
275
  @click.option("--address", default=None, help="The address to bind service.")
276
276
  @click.option("--pid", default=None, type=int, help="The parent process id to monitor.")
277
277
  @click.option("--debug", is_flag=True, help="log debug info")
278
- @click.option("--serve-sock", is_flag=True, help="use socket mode")
279
278
  @display_error
280
279
  def service(
281
280
  sock_port=None,
@@ -283,7 +282,6 @@ def service(
283
282
  address=None,
284
283
  pid=None,
285
284
  debug=False,
286
- serve_sock=False,
287
285
  ):
288
286
  from wandb.sdk.service.server import WandbServer
289
287
 
@@ -293,7 +291,6 @@ def service(
293
291
  address=address,
294
292
  pid=pid,
295
293
  debug=debug,
296
- serve_sock=serve_sock,
297
294
  )
298
295
  server.serve()
299
296
 
@@ -2928,7 +2925,6 @@ def disabled(service):
2928
2925
  try:
2929
2926
  api.set_setting("mode", "disabled", persist=True)
2930
2927
  click.echo("W&B disabled.")
2931
- os.environ[wandb.env._DISABLE_SERVICE] = str(service)
2932
2928
  except configparser.Error:
2933
2929
  click.echo(
2934
2930
  "Unable to write config, copy and paste the following in your terminal to turn off W&B:\nexport WANDB_MODE=disabled"
@@ -2948,7 +2944,6 @@ def enabled(service):
2948
2944
  try:
2949
2945
  api.set_setting("mode", "online", persist=True)
2950
2946
  click.echo("W&B enabled.")
2951
- os.environ[wandb.env._DISABLE_SERVICE] = str(not service)
2952
2947
  except configparser.Error:
2953
2948
  click.echo(
2954
2949
  "Unable to write config, copy and paste the following in your terminal to turn on W&B:\nexport WANDB_MODE=online"