Paths stored in Bank indices shouldn't have leading backslash
shawnboltz opened this issue · 1 comments
Description
The paths that get stored in the indices for the banks have leading backslashes on them, which OSs will interpret as referring to root. This is a nuisance in scenarios where it is necessary to refer to the file directly from that path rather than through the bank's logic.
As a related and much more difficult to reproduce problem, on Windows I've seen the bank store the absolute path rather than the relative path in the bank. Weirdly, the dataset this occurred with happens to live in a shared drive that is used by two people (using the same version of ObsPlus) and when one person adds anything to the bank it uses the absolute path, but for the other user it uses the relative path. This behavior is consistent if the dataset is moved to another location.
To Reproduce
To reproduce the backslash issue:
bingham = load_dataset("bingham_test")
wbank = bingham.waveform_client
path = wbank.read_index().iloc[0].path
print(wbank.bank_path)
print(path)
print(wbank.bank_path / path)
Prints the following:
C:\Users\{username}\opsdata\bingham_test\waveforms
/UU.CFS.01.ENE__20130404T151047Z__20130404T151157Z.mseed
C:\UU.CFS.01.ENE__20130404T151047Z__20130404T151157Z.mseed
Similarly on Ubuntu it prints the following:
/home/{username}/opsdata/bingham_test/waveforms
/UU.CFS.01.ENE__20130404T151047Z__20130404T151157Z.mseed
/UU.CFS.01.ENE__20130404T151047Z__20130404T151157Z.mseed
I can reproduce the absolute path issue with the same dataset where I initially discovered the problem, but haven't been able to reproduce it in any other way... I even tried clearing and redownloading the test datasets on the same machine to make sure they weren't just from a different version of obsplus that didn't have this problem.
Expected behavior
I would expect the path stored in the bank to be relative to the bank path such that the full absolute path could be constructed with bank.bank_path / index.loc["index of relevant record", "path"]
(i.e., the output of the above should be C:\Users\{username}\opsdata\bingham_test\waveforms\UU.CFS.01.ENE__20130404T151047Z__20130404T151157Z.mseed
on Windows and /home/{username}/opsdata/bingham_test/waveforms/UU.CFS.01.ENE__20130404T151047Z__20130404T151157Z.mseed
on Linux.
Versions (please complete the following information):
- OS: Windows 10 (but I've also seen it on Linux)
- ObsPlus Version: Master (commit d5b2e46)
- Python Version: 3.7 and 3.8
closed by #256