-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Define separation of configuration in ~/settings.yml
and the SQlite DB
#1524
Comments
Background and InvestigationI did some digging in git, and tried to find out what rationale we used in the past for deciding where to put settings, in the hope that it helps us make an informed decision.
We kept adding new settings to
In the earlier days of TinyPilot, we offered wider support for customization to users through In any event, as of 2023, we are officially Ansible-free, so the original Ansible-related workings around ProposalUnifying the storage format is not an option for us at the moment, because it would require too much refactoring effort. We therefore content ourselves with the current split-approach, and try to find the clearest-possible definition that gives us sufficient guidance when adding new settings in the future. The proposed definition is:
When adding a new setting, we use the above definition for deciding where the setting should live. We also try to realistically anticipate whether usage of the setting might change in the foreseeable future, to prevent avoidable migration work (if reasonably possible). If requirements for a setting change, we migrate the setting to the appropriate storage format. (We might make pragmatic exceptions for marginal use-cases.) Tasks
DiscussionRequest for comments on the proposal and tasks, @mtlynch / @jdeanwallace. In case we want to discuss this more deeply, I’m happy to turn this into a PR with a “design document” – in this case, just let me know. (I thought we could avoid that overhead, though, in case we’d happen to agree anyways.) |
Could we alter our definition of According to our docstring, tinypilot/app/update/settings.py Lines 56 to 57 in b6a2a61
Which includes settings that don't necessarily get used system wide. For example, tinypilot/app/update/settings.py Lines 59 to 60 in b6a2a61
tinypilot/debian-pkg/debian/tinypilot.postinst Lines 60 to 61 in b6a2a61
|
GoalI just want to make sure we're on the same page in terms of goals. I don't think it's important for us to retrofit rules onto our existing implementation. The more important thing to me is to make a decision about what's best going forward, and it's okay if legacy settings violate that as long as future settings adhere to our rules. ConsiderationsThe other elements I think we should cover are performance and sensitivity.
ComparisonAdvantages of SQLite over
|
Thanks providing your thoughts so comprehensively. I’ll start to work on a PR with the documentation, where I incorporate the things that we’ve discussed so far. Using the SQlite by default
We rely on reading from
We don’t have a good mechanism to programmatically read from I feel if we’d effectively “deprecate” Documenting user-editable settingsRelated #1573. |
Just to clarify, I didn't mean my opinion as an edict. I'm open to other solutions if we want a different strategy.
Yeah, that's a good idea. Can you create ticket for that? It seems like there should be some way of making the Flask CLI faster because what the heck is it doing for several seconds just to do a single SQLite database call? |
I think in the end it’s a bit of a strategic decision which – considering current requirements – is mostly up to our preference. I don’t feel super strongly here, and I think there are valid arguments for each approach, including the hybrid one. In regards to making SQlite our primary option for storing settings, I feel that having a robust programmatic interface makes a big difference, as programmatic access would otherwise be an at least partially blocking problem that would hinder us going down that road. In any event, I see a lot of value in consolidating everything in one place, as that eases future decision-making where to put new settings. I’ll work on a PR with a proposal for documentation, based on our discussion so far. It’s probably easier for us to continue the discussion on that basis.
Yes → #1690 I just measured the Flask execution time on device, by the way: it’s ~1.5s per CLI invocation for the |
Resolves #1524. The outcome of our discussion in the ticket was this: - The SQlite DB (`tinypilot.db`) should be the default place for new settings, whereas the YAML file (`settings.yml`) should only be used in exceptional cases, and obviously for legacy reasons. - We favor having a single storage solution over a dual approach, as that simplifies future decision-making, and eliminates potential migration burden between the two storage formats. - The SQlite DB doesn’t easily allow programmatic access right now (in contrast to the YAML file), so we [created this ticket for removing this hurdle](#1690). - We [will document the parameters in `settings.yml` separately](#1573). This PR adds a comment in `settings.py`, marking its usage as quasi-deprecated. It also adds some historical context, references the SQlite DB as default storage, and lists sample exceptional cases. I realized that we probably don’t need to add any documentation to the SQlite DB, since there is not really an alternative to it any longer. So by deprecating `settings.yml`, the SQlite DB is the only storage option anyway, and there shouldn’t be any ambiguity left. Contrary to [my initial proposal](#1524 (comment)), I also don’t think we should move `settings.py` up to the `app` package, as that might mistakenly promote its usage. <a data-ca-tag href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1692"><img src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review on CodeApprove" /></a> --------- Co-authored-by: Jan Heuermann <[email protected]>
We will reach an de-Ansibilized state in the foreseeable future. One “relict” or by-product is the YAML-based config file,
/home/tinypilot/settings.yml
, which still contains important config parameters that we rely on (independent of Ansible).However, we also have the SQlite database, which contains configuration logic as well – such as whether H.264 or MJPEG is enabled, or whether HTTPS should be required.
I think the current/previous division of concerns was “by consumer”:
~/settings.yml
We should clearly define where things are supposed to go and how our configuration is structured. The SQlite and the
~/settings.yml
also have different practical constraints, which we should be aware of – e.g. the SQlite has a more powerful structure, but it cannot easily be processed outside of the Python app.The text was updated successfully, but these errors were encountered: