wandb 0.19.8__py3-none-any.whl → 0.19.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. wandb/__init__.py +5 -1
  2. wandb/__init__.pyi +15 -8
  3. wandb/_pydantic/__init__.py +30 -0
  4. wandb/_pydantic/base.py +148 -0
  5. wandb/_pydantic/utils.py +66 -0
  6. wandb/_pydantic/v1_compat.py +284 -0
  7. wandb/apis/paginator.py +82 -38
  8. wandb/apis/public/__init__.py +2 -2
  9. wandb/apis/public/api.py +111 -53
  10. wandb/apis/public/artifacts.py +387 -639
  11. wandb/apis/public/automations.py +69 -0
  12. wandb/apis/public/files.py +2 -2
  13. wandb/apis/public/integrations.py +168 -0
  14. wandb/apis/public/projects.py +32 -2
  15. wandb/apis/public/reports.py +2 -2
  16. wandb/apis/public/runs.py +19 -11
  17. wandb/apis/public/utils.py +107 -1
  18. wandb/automations/__init__.py +81 -0
  19. wandb/automations/_filters/__init__.py +40 -0
  20. wandb/automations/_filters/expressions.py +179 -0
  21. wandb/automations/_filters/operators.py +267 -0
  22. wandb/automations/_filters/run_metrics.py +183 -0
  23. wandb/automations/_generated/__init__.py +184 -0
  24. wandb/automations/_generated/create_filter_trigger.py +21 -0
  25. wandb/automations/_generated/create_generic_webhook_integration.py +43 -0
  26. wandb/automations/_generated/delete_trigger.py +19 -0
  27. wandb/automations/_generated/enums.py +33 -0
  28. wandb/automations/_generated/fragments.py +343 -0
  29. wandb/automations/_generated/generic_webhook_integrations_by_entity.py +22 -0
  30. wandb/automations/_generated/get_triggers.py +24 -0
  31. wandb/automations/_generated/get_triggers_by_entity.py +24 -0
  32. wandb/automations/_generated/input_types.py +104 -0
  33. wandb/automations/_generated/integrations_by_entity.py +22 -0
  34. wandb/automations/_generated/operations.py +710 -0
  35. wandb/automations/_generated/slack_integrations_by_entity.py +22 -0
  36. wandb/automations/_generated/update_filter_trigger.py +21 -0
  37. wandb/automations/_utils.py +123 -0
  38. wandb/automations/_validators.py +73 -0
  39. wandb/automations/actions.py +205 -0
  40. wandb/automations/automations.py +109 -0
  41. wandb/automations/events.py +235 -0
  42. wandb/automations/integrations.py +26 -0
  43. wandb/automations/scopes.py +76 -0
  44. wandb/beta/workflows.py +9 -10
  45. wandb/bin/gpu_stats +0 -0
  46. wandb/cli/cli.py +3 -3
  47. wandb/integration/keras/keras.py +2 -1
  48. wandb/integration/langchain/wandb_tracer.py +2 -1
  49. wandb/integration/metaflow/metaflow.py +19 -17
  50. wandb/integration/sacred/__init__.py +1 -1
  51. wandb/jupyter.py +155 -133
  52. wandb/old/summary.py +0 -2
  53. wandb/proto/v3/wandb_internal_pb2.py +297 -292
  54. wandb/proto/v3/wandb_settings_pb2.py +2 -2
  55. wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
  56. wandb/proto/v4/wandb_internal_pb2.py +292 -292
  57. wandb/proto/v4/wandb_settings_pb2.py +2 -2
  58. wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
  59. wandb/proto/v5/wandb_internal_pb2.py +292 -292
  60. wandb/proto/v5/wandb_settings_pb2.py +2 -2
  61. wandb/proto/v5/wandb_telemetry_pb2.py +10 -10
  62. wandb/proto/v6/wandb_base_pb2.py +41 -0
  63. wandb/proto/v6/wandb_internal_pb2.py +393 -0
  64. wandb/proto/v6/wandb_server_pb2.py +78 -0
  65. wandb/proto/v6/wandb_settings_pb2.py +58 -0
  66. wandb/proto/v6/wandb_telemetry_pb2.py +52 -0
  67. wandb/proto/wandb_base_pb2.py +2 -0
  68. wandb/proto/wandb_deprecated.py +10 -0
  69. wandb/proto/wandb_internal_pb2.py +3 -1
  70. wandb/proto/wandb_server_pb2.py +2 -0
  71. wandb/proto/wandb_settings_pb2.py +2 -0
  72. wandb/proto/wandb_telemetry_pb2.py +2 -0
  73. wandb/sdk/artifacts/_generated/__init__.py +248 -0
  74. wandb/sdk/artifacts/_generated/artifact_collection_membership_files.py +43 -0
  75. wandb/sdk/artifacts/_generated/artifact_version_files.py +36 -0
  76. wandb/sdk/artifacts/_generated/create_artifact_collection_tag_assignments.py +36 -0
  77. wandb/sdk/artifacts/_generated/delete_artifact_collection_tag_assignments.py +25 -0
  78. wandb/sdk/artifacts/_generated/delete_artifact_portfolio.py +35 -0
  79. wandb/sdk/artifacts/_generated/delete_artifact_sequence.py +35 -0
  80. wandb/sdk/artifacts/_generated/enums.py +17 -0
  81. wandb/sdk/artifacts/_generated/fragments.py +186 -0
  82. wandb/sdk/artifacts/_generated/input_types.py +16 -0
  83. wandb/sdk/artifacts/_generated/move_artifact_collection.py +35 -0
  84. wandb/sdk/artifacts/_generated/operations.py +510 -0
  85. wandb/sdk/artifacts/_generated/project_artifact_collection.py +101 -0
  86. wandb/sdk/artifacts/_generated/project_artifact_collections.py +33 -0
  87. wandb/sdk/artifacts/_generated/project_artifact_type.py +24 -0
  88. wandb/sdk/artifacts/_generated/project_artifact_types.py +24 -0
  89. wandb/sdk/artifacts/_generated/project_artifacts.py +42 -0
  90. wandb/sdk/artifacts/_generated/run_input_artifacts.py +51 -0
  91. wandb/sdk/artifacts/_generated/run_output_artifacts.py +51 -0
  92. wandb/sdk/artifacts/_generated/update_artifact_portfolio.py +35 -0
  93. wandb/sdk/artifacts/_generated/update_artifact_sequence.py +35 -0
  94. wandb/sdk/artifacts/_graphql_fragments.py +56 -81
  95. wandb/sdk/artifacts/_validators.py +1 -0
  96. wandb/sdk/artifacts/artifact.py +110 -49
  97. wandb/sdk/artifacts/artifact_manifest_entry.py +2 -1
  98. wandb/sdk/artifacts/artifact_saver.py +16 -2
  99. wandb/sdk/artifacts/storage_handlers/azure_handler.py +1 -0
  100. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +23 -2
  101. wandb/sdk/data_types/audio.py +1 -3
  102. wandb/sdk/data_types/base_types/media.py +13 -7
  103. wandb/sdk/data_types/base_types/wb_value.py +34 -11
  104. wandb/sdk/data_types/html.py +36 -9
  105. wandb/sdk/data_types/image.py +56 -37
  106. wandb/sdk/data_types/molecule.py +1 -5
  107. wandb/sdk/data_types/object_3d.py +2 -1
  108. wandb/sdk/data_types/saved_model.py +7 -9
  109. wandb/sdk/data_types/table.py +5 -0
  110. wandb/sdk/data_types/trace_tree.py +2 -0
  111. wandb/sdk/data_types/utils.py +1 -1
  112. wandb/sdk/data_types/video.py +15 -30
  113. wandb/sdk/interface/interface.py +2 -0
  114. wandb/{apis/public → sdk/internal}/_generated/__init__.py +0 -6
  115. wandb/{apis/public → sdk/internal}/_generated/server_features_query.py +3 -3
  116. wandb/sdk/internal/internal_api.py +138 -47
  117. wandb/sdk/internal/profiler.py +6 -5
  118. wandb/sdk/internal/run.py +13 -6
  119. wandb/sdk/internal/sender.py +2 -0
  120. wandb/sdk/internal/sender_config.py +8 -11
  121. wandb/sdk/internal/settings_static.py +24 -2
  122. wandb/sdk/lib/apikey.py +40 -20
  123. wandb/sdk/lib/asyncio_compat.py +1 -1
  124. wandb/sdk/lib/deprecate.py +13 -22
  125. wandb/sdk/lib/disabled.py +2 -1
  126. wandb/sdk/lib/printer.py +37 -8
  127. wandb/sdk/lib/printer_asyncio.py +46 -0
  128. wandb/sdk/lib/redirect.py +10 -5
  129. wandb/sdk/lib/run_moment.py +4 -6
  130. wandb/sdk/lib/wb_logging.py +161 -0
  131. wandb/sdk/service/server_sock.py +19 -14
  132. wandb/sdk/service/service.py +9 -7
  133. wandb/sdk/service/streams.py +5 -0
  134. wandb/sdk/verify/verify.py +6 -3
  135. wandb/sdk/wandb_config.py +44 -43
  136. wandb/sdk/wandb_init.py +323 -141
  137. wandb/sdk/wandb_login.py +13 -4
  138. wandb/sdk/wandb_metadata.py +107 -91
  139. wandb/sdk/wandb_run.py +529 -325
  140. wandb/sdk/wandb_settings.py +422 -202
  141. wandb/sdk/wandb_setup.py +52 -1
  142. wandb/util.py +29 -29
  143. {wandb-0.19.8.dist-info → wandb-0.19.10.dist-info}/METADATA +7 -7
  144. {wandb-0.19.8.dist-info → wandb-0.19.10.dist-info}/RECORD +150 -93
  145. wandb/_globals.py +0 -19
  146. wandb/apis/public/_generated/base.py +0 -128
  147. wandb/apis/public/_generated/typing_compat.py +0 -14
  148. /wandb/{apis/public → sdk/internal}/_generated/enums.py +0 -0
  149. /wandb/{apis/public → sdk/internal}/_generated/input_types.py +0 -0
  150. /wandb/{apis/public → sdk/internal}/_generated/operations.py +0 -0
  151. {wandb-0.19.8.dist-info → wandb-0.19.10.dist-info}/WHEEL +0 -0
  152. {wandb-0.19.8.dist-info → wandb-0.19.10.dist-info}/entry_points.txt +0 -0
  153. {wandb-0.19.8.dist-info → wandb-0.19.10.dist-info}/licenses/LICENSE +0 -0
