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 |
|---|---|---|---|---|---|---|---|
4,201 | send_config | def send_config(self, record: "Record") -> None:
cfg = record.config
config_util.update_from_proto(self._consolidated_config, cfg)
self._update_config() | python | wandb/sdk/internal/sender.py | 1,321 | 1,324 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,202 | send_metric | def send_metric(self, record: "Record") -> None:
metric = record.metric
if metric.glob_name:
logger.warning("Seen metric with glob (shouldn't happen)")
return
# merge or overwrite
old_metric = self._config_metric_dict.get(
metric.name, wandb_internal_pb2.MetricRecord()
)
if metric._control.overwrite:
old_metric.CopyFrom(metric)
else:
old_metric.MergeFrom(metric)
self._config_metric_dict[metric.name] = old_metric
metric = old_metric
# convert step_metric to index
if metric.step_metric:
find_step_idx = self._config_metric_index_dict.get(metric.step_metric)
if find_step_idx is not None:
# make a copy of this metric as we will be modifying it
rec = wandb_internal_pb2.Record()
rec.metric.CopyFrom(metric)
metric = rec.metric
metric.ClearField("step_metric")
metric.step_metric_index = find_step_idx + 1
md: Dict[int, Any] = proto_util.proto_encode_to_dict(metric)
find_idx = self._config_metric_index_dict.get(metric.name)
if find_idx is not None:
self._config_metric_pbdict_list[find_idx] = md
else:
next_idx = len(self._config_metric_pbdict_list)
self._config_metric_pbdict_list.append(md)
self._config_metric_index_dict[metric.name] = next_idx
self._update_config() | python | wandb/sdk/internal/sender.py | 1,326 | 1,363 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,203 | _update_telemetry_record | def _update_telemetry_record(self, telemetry: telemetry.TelemetryRecord) -> None:
self._telemetry_obj.MergeFrom(telemetry)
self._update_config() | python | wandb/sdk/internal/sender.py | 1,365 | 1,367 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,204 | send_telemetry | def send_telemetry(self, record: "Record") -> None:
self._update_telemetry_record(record.telemetry) | python | wandb/sdk/internal/sender.py | 1,369 | 1,370 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,205 | send_request_telemetry_record | def send_request_telemetry_record(self, record: "Record") -> None:
self._update_telemetry_record(record.request.telemetry_record.telemetry) | python | wandb/sdk/internal/sender.py | 1,372 | 1,373 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,206 | _save_file | def _save_file(
self, fname: interface.GlobStr, policy: "interface.PolicyName" = "end"
) -> None:
logger.info("saving file %s with policy %s", fname, policy)
if self._dir_watcher:
self._dir_watcher.update_policy(fname, policy) | python | wandb/sdk/internal/sender.py | 1,375 | 1,380 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,207 | send_files | def send_files(self, record: "Record") -> None:
files = record.files
for k in files.files:
# TODO(jhr): fix paths with directories
self._save_file(
interface.GlobStr(k.path), interface.file_enum_to_policy(k.policy)
) | python | wandb/sdk/internal/sender.py | 1,382 | 1,388 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,208 | send_header | def send_header(self, record: "Record") -> None:
pass | python | wandb/sdk/internal/sender.py | 1,390 | 1,391 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,209 | send_footer | def send_footer(self, record: "Record") -> None:
pass | python | wandb/sdk/internal/sender.py | 1,393 | 1,394 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,210 | send_tbrecord | def send_tbrecord(self, record: "Record") -> None:
# tbrecord watching threads are handled by handler.py
pass | python | wandb/sdk/internal/sender.py | 1,396 | 1,398 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,211 | send_link_artifact | def send_link_artifact(self, record: "Record") -> None:
link = record.link_artifact
client_id = link.client_id
server_id = link.server_id
portfolio_name = link.portfolio_name
entity = link.portfolio_entity
project = link.portfolio_project
aliases = link.portfolio_aliases
logger.debug(
f"link_artifact params - client_id={client_id}, server_id={server_id}, pfolio={portfolio_name}, entity={entity}, project={project}"
)
if (client_id or server_id) and portfolio_name and entity and project:
try:
self._api.link_artifact(
client_id, server_id, portfolio_name, entity, project, aliases
)
except Exception as e:
logger.warning("Failed to link artifact to portfolio: %s", e) | python | wandb/sdk/internal/sender.py | 1,400 | 1,417 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,212 | send_use_artifact | def send_use_artifact(self, record: "Record") -> None:
"""Pretend to send a used artifact.
This function doesn't actually send anything, it is just used internally.
"""
use = record.use_artifact
if use.type == "job":
self._job_builder.disable = True | python | wandb/sdk/internal/sender.py | 1,419 | 1,426 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,213 | send_request_log_artifact | def send_request_log_artifact(self, record: "Record") -> None:
assert record.control.req_resp
result = proto_util._result_from_record(record)
artifact = record.request.log_artifact.artifact
history_step = record.request.log_artifact.history_step
try:
res = self._send_artifact(artifact, history_step)
assert res, "Unable to send artifact"
result.response.log_artifact_response.artifact_id = res["id"]
logger.info(f"logged artifact {artifact.name} - {res}")
except Exception as e:
result.response.log_artifact_response.error_message = (
'error logging artifact "{}/{}": {}'.format(
artifact.type, artifact.name, e
)
)
self._respond_result(result) | python | wandb/sdk/internal/sender.py | 1,428 | 1,446 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,214 | send_request_artifact_send | def send_request_artifact_send(self, record: "Record") -> None:
# TODO: combine and eventually remove send_request_log_artifact()
# for now, we are using req/resp uuid for transaction id
# in the future this should be part of the message to handle idempotency
xid = record.uuid
done_msg = wandb_internal_pb2.ArtifactDoneRequest(xid=xid)
artifact = record.request.artifact_send.artifact
try:
res = self._send_artifact(artifact)
assert res, "Unable to send artifact"
done_msg.artifact_id = res["id"]
logger.info(f"logged artifact {artifact.name} - {res}")
except Exception as e:
done_msg.error_message = 'error logging artifact "{}/{}": {}'.format(
artifact.type, artifact.name, e
)
logger.info("send artifact done")
self._interface._publish_artifact_done(done_msg) | python | wandb/sdk/internal/sender.py | 1,448 | 1,468 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,215 | send_artifact | def send_artifact(self, record: "Record") -> None:
artifact = record.artifact
try:
res = self._send_artifact(artifact)
logger.info(f"sent artifact {artifact.name} - {res}")
except Exception as e:
logger.error(
'send_artifact: failed for artifact "{}/{}": {}'.format(
artifact.type, artifact.name, e
)
) | python | wandb/sdk/internal/sender.py | 1,470 | 1,480 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,216 | _send_artifact | def _send_artifact(
self, artifact: "ArtifactRecord", history_step: Optional[int] = None
) -> Optional[Dict]:
from pkg_resources import parse_version
assert self._pusher
saver = artifacts.ArtifactSaver(
api=self._api,
digest=artifact.digest,
manifest_json=_manifest_json_from_proto(artifact.manifest),
file_pusher=self._pusher,
is_user_created=artifact.user_created,
)
if artifact.distributed_id:
max_cli_version = self._max_cli_version()
if max_cli_version is None or parse_version(
max_cli_version
) < parse_version("0.10.16"):
logger.warning(
"This W&B Server doesn't support distributed artifacts, "
"have your administrator install wandb/local >= 0.9.37"
)
return None
metadata = json.loads(artifact.metadata) if artifact.metadata else None
res = saver.save(
type=artifact.type,
name=artifact.name,
client_id=artifact.client_id,
sequence_client_id=artifact.sequence_client_id,
metadata=metadata,
description=artifact.description,
aliases=artifact.aliases,
use_after_commit=artifact.use_after_commit,
distributed_id=artifact.distributed_id,
finalize=artifact.finalize,
incremental=artifact.incremental_beta1,
history_step=history_step,
)
self._job_builder._set_logged_code_artifact(res, artifact)
return res | python | wandb/sdk/internal/sender.py | 1,482 | 1,524 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,217 | send_alert | def send_alert(self, record: "Record") -> None:
from pkg_resources import parse_version
alert = record.alert
max_cli_version = self._max_cli_version()
if max_cli_version is None or parse_version(max_cli_version) < parse_version(
"0.10.9"
):
logger.warning(
"This W&B server doesn't support alerts, "
"have your administrator install wandb/local >= 0.9.31"
)
else:
try:
self._api.notify_scriptable_run_alert(
title=alert.title,
text=alert.text,
level=alert.level,
wait_duration=alert.wait_duration,
)
except Exception as e:
logger.error(f"send_alert: failed for alert {alert.title!r}: {e}") | python | wandb/sdk/internal/sender.py | 1,526 | 1,547 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,218 | finish | def finish(self) -> None:
logger.info("shutting down sender")
# if self._tb_watcher:
# self._tb_watcher.finish()
self._output_raw_finish()
if self._dir_watcher:
self._dir_watcher.finish()
self._dir_watcher = None
if self._pusher:
self._pusher.finish()
self._pusher.join()
self._pusher = None
if self._fs:
self._fs.finish(self._exit_code)
self._fs = None
wandb._sentry.end_session() | python | wandb/sdk/internal/sender.py | 1,549 | 1,564 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,219 | _max_cli_version | def _max_cli_version(self) -> Optional[str]:
server_info = self.get_server_info()
max_cli_version = server_info.get("cliVersionInfo", {}).get(
"max_cli_version", None
)
if not isinstance(max_cli_version, str):
return None
return max_cli_version | python | wandb/sdk/internal/sender.py | 1,566 | 1,573 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,220 | get_viewer_server_info | def get_viewer_server_info(self) -> None:
if self._cached_server_info and self._cached_viewer:
return
self._cached_viewer, self._cached_server_info = self._api.viewer_server_info() | python | wandb/sdk/internal/sender.py | 1,575 | 1,578 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,221 | get_viewer_info | def get_viewer_info(self) -> Dict[str, Any]:
if not self._cached_viewer:
self.get_viewer_server_info()
return self._cached_viewer | python | wandb/sdk/internal/sender.py | 1,580 | 1,583 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,222 | get_server_info | def get_server_info(self) -> Dict[str, Any]:
if not self._cached_server_info:
self.get_viewer_server_info()
return self._cached_server_info | python | wandb/sdk/internal/sender.py | 1,585 | 1,588 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,223 | get_local_info | def get_local_info(self) -> "LocalInfo":
"""Queries the server to get the local version information.
First, we perform an introspection, if it returns empty we deduce that the
docker image is out-of-date. Otherwise, we use the returned values to deduce the
state of the local server.
"""
local_info = wandb_internal_pb2.LocalInfo()
if self._settings._offline:
local_info.out_of_date = False
return local_info
latest_local_version = "latest"
# Assuming the query is successful if the result is empty it indicates that
# the backend is out of date since it doesn't have the desired field
server_info = self.get_server_info()
latest_local_version_info = server_info.get("latestLocalVersionInfo", {})
if latest_local_version_info is None:
local_info.out_of_date = False
else:
local_info.out_of_date = latest_local_version_info.get("outOfDate", True)
local_info.version = latest_local_version_info.get(
"latestVersionString", latest_local_version
)
return local_info | python | wandb/sdk/internal/sender.py | 1,590 | 1,615 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,224 | _flush_job | def _flush_job(self) -> None:
if self._job_builder.disable or self._settings.get("_offline", False):
return
self._job_builder.set_config(
{k: v for k, v in self._consolidated_config.items() if k != "_wandb"}
)
summary_dict = self._cached_summary.copy()
summary_dict.pop("_wandb", None)
self._job_builder.set_summary(summary_dict)
artifact = self._job_builder.build()
if artifact is not None and self._run is not None:
proto_artifact = self._interface._make_artifact(artifact)
proto_artifact.run_id = self._run.run_id
proto_artifact.project = self._run.project
proto_artifact.entity = self._run.entity
# TODO: this should be removed when the latest tag is handled
# by the backend (WB-12116)
proto_artifact.aliases.append("latest")
proto_artifact.user_created = True
proto_artifact.use_after_commit = True
proto_artifact.finalize = True
self._interface._publish_artifact(proto_artifact) | python | wandb/sdk/internal/sender.py | 1,617 | 1,639 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,225 | __next__ | def __next__(self) -> "Record":
return self._record_q.get(block=True) | python | wandb/sdk/internal/sender.py | 1,641 | 1,642 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,226 | wandb_internal | def wandb_internal(
settings: "SettingsDict",
record_q: "Queue[Record]",
result_q: "Queue[Result]",
port: Optional[int] = None,
user_pid: Optional[int] = None,
) -> None:
"""Internal process function entrypoint.
Read from record queue and dispatch work to various threads.
Arguments:
settings: dictionary of configuration parameters.
record_q: records to be handled
result_q: for sending results back
"""
# mark this process as internal
wandb._set_internal_process()
_setup_tracelog()
started = time.time()
# any sentry events in the internal process will be tagged as such
wandb._sentry.configure_scope(process_context="internal")
# register the exit handler only when wandb_internal is called, not on import
@atexit.register
def handle_exit(*args: "Any") -> None:
logger.info("Internal process exited")
# Let's make sure we don't modify settings so use a static object
_settings = settings_static.SettingsStatic(settings)
if _settings.log_internal:
configure_logging(_settings.log_internal, _settings._log_level)
user_pid = user_pid or os.getppid()
pid = os.getpid()
logger.info(
"W&B internal server running at pid: %s, started at: %s",
pid,
datetime.fromtimestamp(started),
)
tracelog.annotate_queue(record_q, "record_q")
tracelog.annotate_queue(result_q, "result_q")
publish_interface = InterfaceQueue(record_q=record_q)
stopped = threading.Event()
threads: "List[RecordLoopThread]" = []
context_keeper = context.ContextKeeper()
send_record_q: "Queue[Record]" = queue.Queue()
tracelog.annotate_queue(send_record_q, "send_q")
write_record_q: "Queue[Record]" = queue.Queue()
tracelog.annotate_queue(write_record_q, "write_q")
record_sender_thread = SenderThread(
settings=_settings,
record_q=send_record_q,
result_q=result_q,
stopped=stopped,
interface=publish_interface,
debounce_interval_ms=5000,
context_keeper=context_keeper,
)
threads.append(record_sender_thread)
record_writer_thread = WriterThread(
settings=_settings,
record_q=write_record_q,
result_q=result_q,
stopped=stopped,
interface=publish_interface,
sender_q=send_record_q,
context_keeper=context_keeper,
)
threads.append(record_writer_thread)
record_handler_thread = HandlerThread(
settings=_settings,
record_q=record_q,
result_q=result_q,
stopped=stopped,
writer_q=write_record_q,
interface=publish_interface,
context_keeper=context_keeper,
)
threads.append(record_handler_thread)
process_check = ProcessCheck(settings=_settings, user_pid=user_pid)
for thread in threads:
thread.start()
interrupt_count = 0
while not stopped.is_set():
try:
# wait for stop event
while not stopped.is_set():
time.sleep(1)
if process_check.is_dead():
logger.error("Internal process shutdown.")
stopped.set()
except KeyboardInterrupt:
interrupt_count += 1
logger.warning(f"Internal process interrupt: {interrupt_count}")
finally:
if interrupt_count >= 2:
logger.error("Internal process interrupted.")
stopped.set()
for thread in threads:
thread.join()
def close_internal_log() -> None:
root = logging.getLogger("wandb")
for _handler in root.handlers[:]:
_handler.close()
root.removeHandler(_handler)
for thread in threads:
exc_info = thread.get_exception()
if exc_info:
logger.error(f"Thread {thread.name}:", exc_info=exc_info)
print(f"Thread {thread.name}:", file=sys.stderr)
traceback.print_exception(*exc_info)
wandb._sentry.exception(exc_info)
wandb.termerror("Internal wandb error: file data was not synced")
if not settings.get("_disable_service"):
# TODO: We can make this more graceful by returning an error to streams.py
# and potentially just fail the one stream.
os._exit(-1)
sys.exit(-1)
close_internal_log() | python | wandb/sdk/internal/internal.py | 48 | 185 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,227 | handle_exit | def handle_exit(*args: "Any") -> None:
logger.info("Internal process exited") | python | wandb/sdk/internal/internal.py | 75 | 76 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,228 | close_internal_log | def close_internal_log() -> None:
root = logging.getLogger("wandb")
for _handler in root.handlers[:]:
_handler.close()
root.removeHandler(_handler) | python | wandb/sdk/internal/internal.py | 165 | 169 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,229 | _setup_tracelog | def _setup_tracelog() -> None:
# TODO: remove this temporary hack, need to find a better way to pass settings
# to the server. for now lets just look at the environment variable we need
tracelog_mode = os.environ.get("WANDB_TRACELOG")
if tracelog_mode:
tracelog.enable(tracelog_mode) | python | wandb/sdk/internal/internal.py | 188 | 193 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,230 | configure_logging | def configure_logging(
log_fname: str, log_level: int, run_id: Optional[str] = None
) -> None:
# TODO: we may want make prints and stdout make it into the logs
# sys.stdout = open(settings.log_internal, "a")
# sys.stderr = open(settings.log_internal, "a")
log_handler = logging.FileHandler(log_fname)
log_handler.setLevel(log_level)
class WBFilter(logging.Filter):
def filter(self, record: "Any") -> bool:
record.run_id = run_id
return True
if run_id:
formatter = logging.Formatter(
"%(asctime)s %(levelname)-7s %(threadName)-10s:%(process)d "
"[%(run_id)s:%(filename)s:%(funcName)s():%(lineno)s] %(message)s"
)
else:
formatter = logging.Formatter(
"%(asctime)s %(levelname)-7s %(threadName)-10s:%(process)d "
"[%(filename)s:%(funcName)s():%(lineno)s] %(message)s"
)
log_handler.setFormatter(formatter)
if run_id:
log_handler.addFilter(WBFilter())
# If this is called without "wandb", backend logs from this module
# are not streamed to `debug-internal.log` when we spawn with fork
# TODO: (cvp) we should really take another pass at logging in general
root = logging.getLogger("wandb")
root.propagate = False
root.setLevel(logging.DEBUG)
root.addHandler(log_handler) | python | wandb/sdk/internal/internal.py | 196 | 230 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,231 | filter | def filter(self, record: "Any") -> bool:
record.run_id = run_id
return True | python | wandb/sdk/internal/internal.py | 206 | 208 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,232 | __init__ | def __init__(
self,
settings: "SettingsStatic",
record_q: "Queue[Record]",
result_q: "Queue[Result]",
stopped: "Event",
writer_q: "Queue[Record]",
interface: "InterfaceQueue",
context_keeper: context.ContextKeeper,
debounce_interval_ms: "float" = 1000,
) -> None:
super().__init__(
input_record_q=record_q,
result_q=result_q,
stopped=stopped,
debounce_interval_ms=debounce_interval_ms,
)
self.name = "HandlerThread"
self._settings = settings
self._record_q = record_q
self._result_q = result_q
self._stopped = stopped
self._writer_q = writer_q
self._interface = interface
self._context_keeper = context_keeper | python | wandb/sdk/internal/internal.py | 241 | 265 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,233 | _setup | def _setup(self) -> None:
self._hm = handler.HandleManager(
settings=self._settings,
record_q=self._record_q,
result_q=self._result_q,
stopped=self._stopped,
writer_q=self._writer_q,
interface=self._interface,
context_keeper=self._context_keeper,
) | python | wandb/sdk/internal/internal.py | 267 | 276 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,234 | _process | def _process(self, record: "Record") -> None:
self._hm.handle(record) | python | wandb/sdk/internal/internal.py | 278 | 279 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,235 | _finish | def _finish(self) -> None:
self._hm.finish() | python | wandb/sdk/internal/internal.py | 281 | 282 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,236 | _debounce | def _debounce(self) -> None:
self._hm.debounce() | python | wandb/sdk/internal/internal.py | 284 | 285 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,237 | __init__ | def __init__(
self,
settings: "SettingsStatic",
record_q: "Queue[Record]",
result_q: "Queue[Result]",
stopped: "Event",
interface: "InterfaceQueue",
context_keeper: context.ContextKeeper,
debounce_interval_ms: "float" = 5000,
) -> None:
super().__init__(
input_record_q=record_q,
result_q=result_q,
stopped=stopped,
debounce_interval_ms=debounce_interval_ms,
)
self.name = "SenderThread"
self._settings = settings
self._record_q = record_q
self._result_q = result_q
self._interface = interface
self._context_keeper = context_keeper | python | wandb/sdk/internal/internal.py | 295 | 316 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,238 | _setup | def _setup(self) -> None:
self._sm = sender.SendManager(
settings=self._settings,
record_q=self._record_q,
result_q=self._result_q,
interface=self._interface,
context_keeper=self._context_keeper,
) | python | wandb/sdk/internal/internal.py | 318 | 325 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,239 | _process | def _process(self, record: "Record") -> None:
self._sm.send(record) | python | wandb/sdk/internal/internal.py | 327 | 328 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,240 | _finish | def _finish(self) -> None:
self._sm.finish() | python | wandb/sdk/internal/internal.py | 330 | 331 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,241 | _debounce | def _debounce(self) -> None:
self._sm.debounce() | python | wandb/sdk/internal/internal.py | 333 | 334 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,242 | __init__ | def __init__(
self,
settings: "SettingsStatic",
record_q: "Queue[Record]",
result_q: "Queue[Result]",
stopped: "Event",
interface: "InterfaceQueue",
sender_q: "Queue[Record]",
context_keeper: context.ContextKeeper,
debounce_interval_ms: "float" = 1000,
) -> None:
super().__init__(
input_record_q=record_q,
result_q=result_q,
stopped=stopped,
debounce_interval_ms=debounce_interval_ms,
)
self.name = "WriterThread"
self._settings = settings
self._record_q = record_q
self._result_q = result_q
self._sender_q = sender_q
self._interface = interface
self._context_keeper = context_keeper | python | wandb/sdk/internal/internal.py | 344 | 367 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,243 | _setup | def _setup(self) -> None:
self._wm = writer.WriteManager(
settings=self._settings,
record_q=self._record_q,
result_q=self._result_q,
sender_q=self._sender_q,
interface=self._interface,
context_keeper=self._context_keeper,
) | python | wandb/sdk/internal/internal.py | 369 | 377 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,244 | _process | def _process(self, record: "Record") -> None:
self._wm.write(record) | python | wandb/sdk/internal/internal.py | 379 | 380 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,245 | _finish | def _finish(self) -> None:
self._wm.finish() | python | wandb/sdk/internal/internal.py | 382 | 383 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,246 | _debounce | def _debounce(self) -> None:
self._wm.debounce() | python | wandb/sdk/internal/internal.py | 385 | 386 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,247 | __init__ | def __init__(self, settings: "SettingsStatic", user_pid: Optional[int]) -> None:
self.settings = settings
self.pid = user_pid
self.check_process_last = None
self.check_process_interval = settings._internal_check_process | python | wandb/sdk/internal/internal.py | 394 | 398 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,248 | is_dead | def is_dead(self) -> bool:
if not self.check_process_interval or not self.pid:
return False
time_now = time.time()
if (
self.check_process_last
and time_now < self.check_process_last + self.check_process_interval
):
return False
self.check_process_last = time_now
# TODO(jhr): check for os.getppid on unix being 1?
exists = psutil.pid_exists(self.pid)
if not exists:
logger.warning(
f"Internal process exiting, parent pid {self.pid} disappeared"
)
return True
return False | python | wandb/sdk/internal/internal.py | 400 | 418 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,249 | __init__ | def __init__(self, run_obj, settings, datatypes_cb):
super().__init__(settings=settings)
self._run_obj = run_obj
# TODO: This overwrites what's done in the constructor of wandb_run.Run.
# We really want a common interface for wandb_run.Run and InternalRun.
_datatypes_set_callback(datatypes_cb) | python | wandb/sdk/internal/run.py | 13 | 19 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,250 | _set_backend | def _set_backend(self, backend):
# This type of run object can't have a backend
# or do any writes.
pass | python | wandb/sdk/internal/run.py | 21 | 24 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,251 | __init__ | def __init__(self, settings: SettingsStatic):
self._settings = settings
self._metadatafile_path = None
self._requirements_path = None
self._config = None
self._summary = None
self._logged_code_artifact = None
self._disable = settings.disable_job_creation | python | wandb/sdk/internal/job_builder.py | 69 | 76 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,252 | set_config | def set_config(self, config: Dict[str, Any]) -> None:
self._config = config | python | wandb/sdk/internal/job_builder.py | 78 | 79 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,253 | set_summary | def set_summary(self, summary: Dict[str, Any]) -> None:
self._summary = summary | python | wandb/sdk/internal/job_builder.py | 81 | 82 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,254 | disable | def disable(self) -> bool:
return self._disable | python | wandb/sdk/internal/job_builder.py | 85 | 86 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,255 | disable | def disable(self, val: bool) -> None:
self._disable = val | python | wandb/sdk/internal/job_builder.py | 89 | 90 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,256 | _set_logged_code_artifact | def _set_logged_code_artifact(
self, res: Optional[Dict], artifact: "ArtifactRecord"
) -> None:
if artifact.type == "code" and res is not None:
self._logged_code_artifact = ArtifactInfoForJob(
{
"id": res["id"],
"name": artifact.name,
}
) | python | wandb/sdk/internal/job_builder.py | 92 | 101 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,257 | _build_repo_job | def _build_repo_job(
self, metadata: Dict[str, Any], program_relpath: str
) -> Tuple[Artifact, GitSourceDict]:
git_info: Dict[str, str] = metadata.get("git", {})
remote = git_info.get("remote")
commit = git_info.get("commit")
assert remote is not None
assert commit is not None
# TODO: update executable to a method that supports pex
source: GitSourceDict = {
"entrypoint": [
os.path.basename(sys.executable),
program_relpath,
],
"git": {
"remote": remote,
"commit": commit,
},
}
name = make_artifact_name_safe(f"job-{remote}_{program_relpath}")
artifact = Artifact(name, JOB_ARTIFACT_TYPE)
if os.path.exists(os.path.join(self._settings.files_dir, DIFF_FNAME)):
artifact.add_file(
os.path.join(self._settings.files_dir, DIFF_FNAME),
name="diff.patch",
)
return artifact, source | python | wandb/sdk/internal/job_builder.py | 103 | 131 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,258 | _build_artifact_job | def _build_artifact_job(
self, program_relpath: str
) -> Tuple[Artifact, ArtifactSourceDict]:
assert isinstance(self._logged_code_artifact, dict)
# TODO: update executable to a method that supports pex
source: ArtifactSourceDict = {
"entrypoint": [
os.path.basename(sys.executable),
program_relpath,
],
"artifact": f"wandb-artifact://_id/{self._logged_code_artifact['id']}",
}
name = make_artifact_name_safe(f"job-{self._logged_code_artifact['name']}")
artifact = Artifact(name, JOB_ARTIFACT_TYPE)
return artifact, source | python | wandb/sdk/internal/job_builder.py | 133 | 148 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,259 | _build_image_job | def _build_image_job(
self, metadata: Dict[str, Any]
) -> Tuple[Artifact, ImageSourceDict]:
image_name = metadata.get("docker")
assert isinstance(image_name, str)
name = make_artifact_name_safe(f"job-{image_name}")
artifact = Artifact(name, JOB_ARTIFACT_TYPE)
source: ImageSourceDict = {
"image": image_name,
}
return artifact, source | python | wandb/sdk/internal/job_builder.py | 150 | 160 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,260 | build | def build(self) -> Optional[Artifact]:
if not os.path.exists(
os.path.join(self._settings.files_dir, REQUIREMENTS_FNAME)
):
return None
metadata = self._handle_metadata_file()
if metadata is None:
return None
runtime: Optional[str] = metadata.get("python")
# can't build a job without a python version
if runtime is None:
return None
program_relpath: Optional[str] = metadata.get("codePath")
artifact = None
source_type = None
source: Optional[
Union[GitSourceDict, ArtifactSourceDict, ImageSourceDict]
] = None
if self._has_git_job_ingredients(metadata, program_relpath):
assert program_relpath is not None
artifact, source = self._build_repo_job(metadata, program_relpath)
source_type = "repo"
elif self._has_artifact_job_ingredients(program_relpath):
assert program_relpath is not None
artifact, source = self._build_artifact_job(program_relpath)
source_type = "artifact"
elif self._has_image_job_ingredients(metadata):
artifact, source = self._build_image_job(metadata)
source_type = "image"
if artifact is None or source_type is None or source is None:
return None
input_types = TypeRegistry.type_of(self._config).to_json()
output_types = TypeRegistry.type_of(self._summary).to_json()
source_info: JobSourceDict = {
"_version": "v0",
"source_type": source_type,
"source": source,
"input_types": input_types,
"output_types": output_types,
"runtime": runtime,
}
with artifact.new_file("wandb-job.json") as f:
f.write(json.dumps(source_info, indent=4))
artifact.add_file(
os.path.join(self._settings.files_dir, REQUIREMENTS_FNAME),
name=FROZEN_REQUIREMENTS_FNAME,
)
return artifact | python | wandb/sdk/internal/job_builder.py | 162 | 219 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,261 | _handle_metadata_file | def _handle_metadata_file(
self,
) -> Optional[Dict]:
if os.path.exists(os.path.join(self._settings.files_dir, METADATA_FNAME)):
with open(os.path.join(self._settings.files_dir, METADATA_FNAME)) as f:
metadata: Dict = json.load(f)
return metadata
return None | python | wandb/sdk/internal/job_builder.py | 221 | 229 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,262 | _has_git_job_ingredients | def _has_git_job_ingredients(
self, metadata: Dict[str, Any], program_relpath: Optional[str]
) -> bool:
git_info: Dict[str, str] = metadata.get("git", {})
return (
git_info.get("remote") is not None
and git_info.get("commit") is not None
and program_relpath is not None
) | python | wandb/sdk/internal/job_builder.py | 231 | 239 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,263 | _has_artifact_job_ingredients | def _has_artifact_job_ingredients(self, program_relpath: Optional[str]) -> bool:
return self._logged_code_artifact is not None and program_relpath is not None | python | wandb/sdk/internal/job_builder.py | 241 | 242 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,264 | _has_image_job_ingredients | def _has_image_job_ingredients(self, metadata: Dict[str, Any]) -> bool:
return metadata.get("docker") is not None | python | wandb/sdk/internal/job_builder.py | 244 | 245 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,265 | check_httpx_exc_retriable | def check_httpx_exc_retriable(exc: Exception) -> bool:
retriable_codes = (308, 408, 409, 429, 500, 502, 503, 504)
return (
isinstance(exc, (httpx.TimeoutException, httpx.NetworkError))
or (
isinstance(exc, httpx.HTTPStatusError)
and exc.response.status_code in retriable_codes
)
or (
isinstance(exc, httpx.HTTPStatusError)
and exc.response.status_code == 400
and "x-amz-meta-md5" in exc.request.headers
and "RequestTimeout" in str(exc.response.content)
)
) | python | wandb/sdk/internal/internal_api.py | 110 | 124 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,266 | __init__ | def __init__(self) -> None:
self.context = None | python | wandb/sdk/internal/internal_api.py | 130 | 131 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,267 | __init__ | def __init__(
self,
default_settings: Optional[
Union[
"wandb.sdk.wandb_settings.Settings",
"wandb.sdk.internal.settings_static.SettingsStatic",
Settings,
dict,
]
] = None,
load_settings: bool = True,
retry_timedelta: datetime.timedelta = datetime.timedelta( # noqa: B008 # okay because it's immutable
days=7
),
environ: MutableMapping = os.environ,
retry_callback: Optional[Callable[[int, str], Any]] = None,
) -> None:
self._environ = environ
self._global_context = context.Context()
self._local_data = _ThreadLocalData()
self.default_settings: "DefaultSettings" = {
"section": "default",
"git_remote": "origin",
"ignore_globs": [],
"base_url": "https://api.wandb.ai",
"root_dir": None,
"api_key": None,
"entity": None,
"project": None,
"_extra_http_headers": None,
}
self.retry_timedelta = retry_timedelta
# todo: Old Settings do not follow the SupportsKeysAndGetItem Protocol
self.default_settings.update(default_settings or {}) # type: ignore
self.retry_uploads = 10
self._settings = Settings(
load_settings=load_settings,
root_dir=self.default_settings.get("root_dir"),
)
self.git = GitRepo(remote=self.settings("git_remote"))
# Mutable settings set by the _file_stream_api
self.dynamic_settings = {
"system_sample_seconds": 2,
"system_samples": 15,
"heartbeat_seconds": 30,
}
# todo: remove this hacky hack after settings refactor is complete
# keeping this code here to limit scope and so that it is easy to remove later
extra_http_headers = self.settings(
"_extra_http_headers"
) or wandb.sdk.wandb_settings._str_as_dict(
self._environ.get("WANDB__EXTRA_HTTP_HEADERS", {})
)
self.client = Client(
transport=GraphQLSession(
headers={
"User-Agent": self.user_agent,
"X-WANDB-USERNAME": env.get_username(env=self._environ),
"X-WANDB-USER-EMAIL": env.get_user_email(env=self._environ),
**extra_http_headers,
},
use_json=True,
# this timeout won't apply when the DNS lookup fails. in that case, it will be 60s
# https://bugs.python.org/issue22889
timeout=self.HTTP_TIMEOUT,
auth=("api", self.api_key or ""),
url=f"{self.settings('base_url')}/graphql",
)
)
# httpx is an optional dependency, so we lazily instantiate the client
# only when we need it
self._async_httpx_client: Optional["httpx.AsyncClient"] = None
self.retry_callback = retry_callback
self._retry_gql = retry.Retry(
self.execute,
retry_timedelta=retry_timedelta,
check_retry_fn=util.no_retry_auth,
retryable_exceptions=(RetryError, requests.RequestException),
retry_callback=retry_callback,
)
self._current_run_id: Optional[str] = None
self._file_stream_api = None
self._upload_file_session = requests.Session()
# This Retry class is initialized once for each Api instance, so this
# defaults to retrying 1 million times per process or 7 days
self.upload_file_retry = normalize_exceptions(
retry.retriable(retry_timedelta=retry_timedelta)(self.upload_file)
)
self._client_id_mapping: Dict[str, str] = {}
# Large file uploads to azure can optionally use their SDK
self._azure_blob_module = util.get_module("azure.storage.blob")
self.query_types: Optional[List[str]] = None
self.mutation_types: Optional[List[str]] = None
self.server_info_types: Optional[List[str]] = None
self.server_use_artifact_input_info: Optional[List[str]] = None
self._max_cli_version: Optional[str] = None
self._server_settings_type: Optional[List[str]] = None | python | wandb/sdk/internal/internal_api.py | 153 | 254 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,268 | gql | def gql(self, *args: Any, **kwargs: Any) -> Any:
ret = self._retry_gql(
*args,
retry_cancel_event=self.context.cancel_event,
**kwargs,
)
return ret | python | wandb/sdk/internal/internal_api.py | 256 | 262 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,269 | set_local_context | def set_local_context(self, api_context: Optional[context.Context]) -> None:
self._local_data.context = api_context | python | wandb/sdk/internal/internal_api.py | 264 | 265 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,270 | clear_local_context | def clear_local_context(self) -> None:
self._local_data.context = None | python | wandb/sdk/internal/internal_api.py | 267 | 268 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,271 | context | def context(self) -> context.Context:
return self._local_data.context or self._global_context | python | wandb/sdk/internal/internal_api.py | 271 | 272 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,272 | reauth | def reauth(self) -> None:
"""Ensure the current api key is set in the transport."""
self.client.transport.auth = ("api", self.api_key or "") | python | wandb/sdk/internal/internal_api.py | 274 | 276 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,273 | relocate | def relocate(self) -> None:
"""Ensure the current api points to the right server."""
self.client.transport.url = "%s/graphql" % self.settings("base_url") | python | wandb/sdk/internal/internal_api.py | 278 | 280 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,274 | execute | def execute(self, *args: Any, **kwargs: Any) -> "_Response":
"""Wrapper around execute that logs in cases of failure."""
try:
return self.client.execute(*args, **kwargs) # type: ignore
except requests.exceptions.HTTPError as err:
response = err.response
logger.error(f"{response.status_code} response executing GraphQL.")
logger.error(response.text)
for error in parse_backend_error_messages(response):
wandb.termerror(f"Error while calling W&B API: {error} ({response})")
raise | python | wandb/sdk/internal/internal_api.py | 282 | 292 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,275 | disabled | def disabled(self) -> Union[str, bool]:
return self._settings.get(Settings.DEFAULT_SECTION, "disabled", fallback=False) # type: ignore | python | wandb/sdk/internal/internal_api.py | 294 | 295 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,276 | set_current_run_id | def set_current_run_id(self, run_id: str) -> None:
self._current_run_id = run_id | python | wandb/sdk/internal/internal_api.py | 297 | 298 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,277 | current_run_id | def current_run_id(self) -> Optional[str]:
return self._current_run_id | python | wandb/sdk/internal/internal_api.py | 301 | 302 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,278 | user_agent | def user_agent(self) -> str:
return f"W&B Internal Client {__version__}" | python | wandb/sdk/internal/internal_api.py | 305 | 306 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,279 | api_key | def api_key(self) -> Optional[str]:
auth = requests.utils.get_netrc_auth(self.api_url)
key = None
if auth:
key = auth[-1]
# Environment should take precedence
env_key: Optional[str] = self._environ.get(env.API_KEY)
sagemaker_key: Optional[str] = parse_sm_secrets().get(env.API_KEY)
default_key: Optional[str] = self.default_settings.get("api_key")
return env_key or key or sagemaker_key or default_key | python | wandb/sdk/internal/internal_api.py | 309 | 319 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,280 | api_url | def api_url(self) -> str:
return self.settings("base_url") # type: ignore | python | wandb/sdk/internal/internal_api.py | 322 | 323 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,281 | app_url | def app_url(self) -> str:
return wandb.util.app_url(self.api_url) | python | wandb/sdk/internal/internal_api.py | 326 | 327 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,282 | default_entity | def default_entity(self) -> str:
return self.viewer().get("entity") # type: ignore | python | wandb/sdk/internal/internal_api.py | 330 | 331 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,283 | settings | def settings(self, key: Optional[str] = None, section: Optional[str] = None) -> Any:
"""The settings overridden from the wandb/settings file.
Arguments:
key (str, optional): If provided only this setting is returned
section (str, optional): If provided this section of the setting file is
used, defaults to "default"
Returns:
A dict with the current settings
{
"entity": "models",
"base_url": "https://api.wandb.ai",
"project": None
}
"""
result = self.default_settings.copy()
result.update(self._settings.items(section=section)) # type: ignore
result.update(
{
"entity": env.get_entity(
self._settings.get(
Settings.DEFAULT_SECTION,
"entity",
fallback=result.get("entity"),
),
env=self._environ,
),
"project": env.get_project(
self._settings.get(
Settings.DEFAULT_SECTION,
"project",
fallback=result.get("project"),
),
env=self._environ,
),
"base_url": env.get_base_url(
self._settings.get(
Settings.DEFAULT_SECTION,
"base_url",
fallback=result.get("base_url"),
),
env=self._environ,
),
"ignore_globs": env.get_ignore(
self._settings.get(
Settings.DEFAULT_SECTION,
"ignore_globs",
fallback=result.get("ignore_globs"),
),
env=self._environ,
),
}
)
return result if key is None else result[key] # type: ignore | python | wandb/sdk/internal/internal_api.py | 333 | 389 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,284 | clear_setting | def clear_setting(
self, key: str, globally: bool = False, persist: bool = False
) -> None:
self._settings.clear(
Settings.DEFAULT_SECTION, key, globally=globally, persist=persist
) | python | wandb/sdk/internal/internal_api.py | 391 | 396 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,285 | set_setting | def set_setting(
self, key: str, value: Any, globally: bool = False, persist: bool = False
) -> None:
self._settings.set(
Settings.DEFAULT_SECTION, key, value, globally=globally, persist=persist
)
if key == "entity":
env.set_entity(value, env=self._environ)
elif key == "project":
env.set_project(value, env=self._environ)
elif key == "base_url":
self.relocate() | python | wandb/sdk/internal/internal_api.py | 398 | 409 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,286 | parse_slug | def parse_slug(
self, slug: str, project: Optional[str] = None, run: Optional[str] = None
) -> Tuple[str, str]:
"""Parse a slug into a project and run.
Arguments:
slug (str): The slug to parse
project (str, optional): The project to use, if not provided it will be
inferred from the slug
run (str, optional): The run to use, if not provided it will be inferred
from the slug
Returns:
A dict with the project and run
"""
if slug and "/" in slug:
parts = slug.split("/")
project = parts[0]
run = parts[1]
else:
project = project or self.settings().get("project")
if project is None:
raise CommError("No default project configured.")
run = run or slug or self.current_run_id or env.get_run(env=self._environ)
assert run, "run must be specified"
return project, run | python | wandb/sdk/internal/internal_api.py | 411 | 436 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,287 | server_info_introspection | def server_info_introspection(self) -> Tuple[List[str], List[str], List[str]]:
query_string = """
query ProbeServerCapabilities {
QueryType: __type(name: "Query") {
...fieldData
}
MutationType: __type(name: "Mutation") {
...fieldData
}
ServerInfoType: __type(name: "ServerInfo") {
...fieldData
}
}
fragment fieldData on __Type {
fields {
name
}
}
"""
if (
self.query_types is None
or self.mutation_types is None
or self.server_info_types is None
):
query = gql(query_string)
res = self.gql(query)
self.query_types = [
field.get("name", "")
for field in res.get("QueryType", {}).get("fields", [{}])
]
self.mutation_types = [
field.get("name", "")
for field in res.get("MutationType", {}).get("fields", [{}])
]
self.server_info_types = [
field.get("name", "")
for field in res.get("ServerInfoType", {}).get("fields", [{}])
]
return self.query_types, self.server_info_types, self.mutation_types | python | wandb/sdk/internal/internal_api.py | 439 | 479 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,288 | server_settings_introspection | def server_settings_introspection(self) -> None:
query_string = """
query ProbeServerSettings {
ServerSettingsType: __type(name: "ServerSettings") {
...fieldData
}
}
fragment fieldData on __Type {
fields {
name
}
}
"""
if self._server_settings_type is None:
query = gql(query_string)
res = self.gql(query)
self._server_settings_type = (
[
field.get("name", "")
for field in res.get("ServerSettingsType", {}).get("fields", [{}])
]
if res
else []
) | python | wandb/sdk/internal/internal_api.py | 482 | 506 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,289 | server_use_artifact_input_introspection | def server_use_artifact_input_introspection(self) -> List:
query_string = """
query ProbeServerUseArtifactInput {
UseArtifactInputInfoType: __type(name: "UseArtifactInput") {
name
inputFields {
name
}
}
}
"""
if self.server_use_artifact_input_info is None:
query = gql(query_string)
res = self.gql(query)
self.server_use_artifact_input_info = [
field.get("name", "")
for field in res.get("UseArtifactInputInfoType", {}).get(
"inputFields", [{}]
)
]
return self.server_use_artifact_input_info | python | wandb/sdk/internal/internal_api.py | 508 | 529 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,290 | launch_agent_introspection | def launch_agent_introspection(self) -> Optional[str]:
query = gql(
"""
query LaunchAgentIntrospection {
LaunchAgentType: __type(name: "LaunchAgent") {
name
}
}
"""
)
res = self.gql(query)
return res.get("LaunchAgentType") or None | python | wandb/sdk/internal/internal_api.py | 532 | 544 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,291 | fail_run_queue_item_introspection | def fail_run_queue_item_introspection(self) -> bool:
_, _, mutations = self.server_info_introspection()
return "failRunQueueItem" in mutations | python | wandb/sdk/internal/internal_api.py | 547 | 549 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,292 | fail_run_queue_item | def fail_run_queue_item(self, run_queue_item_id: str) -> bool:
mutation = gql(
"""
mutation failRunQueueItem($runQueueItemId: ID!) {
failRunQueueItem(
input: {
runQueueItemId: $runQueueItemId
}
) {
success
}
}
"""
)
response = self.gql(
mutation,
variable_values={
"runQueueItemId": run_queue_item_id,
},
)
result: bool = response["failRunQueueItem"]["success"]
return result | python | wandb/sdk/internal/internal_api.py | 552 | 573 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,293 | viewer | def viewer(self) -> Dict[str, Any]:
query = gql(
"""
query Viewer{
viewer {
id
entity
flags
teams {
edges {
node {
name
}
}
}
}
}
"""
)
res = self.gql(query)
return res.get("viewer") or {} | python | wandb/sdk/internal/internal_api.py | 576 | 596 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,294 | max_cli_version | def max_cli_version(self) -> Optional[str]:
if self._max_cli_version is not None:
return self._max_cli_version
query_types, server_info_types, _ = self.server_info_introspection()
cli_version_exists = (
"serverInfo" in query_types and "cliVersionInfo" in server_info_types
)
if not cli_version_exists:
return None
_, server_info = self.viewer_server_info()
self._max_cli_version = server_info.get("cliVersionInfo", {}).get(
"max_cli_version"
)
return self._max_cli_version | python | wandb/sdk/internal/internal_api.py | 599 | 614 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,295 | viewer_server_info | def viewer_server_info(self) -> Tuple[Dict[str, Any], Dict[str, Any]]:
local_query = """
latestLocalVersionInfo {
outOfDate
latestVersionString
}
"""
cli_query = """
serverInfo {
cliVersionInfo
_LOCAL_QUERY_
}
"""
query_template = """
query Viewer{
viewer {
id
entity
username
email
flags
teams {
edges {
node {
name
}
}
}
}
_CLI_QUERY_
}
"""
query_types, server_info_types, _ = self.server_info_introspection()
cli_version_exists = (
"serverInfo" in query_types and "cliVersionInfo" in server_info_types
)
local_version_exists = (
"serverInfo" in query_types
and "latestLocalVersionInfo" in server_info_types
)
cli_query_string = "" if not cli_version_exists else cli_query
local_query_string = "" if not local_version_exists else local_query
query_string = query_template.replace("_CLI_QUERY_", cli_query_string).replace(
"_LOCAL_QUERY_", local_query_string
)
query = gql(query_string)
res = self.gql(query)
return res.get("viewer") or {}, res.get("serverInfo") or {} | python | wandb/sdk/internal/internal_api.py | 617 | 668 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,296 | list_projects | def list_projects(self, entity: Optional[str] = None) -> List[Dict[str, str]]:
"""List projects in W&B scoped by entity.
Arguments:
entity (str, optional): The entity to scope this project to.
Returns:
[{"id","name","description"}]
"""
query = gql(
"""
query EntityProjects($entity: String) {
models(first: 10, entityName: $entity) {
edges {
node {
id
name
description
}
}
}
}
"""
)
project_list: List[Dict[str, str]] = self._flatten_edges(
self.gql(
query, variable_values={"entity": entity or self.settings("entity")}
)["models"]
)
return project_list | python | wandb/sdk/internal/internal_api.py | 671 | 700 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,297 | project | def project(self, project: str, entity: Optional[str] = None) -> "_Response":
"""Retrieve project.
Arguments:
project (str): The project to get details for
entity (str, optional): The entity to scope this project to.
Returns:
[{"id","name","repo","dockerImage","description"}]
"""
query = gql(
"""
query ProjectDetails($entity: String, $project: String) {
model(name: $project, entityName: $entity) {
id
name
repo
dockerImage
description
}
}
"""
)
response: "_Response" = self.gql(
query, variable_values={"entity": entity, "project": project}
)["model"]
return response | python | wandb/sdk/internal/internal_api.py | 703 | 729 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,298 | sweep | def sweep(
self,
sweep: str,
specs: str,
project: Optional[str] = None,
entity: Optional[str] = None,
) -> Dict[str, Any]:
"""Retrieve sweep.
Arguments:
sweep (str): The sweep to get details for
specs (str): history specs
project (str, optional): The project to scope this sweep to.
entity (str, optional): The entity to scope this sweep to.
Returns:
[{"id","name","repo","dockerImage","description"}]
"""
query = gql(
"""
query SweepWithRuns($entity: String, $project: String, $sweep: String!, $specs: [JSONString!]!) {
project(name: $project, entityName: $entity) {
sweep(sweepName: $sweep) {
id
name
method
state
description
config
createdAt
heartbeatAt
updatedAt
earlyStopJobRunning
bestLoss
controller
scheduler
runs {
edges {
node {
name
state
config
exitcode
heartbeatAt
shouldStop
failed
stopped
running
summaryMetrics
sampledHistory(specs: $specs)
}
}
}
}
}
}
"""
)
entity = entity or self.settings("entity")
project = project or self.settings("project")
response = self.gql(
query,
variable_values={
"entity": entity,
"project": project,
"sweep": sweep,
"specs": specs,
},
)
if response["project"] is None or response["project"]["sweep"] is None:
raise ValueError(f"Sweep {entity}/{project}/{sweep} not found")
data: Dict[str, Any] = response["project"]["sweep"]
if data:
data["runs"] = self._flatten_edges(data["runs"])
return data | python | wandb/sdk/internal/internal_api.py | 732 | 806 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,299 | list_runs | def list_runs(
self, project: str, entity: Optional[str] = None
) -> List[Dict[str, str]]:
"""List runs in W&B scoped by project.
Arguments:
project (str): The project to scope the runs to
entity (str, optional): The entity to scope this project to. Defaults to public models
Returns:
[{"id","name","description"}]
"""
query = gql(
"""
query ProjectRuns($model: String!, $entity: String) {
model(name: $model, entityName: $entity) {
buckets(first: 10) {
edges {
node {
id
name
displayName
description
}
}
}
}
}
"""
)
return self._flatten_edges(
self.gql(
query,
variable_values={
"entity": entity or self.settings("entity"),
"model": project or self.settings("project"),
},
)["model"]["buckets"]
) | python | wandb/sdk/internal/internal_api.py | 809 | 847 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
4,300 | run_config | def run_config(
self, project: str, run: Optional[str] = None, entity: Optional[str] = None
) -> Tuple[str, Dict[str, Any], Optional[str], Dict[str, Any]]:
"""Get the relevant configs for a run.
Arguments:
project (str): The project to download, (can include bucket)
run (str, optional): The run to download
entity (str, optional): The entity to scope this project to.
"""
query = gql(
"""
query RunConfigs(
$name: String!,
$entity: String,
$run: String!,
$pattern: String!,
$includeConfig: Boolean!,
) {
model(name: $name, entityName: $entity) {
bucket(name: $run) {
config @include(if: $includeConfig)
commit @include(if: $includeConfig)
files(pattern: $pattern) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
name
directUrl
}
}
}
}
}
}
"""
)
variable_values = {
"name": project,
"run": run,
"entity": entity,
"includeConfig": True,
}
commit: str = ""
config: Dict[str, Any] = {}
patch: Optional[str] = None
metadata: Dict[str, Any] = {}
# If we use the `names` parameter on the `files` node, then the server
# will helpfully give us and 'open' file handle to the files that don't
# exist. This is so that we can upload data to it. However, in this
# case, we just want to download that file and not upload to it, so
# let's instead query for the files that do exist using `pattern`
# (with no wildcards).
#
# Unfortunately we're unable to construct a single pattern that matches
# our 2 files, we would need something like regex for that.
for filename in [DIFF_FNAME, METADATA_FNAME]:
variable_values["pattern"] = filename
response = self.gql(query, variable_values=variable_values)
if response["model"] is None:
raise CommError(f"Run {entity}/{project}/{run} not found")
run_obj: Dict = response["model"]["bucket"]
# we only need to fetch this config once
if variable_values["includeConfig"]:
commit = run_obj["commit"]
config = json.loads(run_obj["config"] or "{}")
variable_values["includeConfig"] = False
if run_obj["files"] is not None:
for file_edge in run_obj["files"]["edges"]:
name = file_edge["node"]["name"]
url = file_edge["node"]["directUrl"]
res = requests.get(url)
res.raise_for_status()
if name == METADATA_FNAME:
metadata = res.json()
elif name == DIFF_FNAME:
patch = res.text
return commit, config, patch, metadata | python | wandb/sdk/internal/internal_api.py | 850 | 934 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.