Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

params/metrics: do not fail during dir expansion #10375

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

skshetry
Copy link
Member

@skshetry skshetry commented Mar 27, 2024

Closes #10018.

We have to be careful when expanding paths. This PR fall backs to assume it
as a file when either of isdir and find raises error due to some mishaps.
The consequence of this assumption happens when we try to read the file.
In that case, if the directory exists, and we happen to try to open it
as a file, dvc will raise IsADirectoryError, but that is handled correctly
and won't fail catastrophically like this did.

This is what I get now:

$ dvc metrics show --json
DVC failed to load some metrics for following revisions: ''.
{
  "": {
    "data": {
      "results/train/metrics.json": {
        "error": {
          "type": "DataIndexDirError",
          "msg": "failed to load directory ('results', 'train')"
        }
      },
      "results/evaluate/metrics.json": {
        "data": {
          "dice_multi": 0.8789161007343483
        }
      }
    }
  }
}

The error message is not great, but at least it won't fail.

@skshetry skshetry added the bugfix fixes bug label Mar 27, 2024
@skshetry skshetry requested a review from shcheklein March 27, 2024 12:33
@skshetry skshetry self-assigned this Mar 27, 2024
@skshetry skshetry force-pushed the improve-add-failure branch 2 times, most recently from 1b874f6 to dc882a4 Compare March 27, 2024 12:38
Closes iterative#10018.

We have to be careful when expanding paths. This PR fall backs to assume it
as a file when either of `isdir` and `find` raises error due to some mishaps.
The consequence of this assumption happens when we try to read the file.
In that case, if the directory exists, and we happen to try to open it
as a file, dvc will raise `IsADirectoryError`, but that is handled correctly
and won't fail catastrophically like this did.
@skshetry skshetry force-pushed the improve-add-failure branch from dc882a4 to 02453e0 Compare March 27, 2024 12:40
Copy link

codecov bot commented Mar 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.71%. Comparing base (5379aa2) to head (02453e0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10375   +/-   ##
=======================================
  Coverage   90.70%   90.71%           
=======================================
  Files         501      501           
  Lines       38837    38865   +28     
  Branches     5616     5618    +2     
=======================================
+ Hits        35229    35257   +28     
  Misses       2964     2964           
  Partials      644      644           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@skshetry skshetry added A: params Related to dvc params A: metrics Related to dvc metrics labels Mar 27, 2024
Copy link
Member

@shcheklein shcheklein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, @skshetry !

@skshetry skshetry merged commit c223cda into iterative:main Mar 28, 2024
20 checks passed
@skshetry skshetry deleted the improve-add-failure branch March 28, 2024 01:45
BradyJ27 pushed a commit to BradyJ27/dvc that referenced this pull request Apr 22, 2024
params/metrics: assume file when dir expansion raises error

Closes iterative#10018.

We have to be careful when expanding paths. This PR fall backs to assume it
as a file when either of `isdir` and `find` raises error due to some mishaps.
The consequence of this assumption happens when we try to read the file.
In that case, if the directory exists, and we happen to try to open it
as a file, dvc will raise `IsADirectoryError`, but that is handled correctly
and won't fail catastrophically like this did.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: metrics Related to dvc metrics A: params Related to dvc params bugfix fixes bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The whole metrics show fails if a single dir with metrics is missing
2 participants