Skip to content

Commit

Permalink
Merge pull request #37 from lsst/tickets/DM-39915
Browse files Browse the repository at this point in the history
DM-39915: Use new datastore roots API
  • Loading branch information
timj authored Jul 11, 2023
2 parents 06a6be1 + c4c265b commit 5c27103
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin.src/ci_imsim_export_external_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@
],
)

datastore_roots = butler.get_datastore_roots()
assert len(datastore_roots) == 1, "Export script requires a FileDatastore, not ChainedDatastore"
datastore_root = list(datastore_roots.values())[0]
assert datastore_root.schema == "file", "Export assumes POSIX datastore."

def rewrite(dataset: FileDataset) -> FileDataset:
# Join the datastore root to the exported path. This should yield
# absolute paths that start with $CI_IMSIM_DIR.
dataset.path = os.path.join(butler.datastore.root.ospath, dataset.path)
abspath = datastore_root.join(dataset.path)
# Remove symlinks in the path; this should result in absolute paths
# that start with $TESTDATA_CI_IMSIM_DIR, because ci_imsim always
# symlinks these datasets from there.
dataset.path = os.path.realpath(dataset.path)
dataset.path = os.path.realpath(abspath.ospath)
return dataset

with butler.export(filename=args.filename) as export:
Expand Down

0 comments on commit 5c27103

Please sign in to comment.