Esempio n. 1
0
def _get_server_binary():
    """Get path to data server binary or raise `RuntimeError`."""
    env_result = os.environ.get(_ENV_DATA_SERVER_BINARY)
    if env_result:
        logging.info("Server binary (from env): %s", env_result)
        if not os.path.isfile(env_result):
            raise RuntimeError(
                "Found environment variable %s=%s, but no such file exists." %
                (_ENV_DATA_SERVER_BINARY, env_result))
        return env_result

    bundle_result = os.path.join(os.path.dirname(__file__), "server", "server")
    if os.path.exists(bundle_result):
        logging.info("Server binary (from bundle): %s", bundle_result)
        return bundle_result

    try:
        import tensorboard_data_server
    except ImportError:
        pass
    else:
        pkg_result = tensorboard_data_server.server_binary()
        logging.info("Server binary (from Python package): %s", pkg_result)
        if pkg_result is None:
            raise RuntimeError(
                "TensorBoard data server not supported on this platform.")
        return pkg_result

    raise RuntimeError(
        "TensorBoard data server not found. This mode is experimental. "
        "If building from source, pass --define=link_data_server=true.")
Esempio n. 2
0
def _get_server_binary():
    env_result = os.environ.get(_ENV_DATA_SERVER_BINARY)
    if env_result:
        logging.info("Server binary (from env): %s", env_result)
        return env_result

    try:
        import tensorboard_data_server
    except ImportError:
        pass
    else:
        pkg_result = tensorboard_data_server.server_binary()
        logging.info("Server binary (from Python package): %s", pkg_result)
        return pkg_result

    bundle_result = os.path.join(os.path.dirname(__file__), "server", "server")
    logging.info("Server binary (from bundle): %s", bundle_result)
    return bundle_result
Esempio n. 3
0
def tensorboard_data_server_version():
    try:
        import tensorboard_data_server
    except ImportError:
        logging.info("no data server installed")
        return

    path = tensorboard_data_server.server_binary()
    logging.info("data server binary: %r", path)
    if path is None:
        return

    try:
        subprocess_output = subprocess.run(
            [path, "--version"],
            capture_output=True,
            check=True,
        )
    except subprocess.CalledProcessError as e:
        logging.info("failed to check binary version: %s", e)
    else:
        logging.info("data server binary version: %s",
                     subprocess_output.stdout.strip())