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

Platform independent path comparison #17

Open
1 of 2 tasks
suvayu opened this issue Feb 6, 2021 · 4 comments
Open
1 of 2 tasks

Platform independent path comparison #17

suvayu opened this issue Feb 6, 2021 · 4 comments
Assignees
Labels
metadata spec Improve Frictionless Data specification support

Comments

@suvayu
Copy link
Member

suvayu commented Feb 6, 2021

The datapackage spec requires all paths in the package metadata to be POSIX paths, however the implementation doesn't enforce this in a platform independent manner, so some functions when run on Window can generate path strings like "path_to\\data.csv". This poses two problems:

  1. corrupt/non-conformant package metadata maybe written
  2. path comparisons may fail on some OS combinationss (when package creation and the path comparison are not happening on the same OS).

Two separate resolutions are required:

  • ensure paths in the metadata are POSIX paths (implemented in sark.dpkg._ensure_posix)
  • a uniform interface to do path comparisons
    1. if the files are same, aka, Path(..).samefile(..)
    2. if two relative paths are same (may not point to the same file, as depends on base path)
@suvayu suvayu added spec Improve Frictionless Data specification support metadata labels Feb 6, 2021
@suvayu suvayu self-assigned this Feb 6, 2021
@olejandro
Copy link

@suvayu, it seems that ensuring POSIX causes dpkg.read_pkg() to fail on datapackages with inline data (and therefore no path specified). Here is an example: https://github.com/MaREI-EPMG/ireland-carbon-budget-scenarios-2021/security

@suvayu
Copy link
Member Author

suvayu commented Mar 30, 2022

I'm not surprised since I never tested with inline data :(. Do you get KeyError of some kind?

I'm employed elsewhere now, so I need to find some free time outside of work to fix this. Probably not a big fix though.

@olejandro
Copy link

Thanks a lot! yes, it is complaining that path is missing.
I've just submitted a pull request removing a windows specific check for posix. It seems no longer needed (?)

@suvayu
Copy link
Member Author

suvayu commented Apr 18, 2022

Hi @olejandro I fixed the issue with #26, please have a look if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metadata spec Improve Frictionless Data specification support
Projects
None yet
Development

No branches or pull requests

2 participants