-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Sort dvc pipeline list #2669
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
Closed
Closed
Sort dvc pipeline list #2669
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f01acd3
Added path.lstrip for / in imports
SrividyaKK 23fbb04
Merge branch 'master' of github.com:iterative/dvc
SrividyaKK c011d94
Merge branch 'master' of github.com:iterative/dvc
SrividyaKK 81b5dd6
Postorder traversal - pipeline list
SrividyaKK 9d13d0c
Postorder traversal - pipeline list
SrividyaKK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,13 +162,18 @@ def run(self): | |
|
||
class CmdPipelineList(CmdBase): | ||
def run(self): | ||
import networkx | ||
import networkx as nx | ||
|
||
pipelines = self.repo.pipelines | ||
for p in pipelines: | ||
stages = networkx.get_node_attributes(p, "stage") | ||
for stage in stages: | ||
logger.info(stage) | ||
stages = nx.get_node_attributes(p, "stage") | ||
for node in p: | ||
stage = stages[node] | ||
# if not stage.locked: | ||
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. Please don't leave commented-out code like that. Looks like you don't need it, right? If so - remove it. |
||
# continue | ||
for n in nx.dfs_postorder_nodes(p, node): | ||
if n == node: | ||
logger.info(stage) | ||
if len(stages) != 0: | ||
logger.info("=" * 80) | ||
logger.info("{} pipelines total".format(len(pipelines))) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please correct me if I'm wrong, but what you are doing here is you are walking through all nodes in the pipeline in the random order, then you do a dfs_postorder for each one of those and then just print it. This is basically the same as what it was before but now with a redundant step of
dfs_postorder_nodes
. 🙂 Looks like we can do better than that 🙂Uh oh!
There was an error while loading. Please reload this page.
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.
Good way to think about it is to imagine how the pipeline looks. So it has a N start nodes (
p.out_degree(node) == 0
), M end nodes (p.in_degree(node) == 0
) and some nodes between them. The waydvc repro --pipeline
works, is it finds all end nodes and for each of them doesdfs_postorder_nodes
and just runs those. But obviously, that real order of execution is not going to look good here 🙁 Could we somehow order them better here? Maybenx.topological_sort(p)
?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.
Thank you for the explanation. I'll work on 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.
p.out_degree(node) == 0
for end nodes andp.in_degree(node) == 0
for start nodes right?Uh oh!
There was an error while loading. Please reload this page.
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.
@SrividyaKK Actually no, our DAG has a reversed shape right now because we put edges in the direction from dependent stage to the one it depends on. So say your pipeline is
cleanup
step and thenprocess
step, then DAG would look likecleanup <- process
. Just a caveat of the current design, we might change it in the future 😉