How to use the tensorboard.backend.http_util.Respond function in tensorboard

To help you get started, we’ve selected a few tensorboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensorflow / tensorboard / tensorboard / plugins / audio / audio_plugin.py View on Github external
Returns:
          A werkzeug.Response application.
        """
        tag = request.args.get("tag")
        run = request.args.get("run")
        sample = int(request.args.get("sample", 0))

        events = self._multiplexer.Tensors(run, tag)
        try:
            response = self._audio_response_for_run(events, run, tag, sample)
        except KeyError:
            return http_util.Respond(
                request, "Invalid run or tag", "text/plain", code=400
            )
        return http_util.Respond(request, response, "application/json")
github tensorflow / tensorboard / tensorboard / plugins / graph / graphs_plugin.py View on Github external
def info_route(self, request):
        experiment = plugin_util.experiment_id(request.environ)
        info = self.info_impl(experiment)
        return http_util.Respond(request, info, "application/json")
github tensorflow / tensorboard / tensorboard / backend / application.py View on Github external
def wrapper(*args):
        (environ, start_response) = (args[-2], args[-1])
        try:
            return wsgi_app(*args)
        except errors.PublicError as e:
            request = wrappers.Request(environ)
            error_app = http_util.Respond(
                request, str(e), "text/plain", code=e.http_code
            )
            return error_app(environ, start_response)
        # Let other exceptions be handled by the server, as an opaque
github tensorflow / tensorboard / tensorboard / plugins / image / images_plugin.py View on Github external
try to parse information about them or generate them itself, as the format
        may change.

        Args:
          request: A werkzeug.wrappers.Request object.

        Returns:
          A werkzeug.Response application.
        """
        tag = request.args.get("tag")
        run = request.args.get("run")
        sample = int(request.args.get("sample", 0))
        try:
            response = self._image_response_for_run(run, tag, sample)
        except KeyError:
            return http_util.Respond(
                request, "Invalid run or tag", "text/plain", code=400
            )
        return http_util.Respond(request, response, "application/json")
github tensorflow / tensorboard / tensorboard / plugins / projector / projector_plugin.py View on Github external
def _serve_bookmarks(self, request):
        run = request.args.get("run")
        if not run:
            return Respond(
                request, 'query parameter "run" is required', "text/plain", 400
            )

        name = request.args.get("name")
        if name is None:
            return Respond(
                request, 'query parameter "name" is required', "text/plain", 400
            )

        if run not in self.configs:
            return Respond(
                request, 'Unknown run: "%s"' % run, "text/plain", 400
            )

        config = self.configs[run]
        fpath = self._get_bookmarks_file_for_tensor(name, config)
        if not fpath:
            return Respond(
                request,
                'No bookmarks file found for tensor "%s" in the config file "%s"'
                % (name, self.config_fpaths[run]),
                "text/plain",
github tensorflow / tensorboard / tensorboard / plugins / pr_curve / pr_curves_plugin.py View on Github external
def pr_curves_route(self, request):
        """A route that returns a JSON mapping between runs and PR curve data.

        Returns:
          Given a tag and a comma-separated list of runs (both stored within GET
          parameters), fetches a JSON object that maps between run name and objects
          containing data required for PR curves for that run. Runs that either
          cannot be found or that lack tags will be excluded from the response.
        """
        runs = request.args.getlist("run")
        if not runs:
            return http_util.Respond(
                request, "No runs provided when fetching PR curve data", 400
            )

        tag = request.args.get("tag")
        if not tag:
            return http_util.Respond(
                request, "No tag provided when fetching PR curve data", 400
            )

        try:
            response = http_util.Respond(
                request, self.pr_curves_impl(runs, tag), "application/json"
            )
        except ValueError as e:
            return http_util.Respond(request, str(e), "text/plain", 400)
github tensorflow / tensorboard / tensorboard / plugins / interactive_inference / interactive_inference_plugin.py View on Github external
request: A request that should contain 'index' and 'example'.

        Returns:
          An empty response.
        """
        if request.method != "POST":
            return http_util.Respond(
                request,
                {"error": "invalid non-POST request"},
                "application/json",
                code=405,
            )
        example_json = request.form["example"]
        index = int(request.form["index"])
        if index >= len(self.examples):
            return http_util.Respond(
                request,
                {"error": "invalid index provided"},
                "application/json",
                code=400,
            )
        new_example = self.example_class()
        json_format.Parse(example_json, new_example)
        self.examples[index] = new_example
        self.updated_example_indices.add(index)
        self.generate_sprite([ex.SerializeToString() for ex in self.examples])
        return http_util.Respond(request, {}, "application/json")
github tensorflow / tensorboard / tensorboard / plugins / pr_curve / pr_curves_plugin.py View on Github external
return http_util.Respond(
                request, "No runs provided when fetching PR curve data", 400
            )

        tag = request.args.get("tag")
        if not tag:
            return http_util.Respond(
                request, "No tag provided when fetching PR curve data", 400
            )

        try:
            response = http_util.Respond(
                request, self.pr_curves_impl(runs, tag), "application/json"
            )
        except ValueError as e:
            return http_util.Respond(request, str(e), "text/plain", 400)

        return response
github tensorflow / tensorboard / tensorboard / plugins / projector / projector_plugin.py View on Github external
def _serve_metadata(self, request):
        run = request.args.get("run")
        if run is None:
            return Respond(
                request, 'query parameter "run" is required', "text/plain", 400
            )

        name = request.args.get("name")
        if name is None:
            return Respond(
                request, 'query parameter "name" is required', "text/plain", 400
            )

        num_rows = _parse_positive_int_param(request, "num_rows")
        if num_rows == -1:
            return Respond(
                request,
                "query parameter num_rows must be integer > 0",
                "text/plain",
                400,
github tensorflow / tensorboard / tensorboard / plugins / core / core_plugin.py View on Github external
def _serve_asset(self, path, gzipped_asset_bytes, request):
        """Serves a pre-gzipped static asset from the zip file."""
        mimetype = mimetypes.guess_type(path)[0] or "application/octet-stream"
        return http_util.Respond(
            request, gzipped_asset_bytes, mimetype, content_encoding="gzip"
        )