-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Use PEP 562-style lazy exports while still allowing for easy type checking #1229
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
Open
falahat
wants to merge
13
commits into
m-bain:main
Choose a base branch
from
falahat:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+186
−21
Conversation
This file contains hidden or 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
Author
|
Also, I apologize for the numerous commits, I recommend a "squash" merge if you approve the PR |
Author
|
Note, this PR also improves the type checking in diarizer.py to clarify the two (technically 3) ways we can call the diarize model and how it can return the speaker_embeddings or npt |
Author
|
I created an issue, #1232 to track this |
This workflow automates the process of uploading a Python package to PyPI when a release is created, including build and upload steps.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the init.py defines some methods with
args*andkwargs**which intercept method calls and lazily load the real methods (i.e.alignment.load_alignment_model.) This is good for perf, but the exported API is tough to use and opaque. It was unclear to me what the input parameters should be and static type checkers were unhappy.This PR changes the init.py to use PEP 562-style exports, using the getattr method on the module itself to lazily load modules.
However, it also includes an "if TYPE_CHECKING" clause. This explicitly exports the actual methods, types, etc for the static type checking. However, during runtime, these modules are still lazily loaded efficiently.
Also, this PR exposes the DiarizationPipeline class since we need the diarization dataframe (which this pipeline creates) in order to use the "assign_speakers" method anyway. Let me know if that was removed on purpose or is no longer supported.
I couldn't find any unit tests. I will manually test this with my project (I am working on transcribing and diarizing some audio data) and report findings here. So far, I've tested my branch and the imports / type checks work correctly as expected.
Let me know if there is any specific testing I should perform other than basic audio transcription