Skip to content
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

feat: add /usr/share as a config location #128

Merged
merged 1 commit into from
Jun 22, 2024

Conversation

PureTryOut
Copy link
Contributor

/usr/share/ is becoming more and more common for applications to store their default configuration in. Either the application itself or distributions can use this location to ship a config that users will not touch, and instead they are expected to overwrite (parts of) the config in /etc/. This means this config file can be safely updated with new required values without having to worry about overwriting user-made change.

This is useful in general but especially in case of immutable distributions who don't touch anything in /etc and /home

@JarbasAl JarbasAl added the enhancement New feature or request label Jun 8, 2024
Copy link

codecov bot commented Jun 8, 2024

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Please upload report for BASE (dev@9a8fd1f). Learn more about missing BASE report.

Current head ac01002 differs from pull request most recent head a10d5c6

Please upload reports for the commit a10d5c6 to get more accurate results.

Files Patch % Lines
ovos_config/config.py 0.00% 5 Missing ⚠️
ovos_config/locations.py 0.00% 4 Missing ⚠️
ovos_config/models.py 0.00% 4 Missing ⚠️
ovos_config/meta.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##             dev    #128   +/-   ##
=====================================
  Coverage       ?   0.00%           
=====================================
  Files          ?      10           
  Lines          ?     826           
  Branches       ?       0           
=====================================
  Hits           ?       0           
  Misses         ?     826           
  Partials       ?       0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

/usr/share/<application name> is becoming more and more common for
applications to store their default configuration in.
Either the application itself or distributions can use this location to
ship a config that users will not touch, and instead they are expected
to overwrite (parts of) the config in /etc/<application name>. This
means this config file can be safely updated with new required values
without having to worry about overwriting user-made change.

This is useful in general but especially in case of immutable
distributions who don't touch anything in /etc and /home
@PureTryOut PureTryOut force-pushed the feat/distro-config branch from ac01002 to a10d5c6 Compare June 8, 2024 19:36
@NeonDaniel
Copy link
Member

We have documented /etc config as not user-managed so I'm not sure that this new path adds anything functionally different. SYSTEM is read-only to the user and USER is where user overrides are allowed. Would overriding those existing envvars would be sufficient for distros where /etc or /home defaults aren't appropriate without increasing the complexity of the already complex config stack?

@j1nx
Copy link
Member

j1nx commented Jun 12, 2024

I agree with @PureTryOut that more and more linux packages and/ or their developers use /user/share as their default shipped location for configuration files.

It will look like this;
~/.config/ovos/ovos.conf - User OVOS configuration
/etc/ovos/ovos.conf - System OVOS configuration
/usr/share/ovos/ovos.conf - Default OVOS configuration (Basically the default with everything from this ovos-config package)

However, while following best practices in Linux world then perhaps we could also look into using the drop-in config fragment systems they use.

/usr/share/ovos/ovos.conf.d/
/etc/ovos/ovos.conf.d/
~/.config/ovos/ovos.conf.d/

Any *.conf files in those directories with only the configuration fragments of interest will be applied (overwritten from the above) in alphabetically order.

A distribution or package maintainer that wants to ship with specific different configuration values other then the ovos-config default values could use the drop-in directory.

In this case for @PureTryOut he could ship his package with own config file located in /usr/share/ovos/ovos.conf.d/

I also agree with @mikejgray that users and configuration files sometimes do not go well (RTFM) however above appears to be the new Linux way / best practices.

@builderjer
Copy link
Member

To me, this is the best solution. I love the idea of /ovos.conf.d
raspOVOS could ship /usr/share/ovos/ovos.conf.d/raspOVOS.conf with the specific changes there.
Or when using my custom location, just add another conf file to ~/.config/ovos/ovos.conf.d/personal_location.conf
That would make it WAY easier with multiple changes.

@PureTryOut
Copy link
Contributor Author

SYSTEM is read-only to the user

System being /etc, no it's not. Sure, any configuration done through OVOS won't be written there, but a system administrator (read: someone with root rights) most definitely can. And by putting the config file in /etc you as a program are implying that it contains values that can be overwritten.

