-
Notifications
You must be signed in to change notification settings - Fork 778
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
feat: ✨ Change the Graph creation to allow subclassing #2086
base: master
Are you sure you want to change the base?
feat: ✨ Change the Graph creation to allow subclassing #2086
Conversation
Testing[841] @ 0a964bd |
Testing[841] @ 0a964bd had 52 FAILUREs. |
Alright, I finally got around to this and there is an issue that is minor but nonetheless: The reason for this (I think) is that:
I suspect that this would make line-number incorrect so we should probably store line and file or something. This is used in the graph object and we actually rely on it as well for stuff like debug integration (see here: https://github.com/Netflix/metaflow-nflx-extensions/blob/1c534c567beb90de584db7cc2e2b624f08d8498d/metaflow_extensions/netflix_ext/cmd/debug/debug_script_generator.py#L395) So we somehow need to get equivalent information (probably file and line number) and that should be ok. |
Hi @romain-intel, Previously it was the case that all steps were defined in the same module and the In the implementation I used the e.g. from metaflow import FlowSpec, step # line 1
# line 2
...
# line 20
class BaseFlow(FlowSpec): # line 21
@step # line 22 - line 1 in func_ast
def start(self): # line 23 - line 2 in func_ast
print("this is the start") # line 24 - line 3 in func_ast
self.next(self.step1) # line 25 - line 4 in func_ast To resolve the issue I updated the constructor of the However by allowing subclassing of flows one step may be in a different file from another and hence we could still get a To resolve this I changed to iterate on the I also notice in the codebase we use the linenumber in a lot of if re.search("[^a-z0-9_]", node.name) or node.name[0] == "_":
raise LintWarn(msg.format(node), node.func_lineno) We might want to consider extending these warnings to log the |
OK, I like where this is going. Yes, I think you are right that we should indicate the file and line number. I think we also need to add the source file in the node_to_dict function so that we can pick it up in the debug integration. Looping @talsperre to check on this. |
Hi @romain-intel, I am going on holiday for a couple of weeks now but I made a few more changes based on what you suggested:
Let me know what you think 😄 |
Hey @romain-intel , Just wondered if you had any time to get to this? |
Alright. Why are the tests not running here. I'll run them internally and check. |
Testing[902] @ 3b1c1eb |
OK, the changes look good to me, I just need to probably make a few changes here: https://github.com/Netflix/metaflow-nflx-extensions/blob/main/metaflow_extensions/netflix_ext/cmd/debug/debug_script_generator.py#L409 (and probably a few other places) so that it doesn't break when this change merges. I should be able to test this out and make the requisite changes. @talsperre for viz as well. |
Great - thanks @romain-intel. Let me know if there are any outstanding tasks I can help with. |
…ture/enable-subclassing-flows
Testing[902] @ 8840bd2 |
Testing[902] @ 8840bd2 had 12 FAILUREs. |
From the previous comment i can see that 12 failures happened somewhere. Is there anyway I can see these and fix them? |
Make compatible with configs.
Testing[3895224] @ bb83d0c |
Coincidentally, this is now going to be needed for configs too. I've made a tiny change to make it compatible and will merge as soon as the tests pass (or at least nothing unexpected happens). Yes, finally! |
Currently it is not possible to subclass a Flow as in the example snippet below.
This PR alters the graph construction that enables this flow subclassing. Instead of using the
ast.NodeVisitor
class to collect the steps and theirast.FunctionDef
's. I have instead iterated on thedir(flow)
and then extracted the functionast.FunctionDef
's.As referenced in this issue: #144
and discussed in this issue: #245
I have not yet added tests for this PR as the approach to this might take some discussion. The current Test harness setup uses the
FlowFormatter
class to generate flows on the fly but all of these assume the flow directly inherits off the FlowSpec. How might we go about testing this kind of subclassing?Note this PR was originally raised as #2035 but from the wrong branch