-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fetch backfills logs in GQL (#22038)
## Summary & Motivation Fetches backfill logs using the captured log manager. Adds functionality to the captured log manager to read a sequence of files in a directory as if they are a single file by sorting the file names and then reading through the files N lines at a time. The majority of the logic is in the base CapturedLogManager class, but each implementor class will need to implement a method to get the log keys for a given directory. I implemented this method for the LocalComputeLogManager to enable testing, and follow up PRs can implement it for the remaining ComputeLogManagers. internal pr dagster-io/internal#9879 that implements the method for the cloud compute log manager Fetching logs via GQL is gated on an instance method we can override to control roll out ## How I Tested These Changes new unit tests for the pagination scheme, added a unit test where we run a backfill and then fetch the logs
- Loading branch information
1 parent
bf861da
commit 6edf6bc
Showing
11 changed files
with
497 additions
and
8 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import base64 | ||
from typing import NamedTuple, Sequence | ||
|
||
from dagster._seven import json | ||
|
||
|
||
class LogLineCursor(NamedTuple): | ||
"""Representation of a log line cursor, to keep track of the place in the logs. | ||
The captured logs are stored in multiple files in the same direcotry. The cursor keeps | ||
track of the file name and the number of lines read so far. | ||
line=-1 means that the entire file has been read and the next file should be read. This covers the | ||
case when and entire file has been read, but the next file does not exist in storage yet. | ||
line=0 means no lines from the file have been read. | ||
line=n means lines 0 through n-1 have been read from the file. | ||
has_more_now indicates if there are more log lines that can be read immediately. If the process writing | ||
logs is still running, but has not writen a log file, has_more_now will be False once all currently readable | ||
log files have been read. It does not mean that no new logs will be written in the future. | ||
""" | ||
|
||
log_key: Sequence[str] | ||
line: int # maybe rename line_offset? | ||
has_more_now: bool | ||
|
||
def __str__(self) -> str: | ||
return self.to_string() | ||
|
||
def to_string(self) -> str: | ||
raw = json.dumps( | ||
{"log_key": self.log_key, "line": self.line, "has_more_now": self.has_more_now} | ||
) | ||
return base64.b64encode(bytes(raw, encoding="utf-8")).decode("utf-8") | ||
|
||
@staticmethod | ||
def parse(cursor_str: str) -> "LogLineCursor": | ||
raw = json.loads(base64.b64decode(cursor_str).decode("utf-8")) | ||
return LogLineCursor(raw["log_key"], raw["line"], raw["has_more_now"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.