/etc is used by system administrators to configure a service independent of the account that is running. However sometimes distributions will want to ship their own configs and they need to know that they can safely update them without having to worry about overwriting user-made changes.
For example a distribution having an image for the Raspberry Pi could decide to by default enable a specific STT or TTS that is known to work well with that device. A user can then choose to overwrite it (either system-wide if an admin or for their specific user) with some other option. Then the distribution decides that some better option has come along and changes their distro configuration to use the new option and deprecates/removes the old option. The user is at this point still overwriting it so it won't be used, until they go back to their distro-default by removing their own configuration, at which point the newly chosen STT/TTS from the distro is used rather than the old one which at that point might have been deprecated or even removed entirely.

If this wasn't an option and the user has at any point changed their config in /etc, the distro can't update the default config any more because that would overwrite user changes. Meanwhile they might remove an STT option from their distro at which point the installation breaks for the user with no easy way to get back to a working state, because there is no config any more that follows whatever the distro intends.

@JarbasAl
Copy link
Member

config fragments is not a bad idea and deserves it's own issue to discuss/implement separately from this one!

@mikejgray
Copy link
Contributor

mikejgray commented Jun 12, 2024

My 2 cents, as I was tagged: if adding /usr/share makes it easier to ship for a particular distro and conforms more closely to standard Linux practices I'm all for it. However, as a non-blocking separate PR, I'd like to see the number of config file locations decrease by 1 to offset that. IMO we have too many places for config files already and the order of precedence is confusing. This is frequently a source of many user problems and precedence is confusing in many areas - for example, the AWS SDKs and CLI has 10 places to configure credentials, in order of what overrides what, and this is often a considerable problem when troubleshooting permissions in applications and services.

Long-term the solution is to have a user-friendly web UI and eventually a voice UI for handling configurations, but if it's possible to simplify an ever-expanding number of config files, we should do it. Separating config into fragments where each service is responsible for owning and updating its own configuration is also a good practice and I'm very much in support of that - especially since OVOS has morphed into a fully distributed architecture at this point.

I have some thoughts about using something like etcd or even a relational database for config versus flat files. That has been thoroughly addressed elsewhere and I am squarely in the minority, so I'll refrain from echoing those ideas here, especially since they really have nothing to do with this PR and the excellent suggestion and work from @PureTryOut . 🙂

@JarbasAl
Copy link
Member

JarbasAl commented Jun 12, 2024

However, as a non-blocking separate PR, I'd like to see the number of config file locations decrease by 1 to offset that. IMO we have too many places for config files already and the order of precedence is confusing.

we can drop the remote config maybe, any backend implementation can manage the user config instead

the drawbacks here are that we lose the ability to block specific updates from remote, and need to update the ipgeo plugin. but those we can handle in their respective repos

and as mentioned in chat, i want to drop the whole ovos.conf eventually, but thats another discussion

@PureTryOut
Copy link
Contributor Author

In my mind there would ideally be this order of configs, the earlier being overwritten by things later in the chain:

Distribution (/usr/share/ovos/ovos.conf) -> System (/etc/ovos/ovos.conf) -> User (XDG base dir, so unless the relevant env specified, $HOME/.config/ovos/ovos.conf).

One possible problem however would be that I don't know if it would be possible for pip packages to ship their config file to any of these locations. This is relevant for skills and plugins of course. I suppose we could keep the current "default" which just means in-code configuration if no config option for it is found in any of the above mentioned locations. Then we have 4 locations in total which I think is alright. Definitely don't do a ~/.ovos like that AWS tool lol.

@builderjer
Copy link
Member

Pip can definitely place a file in the user's $HOME directory. I do it often.

@JarbasAl
Copy link
Member

Pip can definitely place a file in the user's $HOME directory. I do it often.

on that note, this is useful for individual skills that want to ship default skill settings.json

