dvc: pull: Pulling a `.dvc` file with the option `-d` produces an AssertionError

Bug Report

Description

When I run:

dvc pull -d data/KPI/tracking-metrics.dvc

I go an AssertionError:

  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/graph.py", line 31, in get_pipeline
    assert len(found) == 1

Expected

I think using -d with a dvc file does not make sense but I was expecting a clearer error message. Also, I can’t use the -d option to pull a stage and a dvc file with the same command line (ie. dvc -d data/KPI/tracking-metrics.dvc a_stage_in_dvc_yaml produces the AssertionError)

Additional Information (if any):

Full error message
2021-04-08 11:14:19,615 ERROR: unexpected error
------------------------------------------------------------
Traceback (most recent call last):
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/main.py", line 55, in main
    ret = cmd.run()
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/command/data_sync.py", line 40, in run
    glob=self.args.glob,
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/__init__.py", line 49, in wrapper
    return f(repo, *args, **kwargs)
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/pull.py", line 38, in pull
    run_cache=run_cache,
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/__init__.py", line 49, in wrapper
    return f(repo, *args, **kwargs)
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/fetch.py", line 53, in fetch
    revs=revs,
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/__init__.py", line 392, in used_cache
    for stage, filter_info in pairs:
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/__init__.py", line 388, in <genexpr>
    for target in targets
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/stage.py", line 421, in collect_granular
    accept_group=accept_group,
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/stage.py", line 366, in collect
    return _collect_with_deps(stages, graph or self.graph)
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/stage.py", line 55, in _collect_with_deps
    res.update(collect_pipeline(stage, graph=graph))
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/graph.py", line 44, in collect_pipeline
    pipeline = get_pipeline(get_pipelines(graph), stage)
  File "/app/speech/.venv/lib/python3.7/site-packages/dvc/repo/graph.py", line 31, in get_pipeline
    assert len(found) == 1
AssertionError
------------------------------------------------------------
2021-04-08 11:14:19,720 DEBUG: Version info for developers:
DVC version: 2.0.14 (pip)
---------------------------------
Platform: Python 3.7.5 on Linux-4.19.121-linuxkit-x86_64-with-Ubuntu-18.04-bionic
Supports: http, https, s3
Cache types: hardlink, symlink
Cache directory: overlay on overlay
Caches: local
Remotes: s3
Workspace directory: overlay on overlay
Repo: dvc, git

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

@courentin, yeah it’s wrong that it expects only one pipeline.

https://github.com/iterative/dvc/blob/353e4cf3746345ee94a2d907d16c688e97fb1bfd/dvc/repo/graph.py#L41-L45

We should just do something similar to the following instead:

return chain.from_iterable(nx.dfs_postorder_nodes(graph, source=stage) for stage in stages)