Skip to content

validate_datasets.py: a relative manifest path crashes the failure report instead of printing the ::error line #129

Description

@quantecon-services

Found during the #127 validation (section 3), running the mutation cases through the committed CLI exactly as its docstring shows. Introduced by #126.

What happens

scripts/validate_datasets.py documents this usage:

python scripts/validate_datasets.py lectures/gdp_growth_annual.csv.yml ...

With a relative path and a manifest that fails, the run ends in a traceback instead of the annotation:

$ sed -i -E 's/(F_over_Fmsy:\s*)1\b/\12/' lectures/lingcod_msy_recovery.csv.yml
$ python scripts/validate_datasets.py lectures/lingcod_msy_recovery.csv.yml
  File "scripts/validate_datasets.py", line 123, in main
    print(f'::error file={path.relative_to(REPO)}::{p}')
ValueError: 'lectures/lingcod_msy_recovery.csv.yml' is not in the subpath of '/…/data-lectures' OR one path is relative and the other is absolute.

The same run with an absolute path prints what was intended:

::error file=lectures/lingcod_msy_recovery.csv.yml::F_over_Fmsy: 1 nulls, manifest says exactly 2
FAIL lingcod_msy_recovery.csv.yml: 1 problem(s)

Reproduced under pandas 2.3.3 and 3.0.5 (Python 3.11). The exit code is 1 either way, so nothing passes that should fail — but the one thing a maintainer runs the script for locally, the named failure, is swallowed. CI is unaffected: with no arguments the script globs LECTURES, which is absolute.

Cause

REPO is absolute (pathlib.Path(__file__).resolve().parents[1]) while the CLI arguments are used as given, and PurePath.relative_to() does not resolve. A passing manifest never reaches the relative_to call, which is why the committed 44/44 run hides it.

Fix

Resolve the argument paths once:

paths = [pathlib.Path(a).resolve() for a in argv] or sorted(LECTURES.glob('*.yml'))

(or path.resolve().relative_to(REPO) at the print). Either keeps the annotation path-relative, which is what the checks tab needs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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