@JarbasAl JarbasAl merged commit 3781f01 into OpenVoiceOS:dev Jun 22, 2024
7 checks passed
@PureTryOut PureTryOut deleted the feat/distro-config branch June 22, 2024 06:49
@github-actions github-actions bot mentioned this pull request Sep 2, 2024
JarbasAl added a commit that referenced this pull request Sep 3, 2024
* document transformer plugins (#93)

* derprecated util

* derprecated util

* defaults/transformer_plugins

document transformer plugins and enable utterance normalizer by default

* Increment Version to 0.0.13a1

* Update Changelog

* Create LICENSE

* update/stop_pipeline (#94)

* update/stop_pipeline

add stop to the pipeline by default

companion to OpenVoiceOS/ovos-core#391

* Update mycroft.conf

* Update mycroft.conf

* Increment Version to 0.0.13a2

* Update Changelog

* default utterance plugins (#99)

enable https://github.com/OpenVoiceOS/ovos-utterance-corrections-plugin and https://github.com/OpenVoiceOS/ovos-utterance-plugin-cancel by default if installed

* adjust adapt matcher pipeline defaults (#100)

* Increment Version to 0.0.13a3

* Increment Version to 0.0.13a4

* Update Changelog

* Update Changelog

* Update mycroft.conf (#95)

* Increment Version to 0.0.13a5

* Update Changelog

* readd low adapt matches (intent pipeline) (#101)

* readd low adapt matches

* adjust common_qa

* adjust pipeline

* Increment Version to 0.0.13a6

* Update Changelog

* Create dependabot.yml

* fix/remove_broken_patch (#107)

* fix/remove_broken_patch

patch for mycroft-era `Configuration.get`  (now `Configuration()`) is broken and causes .get to behave weirdly

```
  self.config = dict(Configuration()) # below is False, like in mycroft.conf
        self.config = Configuration() # below is None ????
        self.audio_enabled = self.config.get("enable_old_audioservice")
```

* bad test

* signal breaking change

ripping out a broken patch that we dont use anywhere, but technically a breaking change. 

who knows how many places are not actually reading config...

bumping to 0.1.0 in case anything depends on the broken behaviour

* Update version.py

* Increment Version to 0.0.13a7

* Update Changelog

* fix: "adapt_medium" before padatious (#110)

reprioritize pipeline components

* Increment Version to 0.0.13a8

* Update Changelog

* improve env vars handling (#54)

* Update meta.py

improve env vars handling

* typo

* os.env priority

* Update meta.py

* Increment Version to 0.0.13a9

* Update Changelog

* Update ovos-bus-client requirement from ~=0.0.3 to ~=0.0.8 in /requirements (#106)

Updates the requirements on [ovos-bus-client](https://github.com/OpenVoiceOS/ovos-bus-client) to permit the latest version.
- [Release notes](https://github.com/OpenVoiceOS/ovos-bus-client/releases)
- [Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/blob/dev/CHANGELOG.md)
- [Commits](OpenVoiceOS/ovos-bus-client@V0.0.3...V0.0.8)

---
updated-dependencies:
- dependency-name: ovos-bus-client
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Increment Version to 0.0.13a10

* Update Changelog

* Update ovos-backend-client requirement from <0.1.0 to <0.2.0 in /requirements (#104)

Updates the requirements on [ovos-backend-client](https://github.com/OpenVoiceOS/ovos-backend-client) to permit the latest version.
- [Release notes](https://github.com/OpenVoiceOS/ovos-backend-client/releases)
- [Changelog](https://github.com/OpenVoiceOS/ovos-backend-client/blob/dev/CHANGELOG.md)
- [Commits](OpenVoiceOS/ovos-backend-client@V0.0.1a4...V0.1.0)

---
updated-dependencies:
- dependency-name: ovos-backend-client
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Increment Version to 0.0.13a11

* Update Changelog

* Update mycroft.conf (#112)

remove unimplemented duck_while_listening, docs for non existing features are misleading

change default lang detect plugin to use public servers (no extra deps)

disable mpris by default in OCP, as that seems to be the cause of many issues in core 0.0.7

* Increment Version to 0.0.13a12

* Update Changelog

* move to vosk (#124)

* move to vosk

move from pocketsphinx to vosk

companion to OpenVoiceOS/ovos-dinkum-listener#113

* Update mycroft.conf

* Increment Version to 0.0.13a13

* Update Changelog

* feat/ocp_pipeline (#96)

* feat/ocp_pipeline

* feat/OCP_backends

* Update mycroft.conf

* Update mycroft.conf

* Update mycroft.conf

* Update mycroft.conf

* "adapt_low",

* Update mycroft.conf

* Update mycroft.conf

* remove deprecated flag

got rid of it OpenVoiceOS/ovos-core#491

---------

Co-authored-by: JarbasAi <jarbasai@mailfence.com>
Co-authored-by: JarbasAI <33701864+JarbasAl@users.noreply.github.com>

* Increment Version to 0.0.13a14

* Update Changelog

* fix/typo (#126)

missing an X in pocketsphinX 

#124

* Increment Version to 0.0.13a15

* Update Changelog

* Update python-dateutil requirement from ~=2.6 to ~=2.9 in /requirements (#115)

Updates the requirements on [python-dateutil](https://github.com/dateutil/dateutil) to permit the latest version.
- [Release notes](https://github.com/dateutil/dateutil/releases)
- [Changelog](https://github.com/dateutil/dateutil/blob/master/NEWS)
- [Commits](dateutil/dateutil@2.6.0...2.9.0.post0)

---
updated-dependencies:
- dependency-name: python-dateutil
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Increment Version to 0.0.13a16

* Update Changelog

* fix: unbound local var (#127)

* fix: resolve unbound local variable

Closes #118

* chore: clean up issues identified by linter

* revert rename

* tidy up workflows

* bump pytest

* Increment Version to 0.0.13a17

* Update Changelog

* better listener defaults (#133)

use instant_listen by default, avoids OpenVoiceOS/ovos-dinkum-listener#107 until fixed

enabled remove_silence by default, further making the above a better default  (as listen sound gets removed by silero vad), safe to do since OpenVoiceOS/ovos-dinkum-listener#122

* Increment Version to 0.0.13a18

* Update Changelog

* fix config set (#134)

fix #73 
fix #59

* Increment Version to 0.0.13a19

* Update Changelog

* Update mycroft.conf (#136)

* Update mycroft.conf

add adapt/padatious default values

* Update mycroft.conf

* Update mycroft.conf

* Update mycroft.conf

* Update mycroft.conf

* Increment Version to 0.0.13a20

* Update Changelog

* feat: add /usr/share as a config location (#128)

/usr/share/<application name> is becoming more and more common for
applications to store their default configuration in.
Either the application itself or distributions can use this location to
ship a config that users will not touch, and instead they are expected
to overwrite (parts of) the config in /etc/<application name>. This
means this config file can be safely updated with new required values
without having to worry about overwriting user-made change.

This is useful in general but especially in case of immutable
distributions who don't touch anything in /etc and /home

* Increment Version to 0.0.13a21

* Update Changelog

* revert to single thread (#137)

use single_thread for padatious by default

* Increment Version to 0.0.13a22

* Update Changelog

* tweak OCP defaults (#139)

default to keyword matching instead of using the new classifier (companion to OpenVoiceOS/ovos-core#502)

reduce min_score from 50 to 40 so more results are considered

* Increment Version to 0.0.13a23

* Update Changelog

* document audio options (#141)

* document audio options

document some more ovos-audio options

* Update mycroft.conf

* Increment Version to 0.0.13a24

* Update Changelog

* document "common_query" config options (#143)

* Increment Version to 0.0.13a25

* Update Changelog

* document "fake_barge_in" (#144)

document "fake_barge_in"

* Increment Version to 0.0.13a26

* Update Changelog

* deprecate/ovos_conf (#138)

* deprecate/ovos_conf

move exclusively to env vars, ovos.conf file is of very limited use, also not a standard pattern and very uncommon in other projects, it just causes confusion to users and distro packagers

(i also simply don't like it and don't want to maintain it :P )

* tests

* fix test

* Increment Version to 0.0.13a27

* Update Changelog

* Increment Version to 0.1.0

* Update Changelog

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: JarbasAI <33701864+JarbasAl@users.noreply.github.com>
Co-authored-by: JarbasAl <JarbasAl@users.noreply.github.com>
Co-authored-by: Swen Gross <25036977+emphasize@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: NeonJarbas <59943014+NeonJarbas@users.noreply.github.com>
Co-authored-by: JarbasAi <jarbasai@mailfence.com>
Co-authored-by: Mike <mike@graywind.org>
Co-authored-by: Bart Ribbers <bribbers@disroot.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants