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

Handle trailing slashes in collect_results! #181

Closed
lhupe opened this issue Jul 29, 2020 · 2 comments · Fixed by #380
Closed

Handle trailing slashes in collect_results! #181

lhupe opened this issue Jul 29, 2020 · 2 comments · Fixed by #380
Labels
bug Something isn't working data Related to data management good first issue Easy issue good for newcomers update Updates in the source code or documentation are necessary.

Comments

@lhupe
Copy link
Contributor

lhupe commented Jul 29, 2020

When the folder argument to collect_results! contains a trailing slash (e.g /home/lhupe/coolresults/), the default setting for filename breaks. The result file will be saved as /home/lhupe/coolresults/results_.bson. This has the unfortunate side effect that on the next run, collect_results! will create an entry for its own cache file.
While this is not a bug of DrWatson (the issue is with Base.splitdir, which naively splits paths on the final separator), it would be nice to account for this in the default definition of filename (e.g. using rstrip(folder, '/') to remove trailing slashes).

@Datseris Datseris added bug Something isn't working data Related to data management good first issue Easy issue good for newcomers update Updates in the source code or documentation are necessary. labels Jul 29, 2020
@Datseris
Copy link
Member

Just to be clear here: A path to "X" ends with "X". So a path to a folder should end with the folder name, not with /. Why do you give the final /?

@lhupe
Copy link
Contributor Author

lhupe commented Apr 15, 2023

Trailing slashes are commonly used for paths referring to directories (I guess the slash implies that the directory is not a leaf node of the file system), and a lot of software simply ignores them.

There are some applications where there is a semantic distinction (e.g. the file-copying tool rsync, where a source path with a trailing slash means "copy the contents of the source directory into the target directory", and one without a trailing slash means "copy the source directory into the target directory"), but I don't think this makes sense in this context (to be fair, this was three years ago and I haven't really used any DrWatson functions other than dict_list since then, so I might not have the strongest grasp on what the context is).

If you do decide to distinguish (or just not support trailing slashes), that's definitely worth mentioning prominently in documentation because it will surprise at least some of your users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working data Related to data management good first issue Easy issue good for newcomers update Updates in the source code or documentation are necessary.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants