databroker
databroker copied to clipboard
Make it easier to copy files to an external databroker.
As @tacaswell and I have been discussing it may be helpful to have db.export act somewhat as a callback. Most of this is handled in db.insert, but the copying of assets and assetstore records is not.
Potentially related to #246
Could you clarify with an example what you mean by "act somewhat" as a callback?
I can pass individual documents to it.
RE.subscribe(main_db.insert)
RE.subscribe(export_to_db2_for_user_to_take_home)
for nd_pair in hdr.documents():
db.export(nd_pair)
Why not use db.insert?
Missing filestore records, files not copied into exportable folder.
@CJ-Wright Belatedly, you had a fair point. The asset refactor make this much easier to do. See example: https://gist.github.com/danielballan/24a1e6c055fe24d764462169727dd89f
Once we figure out how to parameterize that nicely, something like it will go into suitcase I think.
What do you mean "parameterize that nicely"?
My example hard-codes assumptions about how to layout the data in the HDF5 file. We have make some assumptions at the level of the Python code, but we'll probably let users configure it a little more than we do in that example.
Coming back to the original question:
It may be helpful to have db.export act somewhat as a callback. Most of this is handled in db.insert, but the copying of assets and assetstore records is not.
Now that all "assetstore records" (datum and resource documents) do go through db.insert, the only remaining issue is copying files to a second location. Some of the db.export code should be factored out to make that easier.