Feature Idea for Database read_data #454
Replies: 1 comment
-
I would like to add one more detail on this proposed change. We already do some filtering of wf document key-value pairs in save/read operations that are not optional. That is, aliases and values set as all space characters are dropped altered and dropped respectively in a save. Hence, adding
I would also note that this section of
I realized on further thought that the value of the |
Beta Was this translation helpful? Give feedback.
-
As noted a number of places I've been working on a revision to the Database class. In working through the tests I was reminded of an awkward feature of the
read_data
method ofDatabase
. That is, in any context except reading from the default collection (wf_TimeSeries) that argument is not really optional.My idea is pretty simple. I suggest the
write_data
method and alsoindex_miniseed
should write some attribute that defines the data type a document can be used to construct. Because we use "wf" collections to define atomic data (i.e. each valid wf document defines one and only one atomic data object - aTimeSeries
orSeismogram
object). I then suggest each wf document should contain adata_type
key-value pair. I suggest it could be either the strings "TimeSeries" or "Seismogram". We might also want to not require the mixed case and match on something like a conversion to upper or lower case, but that is a detail. Might also want to allow the result of str(type(d)) where d is an atomic datum. As you likely know that always yields a more verbose string.Implementing this would not be hard in the new implementation. All calls to
save_data
andindex_mseed
would insert a value for the newdata_type
attribute that is defined by anisinstance
check. That is really trivial to implement, but it will break some of the existing tests. The real need is forread_data
and it presents more of a design challenge on the behavior it should have. I would suggest that if undefined we revert back to the current behavior and depend on the collection argument. If it is defined there are two situations depending on what the schema says the collection should define. That is, if the value of the newdata_type
attribute is consistent with the collection aok. If they are different, log a message and decide which is definitive. I presume the collection argument would override any single datum value, but I could see an argument for the reverse too.Anyway, I wanted to get this idea down for discussion.
Beta Was this translation helpful? Give feedback.
All reactions