etomoscow's picture
download
raw
1.12 kB
"""W&B run initialization with offline-safe fallback."""
from __future__ import annotations
import os
from typing import Any
def init_run(
experiment_id: str,
config: dict[str, Any],
*,
project: str = "mff-lora",
group: str | None = None,
name: str | None = None,
tags: list[str] | None = None,
):
"""Initialize a W&B run; fall back to offline mode if no API key.
Returns the wandb.Run handle (or a no-op stub if wandb is unavailable).
"""
try:
import wandb
except ImportError:
return _NoopRun()
if not os.environ.get("WANDB_API_KEY") and not os.path.exists(
os.path.expanduser("~/.netrc")
):
os.environ.setdefault("WANDB_MODE", "offline")
return wandb.init(
project=project,
group=group or experiment_id,
name=name,
tags=tags,
config=config,
reinit=True,
)
class _NoopRun:
def log(self, *args, **kwargs):
return None
def finish(self, *args, **kwargs):
return None
def __getattr__(self, _name):
return lambda *args, **kwargs: None

Xet Storage Details

Size:
1.12 kB
·
Xet hash:
a2f20521a6e67128c93dc856ac96100f1060d38c90087b2fb5e71dc3c75cbdc6

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.