# Dvc.yaml: \`deps\` & \`outs\` section accessible from code?

**URL:** <https://discuss.dvc.org/t/dvc-yaml-deps-outs-section-accessible-from-code/577>\
**Category:** Questions\
**Created:** [December 8, 2020, 9:35pm UTC](https://discuss.dvc.org/t/dvc-yaml-deps-outs-section-accessible-from-code/577 "2020-12-08T21:35:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rabefabi](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@rabefabi](https://discuss.dvc.org/u/rabefabi)\
**Post date:** [December 8, 2020, 9:35pm UTC](https://discuss.dvc.org/t/dvc-yaml-deps-outs-section-accessible-from-code/577/1 "2020-12-08T21:35:33Z")

</div>

Hey everyone,

How do you avoid having to define the path to dependencies/outputs both in the _dvc.yaml_ as well as your code?

In the _dvc.yaml_ I have to specify paths to dependencies and outputs. In my code, I then will read/write from these paths, but have to define these paths (again) somewhere.  
Is there already a concept in place for me to read the paths directly from the yaml (to avoid defining these paths twice?)

Small example:

The _dvc.yaml_

```auto
stages:
  preprocess:
    cmd: python src/preprocess.py
    deps:
    - data/raw
    - src/preprocessing
    outs:
    - data/preprocessed

```

The `src/preprocess.py`

```python
raw_path = Path("data/raw")
preprocessed_path = Path("data/preprocessed")

preprocess(raw_path, preprocessed_path)
...

```

Obviously, in this case, I could use command line arguments to never spell out the paths inside the script and have my _dvc.yaml_ looking like this:

```auto
stages:
  preprocess:
    cmd: python src/preprocess.py data/raw data/preprocessed
    deps:
    - data/raw
    - src/preprocessing
    outs:
    - data/preprocessed

```

But this still “duplicates” the path (only inside the yaml), and isn’t always easily feasible (e.g., Jupyter Notebooks).

I’m search for something along the lines of “named dependencies and outputs”:

```auto
stages:
  preprocess:
    cmd: python src/preprocess.py data/raw data/preprocessed
    deps:
      my_raw_path: data/raw
      other:
      - src/preprocessing
    outs:
      my_preprocessed_path: data/preprocessed

```

Similar to the _params.yaml_ I could then read the _dvc.yaml_ in my code and look for the path in the dict:

```python
raw_path = Path(dvc_yaml["stages"]["preprocess"]["deps"]["my_raw_path"])
...

```

I’m not convinced whether this solution is the smartest, and was wondering how everyone else is handling this?

Cheers,  
Fabian

---

<div class="post-metadata">

**Author:** ![rabefabi](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@rabefabi](https://discuss.dvc.org/u/rabefabi)\
**Post date:** [December 8, 2020, 9:47pm UTC](https://discuss.dvc.org/t/dvc-yaml-deps-outs-section-accessible-from-code/577/2 "2020-12-08T21:47:19Z")

</div>

Hm, after browsing the forum a bit more I feel silly, seems like a similar question was just discussed a couple days ago: [Parameterlike dependencies](https://discuss.dvc.org/t/parameterlike-dependencies/565/5) .

If I understand this question and [the docs](https://github.com/iterative/dvc/wiki/Parametrization) correctly, I can specify the paths in the _params.yaml_, and have the DVC Pipeline track the values of these parameters as deps/outs:

_dvc.yaml_:

```auto
stages:
  preprocess:
    cmd: python src/preprocess.py
    deps:
      - ${raw_path}
      - src/preprocess
    outs:
      - ${preprocessed_path}

```

_params.yaml_

```auto
raw_path: "data/raw"
preprocessed_path: "data/preprocessed"

```

Just tried it in a small project, and is obviously a better solution than my proposed “named dependencies” from above.

Looking forward to the release!
