Skip to content

Can you evaluate python code within dvc.yaml (any plans for dvc.py)? #6512

@asmith26

Description

@asmith26

Hi there,

I have a python config/templating file, which is used by dvc.yaml for a number of variables. I believe you cannot evaluate any python code within config.py from dvc.yaml - e.g. I was wondering if dvc.yaml can evaluate python so that I could use something like

config.py

from pathlib import Path

raw_data_dir = Path("raw")
processed_data_dir = Path("processed")
processed_data_filename =  "data.csv"
processed_data_path = raw_data_dir / processed_data_filename
model_name = "model.pkl"

dvc.yaml

vars:
  - config.py

stages:
  preprocess:
    cmd: python preprocess.py
    deps:
      - ${raw_data_dir}
    outs:
      - ${processed_data_path}

  train:
    cmd: python train.py
    deps:
      - ${processed_data_path}
    outs:
      - ${model_name}

Can you evaluate python code within dvc.yaml (any plans for dvc.py)? Alternatively, like params can now be a Python file, I'm curious if you have any plans to support something like dvc.py (i.e a python file replacement for dvc.yaml that could potentially evaluate python code)?

Just some thoughts - I welcome any thoughts you may have on any of this and many thanks for these amazing libraries! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions