Skip to content

Commit

Permalink
Fixes to python binoculars client
Browse files Browse the repository at this point in the history
  • Loading branch information
ClifHouck committed Sep 4, 2024
1 parent 0e3effd commit 0fc5468
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/python/armada_client/binoculars_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def logs(
self,
job_id: str,
pod_namespace: str,
since_time: datetime.datetime,
since_time: str,
pod_number: Optional[int] = 0,
log_options: Optional[core_v1.PodLogOptions] = None,
log_options: Optional[core_v1.PodLogOptions] = core_v1.PodLogOptions(),
):
log_request = binoculars_pb2.LogRequest(
job_id=job_id,
pod_number=pod_number,
pod_namespace=pod_namespace,
since_time=since_time.isoformat(),
since_time=since_time,
log_options=log_options,
)
return self.binoculars_stub.Logs(log_request)
Expand Down
36 changes: 36 additions & 0 deletions client/python/examples/binoculars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import grpc
from armada_client.binoculars_client import BinocularsClient

import datetime
import os


def main():
if DISABLE_SSL:
channel = grpc.insecure_channel(f"{HOST}:{PORT}")
else:
channel_credentials = grpc.ssl_channel_credentials()
channel = grpc.secure_channel(
f"{HOST}:{PORT}",
channel_credentials,
)

client = BinocularsClient(channel)

log_response = client.logs(
JOB_ID,
"default",
"",
)

for line in log_response.log:
print(line)


if __name__ == "__main__":
DISABLE_SSL = os.environ.get("DISABLE_SSL", True)
HOST = os.environ.get("BINOCULARS_SERVER", "localhost")
PORT = os.environ.get("BINOCULARS_PORT", "50053")
JOB_ID = os.environ.get("JOB_ID")

main()

0 comments on commit 0fc5468

Please sign in to comment.