-
Notifications
You must be signed in to change notification settings - Fork 202
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
Create a dataclass for indexer worker TaskStatus #4601
Merged
stacimc
merged 4 commits into
WordPress:main
from
akshay-km:dev-index-worker-task-dataclass
Jul 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
534fafb
#4534 -Created a dataclass for indexer worker TaskStatus
akshay-km e823339
Made types more precise in dataclass for indexer worker TaskStatus as…
akshay-km 5871bf2
Changed timestamps to float and type of progress, finish_time to Syn…
akshay-km 4c10cab
Use `Synchronized[float]` type
krysal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types can be more precise here. Below, the times are passed to the
_time_fmt
function that accepts integers, and probablyprogress
is also an integer; @stacimc can confirm.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @krysal ,
finish_time
andprogress
has the same type: <class 'multiprocessing.sharedctypes.Synchronized'> .But the value of
progress
in the api response is100.0
. So should it be set as afloat
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float
would be appropriate for the timestamps (and you can change the type of thetimestamp
parameter in_time_fmt
to match, actually!)progress
andfinish_time
are shared variables usingmultiprocessing.Value
so I believe the correct type would beSynchronized[float]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HI @stacimc When using
Synchronized[float]
, I am getting aTypeError: type 'Synchronized' is not subscriptable
becauseSynchronized
is not a type that can be parameterized in thetyping module
. So I have usedSynchronized
as type ofprogress
andfinish_time
. Also usedfloat
as type for timestamps including for the parameter in_time_fmt_
function.Have made a new commit with these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting! It looks like
Synchronized
is in the typeshed package/not available at runtime. I think the fix should be to addfrom __future__ import annotations
to the top of the file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Learned something new :)