-
Notifications
You must be signed in to change notification settings - Fork 58
feat: Add inherit timeout option for Actor.call and Actor.start
#518
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
Actor.call and Actor.startRemainingTime timeout option for Actor.call and Actor.start
08efc4b to
3fc6e13
Compare
3fc6e13 to
8cbd80d
Compare
barjin
left a comment
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 looks pretty straightforward implementation-wise, so it's almost a go from me 👍
I have these two points to discuss:
packages/apify/src/actor.ts
Outdated
| * Using `RemainingTime` will set timeout of the other Actor run to the time | ||
| * remaining from this Actor run timeout. | ||
| */ | ||
| timeout?: number | 'RemainingTime'; |
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 Pascal-cased string constant doesn't feel right, format-wise. How about 'inherit'?
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.
Not sure about the common casing of string literals in JS, but this is the same literal as in the Python implementation. So, unless there is some name suggestion that is better by a lot, then I would prefer to keep it consistent.
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.
I also like inherit much better.
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.
So what do we do with the Python version now? Deprecate RemainingTime in favor of inherit?
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.
I'd be up for that, what do you think about the naming 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.
Yeah, I don't mind it 🙂
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.
4adfd51 to
f8962e6
Compare
Co-authored-by: Jindřich Bär <[email protected]>
f8962e6 to
358ad03
Compare
1d8b73b to
f8f383f
Compare
packages/apify/src/actor.ts
Outdated
| */ | ||
| private _getRemainingTime(): number | undefined { | ||
| const env = this.getEnv(); | ||
| if (env.isAtHome === '1' && env.timeoutAt !== null) { |
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.
| if (env.isAtHome === '1' && env.timeoutAt !== null) { | |
| if (Boolean(env.isAtHome) && env.timeoutAt !== null) { |
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.
should be just this.isAtHome()
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, we're in Actor 🤦 you're right
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.
Using this.isAtHome()
packages/apify/src/actor.ts
Outdated
| return env.timeoutAt.getTime() - Date.now(); | ||
| } | ||
| log.warning( | ||
| 'Returning `undefined` instead of remaining time. Using `inherit` argument is only possible when ' + |
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 user reading this message won't understand what "Returning undefined" means. I think we could just remove the first sentence and keep the second one.
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.
Ok, removed.
Co-authored-by: Jan Buchar <[email protected]>
B4nan
left a comment
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 changes in the lockfile feels a bit suspicious, surely unrelated
barjin
left a comment
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.
lgtm, thank you!
Two nits:
- please update the PR title (
inheritinstead ofRemainingTime) - When do we add this option for
ActorTask.call/start? Should this happen in this PR?
RemainingTime timeout option for Actor.call and Actor.startinherit timeout option for Actor.call and Actor.start
39db1a1 to
a9b4507
Compare
RemainingTimetimeout option forActor.call,Actor.startandActor.callTask. This will set the timeout of anotherActorrun to whatever is left from the timeout of the currentActorrunRelated to: apify/apify-client-js#632
Python implementation: apify/apify-sdk-python#473