-
Notifications
You must be signed in to change notification settings - Fork 39
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
Improve speed for workflows with hundreds of items #264
Changes from 4 commits
90f4991
4c0f102
2b2d48c
d7db46c
52b8245
f8d2021
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,8 @@ def has_retry(self): | |
def render(self, in_ctx): | ||
action_specs = [] | ||
|
||
item_ctx_value = ctx_util.copy_context(in_ctx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. having the copy here will slow down non with items . move the copy in the else clause. |
||
|
||
if not self.has_items(): | ||
action_spec = { | ||
"action": expr_base.evaluate(self.action, in_ctx), | ||
|
@@ -189,14 +191,14 @@ def render(self, in_ctx): | |
elif item_keys and len(item_keys) == 1: | ||
item = {item_keys[0]: item} | ||
|
||
item_ctx_value = ctx_util.set_current_item(in_ctx, item) | ||
|
||
item_ctx_value = ctx_util.set_current_item(item_ctx_value, item) | ||
action = expr_base.evaluate(self.action, item_ctx_value) | ||
gen_input = expr_base.evaluate(getattr(self, "input", {}), item_ctx_value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is not needed? were you just testing the variable value here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. item_ctx_value is needed i see. 195 and 196 can be reverted. |
||
action_spec = { | ||
"action": expr_base.evaluate(self.action, item_ctx_value), | ||
"input": expr_base.evaluate(getattr(self, "input", {}), item_ctx_value), | ||
"action": action, | ||
"input": gen_input, | ||
"item_id": idx, | ||
} | ||
|
||
action_specs.append(action_spec) | ||
|
||
return self, action_specs | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,11 +40,19 @@ def set_current_task(context, task): | |
return ctx | ||
|
||
|
||
def set_current_item(context, item): | ||
def copy_context(context): | ||
if context and not isinstance(context, dict): | ||
raise TypeError("The context is not type of dict.") | ||
|
||
ctx = json_util.deepcopy(context) if context else dict() | ||
return ctx | ||
|
||
|
||
def set_current_item(context, item): | ||
if context and not isinstance(context, dict): | ||
raise TypeError("The context is not type of dict.") | ||
|
||
ctx = {**context} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a shallow instead of deep copy , correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would actually leave this function as is and just do the operation in render. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, I'll move it over. And yes it's a shallow copy, but intentional. The rest of the sub-objects that are copied in a deep copy don't actually change between iteration from what I saw in testing, but the top level is what needs to change which a shallow copy still facilitates. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @guzzijones thoughts on undoing the changes to had to resend with the correct profile, switched to my laptop and forgot to switch |
||
ctx["__current_item"] = item | ||
|
||
return ctx |
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 change is not needed, correct?
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.
correct, I'll revert some of the additional changes that were made (just moved variables out of return statements to get timing on them, didn't move back)