-
Notifications
You must be signed in to change notification settings - Fork 4
Add polling with overhead to python sdk #109
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
Conversation
railib/api.py
Outdated
overhead_rate: float = 0.1, | ||
start_time: datetime = datetime.now(timezone.utc), | ||
timeout: int = None, | ||
max_retries: int = None |
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.
max_retries
is never used by any tests or examples. Speaking of which, why do we need max_retries
when we have timeout
?
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.
this was inspired from the julia sdk https://github.com/RelationalAI/rai-sdk-julia/blob/main/src/api.jl#L126-L157
timeout
and max_retries
could/should co-exist a polling library for python do the same
https://github.com/justiniso/polling/blob/master/polling.py#L44
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.
Then add tests. Also, 'retry' is usually something you do when you get an error. max_tries
from the polling library seems more correct.
railib/api.py
Outdated
|
||
def poll_with_specified_overhead( | ||
f, | ||
overhead_rate: float = 0.1, |
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.
Is 10% the standard for transactions? Seems a bit high.
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.
it's 10%
for julia sdk https://github.com/RelationalAI/rai-sdk-julia/blob/main/src/api.jl#L91
railib/api.py
Outdated
break | ||
|
||
retries += 1 | ||
duration = (datetime.now(timezone.utc) - start_time).total_seconds() * overhead_rate |
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.
Why do we use time.time()
above and datetime.now()
here?
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.
we use datetime
to convert transaction created_on
timestamp to utc datetime
(the comparison is based on utc timezone) which will require extra processing if using time.time()
we simply use time.time()
to check timeout, we can also use datetime
EDITED: This PR adds support to polling with overhead the the python sdk.
Polling delay is
x%
overhead of the time the transaction has been running so far.By default the overhead isno default value is set10%
for transactions async the overhead is
20%
similar to what we have in golang sdk