Open MaxFBurg opened 8 months ago
I think you're suggesting some sort of a user-provided functions on insert and on fetch for attach
type.
This is very much the idea of DataJoint's AttributeAdapter feature - see here
With that feature, you can define a new DataJoint datatype (e.g. attack_pkl
or something like that).
See some examples here:
Feature Request
Problem
When inserting into a table that has a field
result : attach@minio
, theinsert
table method expects a file path. Similarly,fetch
stores a file and returns a file path. This is often times inconvenient, because (i) the data saved in the file is required as an object in the python script one is executing, and (ii) the saved / downloaded files remains on local storage even after the script terminated.Requirements
Possible solution: Introduce a parameter to
insert
that automatically saves the data that should be inserted to a file, inserts it into the table, and then removes that file. Similarly,fetch
could save the file, and return the file / data loaded within the python script.Justification
See problem section
Alternative Considerations
Currently I am using an
AttachMixin
as a workaround, i.e. my table would be defined asclass MyTable(AttachMixin, dj.Computed)
. The mixin could be the code basis for the feature I suggested, although it would need a little bit of improvement.Related
This issues might be (loosely) related: https://github.com/datajoint/datajoint-python/issues/1109 https://github.com/datajoint/datajoint-python/issues/1099
If you think such a feature could be helpful to be included in datajoint, I would be happy to help implementing it.