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

[DOW-113] deprecate output queue and manually attach workers to each other #593

Conversation

ajar98
Copy link
Contributor

@ajar98 ajar98 commented Jun 28, 2024

overall idea here - pushes the notion of queues under the abstraction barrier of workers. Workers do not need to know about the inner workings of how other workers process their events. In order to wire up workers, manually connect them to each other using instance variables and only use consume_nonblocking to communicate - this also improves the typing of events coming out of workers.

Mechanically:

  • creates AbstractWorker which just knows how to consume inputs, but places no restrictions on how it creates asyncio.Queues to do the processing
  • changes AsyncWorker to only create an input_queue, and not have it be overrideable
  • change the constructor of StreamingConversation so that the workers are connected to each other as described above

Also adds a nice test that asserts that a message can make it through the whole pipeline (test_streaming_conversation_pipeline)

@ajar98 ajar98 force-pushed the ajay/dow-113-deprecate-output-queue-and-manually-attach-workers-to-each branch from c86f666 to 9e28363 Compare June 28, 2024 23:19
@ajar98 ajar98 changed the base branch from main to ajay/dow-105-refactor-interrupts June 28, 2024 23:20
@ajar98 ajar98 marked this pull request as draft June 28, 2024 23:20
@ajar98 ajar98 force-pushed the ajay/dow-113-deprecate-output-queue-and-manually-attach-workers-to-each branch from c787ea0 to 84afa9c Compare July 3, 2024 19:15
@ajar98 ajar98 changed the base branch from ajay/dow-105-refactor-interrupts to main July 3, 2024 19:15
@ajar98 ajar98 changed the title [WIP][DOW-113] deprecate output queue and manually attach workers to each other [DOW-113] deprecate output queue and manually attach workers to each other Jul 3, 2024
@ajar98 ajar98 marked this pull request as ready for review July 3, 2024 19:15
@ajar98 ajar98 requested a review from adnaans July 3, 2024 20:03
vocode/streaming/utils/worker.py Show resolved Hide resolved
vocode/streaming/action/worker.py Show resolved Hide resolved
vocode/streaming/streaming_conversation.py Show resolved Hide resolved
@@ -253,7 +259,9 @@ async def test_transcriptions_worker_ignores_utterances_before_initial_message(
is_final=True,
),
)
assert await _consume_worker_output(streaming_conversation.transcriptions_worker) is None
transcriptions_worker_consumer = QueueConsumer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should remove line 239 right? And attach the consumer earlier? The consumer otherwise doesn't get the consume_nonblocking() results above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, absolutely right!

@@ -310,7 +318,10 @@ async def test_transcriptions_worker_ignores_associated_ignored_utterance(
is_final=False,
),
)
assert await _consume_worker_output(streaming_conversation.transcriptions_worker) is None
transcriptions_worker_consumer = QueueConsumer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm correct above, likewise here and in all other relevant parts below

@ajar98 ajar98 requested a review from adnaans July 5, 2024 19:36
@@ -390,6 +383,7 @@ async def test_transcriptions_worker_interrupts_on_interim_transcripts(

transcriptions_worker_consumer = QueueConsumer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consumer should be added before like 376 again

@@ -437,6 +428,7 @@ async def test_transcriptions_worker_interrupts_immediately_before_bot_has_begun
)
transcriptions_worker_consumer = QueueConsumer()
streaming_conversation.transcriptions_worker.consumer = transcriptions_worker_consumer
streaming_conversation.transcriptions_worker.start()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consumer should be added before 422

@ajar98 ajar98 requested a review from adnaans July 5, 2024 22:38
@ajar98 ajar98 merged commit d4b139e into main Jul 5, 2024
4 checks passed
ajar98 added a commit that referenced this pull request Jul 6, 2024
…other (#593)

* deprecate output queues

* fix quickstarts

* fix mypy

* fix tests

* fix mypy

* adds comment

* adds back streamingconversation test

* make input queue private on AsyncWorker

* update tests

* resolve PR comments
ajar98 added a commit that referenced this pull request Jul 8, 2024
* remove phantom parameter (#612)

* support files in make transcribe (#610)

* support files in make transcribe

* switch comment

* uses .value instead of passing enum for sampling rate (#613)

* [hotfix] fix ref in make transcribe (#614)

* [DOW-113] deprecate output queue and manually attach workers to each other (#593)

* deprecate output queues

* fix quickstarts

* fix mypy

* fix tests

* fix mypy

* adds comment

* adds back streamingconversation test

* make input queue private on AsyncWorker

* update tests

* resolve PR comments

* create scripts for vocodehq-public (#615)

* add script used to make PR

* adds test target for vocodehq-public
@ajar98 ajar98 linked an issue Jul 19, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor workers to abstract away queues
2 participants