Bowrna commented on issue #29405:
URL: https://github.com/apache/airflow/issues/29405#issuecomment-1443662248
@ephraimbuddy just now your comment made sense to me. Please validate this
comment and correct me if I am wrong @bbovenzi you can make API calls like the
one below. In case this didn't work out, share it here.
```
from itsdangerous.exc import BadSignature
from itsdangerous.url_safe import URLSafeSerializer
request_url =
f"api/v1/dags/{DAG_ID}/dagRuns/{RUN_ID}/taskInstances/{TASK_ID}/logs/1"
key = self.app.config["SECRET_KEY"]
serializer = URLSafeSerializer(key)
token = serializer.dumps({"log_pos": 10000})
response = self.client.get(
request_url,
query_string={"token": token},
headers={"Accept": "text/plain"},
environ_overrides={"REMOTE_USER": "test"},
)
continuation_token = response.json["continuation_token"]
try:
metadata = URLSafeSerializer(key).loads(continuation_token)
log_pos = metadata["log_pos"] # Absolute char position to which
log is retrieved
end_of_log = metadata["end_of_log"] # Boolean, True if end of
log is reached or False
except BadSignature:
raise BadRequest("Bad Signature. Please use only the tokens
provided by the API.")
```
Here `log_pos` is the char position to which the log was retrieved in
previous calls.
Say example you make an API call and the log file is too large, you can
render only part of the log chars in the page. To render the next one, you can
send the API call like above with log_pos as say 10000, then the log starting
from char 10000 to last (not the end as the logs may be tailing behind in
running state) will be returned. that way you can do pagination with metadata
as part of the token.
@ephraimbuddy please let me know if what I mentioned above is right. Also,
what's your opinion on the documentation of this part? If yes, can you suggest
where this documentation should belong too?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]