wandb 0.21.0__py3-none-win32.whl → 0.21.2__py3-none-win32.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.
- wandb/__init__.py +16 -14
- wandb/__init__.pyi +427 -450
- wandb/agents/pyagent.py +41 -12
- wandb/analytics/sentry.py +7 -2
- wandb/apis/importers/mlflow.py +1 -1
- wandb/apis/public/__init__.py +1 -1
- wandb/apis/public/api.py +525 -360
- wandb/apis/public/artifacts.py +207 -13
- wandb/apis/public/automations.py +19 -3
- wandb/apis/public/files.py +172 -33
- wandb/apis/public/history.py +67 -15
- wandb/apis/public/integrations.py +25 -2
- wandb/apis/public/jobs.py +90 -2
- wandb/apis/public/projects.py +130 -79
- wandb/apis/public/query_generator.py +11 -1
- wandb/apis/public/registries/_utils.py +14 -16
- wandb/apis/public/registries/registries_search.py +183 -304
- wandb/apis/public/reports.py +96 -15
- wandb/apis/public/runs.py +299 -105
- wandb/apis/public/sweeps.py +222 -22
- wandb/apis/public/teams.py +41 -4
- wandb/apis/public/users.py +45 -4
- wandb/automations/_generated/delete_automation.py +1 -3
- wandb/automations/_generated/enums.py +13 -11
- wandb/beta/workflows.py +66 -30
- wandb/bin/gpu_stats.exe +0 -0
- wandb/bin/wandb-core +0 -0
- wandb/cli/cli.py +127 -3
- wandb/env.py +8 -0
- wandb/errors/errors.py +4 -1
- wandb/integration/lightning/fabric/logger.py +3 -4
- wandb/integration/metaflow/__init__.py +6 -0
- wandb/integration/metaflow/data_pandas.py +74 -0
- wandb/integration/metaflow/data_pytorch.py +75 -0
- wandb/integration/metaflow/data_sklearn.py +76 -0
- wandb/integration/metaflow/errors.py +13 -0
- wandb/integration/metaflow/metaflow.py +167 -223
- wandb/integration/openai/fine_tuning.py +1 -2
- wandb/integration/weave/__init__.py +6 -0
- wandb/integration/weave/interface.py +49 -0
- wandb/integration/weave/weave.py +63 -0
- wandb/jupyter.py +5 -5
- wandb/plot/custom_chart.py +30 -7
- wandb/proto/v3/wandb_internal_pb2.py +281 -280
- wandb/proto/v3/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v4/wandb_internal_pb2.py +280 -280
- wandb/proto/v4/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v5/wandb_internal_pb2.py +280 -280
- wandb/proto/v5/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v6/wandb_internal_pb2.py +280 -280
- wandb/proto/v6/wandb_telemetry_pb2.py +4 -4
- wandb/proto/wandb_deprecated.py +6 -0
- wandb/sdk/artifacts/_factories.py +17 -0
- wandb/sdk/artifacts/_generated/__init__.py +221 -13
- wandb/sdk/artifacts/_generated/artifact_by_id.py +17 -0
- wandb/sdk/artifacts/_generated/artifact_by_name.py +22 -0
- wandb/sdk/artifacts/_generated/artifact_collection_membership_file_urls.py +43 -0
- wandb/sdk/artifacts/_generated/artifact_created_by.py +47 -0
- wandb/sdk/artifacts/_generated/artifact_file_urls.py +22 -0
- wandb/sdk/artifacts/_generated/artifact_type.py +31 -0
- wandb/sdk/artifacts/_generated/artifact_used_by.py +43 -0
- wandb/sdk/artifacts/_generated/artifact_via_membership_by_name.py +26 -0
- wandb/sdk/artifacts/_generated/delete_artifact.py +28 -0
- wandb/sdk/artifacts/_generated/enums.py +5 -0
- wandb/sdk/artifacts/_generated/fetch_artifact_manifest.py +38 -0
- wandb/sdk/artifacts/_generated/fetch_registries.py +32 -0
- wandb/sdk/artifacts/_generated/fragments.py +279 -41
- wandb/sdk/artifacts/_generated/link_artifact.py +6 -0
- wandb/sdk/artifacts/_generated/operations.py +654 -51
- wandb/sdk/artifacts/_generated/registry_collections.py +34 -0
- wandb/sdk/artifacts/_generated/registry_versions.py +34 -0
- wandb/sdk/artifacts/_generated/unlink_artifact.py +25 -0
- wandb/sdk/artifacts/_graphql_fragments.py +3 -86
- wandb/sdk/artifacts/_internal_artifact.py +19 -8
- wandb/sdk/artifacts/_validators.py +14 -4
- wandb/sdk/artifacts/artifact.py +512 -618
- wandb/sdk/artifacts/artifact_file_cache.py +10 -6
- wandb/sdk/artifacts/artifact_manifest.py +10 -9
- wandb/sdk/artifacts/artifact_manifest_entry.py +9 -10
- wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +5 -3
- wandb/sdk/artifacts/storage_handlers/http_handler.py +1 -1
- wandb/sdk/artifacts/storage_handlers/s3_handler.py +1 -1
- wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +1 -1
- wandb/sdk/data_types/audio.py +38 -10
- wandb/sdk/data_types/base_types/media.py +6 -56
- wandb/sdk/data_types/graph.py +48 -14
- wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +1 -3
- wandb/sdk/data_types/helper_types/image_mask.py +1 -3
- wandb/sdk/data_types/histogram.py +34 -21
- wandb/sdk/data_types/html.py +35 -12
- wandb/sdk/data_types/image.py +104 -68
- wandb/sdk/data_types/molecule.py +32 -19
- wandb/sdk/data_types/object_3d.py +36 -17
- wandb/sdk/data_types/plotly.py +18 -5
- wandb/sdk/data_types/saved_model.py +4 -6
- wandb/sdk/data_types/table.py +59 -30
- wandb/sdk/data_types/video.py +53 -26
- wandb/sdk/integration_utils/auto_logging.py +2 -2
- wandb/sdk/interface/interface_queue.py +1 -4
- wandb/sdk/interface/interface_shared.py +26 -37
- wandb/sdk/interface/interface_sock.py +24 -14
- wandb/sdk/internal/internal_api.py +6 -0
- wandb/sdk/internal/job_builder.py +6 -0
- wandb/sdk/internal/settings_static.py +2 -3
- wandb/sdk/launch/agent/agent.py +8 -1
- wandb/sdk/launch/agent/run_queue_item_file_saver.py +2 -2
- wandb/sdk/launch/create_job.py +15 -2
- wandb/sdk/launch/inputs/internal.py +3 -4
- wandb/sdk/launch/inputs/schema.py +1 -0
- wandb/sdk/launch/runner/kubernetes_monitor.py +1 -0
- wandb/sdk/launch/runner/kubernetes_runner.py +323 -1
- wandb/sdk/launch/sweeps/scheduler.py +2 -3
- wandb/sdk/lib/asyncio_compat.py +19 -16
- wandb/sdk/lib/asyncio_manager.py +252 -0
- wandb/sdk/lib/deprecate.py +1 -7
- wandb/sdk/lib/disabled.py +1 -1
- wandb/sdk/lib/hashutil.py +27 -5
- wandb/sdk/lib/module.py +7 -13
- wandb/sdk/lib/printer.py +2 -2
- wandb/sdk/lib/printer_asyncio.py +3 -1
- wandb/sdk/lib/progress.py +0 -19
- wandb/sdk/lib/retry.py +185 -78
- wandb/sdk/lib/service/service_client.py +106 -0
- wandb/sdk/lib/service/service_connection.py +20 -26
- wandb/sdk/lib/service/service_token.py +30 -13
- wandb/sdk/mailbox/mailbox.py +13 -5
- wandb/sdk/mailbox/mailbox_handle.py +22 -13
- wandb/sdk/mailbox/response_handle.py +42 -106
- wandb/sdk/mailbox/wait_with_progress.py +7 -42
- wandb/sdk/wandb_init.py +77 -116
- wandb/sdk/wandb_login.py +19 -15
- wandb/sdk/wandb_metric.py +2 -0
- wandb/sdk/wandb_run.py +497 -469
- wandb/sdk/wandb_settings.py +145 -4
- wandb/sdk/wandb_setup.py +204 -124
- wandb/sdk/wandb_sweep.py +14 -13
- wandb/sdk/wandb_watch.py +4 -6
- wandb/sync/sync.py +10 -0
- wandb/util.py +58 -1
- wandb/wandb_run.py +1 -2
- {wandb-0.21.0.dist-info → wandb-0.21.2.dist-info}/METADATA +1 -1
- {wandb-0.21.0.dist-info → wandb-0.21.2.dist-info}/RECORD +145 -129
- wandb/sdk/interface/interface_relay.py +0 -38
- wandb/sdk/interface/router.py +0 -89
- wandb/sdk/interface/router_queue.py +0 -43
- wandb/sdk/interface/router_relay.py +0 -50
- wandb/sdk/interface/router_sock.py +0 -32
- wandb/sdk/lib/sock_client.py +0 -236
- wandb/vendor/pynvml/__init__.py +0 -0
- wandb/vendor/pynvml/pynvml.py +0 -4779
- {wandb-0.21.0.dist-info → wandb-0.21.2.dist-info}/WHEEL +0 -0
- {wandb-0.21.0.dist-info → wandb-0.21.2.dist-info}/entry_points.txt +0 -0
- {wandb-0.21.0.dist-info → wandb-0.21.2.dist-info}/licenses/LICENSE +0 -0
wandb/apis/public/sweeps.py
CHANGED
@@ -1,4 +1,31 @@
|
|
1
|
-
"""Public API
|
1
|
+
"""W&B Public API for Sweeps.
|
2
|
+
|
3
|
+
This module provides classes for interacting with W&B hyperparameter
|
4
|
+
optimization sweeps.
|
5
|
+
|
6
|
+
Example:
|
7
|
+
```python
|
8
|
+
from wandb.apis.public import Api
|
9
|
+
|
10
|
+
# Get a specific sweep
|
11
|
+
sweep = Api().sweep("entity/project/sweep_id")
|
12
|
+
|
13
|
+
# Access sweep properties
|
14
|
+
print(f"Sweep: {sweep.name}")
|
15
|
+
print(f"State: {sweep.state}")
|
16
|
+
print(f"Best Loss: {sweep.best_loss}")
|
17
|
+
|
18
|
+
# Get best performing run
|
19
|
+
best_run = sweep.best_run()
|
20
|
+
print(f"Best Run: {best_run.name}")
|
21
|
+
print(f"Metrics: {best_run.summary}")
|
22
|
+
```
|
23
|
+
|
24
|
+
Note:
|
25
|
+
This module is part of the W&B Public API and provides read-only access
|
26
|
+
to sweep data. For creating and controlling sweeps, use the wandb.sweep()
|
27
|
+
and wandb.agent() functions from the main wandb package.
|
28
|
+
"""
|
2
29
|
|
3
30
|
import urllib
|
4
31
|
from typing import Optional
|
@@ -9,6 +36,8 @@ import wandb
|
|
9
36
|
from wandb import util
|
10
37
|
from wandb.apis import public
|
11
38
|
from wandb.apis.attrs import Attrs
|
39
|
+
from wandb.apis.paginator import SizedPaginator
|
40
|
+
from wandb.apis.public.api import RetryingClient
|
12
41
|
from wandb.sdk.lib import ipython
|
13
42
|
|
14
43
|
SWEEP_FRAGMENT = """fragment SweepFragment on Sweep {
|
@@ -27,23 +56,154 @@ SWEEP_FRAGMENT = """fragment SweepFragment on Sweep {
|
|
27
56
|
"""
|
28
57
|
|
29
58
|
|
30
|
-
class Sweep
|
31
|
-
"""A
|
59
|
+
class Sweeps(SizedPaginator["Sweep"]):
|
60
|
+
"""A lazy iterator over a collection of `Sweep` objects.
|
32
61
|
|
33
62
|
Examples:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
63
|
+
```python
|
64
|
+
from wandb.apis.public import Api
|
65
|
+
|
66
|
+
sweeps = Api().project(name="project_name", entity="entity").sweeps()
|
67
|
+
|
68
|
+
# Iterate over sweeps and print details
|
69
|
+
for sweep in sweeps:
|
70
|
+
print(f"Sweep name: {sweep.name}")
|
71
|
+
print(f"Sweep ID: {sweep.id}")
|
72
|
+
print(f"Sweep URL: {sweep.url}")
|
73
|
+
print("----------")
|
74
|
+
```
|
75
|
+
"""
|
76
|
+
|
77
|
+
QUERY = gql(
|
78
|
+
f"""#graphql
|
79
|
+
query GetSweeps($project: String!, $entity: String!, $cursor: String, $perPage: Int = 50) {{
|
80
|
+
project(name: $project, entityName: $entity) {{
|
81
|
+
totalSweeps
|
82
|
+
sweeps(after: $cursor, first: $perPage) {{
|
83
|
+
edges {{
|
84
|
+
node {{
|
85
|
+
...SweepFragment
|
86
|
+
}}
|
87
|
+
cursor
|
88
|
+
}}
|
89
|
+
pageInfo {{
|
90
|
+
endCursor
|
91
|
+
hasNextPage
|
92
|
+
}}
|
93
|
+
}}
|
94
|
+
}}
|
95
|
+
}}
|
96
|
+
{SWEEP_FRAGMENT}
|
97
|
+
"""
|
98
|
+
)
|
99
|
+
|
100
|
+
def __init__(
|
101
|
+
self,
|
102
|
+
client: RetryingClient,
|
103
|
+
entity: str,
|
104
|
+
project: str,
|
105
|
+
per_page: int = 50,
|
106
|
+
) -> "Sweeps":
|
107
|
+
"""An iterable collection of `Sweep` objects.
|
108
|
+
|
109
|
+
Args:
|
110
|
+
client: The API client used to query W&B.
|
111
|
+
entity: The entity which owns the sweeps.
|
112
|
+
project: The project which contains the sweeps.
|
113
|
+
per_page: The number of sweeps to fetch per request to the API.
|
114
|
+
"""
|
115
|
+
self.client = client
|
116
|
+
self.entity = entity
|
117
|
+
self.project = project
|
118
|
+
variables = {
|
119
|
+
"project": self.project,
|
120
|
+
"entity": self.entity,
|
121
|
+
}
|
122
|
+
super().__init__(client, variables, per_page)
|
123
|
+
|
124
|
+
@property
|
125
|
+
def _length(self):
|
126
|
+
"""The total number of sweeps in the project.
|
127
|
+
|
128
|
+
<!-- lazydoc-ignore: internal -->
|
129
|
+
"""
|
130
|
+
if not self.last_response:
|
131
|
+
self._load_page()
|
132
|
+
|
133
|
+
return (
|
134
|
+
self.last_response["project"]["totalSweeps"]
|
135
|
+
if self.last_response["project"]["totalSweeps"] is not None
|
136
|
+
else 0
|
137
|
+
)
|
138
|
+
|
139
|
+
@property
|
140
|
+
def more(self):
|
141
|
+
"""Returns whether there are more sweeps to fetch.
|
142
|
+
|
143
|
+
<!-- lazydoc-ignore: internal -->
|
144
|
+
"""
|
145
|
+
if self.last_response:
|
146
|
+
return bool(
|
147
|
+
self.last_response["project"]["sweeps"]["pageInfo"]["hasNextPage"]
|
148
|
+
)
|
149
|
+
else:
|
150
|
+
return True
|
151
|
+
|
152
|
+
@property
|
153
|
+
def cursor(self):
|
154
|
+
"""Returns the cursor for the next page of sweeps.
|
155
|
+
|
156
|
+
<!-- lazydoc-ignore: internal -->
|
157
|
+
"""
|
158
|
+
if self.last_response:
|
159
|
+
return self.last_response["project"]["sweeps"]["pageInfo"]["endCursor"]
|
160
|
+
else:
|
161
|
+
return None
|
162
|
+
|
163
|
+
def update_variables(self):
|
164
|
+
"""Updates the variables for the next page of sweeps.
|
165
|
+
|
166
|
+
<!-- lazydoc-ignore: internal -->
|
167
|
+
"""
|
168
|
+
self.variables.update({"perPage": self.per_page, "cursor": self.cursor})
|
169
|
+
|
170
|
+
def convert_objects(self):
|
171
|
+
"""Converts the last GraphQL response into a list of `Sweep` objects.
|
172
|
+
|
173
|
+
<!-- lazydoc-ignore: internal -->
|
174
|
+
"""
|
175
|
+
if self.last_response is None or self.last_response.get("project") is None:
|
176
|
+
raise ValueError("Could not find project {}".format(self.project))
|
177
|
+
|
178
|
+
if self.last_response["project"]["totalSweeps"] < 1:
|
179
|
+
return []
|
180
|
+
|
181
|
+
return [
|
182
|
+
# match format of existing public sweep apis
|
183
|
+
public.Sweep(
|
184
|
+
self.client,
|
185
|
+
self.entity,
|
186
|
+
self.project,
|
187
|
+
e["node"]["name"],
|
188
|
+
)
|
189
|
+
for e in self.last_response["project"]["sweeps"]["edges"]
|
190
|
+
]
|
191
|
+
|
192
|
+
def __repr__(self):
|
193
|
+
return f"<Sweeps {self.entity}/{self.project}>"
|
194
|
+
|
195
|
+
|
196
|
+
class Sweep(Attrs):
|
197
|
+
"""The set of runs associated with the sweep.
|
39
198
|
|
40
199
|
Attributes:
|
41
|
-
runs
|
42
|
-
id
|
43
|
-
project
|
44
|
-
config
|
45
|
-
state
|
46
|
-
|
200
|
+
runs (Runs): List of runs
|
201
|
+
id (str): Sweep ID
|
202
|
+
project (str): The name of the project the sweep belongs to
|
203
|
+
config (dict): Dictionary containing the sweep configuration
|
204
|
+
state (str): The state of the sweep. Can be "Finished", "Failed",
|
205
|
+
"Crashed", or "Running".
|
206
|
+
expected_run_count (int): The number of expected runs for the sweep
|
47
207
|
"""
|
48
208
|
|
49
209
|
QUERY = gql(
|
@@ -53,6 +213,7 @@ class Sweep(Attrs):
|
|
53
213
|
sweep(sweepName: $name) {
|
54
214
|
id
|
55
215
|
name
|
216
|
+
displayName
|
56
217
|
state
|
57
218
|
runCountExpected
|
58
219
|
bestLoss
|
@@ -92,18 +253,25 @@ class Sweep(Attrs):
|
|
92
253
|
|
93
254
|
@property
|
94
255
|
def entity(self):
|
256
|
+
"""The entity associated with the sweep."""
|
95
257
|
return self._entity
|
96
258
|
|
97
259
|
@property
|
98
260
|
def username(self):
|
261
|
+
"""Deprecated. Use `Sweep.entity` instead."""
|
99
262
|
wandb.termwarn("Sweep.username is deprecated. please use Sweep.entity instead.")
|
100
263
|
return self._entity
|
101
264
|
|
102
265
|
@property
|
103
266
|
def config(self):
|
267
|
+
"""The sweep configuration used for the sweep."""
|
104
268
|
return util.load_yaml(self._attrs["config"])
|
105
269
|
|
106
270
|
def load(self, force: bool = False):
|
271
|
+
"""Fetch and update sweep data logged to the run from GraphQL database.
|
272
|
+
|
273
|
+
<!-- lazydoc-ignore: internal -->
|
274
|
+
"""
|
107
275
|
if force or not self._attrs:
|
108
276
|
sweep = self.get(self.client, self.entity, self.project, self.id)
|
109
277
|
if sweep is None:
|
@@ -115,6 +283,7 @@ class Sweep(Attrs):
|
|
115
283
|
|
116
284
|
@property
|
117
285
|
def order(self):
|
286
|
+
"""Return the order key for the sweep."""
|
118
287
|
if self._attrs.get("config") and self.config.get("metric"):
|
119
288
|
sort_order = self.config["metric"].get("goal", "minimize")
|
120
289
|
prefix = "+" if sort_order == "minimize" else "-"
|
@@ -154,6 +323,9 @@ class Sweep(Attrs):
|
|
154
323
|
|
155
324
|
@property
|
156
325
|
def path(self):
|
326
|
+
"""Returns the path of the project.
|
327
|
+
|
328
|
+
The path is a list containing the entity, project name, and sweep ID."""
|
157
329
|
return [
|
158
330
|
urllib.parse.quote_plus(str(self.entity)),
|
159
331
|
urllib.parse.quote_plus(str(self.project)),
|
@@ -162,26 +334,54 @@ class Sweep(Attrs):
|
|
162
334
|
|
163
335
|
@property
|
164
336
|
def url(self):
|
337
|
+
"""The URL of the sweep.
|
338
|
+
|
339
|
+
The sweep URL is generated from the entity, project, the term
|
340
|
+
"sweeps", and the sweep ID.run_id. For
|
341
|
+
SaaS users, it takes the form
|
342
|
+
of `https://wandb.ai/entity/project/sweeps/sweeps_ID`.
|
343
|
+
"""
|
165
344
|
path = self.path
|
166
345
|
path.insert(2, "sweeps")
|
167
346
|
return self.client.app_url + "/".join(path)
|
168
347
|
|
169
348
|
@property
|
170
349
|
def name(self):
|
171
|
-
|
350
|
+
"""The name of the sweep.
|
351
|
+
|
352
|
+
Returns the first name that exists in the following priority order:
|
353
|
+
|
354
|
+
1. User-edited display name
|
355
|
+
2. Name configured at creation time
|
356
|
+
3. Sweep ID
|
357
|
+
"""
|
358
|
+
return self._attrs.get("displayName") or self.config.get("name") or self.id
|
172
359
|
|
173
360
|
@classmethod
|
174
361
|
def get(
|
175
362
|
cls,
|
176
|
-
client,
|
177
|
-
entity=None,
|
178
|
-
project=None,
|
179
|
-
sid=None,
|
180
|
-
order=None,
|
181
|
-
query=None,
|
363
|
+
client: "RetryingClient",
|
364
|
+
entity: Optional[str] = None,
|
365
|
+
project: Optional[str] = None,
|
366
|
+
sid: Optional[str] = None,
|
367
|
+
order: Optional[str] = None,
|
368
|
+
query: Optional[str] = None,
|
182
369
|
**kwargs,
|
183
370
|
):
|
184
|
-
"""Execute a query against the cloud backend.
|
371
|
+
"""Execute a query against the cloud backend.
|
372
|
+
|
373
|
+
Args:
|
374
|
+
client: The client to use to execute the query.
|
375
|
+
entity: The entity (username or team) that owns the project.
|
376
|
+
project: The name of the project to fetch sweep from.
|
377
|
+
sid: The sweep ID to query.
|
378
|
+
order: The order in which the sweep's runs are returned.
|
379
|
+
query: The query to use to execute the query.
|
380
|
+
**kwargs: Additional keyword arguments to pass to the query.
|
381
|
+
"""
|
382
|
+
if not order:
|
383
|
+
order = "+created_at"
|
384
|
+
|
185
385
|
if query is None:
|
186
386
|
query = cls.QUERY
|
187
387
|
|
wandb/apis/public/teams.py
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
"""Public API
|
1
|
+
"""W&B Public API for managing teams and team members.
|
2
|
+
|
3
|
+
This module provides classes for managing W&B teams and their members.
|
4
|
+
|
5
|
+
Note:
|
6
|
+
This module is part of the W&B Public API and provides methods to manage
|
7
|
+
teams and their members. Team management operations require appropriate
|
8
|
+
permissions.
|
9
|
+
"""
|
2
10
|
|
3
11
|
import requests
|
4
12
|
from wandb_gql import gql
|
@@ -7,6 +15,14 @@ from wandb.apis.attrs import Attrs
|
|
7
15
|
|
8
16
|
|
9
17
|
class Member(Attrs):
|
18
|
+
"""A member of a team.
|
19
|
+
|
20
|
+
Args:
|
21
|
+
client (`wandb.apis.internal.Api`): The client instance to use
|
22
|
+
team (str): The name of the team this member belongs to
|
23
|
+
attrs (dict): The member attributes
|
24
|
+
"""
|
25
|
+
|
10
26
|
DELETE_MEMBER_MUTATION = gql(
|
11
27
|
"""
|
12
28
|
mutation DeleteInvite($id: String, $entityName: String) {
|
@@ -40,6 +56,21 @@ class Member(Attrs):
|
|
40
56
|
|
41
57
|
|
42
58
|
class Team(Attrs):
|
59
|
+
"""A class that represents a W&B team.
|
60
|
+
|
61
|
+
This class provides methods to manage W&B teams, including creating teams,
|
62
|
+
inviting members, and managing service accounts. It inherits from Attrs
|
63
|
+
to handle team attributes.
|
64
|
+
|
65
|
+
Args:
|
66
|
+
client (`wandb.apis.public.Api`): The api instance to use
|
67
|
+
name (str): The name of the team
|
68
|
+
attrs (dict): Optional dictionary of team attributes
|
69
|
+
|
70
|
+
Note:
|
71
|
+
Team management requires appropriate permissions.
|
72
|
+
"""
|
73
|
+
|
43
74
|
CREATE_TEAM_MUTATION = gql(
|
44
75
|
"""
|
45
76
|
mutation CreateTeam($teamName: String!, $teamAdminUserName: String) {
|
@@ -148,11 +179,13 @@ class Team(Attrs):
|
|
148
179
|
"""Invite a user to a team.
|
149
180
|
|
150
181
|
Args:
|
151
|
-
username_or_email: (str) The username or email address of the user
|
152
|
-
|
182
|
+
username_or_email: (str) The username or email address of the user
|
183
|
+
you want to invite.
|
184
|
+
admin: (bool) Whether to make this user a team admin.
|
185
|
+
Defaults to `False`.
|
153
186
|
|
154
187
|
Returns:
|
155
|
-
True on success, False if user was already invited or didn't exist
|
188
|
+
`True` on success, `False` if user was already invited or didn't exist.
|
156
189
|
"""
|
157
190
|
variables = {"entityName": self.name, "admin": admin}
|
158
191
|
if "@" in username_or_email:
|
@@ -185,6 +218,10 @@ class Team(Attrs):
|
|
185
218
|
return None
|
186
219
|
|
187
220
|
def load(self, force=False):
|
221
|
+
"""Return members that belong to a team.
|
222
|
+
|
223
|
+
<!-- lazydoc-ignore: internal -->
|
224
|
+
"""
|
188
225
|
if force or not self._attrs:
|
189
226
|
response = self._client.execute(self.TEAM_QUERY, {"name": self.name})
|
190
227
|
self._attrs = response["entity"]
|
wandb/apis/public/users.py
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
"""Public API
|
1
|
+
"""W&B Public API for managing users and API keys.
|
2
|
+
|
3
|
+
This module provides classes for managing W&B users and their API keys.
|
4
|
+
|
5
|
+
Note:
|
6
|
+
This module is part of the W&B Public API and provides methods to manage
|
7
|
+
users and their authentication. Some operations require admin privileges.
|
8
|
+
"""
|
2
9
|
|
3
10
|
import requests
|
4
11
|
from wandb_gql import gql
|
@@ -8,6 +15,20 @@ from wandb.apis.attrs import Attrs
|
|
8
15
|
|
9
16
|
|
10
17
|
class User(Attrs):
|
18
|
+
"""A class representing a W&B user with authentication and management capabilities.
|
19
|
+
|
20
|
+
This class provides methods to manage W&B users, including creating users,
|
21
|
+
managing API keys, and accessing team memberships. It inherits from Attrs
|
22
|
+
to handle user attributes.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
client: (`wandb.apis.internal.Api`) The client instance to use
|
26
|
+
attrs: (dict) The user attributes
|
27
|
+
|
28
|
+
Note:
|
29
|
+
Some operations require admin privileges
|
30
|
+
"""
|
31
|
+
|
11
32
|
CREATE_USER_MUTATION = gql(
|
12
33
|
"""
|
13
34
|
mutation CreateUserFromAdmin($email: String!, $admin: Boolean) {
|
@@ -63,9 +84,9 @@ class User(Attrs):
|
|
63
84
|
"""Create a new user.
|
64
85
|
|
65
86
|
Args:
|
66
|
-
api
|
67
|
-
email
|
68
|
-
admin
|
87
|
+
api (`Api`): The api instance to use
|
88
|
+
email (str): The name of the team
|
89
|
+
admin (bool): Whether this user should be a global instance admin
|
69
90
|
|
70
91
|
Returns:
|
71
92
|
A `User` object
|
@@ -78,12 +99,24 @@ class User(Attrs):
|
|
78
99
|
|
79
100
|
@property
|
80
101
|
def api_keys(self):
|
102
|
+
"""List of API key names associated with the user.
|
103
|
+
|
104
|
+
Returns:
|
105
|
+
list[str]: Names of API keys associated with the user. Empty list if user
|
106
|
+
has no API keys or if API key data hasn't been loaded.
|
107
|
+
"""
|
81
108
|
if self._attrs.get("apiKeys") is None:
|
82
109
|
return []
|
83
110
|
return [k["node"]["name"] for k in self._attrs["apiKeys"]["edges"]]
|
84
111
|
|
85
112
|
@property
|
86
113
|
def teams(self):
|
114
|
+
"""List of team names that the user is a member of.
|
115
|
+
|
116
|
+
Returns:
|
117
|
+
list (list): Names of teams the user belongs to. Empty list if user has no
|
118
|
+
team memberships or if teams data hasn't been loaded.
|
119
|
+
"""
|
87
120
|
if self._attrs.get("teams") is None:
|
88
121
|
return []
|
89
122
|
return [k["node"]["name"] for k in self._attrs["teams"]["edges"]]
|
@@ -91,6 +124,10 @@ class User(Attrs):
|
|
91
124
|
def delete_api_key(self, api_key):
|
92
125
|
"""Delete a user's api key.
|
93
126
|
|
127
|
+
Args:
|
128
|
+
api_key (str): The name of the API key to delete. This should be
|
129
|
+
one of the names returned by the `api_keys` property.
|
130
|
+
|
94
131
|
Returns:
|
95
132
|
Boolean indicating success
|
96
133
|
|
@@ -110,6 +147,10 @@ class User(Attrs):
|
|
110
147
|
def generate_api_key(self, description=None):
|
111
148
|
"""Generate a new api key.
|
112
149
|
|
150
|
+
Args:
|
151
|
+
description (str, optional): A description for the new API key. This can be
|
152
|
+
used to identify the purpose of the API key.
|
153
|
+
|
113
154
|
Returns:
|
114
155
|
The new api key, or None on failure
|
115
156
|
"""
|
@@ -3,15 +3,13 @@
|
|
3
3
|
|
4
4
|
from __future__ import annotations
|
5
5
|
|
6
|
-
from typing import Optional
|
7
|
-
|
8
6
|
from wandb._pydantic import GQLBase
|
9
7
|
|
10
8
|
from .fragments import DeleteAutomationResult
|
11
9
|
|
12
10
|
|
13
11
|
class DeleteAutomation(GQLBase):
|
14
|
-
result:
|
12
|
+
result: DeleteAutomationResult
|
15
13
|
|
16
14
|
|
17
15
|
DeleteAutomation.model_rebuild()
|
@@ -6,13 +6,10 @@ from __future__ import annotations
|
|
6
6
|
from enum import Enum
|
7
7
|
|
8
8
|
|
9
|
-
class
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
LINK_MODEL = "LINK_MODEL"
|
14
|
-
RUN_METRIC = "RUN_METRIC"
|
15
|
-
RUN_METRIC_CHANGE = "RUN_METRIC_CHANGE"
|
9
|
+
class AlertSeverity(str, Enum):
|
10
|
+
INFO = "INFO"
|
11
|
+
WARN = "WARN"
|
12
|
+
ERROR = "ERROR"
|
16
13
|
|
17
14
|
|
18
15
|
class TriggerScopeType(str, Enum):
|
@@ -20,10 +17,15 @@ class TriggerScopeType(str, Enum):
|
|
20
17
|
ARTIFACT_COLLECTION = "ARTIFACT_COLLECTION"
|
21
18
|
|
22
19
|
|
23
|
-
class
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
class EventTriggeringConditionType(str, Enum):
|
21
|
+
CREATE_ARTIFACT = "CREATE_ARTIFACT"
|
22
|
+
UPDATE_ARTIFACT_ALIAS = "UPDATE_ARTIFACT_ALIAS"
|
23
|
+
ADD_ARTIFACT_ALIAS = "ADD_ARTIFACT_ALIAS"
|
24
|
+
ADD_ARTIFACT_TAG = "ADD_ARTIFACT_TAG"
|
25
|
+
LINK_MODEL = "LINK_MODEL"
|
26
|
+
RUN_METRIC = "RUN_METRIC"
|
27
|
+
RUN_METRIC_CHANGE = "RUN_METRIC_CHANGE"
|
28
|
+
RUN_STATE = "RUN_STATE"
|
27
29
|
|
28
30
|
|
29
31
|
class TriggeredActionType(str, Enum):
|