Skip to content

exp run --set-param fails to update param value  #5777

@scordee

Description

@scordee

Bug Report

exp run --set-param params.py:TrainConfig.TEMP=0.0001 : does not update TrainConfig.TEMP=1e-8

Description

When trying to run an experiment --set-param does not update class variable TrainConfig.TEMP=1e-8 to TrainConfig=0.0001 declared and defined in params.py; however, --set-param does update TrainConfig.TEMP=0.0001 to TrainConfig:TEMP=1e-8.

Reproduce

Example:

  1. Consider the Data Pipelines tutorial example with all the stages already defined in the dvc.yaml file. The yaml file contains stages prepare, featurize, train and evaluate.
  2. Besides the params.yaml file also utilise the example params.py python file, provided here
  3. Add a variable TEMP=1e-8 to TrainConfig class in params.py file
# All standard variable types are supported.
BOOL = True
INT = 5
FLOAT = 0.001
STR = 'abc'
DICT = {'a': 1, 'b': 2}
LIST = [1, 2, 3]
SET = {4, 5, 6}
TUPLE = (10, 100)
NONE = None

# DVC can retrieve class constants and variables defined in __init__
class TrainConfig:

    EPOCHS = 70
    TEMP = 1e-8

    def __init__(self):
        self.layers = 5
        self.layers = 9  # TrainConfig.layers param will be 9
        self.sum = 1 + 2  # Will NOT be found due to the expression
        bar = 3  # Will NOT be found since it's locally scoped


class TestConfig:

    TEST_DIR = 'path'
    METRICS = ['metric']
  1. Add below parameter dependencies to your Data Pipelines dvc.yaml file, such that your train stage looks like below
train:
    cmd: python src/train.py data/features model.pkl
    deps:
    - data/features
    - src/train.py
    params:
    - train.min_split
    - train.n_est
    - train.seed
    - params.py:
      - BOOL
      - INT
      - FLOAT
      - TrainConfig.EPOCHS
      - TrainConfig.TEMP
      - TrainConfig.layers
    outs:
    - model.pkl
  1. dvc repro --force
  2. dvc exp run --set-param params.py:TrainConfig.TEMP=0.0001

Expected

A new experiment with param value TrainConfig.TEMP=0.0001

Environment information

Output of dvc doctor:

DVC version: 2.0.15 (pip)
---------------------------------
Platform: Python 3.9.1 on Linux-5.4.0-70-generic-x86_64-with-glibc2.31
Supports: azure, hdfs, http, https
Cache types: hardlink, symlink
Cache directory: ecryptfs on /home/<username>/.Private
Caches: local
Remotes: local
Workspace directory: ecryptfs on /home/<username>/.Private
Repo: dvc, git

Additional Information (if any):

Metadata

Metadata

Assignees

No one assigned

    Labels

    A: experimentsRelated to dvc expbugDid we break something?p3-nice-to-haveIt should be done this or next sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions