Closed dvandok closed 4 years ago
Thanks for using Yamale and raising this issue. I'll try to find time to address this. If you think you have a good solution, we do welcome PRs.
I cloned the repo and validated that adding the data_path solves the issue. I'll issue a PR shortly. To test this, I verified the failure with unmodified yamale, then modified the yamale/command_line.py and verified the fix.
To verify the failure,
a: str()
and a sample.yml with a: 'string'
a: int()
and a sample.yml with a: 12
After modifying the yamale/command_line.py, I ran three different tox tests and all three succeeded:
commands yamale <full path to testIt>
changedir = <full path to testit>; commands = yamale
Fixed in version 3.0.4
When yamale is run on the command line in a file tree of yaml files and schema files, the program wrongly validates against the schema file in the current directory rather than matching the schema files deeper in the file tree.
Example:
When yamale is run from
cwd
, both data.yml and data2.yml are validated againstcwd/schema.yaml
; if the command is called from another directory (outside or higher in the tree) the filedata2.yml
is validated againstcwd/subdir/schema.yaml
.The reason is that the glob in
_find_schema
will try to match the schema file name without a path prefix, which will match a schema file in the current directory.https://github.com/23andMe/Yamale/blob/7a57de7f1cac4284567e8240ca1fe055bc030c1b/yamale/command_line.py#L55
This should probably be changed to match the directory name of the data file plus the name of the schema.