dvc run -m/-M: inconsistent behavior with dirs

Created on 2 Jun 2020  路  3Comments  路  Source: iterative/dvc

dvc run with -M flag doesn't accept directories as metrics whereas dvc run with -m flag does. This behavior should be unified.

DVC version:

  • 0.94 (snap package)

Additional Information :

Steps to reproduce

  1. Initialize git and dvc

  2. Create evaluate.py:

import argparse
import os
import json

parser = argparse.ArgumentParser()
parser.add_argument("--metrics_dir", required=True)
args = parser.parse_args()
metrics_dir = args.metrics_dir

if not os.path.exists(metrics_dir):
    os.makedirs(metrics_dir)

with open(os.path.join(metrics_dir, "metrics1.json"), "w") as f:
    json.dump({"acc": 1.0}, f)

with open(os.path.join(metrics_dir, "metric2.json"), "w") as f:
    json.dump({"acc": 0.5}, f)
  1. Create new stage with directory as cached metrics output:
$ dvc run -f metrics_cached.dvc -d evaluate.py -m metrics_cached  python3 evaluate.py --metrics_dir metrics_cached
Running command:
        python3 evaluate.py --metrics_dir metrics_cached

To track the changes with git, run:

        git add metrics_cached.dvc .gitignore
  1. Create new stage with directory as not cached metrics output:
$ dvc run -f metrics_not_cached.dvc -d evaluate.py -M metrics_not_cached  python3 evaluate.py --metrics_dir metrics_not_cached
Running command:
        python3 evaluate.py --metrics_dir metrics_not_cached
ERROR: failed to run command - directory 'metrics_not_cached' cannot be used as metrics.

Both commands should either accept directories as metrics either discard them

bug p1-important

All 3 comments

Also found out that dvc run --help explicitly declares support for dirs for both of these options:

  -m <path>, --metrics <path>
                        Declare output metric file or directory.
  -M <path>, --metrics-no-cache <path>
                        Declare output metric file or directory (do not put
                        into DVC cache).

From Discord discussion I assume that -m/-M flags should not accept directories for now.

@nik123 That's correct! Thank you so much for looking into it! :pray:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anotherbugmaster picture anotherbugmaster  路  3Comments

siddygups picture siddygups  路  3Comments

dnabanita7 picture dnabanita7  路  3Comments

mdscruggs picture mdscruggs  路  3Comments

ghost picture ghost  路  3Comments