id
int64
1
6.07M
name
stringlengths
1
295
code
stringlengths
12
426k
language
stringclasses
1 value
source_file
stringlengths
5
202
start_line
int64
1
158k
end_line
int64
1
158k
repo
dict
3,501
_communicate_sampled_history
def _communicate_sampled_history( self, sampled_history: pb.SampledHistoryRequest ) -> Optional[pb.SampledHistoryResponse]: record = self._make_request(sampled_history=sampled_history) result = self._communicate(record) if result is None: return None sampled_history_response = result.response.sampled_history_response assert sampled_history_response return sampled_history_response
python
wandb/sdk/interface/interface_shared.py
536
545
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,502
_communicate_shutdown
def _communicate_shutdown(self) -> None: # shutdown request = pb.Request(shutdown=pb.ShutdownRequest()) record = self._make_record(request=request) _ = self._communicate(record)
python
wandb/sdk/interface/interface_shared.py
547
551
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,503
_get_mailbox
def _get_mailbox(self) -> Mailbox: mailbox = self._mailbox assert mailbox return mailbox
python
wandb/sdk/interface/interface_shared.py
553
556
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,504
_deliver_record
def _deliver_record(self, record: pb.Record) -> MailboxHandle: mailbox = self._get_mailbox() handle = mailbox._deliver_record(record, interface=self) return handle
python
wandb/sdk/interface/interface_shared.py
558
561
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,505
_deliver_run
def _deliver_run(self, run: pb.RunRecord) -> MailboxHandle: record = self._make_record(run=run) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
563
565
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,506
_deliver_run_start
def _deliver_run_start(self, run_start: pb.RunStartRequest) -> MailboxHandle: record = self._make_request(run_start=run_start) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
567
569
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,507
_deliver_get_summary
def _deliver_get_summary(self, get_summary: pb.GetSummaryRequest) -> MailboxHandle: record = self._make_request(get_summary=get_summary) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
571
573
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,508
_deliver_exit
def _deliver_exit(self, exit_data: pb.RunExitRecord) -> MailboxHandle: record = self._make_record(exit=exit_data) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
575
577
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,509
_deliver_poll_exit
def _deliver_poll_exit(self, poll_exit: pb.PollExitRequest) -> MailboxHandle: record = self._make_request(poll_exit=poll_exit) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
579
581
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,510
_deliver_stop_status
def _deliver_stop_status(self, stop_status: pb.StopStatusRequest) -> MailboxHandle: record = self._make_request(stop_status=stop_status) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
583
585
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,511
_deliver_attach
def _deliver_attach(self, attach: pb.AttachRequest) -> MailboxHandle: record = self._make_request(attach=attach) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
587
589
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,512
_deliver_check_version
def _deliver_check_version( self, check_version: pb.CheckVersionRequest ) -> MailboxHandle: record = self._make_request(check_version=check_version) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
591
595
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,513
_deliver_network_status
def _deliver_network_status( self, network_status: pb.NetworkStatusRequest ) -> MailboxHandle: record = self._make_request(network_status=network_status) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
597
601
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,514
_deliver_request_server_info
def _deliver_request_server_info( self, server_info: pb.ServerInfoRequest ) -> MailboxHandle: record = self._make_request(server_info=server_info) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
603
607
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,515
_deliver_request_sampled_history
def _deliver_request_sampled_history( self, sampled_history: pb.SampledHistoryRequest ) -> MailboxHandle: record = self._make_request(sampled_history=sampled_history) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
609
613
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,516
_deliver_request_run_status
def _deliver_request_run_status( self, run_status: pb.RunStatusRequest ) -> MailboxHandle: record = self._make_request(run_status=run_status) return self._deliver_record(record)
python
wandb/sdk/interface/interface_shared.py
615
619
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,517
_transport_keepalive_failed
def _transport_keepalive_failed(self, keepalive_interval: int = 5) -> bool: if self._transport_failed: return True now = time.monotonic() if now < self._transport_success_timestamp + keepalive_interval: return False try: self.publish_keepalive() except Exception: self._transport_mark_failed() else: self._transport_mark_success() return self._transport_failed
python
wandb/sdk/interface/interface_shared.py
621
635
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,518
join
def join(self) -> None: super().join() if self._router: self._router.join()
python
wandb/sdk/interface/interface_shared.py
637
641
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,519
__init__
def __init__( self, record_q: Optional["Queue[pb.Record]"] = None, result_q: Optional["Queue[pb.Result]"] = None, process: Optional[BaseProcess] = None, process_check: bool = True, mailbox: Optional[Mailbox] = None, ) -> None: self.record_q = record_q self.result_q = result_q if self.record_q: tracelog.annotate_queue(self.record_q, "record_q") if self.result_q: tracelog.annotate_queue(self.result_q, "result_q") super().__init__(process=process, process_check=process_check, mailbox=mailbox)
python
wandb/sdk/interface/interface_queue.py
30
44
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,520
_init_router
def _init_router(self) -> None: if self.record_q and self.result_q: self._router = MessageQueueRouter( self.record_q, self.result_q, mailbox=self._mailbox )
python
wandb/sdk/interface/interface_queue.py
46
50
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,521
_publish
def _publish(self, record: "pb.Record", local: Optional[bool] = None) -> None: if self._process_check and self._process and not self._process.is_alive(): raise Exception("The wandb backend process has shutdown") if local: record.control.local = local if self.record_q: tracelog.log_message_queue(record, self.record_q) self.record_q.put(record)
python
wandb/sdk/interface/interface_queue.py
52
59
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,522
__init__
def __init__( self, request_queue: "Queue[pb.Record]", response_queue: "Queue[pb.Result]", relay_queue: "Queue[pb.Result]", mailbox: Mailbox, ) -> None: self._relay_queue = relay_queue super().__init__( request_queue=request_queue, response_queue=response_queue, mailbox=mailbox )
python
wandb/sdk/interface/router_relay.py
22
32
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,523
_handle_msg_rcv
def _handle_msg_rcv(self, msg: "pb.Result") -> None: if msg.control.relay_id: tracelog.log_message_queue(msg, self._relay_queue) self._relay_queue.put(msg) return super()._handle_msg_rcv(msg)
python
wandb/sdk/interface/router_relay.py
34
39
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,524
__init__
def __init__(self) -> None: self._object = None self._object_ready = threading.Event()
python
wandb/sdk/interface/message_future.py
17
19
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,525
_set_object
def _set_object(self, obj: pb.Result) -> None: self._object = obj self._object_ready.set()
python
wandb/sdk/interface/message_future.py
21
23
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,526
get
def get(self, timeout: Optional[int] = None) -> Optional[pb.Result]: raise NotImplementedError
python
wandb/sdk/interface/message_future.py
26
27
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,527
__init__
def __init__(self) -> None: super().__init__()
python
wandb/sdk/interface/router.py
32
33
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,528
get
def get(self, timeout: Optional[int] = None) -> Optional["pb.Result"]: is_set = self._object_ready.wait(timeout) if is_set and self._object: return self._object return None
python
wandb/sdk/interface/router.py
35
39
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,529
__init__
def __init__(self, mailbox: Optional[mailbox.Mailbox] = None) -> None: self._mailbox = mailbox self._pending_reqs = {} self._lock = threading.Lock() self._join_event = threading.Event() self._thread = threading.Thread(target=self.message_loop) self._thread.name = "MsgRouterThr" self._thread.daemon = True self._thread.start()
python
wandb/sdk/interface/router.py
48
57
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,530
_read_message
def _read_message(self) -> Optional["pb.Result"]: raise NotImplementedError
python
wandb/sdk/interface/router.py
60
61
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,531
_send_message
def _send_message(self, record: "pb.Record") -> None: raise NotImplementedError
python
wandb/sdk/interface/router.py
64
65
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,532
message_loop
def message_loop(self) -> None: while not self._join_event.is_set(): try: msg = self._read_message() except EOFError: # On abnormal shutdown the queue will be destroyed underneath # resulting in EOFError. message_loop needs to exit.. logger.warning("EOFError seen in message_loop") break except MessageRouterClosedError: logger.warning("message_loop has been closed") break if not msg: continue self._handle_msg_rcv(msg)
python
wandb/sdk/interface/router.py
67
81
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,533
send_and_receive
def send_and_receive( self, rec: "pb.Record", local: Optional[bool] = None ) -> MessageFuture: rec.control.req_resp = True if local: rec.control.local = local rec.uuid = uuid.uuid4().hex future = MessageFutureObject() with self._lock: self._pending_reqs[rec.uuid] = future self._send_message(rec) return future
python
wandb/sdk/interface/router.py
83
96
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,534
join
def join(self) -> None: self._join_event.set() self._thread.join()
python
wandb/sdk/interface/router.py
98
100
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,535
_handle_msg_rcv
def _handle_msg_rcv(self, msg: "pb.Result") -> None: # deliver mailbox addressed messages to mailbox if self._mailbox and msg.control.mailbox_slot: self._mailbox.deliver(msg) return with self._lock: future = self._pending_reqs.pop(msg.uuid, None) if future is None: # TODO (cvp): saw this in tests, seemed benign enough to ignore, but # could point to other issues. if msg.uuid != "": tracelog.log_message_assert(msg) logger.warning( "No listener found for msg with uuid %s (%s)", msg.uuid, msg ) return future._set_object(msg)
python
wandb/sdk/interface/router.py
102
118
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,536
__init__
def __init__(self, sock_client: SockClient, mailbox: Mailbox) -> None: # _sock_client is used when abstract method _init_router() is called by constructor self._sock_client = sock_client super().__init__(mailbox=mailbox) self._process_check = False self._stream_id = None
python
wandb/sdk/interface/interface_sock.py
30
35
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,537
_init_router
def _init_router(self) -> None: self._router = MessageSockRouter(self._sock_client, mailbox=self._mailbox)
python
wandb/sdk/interface/interface_sock.py
37
38
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,538
_hack_set_run
def _hack_set_run(self, run: "Run") -> None: super()._hack_set_run(run) assert run._run_id self._stream_id = run._run_id
python
wandb/sdk/interface/interface_sock.py
40
43
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,539
_assign
def _assign(self, record: Any) -> None: assert self._stream_id record._info.stream_id = self._stream_id
python
wandb/sdk/interface/interface_sock.py
45
47
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,540
_publish
def _publish(self, record: "pb.Record", local: Optional[bool] = None) -> None: self._assign(record) self._sock_client.send_record_publish(record)
python
wandb/sdk/interface/interface_sock.py
49
51
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,541
_communicate_async
def _communicate_async( self, rec: "pb.Record", local: Optional[bool] = None ) -> MessageFuture: self._assign(rec) assert self._router if self._process_check and self._process and not self._process.is_alive(): raise Exception("The wandb backend process has shutdown") future = self._router.send_and_receive(rec, local=local) return future
python
wandb/sdk/interface/interface_sock.py
53
61
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,542
_communicate_stop_status
def _communicate_stop_status( self, status: "pb.StopStatusRequest" ) -> Optional["pb.StopStatusResponse"]: # Message stop_status is called from a daemon thread started by wandb_run # The underlying socket might go away while the thread is still running. # Handle this like a timed-out message as the daemon thread will eventually # be killed. try: data = super()._communicate_stop_status(status) except BrokenPipeError: data = None return data
python
wandb/sdk/interface/interface_sock.py
63
74
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,543
_communicate_network_status
def _communicate_network_status( self, status: "pb.NetworkStatusRequest" ) -> Optional["pb.NetworkStatusResponse"]: # Message network_status is called from a daemon thread started by wandb_run # The underlying socket might go away while the thread is still running. # Handle this like a timed-out message as the daemon thread will eventually # be killed. try: data = super()._communicate_network_status(status) except BrokenPipeError: data = None return data
python
wandb/sdk/interface/interface_sock.py
76
87
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,544
__init__
def __init__( self, artifact: Optional["Artifact"] = None, attr: Optional[str] = None, msg: str = "Artifact is in an invalid state for the requested operation.", ): object_name = artifact.__class__.__name__ if artifact else "Artifact" method_id = f"{object_name}.{attr}" if attr else object_name super().__init__(msg.format(artifact=artifact, attr=attr, method_id=method_id)) # Follow the same pattern as AttributeError. self.obj = artifact self.name = attr
python
wandb/sdk/interface/artifacts/artifact.py
15
26
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,545
__init__
def __init__( self, artifact: Optional["Artifact"] = None, attr: Optional[str] = None ): super().__init__( artifact, attr, "'{method_id}' used prior to logging artifact or while in offline mode. " "Call wait() before accessing logged artifact properties.", )
python
wandb/sdk/interface/artifacts/artifact.py
32
40
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,546
__init__
def __init__( self, artifact: Optional["Artifact"] = None, attr: Optional[str] = None ): super().__init__( artifact, attr, "'{method_id}' used on logged artifact. Can't add to finalized artifact.", )
python
wandb/sdk/interface/artifacts/artifact.py
46
53
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,547
id
def id(self) -> Optional[str]: """The artifact's ID.""" raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
58
60
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,548
version
def version(self) -> str: """The version of this artifact. For example, if this is the first version of an artifact, its `version` will be 'v0'. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
63
69
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,549
source_version
def source_version(self) -> Optional[str]: """The artifact's version index under its parent artifact collection. A string with the format "v{number}". """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
72
77
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,550
name
def name(self) -> str: """The artifact's name.""" raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
80
82
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,551
type
def type(self) -> str: """The artifact's type.""" raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
85
87
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,552
entity
def entity(self) -> str: """The name of the entity this artifact belongs to.""" raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
90
92
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,553
project
def project(self) -> str: """The name of the project this artifact belongs to.""" raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
95
97
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,554
manifest
def manifest(self) -> "ArtifactManifest": """The artifact's manifest. The manifest lists all of its contents, and can't be changed once the artifact has been logged. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
100
106
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,555
digest
def digest(self) -> str: """The logical digest of the artifact. The digest is the checksum of the artifact's contents. If an artifact has the same digest as the current `latest` version, then `log_artifact` is a no-op. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
109
115
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,556
state
def state(self) -> str: """The status of the artifact. One of: "PENDING", "COMMITTED", or "DELETED".""" raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
118
120
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,557
size
def size(self) -> int: """The total size of the artifact in bytes. Returns: (int): The size in bytes of the artifact. Includes any references tracked by this artifact. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
123
130
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,558
commit_hash
def commit_hash(self) -> str: """The hash returned when this artifact was committed. Returns: (str): The artifact's commit hash which is used in http URLs. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
133
139
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,559
description
def description(self) -> Optional[str]: """The artifact description. Returns: (str): Free text that offers a user-set description of the artifact. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
142
148
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,560
description
def description(self, desc: Optional[str]) -> None: """Set the description of the artifact. The description is markdown rendered in the UI, so this is a good place to put links, etc. Arguments: desc: Free text that offers a description of the artifact. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
151
160
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,561
metadata
def metadata(self) -> dict: """User-defined artifact metadata. Returns: (dict): Structured data associated with the artifact. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
163
169
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,562
metadata
def metadata(self, metadata: dict) -> None: """User-defined artifact metadata. Metadata set this way will eventually be queryable and plottable in the UI; e.g. the class distribution of a dataset. Note: There is currently a limit of 100 total keys. Arguments: metadata: (dict) Structured data associated with the artifact. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
172
183
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,563
aliases
def aliases(self) -> List[str]: """The aliases associated with this artifact. The list is mutable and calling `save()` will persist all alias changes. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
186
191
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,564
aliases
def aliases(self, aliases: List[str]) -> None: """Set the aliases associated with this artifact.""" raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
194
196
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,565
used_by
def used_by(self) -> List["wandb.apis.public.Run"]: """Get a list of the runs that have used this artifact.""" raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
198
200
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,566
logged_by
def logged_by(self) -> "wandb.apis.public.Run": """Get the run that first logged this artifact.""" raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
202
204
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,567
new_file
def new_file( self, name: str, mode: str = "w", encoding: Optional[str] = None ) -> ContextManager[IO]: """Open a new temporary file that will be automatically added to the artifact. Arguments: name: (str) The name of the new file being added to the artifact. mode: (str, optional) The mode in which to open the new file. encoding: (str, optional) The encoding in which to open the new file. Examples: ``` artifact = wandb.Artifact('my_data', type='dataset') with artifact.new_file('hello.txt') as f: f.write('hello!') wandb.log_artifact(artifact) ``` Returns: (file): A new file object that can be written to. Upon closing, the file will be automatically added to the artifact. Raises: ArtifactFinalizedError: if the artifact has already been finalized. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
206
231
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,568
add_file
def add_file( self, local_path: str, name: Optional[str] = None, is_tmp: Optional[bool] = False, ) -> "ArtifactManifestEntry": """Add a local file to the artifact. Arguments: local_path: (str) The path to the file being added. name: (str, optional) The path within the artifact to use for the file being added. Defaults to the basename of the file. is_tmp: (bool, optional) If true, then the file is renamed deterministically to avoid collisions. (default: False) Examples: Add a file without an explicit name: ``` # Add as `file.txt' artifact.add_file('path/to/file.txt') ``` Add a file with an explicit name: ``` # Add as 'new/path/file.txt' artifact.add_file('path/to/file.txt', name='new/path/file.txt') ``` Raises: ArtifactFinalizedError: if the artifact has already been finalized. Returns: ArtifactManifestEntry: the added manifest entry """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
233
268
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,569
add_dir
def add_dir(self, local_path: str, name: Optional[str] = None) -> None: """Add a local directory to the artifact. Arguments: local_path: (str) The path to the directory being added. name: (str, optional) The path within the artifact to use for the directory being added. Defaults to the root of the artifact. Examples: Add a directory without an explicit name: ``` # All files in `my_dir/` are added at the root of the artifact. artifact.add_dir('my_dir/') ``` Add a directory and name it explicitly: ``` # All files in `my_dir/` are added under `destination/`. artifact.add_dir('my_dir/', name='destination') ``` Raises: ArtifactFinalizedError: if the artifact has already been finalized. Returns: None """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
270
297
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,570
add_reference
def add_reference( self, uri: Union["ArtifactManifestEntry", str], name: Optional[str] = None, checksum: bool = True, max_objects: Optional[int] = None, ) -> Sequence["ArtifactManifestEntry"]: """Add a reference denoted by a URI to the artifact. Unlike adding files or directories, references are NOT uploaded to W&B. However, artifact methods such as `download()` can be used regardless of whether the artifact contains references or uploaded files. By default, W&B offers special handling for the following schemes: - http(s): The size and digest of the file will be inferred by the `Content-Length` and the `ETag` response headers returned by the server. - s3: The checksum and size will be pulled from the object metadata. If bucket versioning is enabled, then the version ID is also tracked. - gs: The checksum and size will be pulled from the object metadata. If bucket versioning is enabled, then the version ID is also tracked. - file: The checksum and size will be pulled from the file system. This scheme is useful if you have an NFS share or other externally mounted volume containing files you wish to track but not necessarily upload. For any other scheme, the digest is just a hash of the URI and the size is left blank. Arguments: uri: (str) The URI path of the reference to add. Can be an object returned from Artifact.get_path to store a reference to another artifact's entry. name: (str) The path within the artifact to place the contents of this reference checksum: (bool, optional) Whether or not to checksum the resource(s) located at the reference URI. Checksumming is strongly recommended as it enables automatic integrity validation, however it can be disabled to speed up artifact creation. (default: True) max_objects: (int, optional) The maximum number of objects to consider when adding a reference that points to directory or bucket store prefix. For S3 and GCS, this limit is 10,000 by default but is uncapped for other URI schemes. (default: None) Raises: ArtifactFinalizedError: if the artifact has already been finalized. Returns: List["ArtifactManifestEntry"]: The added manifest entries. Examples: Add an HTTP link: ```python # Adds `file.txt` to the root of the artifact as a reference. artifact.add_reference("http://myserver.com/file.txt") ``` Add an S3 prefix without an explicit name: ```python # All objects under `prefix/` will be added at the root of the artifact. artifact.add_reference("s3://mybucket/prefix") ``` Add a GCS prefix with an explicit name: ```python # All objects under `prefix/` will be added under `path/` at the artifact root. artifact.add_reference("gs://mybucket/prefix", name="path") ``` """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
299
368
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,571
add
def add(self, obj: WBValue, name: str) -> "ArtifactManifestEntry": """Add wandb.WBValue `obj` to the artifact. ``` obj = artifact.get(name) ``` Arguments: obj: (wandb.WBValue) The object to add. Currently support one of Bokeh, JoinedTable, PartitionedTable, Table, Classes, ImageMask, BoundingBoxes2D, Audio, Image, Video, Html, Object3D name: (str) The path within the artifact to add the object. Returns: ArtifactManifestEntry: the added manifest entry Raises: ArtifactFinalizedError: if the artifact has already been finalized. Examples: Basic usage ``` artifact = wandb.Artifact('my_table', 'dataset') table = wandb.Table(columns=["a", "b", "c"], data=[[i, i*2, 2**i]]) artifact.add(table, "my_table") wandb.log_artifact(artifact) ``` Retrieve an object: ``` artifact = wandb.use_artifact('my_table:latest') table = artifact.get("my_table") ``` """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
370
405
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,572
get_path
def get_path(self, name: str) -> "ArtifactManifestEntry": """Get the path to the file located at the artifact relative `name`. Arguments: name: (str) The artifact relative name to get Raises: ArtifactNotLoggedError: if the artifact isn't logged or the run is offline Examples: Basic usage ``` # Run logging the artifact with wandb.init() as r: artifact = wandb.Artifact('my_dataset', type='dataset') artifact.add_file('path/to/file.txt') wandb.log_artifact(artifact) # Run using the artifact with wandb.init() as r: artifact = r.use_artifact('my_dataset:latest') path = artifact.get_path('file.txt') # Can now download 'file.txt' directly: path.download() ``` """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
407
434
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,573
get
def get(self, name: str) -> WBValue: """Get the WBValue object located at the artifact relative `name`. Arguments: name: (str) The artifact relative name to get Raises: ArtifactNotLoggedError: if the artifact isn't logged or the run is offline Examples: Basic usage ``` # Run logging the artifact with wandb.init() as r: artifact = wandb.Artifact('my_dataset', type='dataset') table = wandb.Table(columns=["a", "b", "c"], data=[[i, i*2, 2**i]]) artifact.add(table, "my_table") wandb.log_artifact(artifact) # Run using the artifact with wandb.init() as r: artifact = r.use_artifact('my_dataset:latest') table = r.get('my_table') ``` """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
436
461
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,574
download
def download( self, root: Optional[str] = None, recursive: bool = False ) -> FilePathStr: """Download the contents of the artifact to the specified root directory. NOTE: Any existing files at `root` are left untouched. Explicitly delete root before calling `download` if you want the contents of `root` to exactly match the artifact. Arguments: root: (str, optional) The directory in which to download this artifact's files. recursive: (bool, optional) If true, then all dependent artifacts are eagerly downloaded. Otherwise, the dependent artifacts are downloaded as needed. Returns: (str): The path to the downloaded contents. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
463
480
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,575
checkout
def checkout(self, root: Optional[str] = None) -> str: """Replace the specified root directory with the contents of the artifact. WARNING: This will DELETE all files in `root` that are not included in the artifact. Arguments: root: (str, optional) The directory to replace with this artifact's files. Returns: (str): The path to the checked out contents. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
482
494
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,576
verify
def verify(self, root: Optional[str] = None) -> bool: """Verify that the actual contents of an artifact match the manifest. All files in the directory are checksummed and the checksums are then cross-referenced against the artifact's manifest. NOTE: References are not verified. Arguments: root: (str, optional) The directory to verify. If None artifact will be downloaded to './artifacts/self.name/' Raises: (ValueError): If the verification fails. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
496
511
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,577
save
def save(self) -> None: """Persist any changes made to the artifact. Returns: None """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
513
519
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,578
link
def link(self, target_path: str, aliases: Optional[List[str]] = None) -> None: """Link this artifact to a portfolio (a promoted collection of artifacts), with aliases. Arguments: target_path: (str) The path to the portfolio. It must take the form {portfolio}, {project}/{portfolio} or {entity}/{project}/{portfolio}. aliases: (Optional[List[str]]) A list of strings which uniquely identifies the artifact inside the specified portfolio. Returns: None """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
521
533
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,579
delete
def delete(self) -> None: """Delete this artifact, cleaning up all files associated with it. NOTE: Deletion is permanent and CANNOT be undone. Returns: None """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
535
543
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,580
wait
def wait(self) -> "Artifact": """Wait for this artifact to finish logging, if needed. Returns: Artifact """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact.py
545
551
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,581
__getitem__
def __getitem__(self, name: str) -> Optional[WBValue]: """Get the WBValue object located at the artifact relative `name`. Arguments: name: (str) The artifact relative name to get Raises: ArtifactNotLoggedError: if the artifact isn't logged or the run is offline Examples: Basic usage ``` artifact = wandb.Artifact('my_table', 'dataset') table = wandb.Table(columns=["a", "b", "c"], data=[[i, i*2, 2**i]]) artifact["my_table"] = table wandb.log_artifact(artifact) ``` Retrieving an object: ``` artifact = wandb.use_artifact('my_table:latest') table = artifact["my_table"] ``` """ return self.get(name)
python
wandb/sdk/interface/artifacts/artifact.py
553
578
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,582
__setitem__
def __setitem__(self, name: str, item: WBValue) -> "ArtifactManifestEntry": """Add `item` to the artifact at path `name`. Arguments: name: (str) The path within the artifact to add the object. item: (wandb.WBValue) The object to add. Returns: ArtifactManifestEntry: the added manifest entry Raises: ArtifactFinalizedError: if the artifact has already been finalized. Examples: Basic usage ``` artifact = wandb.Artifact('my_table', 'dataset') table = wandb.Table(columns=["a", "b", "c"], data=[[i, i*2, 2**i]]) artifact["my_table"] = table wandb.log_artifact(artifact) ``` Retrieving an object: ``` artifact = wandb.use_artifact('my_table:latest') table = artifact["my_table"] ``` """ return self.add(item, name)
python
wandb/sdk/interface/artifacts/artifact.py
580
609
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,583
__call__
def __call__(self, mode: str = ...) -> ContextManager[IO]: pass
python
wandb/sdk/interface/artifacts/artifact_cache.py
24
25
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,584
__init__
def __init__(self, cache_dir: StrPath) -> None: self._cache_dir = cache_dir mkdir_exists_ok(self._cache_dir) self._md5_obj_dir = os.path.join(self._cache_dir, "obj", "md5") self._etag_obj_dir = os.path.join(self._cache_dir, "obj", "etag") self._artifacts_by_id: Dict[str, Artifact] = {} self._artifacts_by_client_id: Dict[str, "wandb_artifacts.Artifact"] = {}
python
wandb/sdk/interface/artifacts/artifact_cache.py
31
37
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,585
check_md5_obj_path
def check_md5_obj_path( self, b64_md5: B64MD5, size: int ) -> Tuple[FilePathStr, bool, "Opener"]: hex_md5 = b64_to_hex_id(b64_md5) path = os.path.join(self._cache_dir, "obj", "md5", hex_md5[:2], hex_md5[2:]) opener = self._cache_opener(path) if os.path.isfile(path) and os.path.getsize(path) == size: return FilePathStr(path), True, opener mkdir_exists_ok(os.path.dirname(path)) return FilePathStr(path), False, opener
python
wandb/sdk/interface/artifacts/artifact_cache.py
39
48
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,586
check_etag_obj_path
def check_etag_obj_path( self, url: URIStr, etag: ETag, size: int, ) -> Tuple[FilePathStr, bool, "Opener"]: hexhash = hashlib.sha256( hashlib.sha256(url.encode("utf-8")).digest() + hashlib.sha256(etag.encode("utf-8")).digest() ).hexdigest() path = os.path.join(self._cache_dir, "obj", "etag", hexhash[:2], hexhash[2:]) opener = self._cache_opener(path) if os.path.isfile(path) and os.path.getsize(path) == size: return FilePathStr(path), True, opener mkdir_exists_ok(os.path.dirname(path)) return FilePathStr(path), False, opener
python
wandb/sdk/interface/artifacts/artifact_cache.py
52
67
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,587
get_artifact
def get_artifact(self, artifact_id: str) -> Optional["Artifact"]: return self._artifacts_by_id.get(artifact_id)
python
wandb/sdk/interface/artifacts/artifact_cache.py
69
70
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,588
store_artifact
def store_artifact(self, artifact: "Artifact") -> None: if not artifact.id: raise ArtifactNotLoggedError(artifact, "store_artifact") self._artifacts_by_id[artifact.id] = artifact
python
wandb/sdk/interface/artifacts/artifact_cache.py
72
75
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,589
get_client_artifact
def get_client_artifact( self, client_id: str ) -> Optional["wandb_artifacts.Artifact"]: return self._artifacts_by_client_id.get(client_id)
python
wandb/sdk/interface/artifacts/artifact_cache.py
77
80
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,590
store_client_artifact
def store_client_artifact(self, artifact: "wandb_artifacts.Artifact") -> None: self._artifacts_by_client_id[artifact._client_id] = artifact
python
wandb/sdk/interface/artifacts/artifact_cache.py
82
83
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,591
cleanup
def cleanup(self, target_size: int) -> int: bytes_reclaimed = 0 paths = {} total_size = 0 for root, _, files in os.walk(self._cache_dir): for file in files: try: path = str(os.path.join(root, file)) stat = os.stat(path) if file.startswith(ArtifactsCache._TMP_PREFIX): os.remove(path) bytes_reclaimed += stat.st_size continue except OSError: continue paths[path] = stat total_size += stat.st_size sorted_paths = sorted(paths.items(), key=lambda x: x[1].st_atime) for path, stat in sorted_paths: if total_size < target_size: return bytes_reclaimed try: os.remove(path) except OSError: pass total_size -= stat.st_size bytes_reclaimed += stat.st_size return bytes_reclaimed
python
wandb/sdk/interface/artifacts/artifact_cache.py
85
116
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,592
_cache_opener
def _cache_opener(self, path: StrPath) -> "Opener": @contextlib.contextmanager def helper(mode: str = "w") -> Generator[IO, None, None]: if "a" in mode: raise ValueError("Appending to cache files is not supported") dirname = os.path.dirname(path) tmp_file = os.path.join( dirname, f"{ArtifactsCache._TMP_PREFIX}_{secrets.token_hex(8)}" ) with util.fsync_open(tmp_file, mode=mode) as f: yield f try: # Use replace where we can, as it implements an atomic # move on most platforms. If it doesn't exist, we have # to use rename which isn't atomic in all cases but there # isn't a better option. # # The atomic replace is important in the event multiple processes # attempt to write to / read from the cache at the same time. Each # writer firsts stages its writes to a temporary file in the cache. # Once it is finished, we issue an atomic replace operation to update # the cache. Although this can result in redundant downloads, this # guarantees that readers can NEVER read incomplete files from the # cache. # # IMPORTANT: Replace is NOT atomic across different filesystems. This why # it is critical that the temporary files sit directly in the cache -- # they need to be on the same filesystem! os.replace(tmp_file, path) except AttributeError: os.rename(tmp_file, path) return helper
python
wandb/sdk/interface/artifacts/artifact_cache.py
118
152
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,593
helper
def helper(mode: str = "w") -> Generator[IO, None, None]: if "a" in mode: raise ValueError("Appending to cache files is not supported") dirname = os.path.dirname(path) tmp_file = os.path.join( dirname, f"{ArtifactsCache._TMP_PREFIX}_{secrets.token_hex(8)}" ) with util.fsync_open(tmp_file, mode=mode) as f: yield f try: # Use replace where we can, as it implements an atomic # move on most platforms. If it doesn't exist, we have # to use rename which isn't atomic in all cases but there # isn't a better option. # # The atomic replace is important in the event multiple processes # attempt to write to / read from the cache at the same time. Each # writer firsts stages its writes to a temporary file in the cache. # Once it is finished, we issue an atomic replace operation to update # the cache. Although this can result in redundant downloads, this # guarantees that readers can NEVER read incomplete files from the # cache. # # IMPORTANT: Replace is NOT atomic across different filesystems. This why # it is critical that the temporary files sit directly in the cache -- # they need to be on the same filesystem! os.replace(tmp_file, path) except AttributeError: os.rename(tmp_file, path)
python
wandb/sdk/interface/artifacts/artifact_cache.py
120
150
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,594
get_artifacts_cache
def get_artifacts_cache() -> ArtifactsCache: global _artifacts_cache if _artifacts_cache is None: cache_dir = os.path.join(env.get_cache_dir(), "artifacts") _artifacts_cache = ArtifactsCache(cache_dir) return _artifacts_cache
python
wandb/sdk/interface/artifacts/artifact_cache.py
158
163
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,595
__post_init__
def __post_init__(self) -> None: self.path = util.to_forward_slash_path(self.path) self.extra = self.extra or {} if self.local_path and self.size is None: raise ValueError("size required when local_path specified")
python
wandb/sdk/interface/artifacts/artifact_manifest.py
23
27
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,596
parent_artifact
def parent_artifact(self) -> "Artifact": """Get the artifact to which this artifact entry belongs. Returns: (Artifact): The parent artifact """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact_manifest.py
29
35
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,597
download
def download(self, root: Optional[str] = None) -> FilePathStr: """Download this artifact entry to the specified root path. Arguments: root: (str, optional) The root path in which to download this artifact entry. Defaults to the artifact's root. Returns: (str): The path of the downloaded artifact entry. """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact_manifest.py
37
48
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,598
ref_target
def ref_target(self) -> str: """Get the reference URL that is targeted by this artifact entry. Returns: (str): The reference URL of this artifact entry. Raises: ValueError: If this artifact entry was not a reference. """ if self.ref is None: raise ValueError("Only reference entries support ref_target().") return self.ref
python
wandb/sdk/interface/artifacts/artifact_manifest.py
50
61
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,599
ref_url
def ref_url(self) -> str: """Get a URL to this artifact entry. These URLs can be referenced by another artifact. Returns: (str): A URL representing this artifact entry. Examples: Basic usage ``` ref_url = source_artifact.get_path('file.txt').ref_url() derived_artifact.add_reference(ref_url) ``` """ raise NotImplementedError
python
wandb/sdk/interface/artifacts/artifact_manifest.py
63
78
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,600
from_manifest_json
def from_manifest_json(cls, manifest_json: Dict) -> "ArtifactManifest": if "version" not in manifest_json: raise ValueError("Invalid manifest format. Must contain version field.") version = manifest_json["version"] for sub in cls.__subclasses__(): if sub.version() == version: return sub.from_manifest_json(manifest_json) raise ValueError("Invalid manifest version.")
python
wandb/sdk/interface/artifacts/artifact_manifest.py
85
92
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }