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

FIX: If resource_path is absolute, patch it up on the way out #171

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions databroker/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1725,15 +1725,33 @@ def export(self, headers, db, new_root=None, copy_kwargs=None):
db.mds.insert_run_stop(**_sanitize(header['stop']))
# insert assets
res_uids = self.get_resource_uids(header)

for uid in res_uids:
fps = self.reg.copy_files(uid, new_root=new_root,
**copy_kwargs)
file_pairs.extend(fps)
res = self.reg.resource_given_uid(uid)
r_path = res['resource_path']
out_root = new_root
if os.path.isabs(r_path):
if not res['root']:
r_path = os.path.relpath(r_path, os.path.sep)
if new_root is None:
out_root = os.path.sep
else:
raise RuntimeError("Resource has non-trivial root "
"and an absolute resource path. "
"This is inconsistent, aborting")
else:
if new_root is None:
out_root = res['root']
else:
out_root = new_root

new_res = db.reg.insert_resource(res['spec'],
res['resource_path'],
r_path,
res['resource_kwargs'],
root=new_root)
root=out_root)
# Note that new_res has a different resource id than res.
datums = self.reg.datum_gen_given_resource(uid)
for datum in datums:
Expand Down