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 |
|---|---|---|---|---|---|---|---|
5,201 | dict_from_config_file | def dict_from_config_file(
filename: str, must_exist: bool = False
) -> Optional[Dict[str, Any]]:
if not os.path.exists(filename):
if must_exist:
raise ConfigError("config file %s doesn't exist" % filename)
logger.debug("no default config file found in %s" % filename)
return None
try:
conf_file = open(filename)
except OSError:
raise ConfigError("Couldn't read config file: %s" % filename)
try:
loaded = load_yaml(conf_file)
except yaml.parser.ParserError:
raise ConfigError("Invalid YAML in config yaml")
if loaded is None:
wandb.termwarn(
"Found an empty default config file (config-defaults.yaml). Proceeding with no defaults."
)
return None
config_version = loaded.pop("wandb_version", None)
if config_version is not None and config_version != 1:
raise ConfigError("Unknown config version")
data = dict()
for k, v in loaded.items():
data[k] = v["value"]
return data | python | wandb/sdk/lib/config_util.py | 98 | 125 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,202 | _fixup_anon_mode | def _fixup_anon_mode(default):
# Convert weird anonymode values from legacy settings files
# into one of our expected values.
anon_mode = default or "never"
mapping = {"true": "allow", "false": "never"}
return mapping.get(anon_mode, anon_mode) | python | wandb/sdk/lib/apikey.py | 36 | 41 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,203 | prompt_api_key | def prompt_api_key( # noqa: C901
settings,
api=None,
input_callback=None,
browser_callback=None,
no_offline=False,
no_create=False,
local=False,
):
"""Prompt for api key.
Returns:
str - if key is configured
None - if dryrun is selected
False - if unconfigured (notty)
"""
input_callback = input_callback or getpass
log_string = term.LOG_STRING
api = api or InternalApi(settings)
anon_mode = _fixup_anon_mode(settings.anonymous)
jupyter = settings._jupyter or False
app_url = api.app_url
choices = [choice for choice in LOGIN_CHOICES]
if anon_mode == "never":
# Omit LOGIN_CHOICE_ANON as a choice if the env var is set to never
choices.remove(LOGIN_CHOICE_ANON)
if (jupyter and not settings.login_timeout) or no_offline:
choices.remove(LOGIN_CHOICE_DRYRUN)
if (jupyter and not settings.login_timeout) or no_create:
choices.remove(LOGIN_CHOICE_NEW)
if jupyter and "google.colab" in sys.modules:
log_string = term.LOG_STRING_NOCOLOR
key = wandb.jupyter.attempt_colab_login(app_url)
if key is not None:
write_key(settings, key, api=api)
return key
if anon_mode == "must":
result = LOGIN_CHOICE_ANON
# If we're not in an interactive environment, default to dry-run.
elif (
not jupyter and (not isatty(sys.stdout) or not isatty(sys.stdin))
) or _is_databricks():
result = LOGIN_CHOICE_NOTTY
elif local:
result = LOGIN_CHOICE_EXISTS
elif len(choices) == 1:
result = choices[0]
else:
result = prompt_choices(
choices, input_timeout=settings.login_timeout, jupyter=jupyter
)
api_ask = (
f"{log_string}: Paste an API key from your profile and hit enter, "
"or press ctrl+c to quit"
)
if result == LOGIN_CHOICE_ANON:
key = api.create_anonymous_api_key()
write_key(settings, key, api=api, anonymous=True)
return key
elif result == LOGIN_CHOICE_NEW:
key = browser_callback(signup=True) if browser_callback else None
if not key:
wandb.termlog(f"Create an account here: {app_url}/authorize?signup=true")
key = input_callback(api_ask).strip()
write_key(settings, key, api=api)
return key
elif result == LOGIN_CHOICE_EXISTS:
key = browser_callback() if browser_callback else None
if not key:
if not (settings.is_local or local):
host = app_url
for prefix in "http://", "https://":
if app_url.startswith(prefix):
host = app_url[len(prefix) :]
wandb.termlog(
f"Logging into {host}. (Learn how to deploy a W&B server locally: {wburls.get('wandb_server')})"
)
wandb.termlog(
f"You can find your API key in your browser here: {app_url}/authorize"
)
key = input_callback(api_ask).strip()
write_key(settings, key, api=api)
return key
elif result == LOGIN_CHOICE_NOTTY:
# TODO: Needs refactor as this needs to be handled by caller
return False
elif result == LOGIN_CHOICE_DRYRUN:
return None
else:
# Jupyter environments don't have a tty, but we can still try logging in using
# the browser callback if one is supplied.
key, anonymous = (
browser_callback() if jupyter and browser_callback else (None, False)
)
write_key(settings, key, api=api)
return key | python | wandb/sdk/lib/apikey.py | 44 | 148 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,204 | write_netrc | def write_netrc(host, entity, key):
"""Add our host and key to .netrc."""
key_prefix, key_suffix = key.split("-", 1) if "-" in key else ("", key)
if len(key_suffix) != 40:
wandb.termerror(
"API-key must be exactly 40 characters long: {} ({} chars)".format(
key_suffix, len(key_suffix)
)
)
return None
try:
normalized_host = urlparse(host).netloc.split(":")[0]
if normalized_host != "localhost" and "." not in normalized_host:
wandb.termerror(
f"Host must be a url in the form https://some.address.com, received {host}"
)
return None
wandb.termlog(
"Appending key for {} to your netrc file: {}".format(
normalized_host, os.path.expanduser("~/.netrc")
)
)
machine_line = f"machine {normalized_host}"
path = os.path.expanduser("~/.netrc")
orig_lines = None
try:
with open(path) as f:
orig_lines = f.read().strip().split("\n")
except OSError:
pass
with open(path, "w") as f:
if orig_lines:
# delete this machine from the file if it's already there.
skip = 0
for line in orig_lines:
# we fix invalid netrc files with an empty host that we wrote before
# verifying host...
if line == "machine " or machine_line in line:
skip = 2
elif skip:
skip -= 1
else:
f.write("%s\n" % line)
f.write(
textwrap.dedent(
"""\
machine {host}
login {entity}
password {key}
"""
).format(host=normalized_host, entity=entity, key=key)
)
os.chmod(os.path.expanduser("~/.netrc"), stat.S_IRUSR | stat.S_IWUSR)
return True
except OSError:
wandb.termerror("Unable to read ~/.netrc")
return None | python | wandb/sdk/lib/apikey.py | 151 | 207 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,205 | write_key | def write_key(settings, key, api=None, anonymous=False):
if not key:
raise ValueError("No API key specified.")
# TODO(jhr): api shouldn't be optional or it shouldn't be passed, clean up callers
api = api or InternalApi()
# Normal API keys are 40-character hex strings. On-prem API keys have a
# variable-length prefix, a dash, then the 40-char string.
prefix, suffix = key.split("-", 1) if "-" in key else ("", key)
if len(suffix) != 40:
raise ValueError("API key must be 40 characters long, yours was %s" % len(key))
if anonymous:
api.set_setting("anonymous", "true", globally=True, persist=True)
else:
api.clear_setting("anonymous", globally=True, persist=True)
write_netrc(settings.base_url, "user", key) | python | wandb/sdk/lib/apikey.py | 210 | 229 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,206 | api_key | def api_key(settings=None):
if not settings:
settings = wandb.setup().settings
if settings.api_key:
return settings.api_key
auth = requests.utils.get_netrc_auth(settings.base_url)
if auth:
return auth[-1]
return None | python | wandb/sdk/lib/apikey.py | 232 | 240 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,207 | sparklines | def sparklines(self, series: List[Union[int, float]]) -> Optional[str]:
# Only print sparklines if the terminal is utf-8
if wandb.util.is_unicode_safe(sys.stdout):
return sparkline.sparkify(series)
return None | python | wandb/sdk/lib/printer.py | 47 | 51 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,208 | abort | def abort(
self,
) -> str:
return "Control-C" if platform.system() != "Windows" else "Ctrl-C" | python | wandb/sdk/lib/printer.py | 53 | 56 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,209 | display | def display(
self,
text: Union[str, List[str], Tuple[str]],
*,
level: Optional[Union[str, int]] = None,
off: Optional[bool] = None,
default_text: Optional[Union[str, List[str], Tuple[str]]] = None,
) -> None:
if off:
return
self._display(text, level=level, default_text=default_text) | python | wandb/sdk/lib/printer.py | 58 | 68 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,210 | _display | def _display(
self,
text: Union[str, List[str], Tuple[str]],
*,
level: Optional[Union[str, int]] = None,
default_text: Optional[Union[str, List[str], Tuple[str]]] = None,
) -> None:
raise NotImplementedError | python | wandb/sdk/lib/printer.py | 71 | 78 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,211 | _sanitize_level | def _sanitize_level(name_or_level: Optional[Union[str, int]]) -> int:
if isinstance(name_or_level, str):
try:
return _name_to_level[name_or_level.upper()]
except KeyError:
raise ValueError(
f"Unknown level name: {name_or_level}, supported levels: {_name_to_level.keys()}"
)
if isinstance(name_or_level, int):
return name_or_level
if name_or_level is None:
return INFO
raise ValueError(f"Unknown status level {name_or_level}") | python | wandb/sdk/lib/printer.py | 81 | 96 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,212 | code | def code(self, text: str) -> str:
raise NotImplementedError | python | wandb/sdk/lib/printer.py | 99 | 100 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,213 | name | def name(self, text: str) -> str:
raise NotImplementedError | python | wandb/sdk/lib/printer.py | 103 | 104 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,214 | link | def link(self, link: str, text: Optional[str] = None) -> str:
raise NotImplementedError | python | wandb/sdk/lib/printer.py | 107 | 108 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,215 | emoji | def emoji(self, name: str) -> str:
raise NotImplementedError | python | wandb/sdk/lib/printer.py | 111 | 112 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,216 | status | def status(self, text: str, failure: Optional[bool] = None) -> str:
raise NotImplementedError | python | wandb/sdk/lib/printer.py | 115 | 116 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,217 | files | def files(self, text: str) -> str:
raise NotImplementedError | python | wandb/sdk/lib/printer.py | 119 | 120 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,218 | grid | def grid(self, rows: List[List[str]], title: Optional[str] = None) -> str:
raise NotImplementedError | python | wandb/sdk/lib/printer.py | 123 | 124 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,219 | panel | def panel(self, columns: List[str]) -> str:
raise NotImplementedError | python | wandb/sdk/lib/printer.py | 127 | 128 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,220 | __init__ | def __init__(self) -> None:
super().__init__()
self._html = False
self._progress = itertools.cycle(["-", "\\", "|", "/"]) | python | wandb/sdk/lib/printer.py | 132 | 135 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,221 | _display | def _display(
self,
text: Union[str, List[str], Tuple[str]],
*,
level: Optional[Union[str, int]] = None,
default_text: Optional[Union[str, List[str], Tuple[str]]] = None,
) -> None:
text = "\n".join(text) if isinstance(text, (list, tuple)) else text
if default_text is not None:
default_text = (
"\n".join(default_text)
if isinstance(default_text, (list, tuple))
else default_text
)
text = text or default_text
self._display_fn_mapping(level)(text) | python | wandb/sdk/lib/printer.py | 137 | 152 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,222 | _display_fn_mapping | def _display_fn_mapping(level: Optional[Union[str, int]]) -> Callable[[str], None]:
level = _Printer._sanitize_level(level)
if level >= CRITICAL:
return wandb.termerror
elif ERROR <= level < CRITICAL:
return wandb.termerror
elif WARNING <= level < ERROR:
return wandb.termwarn
elif INFO <= level < WARNING:
return wandb.termlog
elif DEBUG <= level < INFO:
return wandb.termlog
else:
return wandb.termlog | python | wandb/sdk/lib/printer.py | 155 | 169 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,223 | progress_update | def progress_update(self, text: str, percent_done: Optional[float] = None) -> None:
wandb.termlog(f"{next(self._progress)} {text}", newline=False) | python | wandb/sdk/lib/printer.py | 171 | 172 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,224 | progress_close | def progress_close(self) -> None:
wandb.termlog(" " * 79) | python | wandb/sdk/lib/printer.py | 174 | 175 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,225 | code | def code(self, text: str) -> str:
ret: str = click.style(text, bold=True)
return ret | python | wandb/sdk/lib/printer.py | 177 | 179 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,226 | name | def name(self, text: str) -> str:
ret: str = click.style(text, fg="yellow")
return ret | python | wandb/sdk/lib/printer.py | 181 | 183 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,227 | link | def link(self, link: str, text: Optional[str] = None) -> str:
ret: str = click.style(link, fg="blue", underline=True)
# ret = f"\x1b[m{text or link}\x1b[0m"
# ret = f"\x1b]8;;{link}\x1b\\{ret}\x1b]8;;\x1b\\"
return ret | python | wandb/sdk/lib/printer.py | 185 | 189 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,228 | emoji | def emoji(self, name: str) -> str:
emojis = dict()
if platform.system() != "Windows" and wandb.util.is_unicode_safe(sys.stdout):
emojis = dict(star="⭐️", broom="🧹", rocket="🚀", gorilla="🦍", turtle="🐢")
return emojis.get(name, "") | python | wandb/sdk/lib/printer.py | 191 | 196 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,229 | status | def status(self, text: str, failure: Optional[bool] = None) -> str:
color = "red" if failure else "green"
ret: str = click.style(text, fg=color)
return ret | python | wandb/sdk/lib/printer.py | 198 | 201 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,230 | files | def files(self, text: str) -> str:
ret: str = click.style(text, fg="magenta", bold=True)
return ret | python | wandb/sdk/lib/printer.py | 203 | 205 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,231 | grid | def grid(self, rows: List[List[str]], title: Optional[str] = None) -> str:
max_len = max(len(row[0]) for row in rows)
format_row = " ".join(["{:>{max_len}}", "{}" * (len(rows[0]) - 1)])
grid = "\n".join([format_row.format(*row, max_len=max_len) for row in rows])
if title:
return f"{title}\n{grid}\n"
return f"{grid}\n" | python | wandb/sdk/lib/printer.py | 207 | 213 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,232 | panel | def panel(self, columns: List[str]) -> str:
return "\n" + "\n".join(columns) | python | wandb/sdk/lib/printer.py | 215 | 216 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,233 | __init__ | def __init__(self) -> None:
super().__init__()
self._html = True
self._progress = ipython.jupyter_progress_bar() | python | wandb/sdk/lib/printer.py | 220 | 223 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,234 | _display | def _display(
self,
text: Union[str, List[str], Tuple[str]],
*,
level: Optional[Union[str, int]] = None,
default_text: Optional[Union[str, List[str], Tuple[str]]] = None,
) -> None:
text = "<br/>".join(text) if isinstance(text, (list, tuple)) else text
if default_text is not None:
default_text = (
"<br/>".join(default_text)
if isinstance(default_text, (list, tuple))
else default_text
)
text = text or default_text
self._display_fn_mapping(level)(text) | python | wandb/sdk/lib/printer.py | 225 | 240 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,235 | _display_fn_mapping | def _display_fn_mapping(level: Optional[Union[str, int]]) -> Callable[[str], None]:
level = _Printer._sanitize_level(level)
if level >= CRITICAL:
return ipython.display_html
elif ERROR <= level < CRITICAL:
return ipython.display_html
elif WARNING <= level < ERROR:
return ipython.display_html
elif INFO <= level < WARNING:
return ipython.display_html
elif DEBUG <= level < INFO:
return ipython.display_html
else:
return ipython.display_html | python | wandb/sdk/lib/printer.py | 243 | 257 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,236 | code | def code(self, text: str) -> str:
return f"<code>{text}<code>" | python | wandb/sdk/lib/printer.py | 259 | 260 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,237 | name | def name(self, text: str) -> str:
return f'<strong style="color:#cdcd00">{text}</strong>' | python | wandb/sdk/lib/printer.py | 262 | 263 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,238 | link | def link(self, link: str, text: Optional[str] = None) -> str:
return f'<a href={link!r} target="_blank">{text or link}</a>' | python | wandb/sdk/lib/printer.py | 265 | 266 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,239 | emoji | def emoji(self, name: str) -> str:
return "" | python | wandb/sdk/lib/printer.py | 268 | 269 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,240 | status | def status(self, text: str, failure: Optional[bool] = None) -> str:
color = "red" if failure else "green"
return f'<strong style="color:{color}">{text}</strong>' | python | wandb/sdk/lib/printer.py | 271 | 273 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,241 | files | def files(self, text: str) -> str:
return f"<code>{text}</code>" | python | wandb/sdk/lib/printer.py | 275 | 276 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,242 | progress_update | def progress_update(self, text: str, percent_done: float) -> None:
if self._progress:
self._progress.update(percent_done, text) | python | wandb/sdk/lib/printer.py | 278 | 280 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,243 | progress_close | def progress_close(self) -> None:
if self._progress:
self._progress.close() | python | wandb/sdk/lib/printer.py | 282 | 284 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,244 | grid | def grid(self, rows: List[List[str]], title: Optional[str] = None) -> str:
format_row = "".join(["<tr>", "<td>{}</td>" * len(rows[0]), "</tr>"])
grid = "".join([format_row.format(*row) for row in rows])
grid = f'<table class="wandb">{grid}</table>'
if title:
return f"<h3>{title}</h3><br/>{grid}<br/>"
return f"{grid}<br/>" | python | wandb/sdk/lib/printer.py | 286 | 293 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,245 | panel | def panel(self, columns: List[str]) -> str:
row = "".join([f'<div class="wandb-col">{col}</div>' for col in columns])
return f'{ipython.TABLE_STYLES}<div class="wandb-row">{row}</div>' | python | wandb/sdk/lib/printer.py | 295 | 297 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,246 | get_printer | def get_printer(_jupyter: Optional[bool] = None) -> Printer:
if _jupyter and ipython.in_jupyter():
return PrinterJupyter()
return PrinterTerm() | python | wandb/sdk/lib/printer.py | 303 | 306 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,247 | on_check | def on_check(self, inputs: T_FsmInputs) -> None:
... # pragma: no cover | python | wandb/sdk/lib/fsm.py | 53 | 54 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,248 | on_state | def on_state(self, inputs: T_FsmInputs) -> None:
... # pragma: no cover | python | wandb/sdk/lib/fsm.py | 60 | 61 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,249 | on_enter | def on_enter(self, inputs: T_FsmInputs) -> None:
... # pragma: no cover | python | wandb/sdk/lib/fsm.py | 67 | 68 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,250 | on_enter | def on_enter(self, inputs: T_FsmInputs, context: T_FsmContext_contra) -> None:
... # pragma: no cover | python | wandb/sdk/lib/fsm.py | 74 | 75 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,251 | on_stay | def on_stay(self, inputs: T_FsmInputs) -> None:
... # pragma: no cover | python | wandb/sdk/lib/fsm.py | 81 | 82 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,252 | on_exit | def on_exit(self, inputs: T_FsmInputs) -> T_FsmContext_cov:
... # pragma: no cover | python | wandb/sdk/lib/fsm.py | 88 | 89 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,253 | __init__ | def __init__(
self,
states: Sequence[FsmState],
table: FsmTableWithContext[T_FsmInputs, T_FsmContext],
) -> None:
self._states = states
self._table = table
self._state_dict = {type(s): s for s in states}
self._state = self._state_dict[type(states[0])] | python | wandb/sdk/lib/fsm.py | 128 | 136 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,254 | _transition | def _transition(
self,
inputs: T_FsmInputs,
new_state: Type[FsmState[T_FsmInputs, T_FsmContext]],
action: Optional[Callable[[T_FsmInputs], None]],
) -> None:
if action:
action(inputs)
context = None
if isinstance(self._state, FsmStateExit):
context = self._state.on_exit(inputs)
prev_state = type(self._state)
if prev_state == new_state:
if isinstance(self._state, FsmStateStay):
self._state.on_stay(inputs)
else:
self._state = self._state_dict[new_state]
if context and isinstance(self._state, FsmStateEnterWithContext):
self._state.on_enter(inputs, context=context)
elif isinstance(self._state, FsmStateEnter):
self._state.on_enter(inputs) | python | wandb/sdk/lib/fsm.py | 138 | 160 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,255 | _check_transitions | def _check_transitions(self, inputs: T_FsmInputs) -> None:
for entry in self._table[type(self._state)]:
if entry.condition(inputs):
self._transition(inputs, entry.target_state, entry.action)
return | python | wandb/sdk/lib/fsm.py | 162 | 166 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,256 | input | def input(self, inputs: T_FsmInputs) -> None:
if isinstance(self._state, FsmStateCheck):
self._state.on_check(inputs)
self._check_transitions(inputs)
if isinstance(self._state, FsmStateOutput):
self._state.on_state(inputs) | python | wandb/sdk/lib/fsm.py | 168 | 173 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,257 | __init__ | def __init__(
self,
local_name, # pylint: disable=super-on-old-class
parent_module_globals,
name,
warning=None,
):
self._local_name = local_name
self._parent_module_globals = parent_module_globals
self._warning = warning
super().__init__(str(name)) | python | wandb/sdk/lib/lazyloader.py | 17 | 28 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,258 | _load | def _load(self):
"""Load the module and insert it into the parent's globals."""
# Import the target module and insert it into the parent's namespace
module = importlib.import_module(self.__name__)
self._parent_module_globals[self._local_name] = module
# print("import", self.__name__)
# print("Set global", self._local_name)
# print("mod", module)
sys.modules[self._local_name] = module
# Emit a warning if one was specified
if self._warning:
print(self._warning)
# Make sure to only warn once.
self._warning = None
# Update this object's dict so that if someone keeps a reference to the
# LazyLoader, lookups are efficient (__getattr__ is only called on lookups
# that fail).
self.__dict__.update(module.__dict__)
return module | python | wandb/sdk/lib/lazyloader.py | 30 | 51 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,259 | __getattr__ | def __getattr__(self, item):
# print("getattr", item)
module = self._load()
return getattr(module, item) | python | wandb/sdk/lib/lazyloader.py | 56 | 59 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,260 | __dir__ | def __dir__(self):
# print("dir")
module = self._load()
return dir(module) | python | wandb/sdk/lib/lazyloader.py | 61 | 64 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,261 | generate | def generate() -> None:
urls = wburls._get_urls()
literal_list = ", ".join([f"{key!r}" for key in urls])
print(template.replace("$literal_list", literal_list)) | python | wandb/sdk/lib/_wburls_generate.py | 18 | 21 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,262 | __init__ | def __init__(self, settings):
self._settings = settings
self._errors = []
self._warnings = []
self._num_errors = 0
self._num_warnings = 0
self._context = dict() | python | wandb/sdk/lib/reporting.py | 9 | 15 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,263 | error | def error(self, __s, *args):
pass | python | wandb/sdk/lib/reporting.py | 17 | 18 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,264 | warning | def warning(self, __s, *args):
show = self._settings.show_warnings
summary = self._settings.summary_warnings
if show is not None or summary is not None:
s = __s % args
self._num_warnings += 1
if show is not None:
if self._num_warnings <= show or show == 0:
print("[WARNING]", s)
if self._num_warnings == show:
print("not showing any more warnings")
if summary is not None:
if self._num_warnings <= summary or summary == 0:
self._warnings.append(s) | python | wandb/sdk/lib/reporting.py | 20 | 33 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,265 | info | def info(self, __s, *args):
if self._settings.show_info:
print(("[INFO]" + __s) % args) | python | wandb/sdk/lib/reporting.py | 35 | 37 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,266 | internal | def internal(self, __s, *args):
pass | python | wandb/sdk/lib/reporting.py | 39 | 40 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,267 | problem | def problem(self, bool, __s=None, *args):
pass | python | wandb/sdk/lib/reporting.py | 42 | 43 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,268 | set_context | def set_context(self, __d=None, **kwargs):
if __d:
self._context.update(__d)
self._context.update(**kwargs) | python | wandb/sdk/lib/reporting.py | 45 | 48 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,269 | clear_context | def clear_context(self, keys=None):
if keys is None:
self._context = dict()
return
for k in keys:
self._context.pop(k, None) | python | wandb/sdk/lib/reporting.py | 50 | 55 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,270 | warning_count | def warning_count(self):
return self._num_warnings | python | wandb/sdk/lib/reporting.py | 58 | 59 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,271 | error_count | def error_count(self):
return self._num_errors | python | wandb/sdk/lib/reporting.py | 62 | 63 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,272 | warning_lines | def warning_lines(self):
return self._warnings | python | wandb/sdk/lib/reporting.py | 66 | 67 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,273 | error_lines | def error_lines(self):
return self._errors | python | wandb/sdk/lib/reporting.py | 70 | 71 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,274 | __init__ | def __init__(self, settings=None):
if Reporter._instance is not None:
return
if settings is None:
logging.error("internal issue: reporter not setup")
Reporter._instance = _Reporter(settings) | python | wandb/sdk/lib/reporting.py | 77 | 83 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,275 | __getattr__ | def __getattr__(self, name):
return getattr(self._instance, name) | python | wandb/sdk/lib/reporting.py | 85 | 86 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,276 | setup_reporter | def setup_reporter(settings):
# fixme: why?
# if not settings.is_frozen():
# logging.error("internal issue: settings not frozen")
r = Reporter(settings=settings)
return r | python | wandb/sdk/lib/reporting.py | 89 | 94 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,277 | get_reporter | def get_reporter():
r = Reporter()
return r | python | wandb/sdk/lib/reporting.py | 97 | 99 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,278 | __init__ | def __init__(self) -> None:
self._stub = None | python | wandb/sdk/service/service_grpc.py | 22 | 23 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,279 | get_transport | def get_transport(self) -> str:
return "grpc" | python | wandb/sdk/service/service_grpc.py | 25 | 26 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,280 | _svc_connect | def _svc_connect(self, port: int) -> None:
channel = grpc.insecure_channel(f"localhost:{port}")
stub = pbgrpc.InternalServiceStub(channel)
self._stub = stub
# TODO: make sure service is up | python | wandb/sdk/service/service_grpc.py | 28 | 32 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,281 | _get_stub | def _get_stub(self) -> pbgrpc.InternalServiceStub:
assert self._stub
return self._stub | python | wandb/sdk/service/service_grpc.py | 34 | 36 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,282 | _svc_inform_init | def _svc_inform_init(self, settings: "Settings", run_id: str) -> None:
inform_init = spb.ServerInformInitRequest()
settings_dict = settings.make_static()
_pbmap_apply_dict(inform_init._settings_map, settings_dict)
inform_init._info.stream_id = run_id
assert self._stub
_ = self._stub.ServerInformInit(inform_init) | python | wandb/sdk/service/service_grpc.py | 38 | 45 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,283 | _svc_inform_start | def _svc_inform_start(self, settings: "Settings", run_id: str) -> None:
inform_start = spb.ServerInformStartRequest()
settings_dict = settings.make_static()
_pbmap_apply_dict(inform_start._settings_map, settings_dict)
inform_start._info.stream_id = run_id
assert self._stub
_ = self._stub.ServerInformStart(inform_start) | python | wandb/sdk/service/service_grpc.py | 47 | 54 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,284 | _svc_inform_finish | def _svc_inform_finish(self, run_id: Optional[str] = None) -> None:
assert run_id
inform_finish = spb.ServerInformFinishRequest()
inform_finish._info.stream_id = run_id
assert self._stub
_ = self._stub.ServerInformFinish(inform_finish) | python | wandb/sdk/service/service_grpc.py | 56 | 62 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,285 | _svc_inform_attach | def _svc_inform_attach(self, attach_id: str) -> spb.ServerInformAttachResponse:
assert self._stub
inform_attach = spb.ServerInformAttachRequest()
inform_attach._info.stream_id = attach_id
return self._stub.ServerInformAttach(inform_attach) # type: ignore | python | wandb/sdk/service/service_grpc.py | 64 | 69 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,286 | _svc_inform_teardown | def _svc_inform_teardown(self, exit_code: int) -> None:
inform_teardown = spb.ServerInformTeardownRequest(exit_code=exit_code)
assert self._stub
_ = self._stub.ServerInformTeardown(inform_teardown) | python | wandb/sdk/service/service_grpc.py | 71 | 75 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,287 | __init__ | def __init__(
self,
settings: "Settings",
) -> None:
self._settings = settings
self._stub = None
self._grpc_port = None
self._sock_port = None
self._internal_proc = None
self._startup_debug_enabled = _startup_debug.is_enabled()
_sentry.configure_scope(process_context="service")
# Temporary setting to allow use of grpc so that we can keep
# that code from rotting during the transition
self._use_grpc = self._settings._service_transport == "grpc"
# current code only supports grpc or socket server implementation, in the
# future we might be able to support both
if self._use_grpc:
from .service_grpc import ServiceGrpcInterface
self._service_interface = ServiceGrpcInterface()
else:
self._service_interface = ServiceSockInterface() | python | wandb/sdk/service/service.py | 53 | 77 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,288 | _startup_debug_print | def _startup_debug_print(self, message: str) -> None:
if not self._startup_debug_enabled:
return
_startup_debug.print_message(message) | python | wandb/sdk/service/service.py | 79 | 82 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,289 | _wait_for_ports | def _wait_for_ports(
self, fname: str, proc: Optional[subprocess.Popen] = None
) -> None:
"""Wait for the service to write the port file and then read it.
Args:
fname: The path to the port file.
proc: The process to wait for.
Raises:
ServiceStartTimeoutError: If the service takes too long to start.
ServiceStartPortError: If the service writes an invalid port file or unable to read it.
ServiceStartProcessError: If the service process exits unexpectedly.
"""
time_max = time.monotonic() + self._settings._service_wait
while time.monotonic() < time_max:
if proc and proc.poll():
# process finished
# define these variables for sentry context grab:
# command = proc.args
# sys_executable = sys.executable
# which_python = shutil.which("python3")
# proc_out = proc.stdout.read()
# proc_err = proc.stderr.read()
context = dict(
command=proc.args,
sys_executable=sys.executable,
which_python=shutil.which("python3"),
proc_out=proc.stdout.read() if proc.stdout else "",
proc_err=proc.stderr.read() if proc.stderr else "",
)
raise ServiceStartProcessError(
f"The wandb service process exited with {proc.returncode}. "
"Ensure that `sys.executable` is a valid python interpreter. "
"You can override it with the `_executable` setting "
"or with the `WANDB__EXECUTABLE` environment variable.",
context=context,
)
if not os.path.isfile(fname):
time.sleep(0.2)
continue
try:
pf = port_file.PortFile()
pf.read(fname)
if not pf.is_valid:
time.sleep(0.2)
continue
self._grpc_port = pf.grpc_port
self._sock_port = pf.sock_port
except Exception as e:
# todo: point at the docs. this could be due to a number of reasons,
# for example, being unable to write to the port file etc.
raise ServiceStartPortError(
f"Failed to allocate port for wandb service: {e}."
)
return
raise ServiceStartTimeoutError(
"Timed out waiting for wandb service to start after "
f"{self._settings._service_wait} seconds. "
"Try increasing the timeout with the `_service_wait` setting."
) | python | wandb/sdk/service/service.py | 84 | 145 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,290 | _launch_server | def _launch_server(self) -> None:
"""Launch server and set ports."""
# References for starting processes
# - https://github.com/wandb/wandb/blob/archive/old-cli/wandb/__init__.py
# - https://stackoverflow.com/questions/1196074/how-to-start-a-background-process-in-python
self._startup_debug_print("launch")
kwargs: Dict[str, Any] = dict(close_fds=True)
# flags to handle keyboard interrupt signal that is causing a hang
if platform.system() == "Windows":
kwargs.update(creationflags=subprocess.CREATE_NEW_PROCESS_GROUP) # type: ignore [attr-defined]
else:
kwargs.update(start_new_session=True)
pid = str(os.getpid())
with tempfile.TemporaryDirectory() as tmpdir:
fname = os.path.join(tmpdir, f"port-{pid}.txt")
executable = self._settings._executable
exec_cmd_list = [executable, "-m"]
# Add coverage collection if needed
if os.environ.get("YEA_RUN_COVERAGE") and os.environ.get("COVERAGE_RCFILE"):
exec_cmd_list += ["coverage", "run", "-m"]
service_args = [
"wandb",
"service",
"--port-filename",
fname,
"--pid",
pid,
"--debug",
]
if self._use_grpc:
service_args.append("--serve-grpc")
else:
service_args.append("--serve-sock")
internal_proc = subprocess.Popen(
exec_cmd_list + service_args,
env=os.environ,
**kwargs,
)
self._startup_debug_print("wait_ports")
try:
self._wait_for_ports(fname, proc=internal_proc)
except Exception as e:
_sentry.reraise(e)
self._startup_debug_print("wait_ports_done")
self._internal_proc = internal_proc
self._startup_debug_print("launch_done") | python | wandb/sdk/service/service.py | 147 | 196 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,291 | start | def start(self) -> None:
self._launch_server() | python | wandb/sdk/service/service.py | 198 | 199 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,292 | grpc_port | def grpc_port(self) -> Optional[int]:
return self._grpc_port | python | wandb/sdk/service/service.py | 202 | 203 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,293 | sock_port | def sock_port(self) -> Optional[int]:
return self._sock_port | python | wandb/sdk/service/service.py | 206 | 207 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,294 | service_interface | def service_interface(self) -> ServiceInterface:
return self._service_interface | python | wandb/sdk/service/service.py | 210 | 211 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,295 | join | def join(self) -> int:
ret = 0
if self._internal_proc:
ret = self._internal_proc.wait()
return ret | python | wandb/sdk/service/service.py | 213 | 217 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,296 | __init__ | def __init__(
self,
grpc_port: Optional[int] = None,
sock_port: Optional[int] = None,
port_fname: Optional[str] = None,
address: Optional[str] = None,
pid: Optional[int] = None,
debug: bool = True,
serve_grpc: bool = False,
serve_sock: bool = False,
) -> None:
self._grpc_port = grpc_port
self._sock_port = sock_port
self._port_fname = port_fname
self._address = address
self._pid = pid
self._debug = debug
self._serve_grpc = serve_grpc
self._serve_sock = serve_sock
self._sock_server = None
self._startup_debug_enabled = _startup_debug.is_enabled()
if grpc_port:
_ = wandb.util.get_module(
"grpc",
required="grpc port requires the grpcio library, run pip install wandb[grpc]",
)
if debug:
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) | python | wandb/sdk/service/server.py | 30 | 59 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,297 | _inform_used_ports | def _inform_used_ports(
self, grpc_port: Optional[int], sock_port: Optional[int]
) -> None:
if not self._port_fname:
return
pf = port_file.PortFile(grpc_port=grpc_port, sock_port=sock_port)
pf.write(self._port_fname) | python | wandb/sdk/service/server.py | 61 | 67 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,298 | _start_grpc | def _start_grpc(self, mux: StreamMux) -> int:
import grpc
from wandb.proto import wandb_server_pb2_grpc as spb_grpc
from .server_grpc import WandbServicer
address: str = self._address or "127.0.0.1"
port: int = self._grpc_port or 0
pid: int = self._pid or 0
server = grpc.server(
futures.ThreadPoolExecutor(max_workers=10, thread_name_prefix="GrpcPoolThr")
)
servicer = WandbServicer(server=server, mux=mux)
try:
spb_grpc.add_InternalServiceServicer_to_server(servicer, server)
port = server.add_insecure_port(f"{address}:{port}")
mux.set_port(port)
mux.set_pid(pid)
server.start()
except KeyboardInterrupt:
mux.cleanup()
server.stop(0)
raise
except Exception:
mux.cleanup()
server.stop(0)
raise
return port | python | wandb/sdk/service/server.py | 69 | 97 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,299 | _start_sock | def _start_sock(self, mux: StreamMux) -> int:
address: str = self._address or "127.0.0.1"
port: int = self._sock_port or 0
self._sock_server = SocketServer(mux=mux, address=address, port=port)
try:
self._sock_server.start()
port = self._sock_server.port
if self._pid:
mux.set_pid(self._pid)
except KeyboardInterrupt:
mux.cleanup()
raise
except Exception:
mux.cleanup()
raise
return port | python | wandb/sdk/service/server.py | 99 | 114 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,300 | _stop_servers | def _stop_servers(self) -> None:
if self._sock_server:
self._sock_server.stop() | python | wandb/sdk/service/server.py | 116 | 118 | {
"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.