wandb 0.19.7__py3-none-macosx_11_0_arm64.whl → 0.19.8__py3-none-macosx_11_0_arm64.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 +1 -1
- wandb/__init__.pyi +32 -2
- wandb/bin/gpu_stats +0 -0
- wandb/bin/wandb-core +0 -0
- wandb/data_types.py +1 -1
- wandb/filesync/dir_watcher.py +2 -1
- wandb/proto/v3/wandb_settings_pb2.py +2 -2
- wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
- wandb/proto/v4/wandb_settings_pb2.py +2 -2
- wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
- wandb/proto/v5/wandb_settings_pb2.py +2 -2
- wandb/proto/v5/wandb_telemetry_pb2.py +10 -10
- wandb/sdk/artifacts/artifact.py +11 -10
- wandb/sdk/backend/backend.py +16 -5
- wandb/sdk/interface/interface.py +65 -43
- wandb/sdk/interface/interface_queue.py +0 -7
- wandb/sdk/interface/interface_relay.py +6 -16
- wandb/sdk/interface/interface_shared.py +47 -40
- wandb/sdk/interface/interface_sock.py +1 -8
- wandb/sdk/interface/router.py +22 -54
- wandb/sdk/interface/router_queue.py +11 -10
- wandb/sdk/interface/router_relay.py +24 -12
- wandb/sdk/interface/router_sock.py +6 -11
- wandb/sdk/internal/sender.py +3 -1
- wandb/sdk/lib/console_capture.py +172 -0
- wandb/sdk/lib/redirect.py +102 -76
- wandb/sdk/lib/service_connection.py +37 -17
- wandb/sdk/lib/sock_client.py +2 -52
- wandb/sdk/mailbox/__init__.py +3 -3
- wandb/sdk/mailbox/mailbox.py +31 -17
- wandb/sdk/mailbox/mailbox_handle.py +127 -0
- wandb/sdk/mailbox/{handles.py → response_handle.py} +34 -66
- wandb/sdk/mailbox/wait_with_progress.py +16 -15
- wandb/sdk/service/server_sock.py +4 -2
- wandb/sdk/service/streams.py +10 -5
- wandb/sdk/wandb_init.py +12 -15
- wandb/sdk/wandb_run.py +8 -10
- wandb/sdk/wandb_settings.py +7 -1
- wandb/sdk/wandb_sync.py +1 -7
- {wandb-0.19.7.dist-info → wandb-0.19.8.dist-info}/METADATA +1 -1
- {wandb-0.19.7.dist-info → wandb-0.19.8.dist-info}/RECORD +44 -44
- wandb/sdk/interface/message_future.py +0 -27
- wandb/sdk/interface/message_future_poll.py +0 -50
- {wandb-0.19.7.dist-info → wandb-0.19.8.dist-info}/WHEEL +0 -0
- {wandb-0.19.7.dist-info → wandb-0.19.8.dist-info}/entry_points.txt +0 -0
- {wandb-0.19.7.dist-info → wandb-0.19.8.dist-info}/licenses/LICENSE +0 -0
@@ -14,24 +14,14 @@ from wandb.sdk.mailbox import Mailbox, MailboxHandle
|
|
14
14
|
from wandb.util import json_dumps_safer, json_friendly
|
15
15
|
|
16
16
|
from .interface import InterfaceBase
|
17
|
-
from .router import MessageRouter
|
18
17
|
|
19
18
|
logger = logging.getLogger("wandb")
|
20
19
|
|
21
20
|
|
22
21
|
class InterfaceShared(InterfaceBase):
|
23
|
-
|
24
|
-
_mailbox: Optional[Mailbox]
|
25
|
-
|
26
|
-
def __init__(self, mailbox: Optional[Any] = None) -> None:
|
22
|
+
def __init__(self, mailbox: Optional[Mailbox] = None) -> None:
|
27
23
|
super().__init__()
|
28
|
-
self._router = None
|
29
24
|
self._mailbox = mailbox
|
30
|
-
self._init_router()
|
31
|
-
|
32
|
-
@abstractmethod
|
33
|
-
def _init_router(self) -> None:
|
34
|
-
raise NotImplementedError
|
35
25
|
|
36
26
|
def _publish_output(self, outdata: pb.OutputRecord) -> None:
|
37
27
|
rec = pb.Record()
|
@@ -69,7 +59,9 @@ class InterfaceShared(InterfaceBase):
|
|
69
59
|
rec = self._make_record(telemetry=telem)
|
70
60
|
self._publish(rec)
|
71
61
|
|
72
|
-
def _publish_job_input(
|
62
|
+
def _publish_job_input(
|
63
|
+
self, job_input: pb.JobInputRequest
|
64
|
+
) -> MailboxHandle[pb.Result]:
|
73
65
|
record = self._make_request(job_input=job_input)
|
74
66
|
return self._deliver_record(record)
|
75
67
|
|
@@ -342,19 +334,19 @@ class InterfaceShared(InterfaceBase):
|
|
342
334
|
def _deliver_artifact(
|
343
335
|
self,
|
344
336
|
log_artifact: pb.LogArtifactRequest,
|
345
|
-
) -> MailboxHandle:
|
337
|
+
) -> MailboxHandle[pb.Result]:
|
346
338
|
rec = self._make_request(log_artifact=log_artifact)
|
347
339
|
return self._deliver_record(rec)
|
348
340
|
|
349
341
|
def _deliver_download_artifact(
|
350
342
|
self, download_artifact: pb.DownloadArtifactRequest
|
351
|
-
) -> MailboxHandle:
|
343
|
+
) -> MailboxHandle[pb.Result]:
|
352
344
|
rec = self._make_request(download_artifact=download_artifact)
|
353
345
|
return self._deliver_record(rec)
|
354
346
|
|
355
347
|
def _deliver_link_artifact(
|
356
348
|
self, link_artifact: pb.LinkArtifactRequest
|
357
|
-
) -> MailboxHandle:
|
349
|
+
) -> MailboxHandle[pb.Result]:
|
358
350
|
rec = self._make_request(link_artifact=link_artifact)
|
359
351
|
return self._deliver_record(rec)
|
360
352
|
|
@@ -369,7 +361,7 @@ class InterfaceShared(InterfaceBase):
|
|
369
361
|
def _deliver_status(
|
370
362
|
self,
|
371
363
|
status: pb.StatusRequest,
|
372
|
-
) -> MailboxHandle:
|
364
|
+
) -> MailboxHandle[pb.Result]:
|
373
365
|
req = self._make_request(status=status)
|
374
366
|
return self._deliver_record(req)
|
375
367
|
|
@@ -381,7 +373,7 @@ class InterfaceShared(InterfaceBase):
|
|
381
373
|
record = self._make_request(keepalive=keepalive)
|
382
374
|
self._publish(record)
|
383
375
|
|
384
|
-
def _deliver_shutdown(self) -> MailboxHandle:
|
376
|
+
def _deliver_shutdown(self) -> MailboxHandle[pb.Result]:
|
385
377
|
request = pb.Request(shutdown=pb.ShutdownRequest())
|
386
378
|
record = self._make_record(request=request)
|
387
379
|
return self._deliver_record(record)
|
@@ -391,43 +383,55 @@ class InterfaceShared(InterfaceBase):
|
|
391
383
|
assert mailbox
|
392
384
|
return mailbox
|
393
385
|
|
394
|
-
def _deliver_record(self, record: pb.Record) -> MailboxHandle:
|
386
|
+
def _deliver_record(self, record: pb.Record) -> MailboxHandle[pb.Result]:
|
395
387
|
mailbox = self._get_mailbox()
|
396
388
|
|
397
389
|
handle = mailbox.require_response(record)
|
398
390
|
self._publish(record)
|
399
391
|
|
400
|
-
return handle
|
392
|
+
return handle.map(lambda resp: resp.result_communicate)
|
401
393
|
|
402
|
-
def _deliver_run(self, run: pb.RunRecord) -> MailboxHandle:
|
394
|
+
def _deliver_run(self, run: pb.RunRecord) -> MailboxHandle[pb.Result]:
|
403
395
|
record = self._make_record(run=run)
|
404
396
|
return self._deliver_record(record)
|
405
397
|
|
406
|
-
def _deliver_finish_sync(
|
398
|
+
def _deliver_finish_sync(
|
399
|
+
self,
|
400
|
+
sync_finish: pb.SyncFinishRequest,
|
401
|
+
) -> MailboxHandle[pb.Result]:
|
407
402
|
record = self._make_request(sync_finish=sync_finish)
|
408
403
|
return self._deliver_record(record)
|
409
404
|
|
410
|
-
def _deliver_run_start(
|
405
|
+
def _deliver_run_start(
|
406
|
+
self,
|
407
|
+
run_start: pb.RunStartRequest,
|
408
|
+
) -> MailboxHandle[pb.Result]:
|
411
409
|
record = self._make_request(run_start=run_start)
|
412
410
|
return self._deliver_record(record)
|
413
411
|
|
414
|
-
def _deliver_get_summary(
|
412
|
+
def _deliver_get_summary(
|
413
|
+
self,
|
414
|
+
get_summary: pb.GetSummaryRequest,
|
415
|
+
) -> MailboxHandle[pb.Result]:
|
415
416
|
record = self._make_request(get_summary=get_summary)
|
416
417
|
return self._deliver_record(record)
|
417
418
|
|
418
419
|
def _deliver_get_system_metrics(
|
419
420
|
self, get_system_metrics: pb.GetSystemMetricsRequest
|
420
|
-
) -> MailboxHandle:
|
421
|
+
) -> MailboxHandle[pb.Result]:
|
421
422
|
record = self._make_request(get_system_metrics=get_system_metrics)
|
422
423
|
return self._deliver_record(record)
|
423
424
|
|
424
425
|
def _deliver_get_system_metadata(
|
425
426
|
self, get_system_metadata: pb.GetSystemMetadataRequest
|
426
|
-
) -> MailboxHandle:
|
427
|
+
) -> MailboxHandle[pb.Result]:
|
427
428
|
record = self._make_request(get_system_metadata=get_system_metadata)
|
428
429
|
return self._deliver_record(record)
|
429
430
|
|
430
|
-
def _deliver_exit(
|
431
|
+
def _deliver_exit(
|
432
|
+
self,
|
433
|
+
exit_data: pb.RunExitRecord,
|
434
|
+
) -> MailboxHandle[pb.Result]:
|
431
435
|
record = self._make_record(exit=exit_data)
|
432
436
|
return self._deliver_record(record)
|
433
437
|
|
@@ -435,50 +439,53 @@ class InterfaceShared(InterfaceBase):
|
|
435
439
|
record = self._make_request(operation_stats=pb.OperationStatsRequest())
|
436
440
|
return self._deliver_record(record)
|
437
441
|
|
438
|
-
def _deliver_poll_exit(
|
442
|
+
def _deliver_poll_exit(
|
443
|
+
self,
|
444
|
+
poll_exit: pb.PollExitRequest,
|
445
|
+
) -> MailboxHandle[pb.Result]:
|
439
446
|
record = self._make_request(poll_exit=poll_exit)
|
440
447
|
return self._deliver_record(record)
|
441
448
|
|
442
449
|
def _deliver_finish_without_exit(
|
443
450
|
self, run_finish_without_exit: pb.RunFinishWithoutExitRequest
|
444
|
-
) -> MailboxHandle:
|
451
|
+
) -> MailboxHandle[pb.Result]:
|
445
452
|
record = self._make_request(run_finish_without_exit=run_finish_without_exit)
|
446
453
|
return self._deliver_record(record)
|
447
454
|
|
448
|
-
def _deliver_stop_status(
|
455
|
+
def _deliver_stop_status(
|
456
|
+
self,
|
457
|
+
stop_status: pb.StopStatusRequest,
|
458
|
+
) -> MailboxHandle[pb.Result]:
|
449
459
|
record = self._make_request(stop_status=stop_status)
|
450
460
|
return self._deliver_record(record)
|
451
461
|
|
452
|
-
def _deliver_attach(
|
462
|
+
def _deliver_attach(
|
463
|
+
self,
|
464
|
+
attach: pb.AttachRequest,
|
465
|
+
) -> MailboxHandle[pb.Result]:
|
453
466
|
record = self._make_request(attach=attach)
|
454
467
|
return self._deliver_record(record)
|
455
468
|
|
456
469
|
def _deliver_network_status(
|
457
470
|
self, network_status: pb.NetworkStatusRequest
|
458
|
-
) -> MailboxHandle:
|
471
|
+
) -> MailboxHandle[pb.Result]:
|
459
472
|
record = self._make_request(network_status=network_status)
|
460
473
|
return self._deliver_record(record)
|
461
474
|
|
462
475
|
def _deliver_internal_messages(
|
463
476
|
self, internal_message: pb.InternalMessagesRequest
|
464
|
-
) -> MailboxHandle:
|
477
|
+
) -> MailboxHandle[pb.Result]:
|
465
478
|
record = self._make_request(internal_messages=internal_message)
|
466
479
|
return self._deliver_record(record)
|
467
480
|
|
468
481
|
def _deliver_request_sampled_history(
|
469
482
|
self, sampled_history: pb.SampledHistoryRequest
|
470
|
-
) -> MailboxHandle:
|
483
|
+
) -> MailboxHandle[pb.Result]:
|
471
484
|
record = self._make_request(sampled_history=sampled_history)
|
472
485
|
return self._deliver_record(record)
|
473
486
|
|
474
487
|
def _deliver_request_run_status(
|
475
488
|
self, run_status: pb.RunStatusRequest
|
476
|
-
) -> MailboxHandle:
|
489
|
+
) -> MailboxHandle[pb.Result]:
|
477
490
|
record = self._make_request(run_status=run_status)
|
478
491
|
return self._deliver_record(record)
|
479
|
-
|
480
|
-
def join(self) -> None:
|
481
|
-
super().join()
|
482
|
-
|
483
|
-
if self._router:
|
484
|
-
self._router.join()
|
@@ -11,7 +11,6 @@ from wandb.sdk.mailbox import Mailbox
|
|
11
11
|
|
12
12
|
from ..lib.sock_client import SockClient
|
13
13
|
from .interface_shared import InterfaceShared
|
14
|
-
from .router_sock import MessageSockRouter
|
15
14
|
|
16
15
|
if TYPE_CHECKING:
|
17
16
|
from wandb.proto import wandb_internal_pb2 as pb
|
@@ -21,22 +20,16 @@ logger = logging.getLogger("wandb")
|
|
21
20
|
|
22
21
|
|
23
22
|
class InterfaceSock(InterfaceShared):
|
24
|
-
_mailbox: Mailbox
|
25
|
-
|
26
23
|
def __init__(
|
27
24
|
self,
|
28
25
|
sock_client: SockClient,
|
29
26
|
mailbox: Mailbox,
|
30
27
|
stream_id: str,
|
31
28
|
) -> None:
|
32
|
-
# _sock_client is used when abstract method _init_router() is called by constructor
|
33
|
-
self._sock_client = sock_client
|
34
29
|
super().__init__(mailbox=mailbox)
|
30
|
+
self._sock_client = sock_client
|
35
31
|
self._stream_id = stream_id
|
36
32
|
|
37
|
-
def _init_router(self) -> None:
|
38
|
-
self._router = MessageSockRouter(self._sock_client, mailbox=self._mailbox)
|
39
|
-
|
40
33
|
def _assign(self, record: Any) -> None:
|
41
34
|
assert self._stream_id
|
42
35
|
record._info.stream_id = self._stream_id
|
wandb/sdk/interface/router.py
CHANGED
@@ -4,21 +4,20 @@ Router to manage responses.
|
|
4
4
|
|
5
5
|
"""
|
6
6
|
|
7
|
+
from __future__ import annotations
|
8
|
+
|
7
9
|
import logging
|
8
10
|
import threading
|
9
|
-
import uuid
|
10
11
|
from abc import abstractmethod
|
11
|
-
from typing import TYPE_CHECKING
|
12
|
+
from typing import TYPE_CHECKING
|
12
13
|
|
14
|
+
from wandb.proto import wandb_internal_pb2 as pb
|
15
|
+
from wandb.proto import wandb_server_pb2 as spb
|
13
16
|
from wandb.sdk import mailbox
|
14
17
|
|
15
|
-
from .message_future import MessageFuture
|
16
|
-
|
17
18
|
if TYPE_CHECKING:
|
18
19
|
from queue import Queue
|
19
20
|
|
20
|
-
from wandb.proto import wandb_internal_pb2 as pb
|
21
|
-
|
22
21
|
|
23
22
|
logger = logging.getLogger("wandb")
|
24
23
|
|
@@ -27,26 +26,13 @@ class MessageRouterClosedError(Exception):
|
|
27
26
|
"""Router has been closed."""
|
28
27
|
|
29
28
|
|
30
|
-
class MessageFutureObject(MessageFuture):
|
31
|
-
def __init__(self) -> None:
|
32
|
-
super().__init__()
|
33
|
-
|
34
|
-
def get(self, timeout: Optional[int] = None) -> Optional["pb.Result"]:
|
35
|
-
is_set = self._object_ready.wait(timeout)
|
36
|
-
if is_set and self._object:
|
37
|
-
return self._object
|
38
|
-
return None
|
39
|
-
|
40
|
-
|
41
29
|
class MessageRouter:
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
_mailbox: Optional[mailbox.Mailbox]
|
30
|
+
_request_queue: Queue[pb.Record]
|
31
|
+
_response_queue: Queue[pb.Result]
|
32
|
+
_mailbox: mailbox.Mailbox | None
|
46
33
|
|
47
|
-
def __init__(self, mailbox:
|
34
|
+
def __init__(self, mailbox: mailbox.Mailbox | None = None) -> None:
|
48
35
|
self._mailbox = mailbox
|
49
|
-
self._pending_reqs = {}
|
50
36
|
self._lock = threading.Lock()
|
51
37
|
|
52
38
|
self._join_event = threading.Event()
|
@@ -56,11 +42,11 @@ class MessageRouter:
|
|
56
42
|
self._thread.start()
|
57
43
|
|
58
44
|
@abstractmethod
|
59
|
-
def _read_message(self) ->
|
45
|
+
def _read_message(self) -> pb.Result | spb.ServerResponse | None:
|
60
46
|
raise NotImplementedError
|
61
47
|
|
62
48
|
@abstractmethod
|
63
|
-
def _send_message(self, record:
|
49
|
+
def _send_message(self, record: pb.Record) -> None:
|
64
50
|
raise NotImplementedError
|
65
51
|
|
66
52
|
def message_loop(self) -> None:
|
@@ -84,38 +70,20 @@ class MessageRouter:
|
|
84
70
|
if self._mailbox:
|
85
71
|
self._mailbox.close()
|
86
72
|
|
87
|
-
def send_and_receive(
|
88
|
-
self, rec: "pb.Record", local: Optional[bool] = None
|
89
|
-
) -> MessageFuture:
|
90
|
-
rec.control.req_resp = True
|
91
|
-
if local:
|
92
|
-
rec.control.local = local
|
93
|
-
rec.uuid = uuid.uuid4().hex
|
94
|
-
future = MessageFutureObject()
|
95
|
-
with self._lock:
|
96
|
-
self._pending_reqs[rec.uuid] = future
|
97
|
-
|
98
|
-
self._send_message(rec)
|
99
|
-
|
100
|
-
return future
|
101
|
-
|
102
73
|
def join(self) -> None:
|
103
74
|
self._join_event.set()
|
104
75
|
self._thread.join()
|
105
76
|
|
106
|
-
def _handle_msg_rcv(self, msg:
|
107
|
-
|
108
|
-
if self._mailbox and msg.control.mailbox_slot:
|
109
|
-
self._mailbox.deliver(msg)
|
77
|
+
def _handle_msg_rcv(self, msg: pb.Result | spb.ServerResponse) -> None:
|
78
|
+
if not self._mailbox:
|
110
79
|
return
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
logger.warning(
|
118
|
-
"No listener found for msg with uuid %s (%s)", msg.uuid, msg
|
80
|
+
|
81
|
+
if isinstance(msg, pb.Result) and msg.control.mailbox_slot:
|
82
|
+
self._mailbox.deliver(
|
83
|
+
spb.ServerResponse(
|
84
|
+
request_id=msg.control.mailbox_slot,
|
85
|
+
result_communicate=msg,
|
119
86
|
)
|
120
|
-
|
121
|
-
|
87
|
+
)
|
88
|
+
elif isinstance(msg, spb.ServerResponse) and msg.request_id:
|
89
|
+
self._mailbox.deliver(msg)
|
@@ -4,9 +4,12 @@ Router to manage responses from a queue.
|
|
4
4
|
|
5
5
|
"""
|
6
6
|
|
7
|
+
from __future__ import annotations
|
8
|
+
|
7
9
|
import queue
|
8
|
-
from typing import TYPE_CHECKING
|
10
|
+
from typing import TYPE_CHECKING
|
9
11
|
|
12
|
+
from wandb.proto import wandb_internal_pb2 as pb
|
10
13
|
from wandb.sdk.mailbox import Mailbox
|
11
14
|
|
12
15
|
from .router import MessageRouter
|
@@ -14,29 +17,27 @@ from .router import MessageRouter
|
|
14
17
|
if TYPE_CHECKING:
|
15
18
|
from queue import Queue
|
16
19
|
|
17
|
-
from wandb.proto import wandb_internal_pb2 as pb
|
18
|
-
|
19
20
|
|
20
21
|
class MessageQueueRouter(MessageRouter):
|
21
|
-
_request_queue:
|
22
|
-
_response_queue:
|
22
|
+
_request_queue: Queue[pb.Record]
|
23
|
+
_response_queue: Queue[pb.Result]
|
23
24
|
|
24
25
|
def __init__(
|
25
26
|
self,
|
26
|
-
request_queue:
|
27
|
-
response_queue:
|
28
|
-
mailbox:
|
27
|
+
request_queue: Queue[pb.Record],
|
28
|
+
response_queue: Queue[pb.Result],
|
29
|
+
mailbox: Mailbox | None = None,
|
29
30
|
) -> None:
|
30
31
|
self._request_queue = request_queue
|
31
32
|
self._response_queue = response_queue
|
32
33
|
super().__init__(mailbox=mailbox)
|
33
34
|
|
34
|
-
def _read_message(self) ->
|
35
|
+
def _read_message(self) -> pb.Result | None:
|
35
36
|
try:
|
36
37
|
msg = self._response_queue.get(timeout=1)
|
37
38
|
except queue.Empty:
|
38
39
|
return None
|
39
40
|
return msg
|
40
41
|
|
41
|
-
def _send_message(self, record:
|
42
|
+
def _send_message(self, record: pb.Record) -> None:
|
42
43
|
self._request_queue.put(record)
|
@@ -4,8 +4,12 @@ Router to manage responses from a queue with relay.
|
|
4
4
|
|
5
5
|
"""
|
6
6
|
|
7
|
+
from __future__ import annotations
|
8
|
+
|
7
9
|
from typing import TYPE_CHECKING
|
8
10
|
|
11
|
+
from wandb.proto import wandb_internal_pb2 as pb
|
12
|
+
from wandb.proto import wandb_server_pb2 as spb
|
9
13
|
from wandb.sdk.mailbox import Mailbox
|
10
14
|
|
11
15
|
from .router_queue import MessageQueueRouter
|
@@ -13,26 +17,34 @@ from .router_queue import MessageQueueRouter
|
|
13
17
|
if TYPE_CHECKING:
|
14
18
|
from queue import Queue
|
15
19
|
|
16
|
-
from wandb.proto import wandb_internal_pb2 as pb
|
17
|
-
|
18
20
|
|
19
21
|
class MessageRelayRouter(MessageQueueRouter):
|
20
|
-
_relay_queue:
|
22
|
+
_relay_queue: Queue[pb.Result]
|
21
23
|
|
22
24
|
def __init__(
|
23
25
|
self,
|
24
|
-
request_queue:
|
25
|
-
response_queue:
|
26
|
-
relay_queue:
|
26
|
+
request_queue: Queue[pb.Record],
|
27
|
+
response_queue: Queue[pb.Result],
|
28
|
+
relay_queue: Queue[pb.Result],
|
27
29
|
mailbox: Mailbox,
|
28
30
|
) -> None:
|
29
31
|
self._relay_queue = relay_queue
|
30
32
|
super().__init__(
|
31
|
-
request_queue=request_queue,
|
33
|
+
request_queue=request_queue,
|
34
|
+
response_queue=response_queue,
|
35
|
+
mailbox=mailbox,
|
32
36
|
)
|
33
37
|
|
34
|
-
def _handle_msg_rcv(self, msg:
|
35
|
-
if msg.
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
def _handle_msg_rcv(self, msg: pb.Result | spb.ServerResponse) -> None:
|
39
|
+
if isinstance(msg, pb.Result):
|
40
|
+
relay_msg = msg
|
41
|
+
else:
|
42
|
+
relay_msg = msg.result_communicate
|
43
|
+
|
44
|
+
# This is legacy-service logic for returning responses to the client.
|
45
|
+
# A different thread reads the "relay queue" and writes responses on
|
46
|
+
# the socket.
|
47
|
+
if relay_msg.control.relay_id:
|
48
|
+
self._relay_queue.put(relay_msg)
|
49
|
+
else:
|
50
|
+
super()._handle_msg_rcv(msg)
|
@@ -4,16 +4,15 @@ Router to manage responses from a socket client.
|
|
4
4
|
|
5
5
|
"""
|
6
6
|
|
7
|
-
from
|
7
|
+
from __future__ import annotations
|
8
8
|
|
9
|
+
from wandb.proto import wandb_internal_pb2 as pb
|
10
|
+
from wandb.proto import wandb_server_pb2 as spb
|
9
11
|
from wandb.sdk.lib.sock_client import SockClient, SockClientClosedError
|
10
12
|
from wandb.sdk.mailbox import Mailbox
|
11
13
|
|
12
14
|
from .router import MessageRouter, MessageRouterClosedError
|
13
15
|
|
14
|
-
if TYPE_CHECKING:
|
15
|
-
from wandb.proto import wandb_internal_pb2 as pb
|
16
|
-
|
17
16
|
|
18
17
|
class MessageSockRouter(MessageRouter):
|
19
18
|
_sock_client: SockClient
|
@@ -23,15 +22,11 @@ class MessageSockRouter(MessageRouter):
|
|
23
22
|
self._sock_client = sock_client
|
24
23
|
super().__init__(mailbox=mailbox)
|
25
24
|
|
26
|
-
def _read_message(self) ->
|
25
|
+
def _read_message(self) -> spb.ServerResponse | None:
|
27
26
|
try:
|
28
|
-
|
27
|
+
return self._sock_client.read_server_response(timeout=1)
|
29
28
|
except SockClientClosedError as e:
|
30
29
|
raise MessageRouterClosedError from e
|
31
|
-
if not resp:
|
32
|
-
return None
|
33
|
-
msg = resp.result_communicate
|
34
|
-
return msg
|
35
30
|
|
36
|
-
def _send_message(self, record:
|
31
|
+
def _send_message(self, record: pb.Record) -> None:
|
37
32
|
self._sock_client.send_record_communicate(record)
|
wandb/sdk/internal/sender.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"""sender."""
|
2
2
|
|
3
3
|
import contextlib
|
4
|
+
import glob
|
4
5
|
import gzip
|
5
6
|
import json
|
6
7
|
import logging
|
@@ -1408,7 +1409,8 @@ class SendManager:
|
|
1408
1409
|
for k in files.files:
|
1409
1410
|
# TODO(jhr): fix paths with directories
|
1410
1411
|
self._save_file(
|
1411
|
-
interface.GlobStr(k.path),
|
1412
|
+
interface.GlobStr(glob.escape(k.path)),
|
1413
|
+
interface.file_enum_to_policy(k.policy),
|
1412
1414
|
)
|
1413
1415
|
|
1414
1416
|
def send_header(self, record: "Record") -> None:
|