Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add octue logs CLI command #662

Open
cortadocodes opened this issue Jun 24, 2024 · 1 comment
Open

Add octue logs CLI command #662

cortadocodes opened this issue Jun 24, 2024 · 1 comment
Labels
feature A new feature of the app

Comments

@cortadocodes
Copy link
Member

Feature request

Use Case

I'd like to be able to connect to a question running on a service revision at any given time and see the latest logs stream to me in real time.

Current state

I can use the get_events function and EventReplayer class periodically but this requires repeated manual execution.

Proposed Solution

Add an octue logs CLI command that sets up a subscriber to the events of a question and displays them in real time.

@cortadocodes cortadocodes added the feature A new feature of the app label Jun 24, 2024
@cortadocodes
Copy link
Member Author

It could looks something like this

from octue.cloud.pub_sub import Subscription, Topic
from octue.resources.service_backends import GCPPubSubBackend
from octue.cloud.pub_sub.service import Service
from octue.cloud.pub_sub.events import GoogleCloudPubSubEventHandler


question_uuid = "facd9ada-f9be-4276-89bb-d114eb6a5302"


topic = Topic(name="octue.services", project_name=PROJECT_NAME)
subscription = Subscription(
    name=f"octue.services.gulfwindtech.dlc-service.add-real-dlc-ser.answers.{question_uuid}",
    topic=topic,
    filter=(
        f'attributes.question_uuid = "{question_uuid}" '
        f'AND attributes.sender_type = "CHILD"'
    ),
)
subscription.create()

event_handler = GoogleCloudPubSubEventHandler(
    subscription=subscription,
    recipient=Service(backend=GCPPubSubBackend(project_name=PROJECT_NAME)),
)

event_handler.handle_events()

subscription.delete()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature of the app
Projects
None yet
Development

No branches or pull requests

1 participant