wandb/sdk/wandb_setup.py CHANGED
@@ -21,12 +21,13 @@ from typing import TYPE_CHECKING, Any, Union
21
21
 
22
22
  import wandb
23
23
  import wandb.integration.sagemaker as sagemaker
24
- from wandb.sdk.lib import import_hooks
24
+ from wandb.sdk.lib import import_hooks, wb_logging
25
25
 
26
26
  from . import wandb_settings
27
27
  from .lib import config_util, server
28
28
 
29
29
  if TYPE_CHECKING:
30
+ from wandb.sdk import wandb_run
30
31
  from wandb.sdk.lib.service_connection import ServiceConnection
31
32
  from wandb.sdk.wandb_settings import Settings
32
33
 
@@ -83,6 +84,8 @@ class _WandbSetup:
83
84
  ) -> None:
84
85
  self._connection: ServiceConnection | None = None
85
86
 
87
+ self._active_runs: list[wandb_run.Run] = []
88
+
86
89
  self._environ = environ or dict(os.environ)
87
90
  self._sweep_config: dict | None = None
88
91
  self._config: dict | None = None
@@ -100,6 +103,52 @@ class _WandbSetup:
100
103
  self._check()
101
104
  self._setup()
102
105
 
106
+ def add_active_run(self, run: wandb_run.Run) -> None:
107
+ """Append a run to the active runs list.
108
+
109
+ This must be called when a run is initialized.
110
+
111
+ Args:
112
+ run: A newly initialized run.
113
+ """
114
+ if run not in self._active_runs:
115
+ self._active_runs.append(run)
116
+
117
+ def remove_active_run(self, run: wandb_run.Run) -> None:
118
+ """Remove the run from the active runs list.
119
+
120
+ This must be called when a run is finished.
121
+
122
+ Args:
123
+ run: A run that is finished or crashed.
124
+ """
125
+ try:
126
+ self._active_runs.remove(run)
127
+ except ValueError:
128
+ pass # Removing a run multiple times is not an error.
129
+
130
+ @property
131
+ def most_recent_active_run(self) -> wandb_run.Run | None:
132
+ """The most recently initialized run that is not yet finished."""
133
+ if not self._active_runs:
134
+ return None
135
+
136
+ return self._active_runs[-1]
137
+
138
+ def finish_all_active_runs(self) -> None:
139
+ """Finish all unfinished runs.
140
+
141
+ NOTE: This is slightly inefficient as it finishes runs one at a time.
142
+ This only exists to support using the `reinit="finish_previous"`
143
+ setting together with `reinit="create_new"` which does not seem to be a
144
+ useful pattern. Since `"create_new"` should eventually become the
145
+ default and only behavior, it does not seem worth optimizing.
146
+ """
147
+ # Take a snapshot as each call to `finish()` modifies `_active_runs`.
148
+ runs_copy = list(self._active_runs)
149
+ for run in runs_copy:
150
+ run.finish()
151
+
103
152
  def _settings_setup(
104
153
  self,
105
154
  settings: Settings | None,
@@ -294,6 +343,7 @@ def singleton() -> _WandbSetup | None:
294
343
  return None
295
344
 
296
345
 
346
+ @wb_logging.log_to_all_runs()
297
347
  def _setup(
298
348
  settings: Settings | None = None,
299
349
  start_service: bool = True,
@@ -382,6 +432,7 @@ def setup(settings: Settings | None = None) -> _WandbSetup:
382
432
  return _setup(settings=settings)
383
433
 
384
434
 
435
+ @wb_logging.log_to_all_runs()
385
436
  def teardown(exit_code: int | None = None) -> None:
386
437
  """Waits for wandb to finish and frees resources.
387
438
 
wandb/util.py CHANGED
@@ -51,6 +51,11 @@ from typing import (
51
51
  Union,
52
52
  )
53
53
 
54
+ if sys.version_info < (3, 10):
55
+ from typing_extensions import TypeGuard
56
+ else:
57
+ from typing import TypeGuard
58
+
54
59
  import requests
55
60
  import yaml
56
61
 
@@ -184,6 +189,13 @@ class LazyModuleState:
184
189
  self.module.__spec__.loader.exec_module(self.module)
185
190
  self.module.__class__ = types.ModuleType
186
191
 
192
+ # Set the submodule as an attribute on the parent module
193
+ # This enables access to the submodule via normal attribute access.
194
+ parent, _, child = self.module.__name__.rpartition(".")
195
+ if parent:
196
+ parent_module = sys.modules[parent]
197
+ setattr(parent_module, child, self.module)
198
+
187
199
 
188
200
  class LazyModule(types.ModuleType):
189
201
  def __getattribute__(self, name: str) -> Any:
@@ -1060,18 +1072,6 @@ def has_num(dictionary: Mapping, key: Any) -> bool:
1060
1072
  return key in dictionary and isinstance(dictionary[key], numbers.Number)
1061
1073
 
1062
1074
 
1063
- def get_log_file_path() -> str:
1064
- """Log file path used in error messages.
1065
-
1066
- It would probably be better if this pointed to a log file in a
1067
- run directory.
1068
- """
1069
- # TODO(jhr, cvp): refactor
1070
- if wandb.run is not None:
1071
- return wandb.run._settings.log_internal
1072
- return os.path.join("wandb", "debug-internal.log")
1073
-
1074
-
1075
1075
  def docker_image_regex(image: str) -> Any:
1076
1076
  """Regex match for valid docker image names."""
1077
1077
  if image:
@@ -1438,6 +1438,20 @@ def auto_project_name(program: Optional[str]) -> str:
1438
1438
  return str(project.replace(os.sep, "_"))
1439
1439
 
1440
1440
 
1441
+ def are_paths_on_same_drive(path1: str, path2: str) -> bool:
1442
+ """Check if two paths are on the same drive.
1443
+
1444
+ This check is only relevant on Windows,
1445
+ since the concept of drives only exists on Windows.
1446
+ """
1447
+ if platform.system() != "Windows":
1448
+ return True
1449
+
1450
+ path1_drive = pathlib.Path(path1).resolve().drive
1451
+ path2_drive = pathlib.Path(path2).resolve().drive
1452
+ return path1_drive == path2_drive
1453
+
1454
+
1441
1455
  # TODO(hugh): Deprecate version here and use wandb/sdk/lib/paths.py
1442
1456
  def to_forward_slash_path(path: str) -> str:
1443
1457
  if platform.system() == "Windows":
@@ -1698,15 +1712,15 @@ def _resolve_aliases(aliases: Optional[Union[str, Iterable[str]]]) -> List[str]:
1698
1712
  raise ValueError("`aliases` must be Iterable or None") from exc
1699
1713
 
1700
1714
 
1701
- def _is_artifact_object(v: Any) -> bool:
1715
+ def _is_artifact_object(v: Any) -> "TypeGuard[wandb.Artifact]":
1702
1716
  return isinstance(v, wandb.Artifact)
1703
1717
 
1704
1718
 
1705
- def _is_artifact_string(v: Any) -> bool:
1719
+ def _is_artifact_string(v: Any) -> "TypeGuard[str]":
1706
1720
  return isinstance(v, str) and v.startswith("wandb-artifact://")
1707
1721
 
1708
1722
 
1709
- def _is_artifact_version_weave_dict(v: Any) -> bool:
1723
+ def _is_artifact_version_weave_dict(v: Any) -> "TypeGuard[dict]":
1710
1724
  return isinstance(v, dict) and v.get("_type") == "artifactVersion"
1711
1725
 
1712
1726
 
@@ -1750,20 +1764,6 @@ def _get_max_cli_version() -> Union[str, None]:
1750
1764
  return str(max_cli_version) if max_cli_version is not None else None
1751
1765
 
1752
1766
 
1753
- def _is_offline() -> bool:
1754
- """Returns true if wandb is configured to be offline.
1755
-
1756
- If there is an active run, returns whether the run is offline.
1757
- Otherwise, returns the default mode, which is affected by explicit settings
1758
- passed to `wandb.setup()`, environment variables, and W&B configuration
1759
- files.
1760
- """
1761
- if wandb.run:
1762
- return wandb.run.settings._offline
1763
- else:
1764
- return wandb.setup().settings._offline
1765
-
1766
-
1767
1767
  def ensure_text(
1768
1768
  string: Union[str, bytes], encoding: str = "utf-8", errors: str = "strict"
1769
1769
  ) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wandb
3
- Version: 0.19.8
3
+ Version: 0.19.10
4
4
  Summary: A CLI and library for interacting with the Weights & Biases API.
5
5
  Project-URL: Source, https://github.com/wandb/wandb
6
6
  Project-URL: Bug Reports, https://github.com/wandb/wandb/issues
@@ -52,18 +52,18 @@ Requires-Dist: docker-pycreds>=0.4.0
52
52
  Requires-Dist: eval-type-backport; python_version < '3.10'
53
53
  Requires-Dist: gitpython!=3.1.29,>=1.0.0
54
54
  Requires-Dist: platformdirs
55
- Requires-Dist: protobuf!=4.21.0,!=5.28.0,<6,>=3.12.0; python_version < '3.9' and sys_platform == 'linux'
56
- Requires-Dist: protobuf!=4.21.0,!=5.28.0,<6,>=3.15.0; python_version == '3.9' and sys_platform == 'linux'
57
- Requires-Dist: protobuf!=4.21.0,!=5.28.0,<6,>=3.19.0; python_version > '3.9' and sys_platform == 'linux'
58
- Requires-Dist: protobuf!=4.21.0,!=5.28.0,<6,>=3.19.0; sys_platform != 'linux'
55
+ Requires-Dist: protobuf!=4.21.0,!=5.28.0,<7,>=3.12.0; python_version < '3.9' and sys_platform == 'linux'
56
+ Requires-Dist: protobuf!=4.21.0,!=5.28.0,<7,>=3.15.0; python_version == '3.9' and sys_platform == 'linux'
57
+ Requires-Dist: protobuf!=4.21.0,!=5.28.0,<7,>=3.19.0; python_version > '3.9' and sys_platform == 'linux'
58
+ Requires-Dist: protobuf!=4.21.0,!=5.28.0,<7,>=3.19.0; sys_platform != 'linux'
59
59
  Requires-Dist: psutil>=5.0.0
60
- Requires-Dist: pydantic<3,>=2.6
60
+ Requires-Dist: pydantic<3
61
61
  Requires-Dist: pyyaml
62
62
  Requires-Dist: requests<3,>=2.0.0
63
63
  Requires-Dist: sentry-sdk>=2.0.0
64
64
  Requires-Dist: setproctitle
65
65
  Requires-Dist: setuptools
66
- Requires-Dist: typing-extensions<5,>=4.4; python_version < '3.12'
66
+ Requires-Dist: typing-extensions<5,>=4.4
67
67
  Provides-Extra: aws
68
68
  Requires-Dist: boto3; extra == 'aws'
69
69
  Requires-Dist: botocore>=1.5.76; extra == 'aws'