mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-07 23:09:21 +01:00
dvc: introduce pipeline list command
Fixes #1301 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+9
-1
@@ -25,7 +25,7 @@ from dvc.command.metrics import CmdMetricsRemove, CmdMetricsModify
|
||||
from dvc.command.install import CmdInstall
|
||||
from dvc.command.root import CmdRoot
|
||||
from dvc.command.lock import CmdLock, CmdUnlock
|
||||
from dvc.command.pipeline import CmdPipelineShow
|
||||
from dvc.command.pipeline import CmdPipelineShow, CmdPipelineList
|
||||
from dvc.logger import Logger
|
||||
from dvc import VERSION
|
||||
|
||||
@@ -927,6 +927,14 @@ def parse_args(argv=None):
|
||||
help="DVC files. 'Dvcfile' by default.")
|
||||
pipeline_show_parser.set_defaults(func=CmdPipelineShow)
|
||||
|
||||
PIPELINE_LIST_HELP = 'List pipelines.'
|
||||
pipeline_list_parser = pipeline_subparsers.add_parser(
|
||||
'list',
|
||||
parents=[parent_parser],
|
||||
description=PIPELINE_LIST_HELP,
|
||||
help=PIPELINE_LIST_HELP)
|
||||
pipeline_list_parser.set_defaults(func=CmdPipelineList)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
if (issubclass(args.func, CmdRepro)
|
||||
|
||||
@@ -110,3 +110,19 @@ class CmdPipelineShow(CmdBase):
|
||||
self.project.logger.error(msg, ex)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
class CmdPipelineList(CmdBase):
|
||||
def run(self):
|
||||
import networkx
|
||||
|
||||
pipelines = self.project.pipelines()
|
||||
for p in pipelines:
|
||||
stages = networkx.get_node_attributes(p, 'stage')
|
||||
for stage in stages:
|
||||
self.project.logger.info(stage)
|
||||
if len(stages) != 0:
|
||||
self.project.logger.info("="*80)
|
||||
self.project.logger.info("{} pipeline(s) total".format(len(pipelines)))
|
||||
|
||||
return 0
|
||||
|
||||
@@ -165,3 +165,15 @@ class TestPipelineShowDeep(TestReproChangedDeepData):
|
||||
def test_non_existing(self):
|
||||
ret = main(['pipeline', 'show', 'non-existing'])
|
||||
self.assertNotEqual(ret, 0)
|
||||
|
||||
|
||||
class TestPipelineListEmpty(TestDvc):
|
||||
def test(self):
|
||||
ret = main(['pipeline', 'list'])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
|
||||
class TestPipelineListSingle(TestPipelineShowDeep):
|
||||
def test(self):
|
||||
ret = main(['pipeline', 'list'])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
Reference in New Issue
Block a user