New getUri() functionality for debugging Butler gets/puts

As described in DM-10319, the _filename magic does not usually return the actual filename of a file in the given repository, instead returning the first mappable repository instead of search through parents.

With the help of @price I have implemented a new getUri() functionality to tell you where in the repository a given dataset will be read from (or written to, if write=True). This functionality is intended to be used for debugging purposes only, and not in regular production. However, it can be invaluable for debugging! Note that this currently does not support composite datasets.

>>> import lsst.daf.persistence as dafPersistence
>>> import os
>>> butler = dafPersistence.butler.Butler(inputs='/datasets/hsc/repo/rerun/RC/w_2018_06/DM-13435')
CameraMapper INFO: Loading exposure registry from /datasets/hsc/repo/registry.sqlite3
CameraMapper INFO: Loading calib registry from /datasets/hsc/repo/CALIB/calibRegistry.sqlite3
CameraMapper INFO: Loading calib registry from /datasets/hsc/repo/CALIB/calibRegistry.sqlite3
>>> dataId = dafPersistence.DataId({'visit': 29340, 'ccd': 13})
>>> uri = butler.getUri('raw', dataId)
>>> print(uri)
>>> print(os.path.isfile(uri))
>>> filename = butler.get('raw_filename', dataId)[0]
>>> print(filename)
>>> print(os.path.isfile(filename[0]))
1 Like