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
Initial wee_database --calc-missing option #394
Conversation
A few comments:
|
@tkeffer Some follow-ups:
|
For 2, simply rewrite For 4, you have two choices. Either rewrite Why does this matter? Because I suspect that an UPDATE will prove to be much faster than a DELETE followed by an INSERT because the indexes don't have to be touched. But, I have no proof of that. Even so, adding these new fields could prove to be very slow --- it would be good to do a test or two. There are speed up techniques we can use if it's a problem. |
I think I'm still a little bit lost on item 4. I have figured out that within Nonetheless if I move past that, where I'm really lost is how to determine how to So I did some quick research on how to compare 2 dictionaries to find only the changes. Seemed rather simple, you convert to a set, subtract the two lists, then convert back to dict. Except it doesn't appear to be working well with For example (long hand):
This returns an empty dictionary all the time. However If I try the below example manually:
I get:
Which looks like it'll satisfy what you're looking for by returning only the changed values. Then it makes sense to loop this changed dict and run Any insight? |
|
Thanks for the insight on item 1. I wasn't lost on that one but good to know I was on the right track. I was only lost on the dict diffs. My previous reply was only focused on the dict diffs. I'll give your suggestions a try and see how it fares. Thanks |
I have to admit I'm lost on this one. Your suggested diff code is not working within this function. Let me explain: I have a small Simulator sqlite db extended for Your code example works when comparing dicts outside of weewx, but comparing the dicts inside of weewx returns an empty diff. Below is the code I'm trying to validate. Within
For the sake of brevity, here's the output of 1 record as it passes through this function:
It's updated 6 times (as evidence by the dateTime record), and by the time it's done with I haven't followed why it's firing 6 times yet, so this is where I'm at - a little lost on where to go. |
This is being addressed in #443. Closing. |
Ok, thanks |
Updates #363
For review on adding a new option to
wee_database
called--calc-missing
. This will calculate all missing observation types within the database that StdWXCalculate knows about.In order to do this action the database fields are put into a temporary variable (
_rec
), the data is dropped from the database (newdeleteRecord()
function), and is then re-added to the database (addRecord(_rec)
). I feel this level of risk needs thorough review.My test scenario:
generator
mode to quickly produce recordsappTemp
andwindrun
as example schema extensionswee_database --calc-missing
and entery
to continueappTemp
andwindrun
have their missing values updated by opening the database and manually checkingMy initial tests show that the newly extended fields in the schema are populated with data with no data loss to other fields.