-
Notifications
You must be signed in to change notification settings - Fork 815
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
[Ready for Review] Make TOGGLE_DECOSPECS only add default decorator once. #2097
Conversation
bf90146
to
c0c0299
Compare
10b9856
to
2ba22db
Compare
metaflow/metaflow_config.py
Outdated
@@ -285,7 +285,7 @@ | |||
### | |||
# Format is a space separated string of decospecs (what is passed | |||
# using --with) | |||
DECOSPECS = from_conf("DECOSPECS", "") | |||
DECOSPECS = from_conf("DEFAULT_DECOSPECS", "") |
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.
To be consistent, I would rename this: DEFAULT_DECOSPECS = from_conf("DEFAULT_DECOSPECS", "")
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.
updated
@@ -739,7 +739,9 @@ class BlankCard(MetaflowCard): | |||
|
|||
type = "blank" | |||
|
|||
def __init__(self, options=dict(title=""), components=[], graph=None, **kwargs): | |||
def __init__( | |||
self, options=dict(title=""), components=[], graph=None, flow=None, **kwargs |
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.
unrelated change? I think it's valid though but jsut checking.
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.
its old, removed
metaflow/cli_components/step_cmd.py
Outdated
@@ -7,6 +7,7 @@ | |||
from ..task import MetaflowTask | |||
from ..unbounded_foreach import UBF_CONTROL, UBF_TASK | |||
from ..util import decompress_list | |||
from ..metaflow_config import DECOSPECS |
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 would therefore be DEFAULT_DECOSPECS
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.
updated
metaflow/cli_components/step_cmd.py
Outdated
@@ -127,6 +128,20 @@ def step( | |||
raise CommandException("Function *%s* is not a step." % step_name) | |||
echo("Executing a step, *%s*" % step_name, fg="magenta", bold=False) | |||
|
|||
decospecs = tuple(DECOSPECS.split()) | |||
if decospecs: | |||
decorators._attach_decorators_to_step(func, decospecs) |
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 think this needs to be done earlier when we do _attach_decorators
because here you may be missing out on some of the lifecycle hooks. The issue though is we still need to prevent them from loading the second time around. What I would suggest (and not 100% sure this would work) is that when we launch the subprocess (or any of the commands), we explicitly set METAFLOW_DEFAULT_DECOSPECS
to an empty value since all decospecs will now be passed using METAFLOW_DECOSPECS
or on the CL.
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 just realized that we can rely on run_cmd because it also add decorator to downstream. can you help review updated PR?
metaflow/decorators.py
Outdated
# then check if we see any duplicate attributes. If we do, | ||
# we ignore the new decorator and continue. | ||
for deco in func.decorators: | ||
if deco.name == decotype.name and deco.attributes == kwargs: |
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 think this is where we can merge with defaults so that we can properly compare.
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.
weird enough, we dont reach this function now (maybe some changes to the flow or maybe I hallucinated, I need to take a deeper look on what's going on with the check
2ba22db
to
b7c147f
Compare
1feac60
to
92b248f
Compare
how did you test this PR? |
added the test command in the description |
Can we add an actual test for this? Edit: just realized this is in the OSS repo. Maybe add a UX test on our end? |
yes, I made this change so that we can add default metrics card for runs with GPU, will update UX test for that |
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 think this is fine. I think we can further simplify though.
metaflow/cli_components/run_cmds.py
Outdated
# from_conf) | ||
|
||
# Special case where DEFAULT_DECOSPECS and value are the same. This happens | ||
# when there is no --with option at the TL and DEFAULT_DECOSPECS is read from |
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.
nit: it's not the TL but more at the run/resume level.
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.
updated
metaflow/cli_components/run_cmds.py
Outdated
# when there is no --with option at the TL and DEFAULT_DECOSPECS is read from | ||
# the env var. In this case, click also passes it as value | ||
splits = DEFAULT_DECOSPECS.split() | ||
if len(splits) == len(value) and all([a == b for (a, b) in zip(splits, value)]): |
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.
Looking at this: https://click.palletsprojects.com/en/stable/advanced/#callback-evaluation-order, the callback is called even if there is no value passed in but I don't think it will have the value DEFAULT_DECOSPECS since now that is not the same name as before. I think we can get rid this line.
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.
updated, and also comments.
This is needed when we add value to DECOSPECS (or TOGGLE_DECOPSECS).
Changes:
--with
config_merge_cb
fromstart
but move it torun
. This is because "start" is called both in beginning of runtime and start of each task subprocess. Moving it torun
will also attach decorator to each step.Before the change:
when we use TOGGLE_DECOSPECS and run a flow, it first inject
X
as decorator at flow level (by thisconfig_merge_cb
. It then get passed to the subprocess when we runstep
. Whenstep
starts, it injects thisX
again, resulting in double decoratorsAfter the change
when we use TOGGLE_DECOSPECS and run a flow, it no longer inject
X
(because thisconfig_merge_cb
is no longer instart
incli.py
), When subprocess starts to runstep
, we inject thisX
to decorator (within step command line execution).To test:
The following should include default card (once) in each step.