コード例 #1
0
ファイル: sdk.py プロジェクト: krfricke/ray
    def get_job_logs(self, job_id: str) -> str:
        """Get all logs produced by a job.

        Example:
            >>> from ray.job_submission import JobSubmissionClient
            >>> client = JobSubmissionClient("http://127.0.0.1:8265") # doctest: +SKIP
            >>> job_id = client.submit_job(entrypoint="echo hello") # doctest: +SKIP
            >>> client.get_job_logs(job_id) # doctest: +SKIP
            'hello\\n'

        Args:
            job_id: The ID of the job whose logs are being requested.

        Returns:
            A string containing the full logs of the job.

        Raises:
            RuntimeError: If the job does not exist or if the request to the
            job server fails.
        """
        r = self._do_request("GET", f"/api/jobs/{job_id}/logs")

        if r.status_code == 200:
            return JobLogsResponse(**r.json()).logs
        else:
            self._raise_error(r)
コード例 #2
0
ファイル: sdk.py プロジェクト: wuisawesome/ray
    def get_job_logs(self, job_id: str) -> str:
        r = self._do_request("GET", f"/api/jobs/{job_id}/logs")

        if r.status_code == 200:
            return JobLogsResponse(**r.json()).logs
        else:
            self._raise_error(r)
コード例 #3
0
    async def get_job_logs(self, req: Request) -> Response:
        job_id = req.match_info["job_id"]
        if not self.job_exists(job_id):
            return Response(text=f"Job {job_id} does not exist",
                            status=aiohttp.web.HTTPNotFound.status_code)

        logs: str = self._job_manager.get_job_logs(job_id)
        # TODO(jiaodong): Support log streaming #19415
        resp = JobLogsResponse(logs=logs)
        return Response(text=json.dumps(dataclasses.asdict(resp)),
                        content_type="application/json")