datalad / datalad-next

DataLad extension for new functionality and improved user experience
https://datalad.org
Other
9 stars 9 forks source link

Develop replacement for `ConfigManager` #397

Closed mih closed 1 week ago

mih commented 1 year ago

This is a key component of any datalad code. It is present in any datalad session datalad.cfg and part of any Dataset or *Repo instance.

The implementation in datalad-core is old, has various spaghetti pieces, and comprises at least 3 different APIs.

I believe this code needs an update for a number of reasons:

Given the essential nature of this code, I think a replacement must

TODO:

Thoughts

Maybe have a dataclass

GitConfigItem:
   scope: GitConfigScopeType
   origin: str
   key: str
   value: str | Any

maybe with additional accessors like

The internal representation within ConfigManager could be a list of these items, with amend/overwrite/replace rules applied on access. Or a series of lists, grouped by scope in a dict (likely scope removed from GitConfigScopeType then), or even grouped by (scope, origin) to facilitate reloads.

It could also make sense to have an explicit GitConfigMultiValueItem, that exposes a get_all() equivalent, rather than (only) having ConfigManager.get(getall: bool)

adswa commented 1 year ago

linking a few config manager related issues from core:

mih commented 1 year ago

More corner/use cases are:

mih commented 1 year ago

The ping in https://github.com/datalad/datalad/issues/5383 reminded me that the present config manager also has no support for git annex config. And this one is special, because it has a fixed set it items, and rules of "engagement" are more complex

mih commented 1 month ago

Making a start for this effort now.

mih commented 1 week ago

https://github.com/datalad/datalad-core/pull/19 provides a new ConfigManager implementation, built to support all aspects gathered in this issue. Even though, it may not actually support all proposed features at this point.

https://github.com/datalad/datalad-next/pull/760 has an exploration whether it would be possible to implement an adapter for the new manager with the API of the old one. This seems possible, except for some edge cases (some of which a more like bugs than features).

I am closing this issue here. Feature requests can be posted to https://github.com/datalad/datalad-core