Closed pmeier closed 1 year ago
My two cents is that you're right. Most internals should be private. We don't intend people to depend on them and we don't guarantee backwards compatibility of the API. It seems like quite a bit of work so I also like the disclaimer somewhere in the README that says all internals are private it the meantime.
My thoughts.
To me I see Nebari is an application.But with that said conda also thought they were just a cli and then they are now used as an api. I would like to get ahead on this.
Notes from discussion on 2nd May:
This RFD is accepted, unanimously. :)
Closed in nebari-dev/nebari#1778.
Make
nebari
internals aggressively privateSummary
Currently, all internals of
nebari
are public and with that there comes a set of expectations from the users with the main one being backwards compatibility. Although there is no such thing as true private functionality in Python, it is the canonical understanding of the community that a leading underscore in a module / function / class name implies privacy and thus no BC guarantees.AFAIK,
nebari
does not have an API. Thus, I propose to "prefix" everything with a leading underscore to avoid needing to keep BC for that.User benefit
This proposal brings no benefit for the user, but rather for the developers. As explained above, having a fully public API brings BC guarantees with it. At least that is what users expect. With them in place it can be really hard to refactor / change internals later on although we never intended that to happen.
Design Proposal
The canonical understanding for privacy in Python is that it is implied by a leading underscore somewhere in the "path". For example
_foo
foo._bar
,_foo.bar
,foo._Bar.baz
foo.Bar._baz
_foo.Bar.baz
_foo.Bar.baz
are all considered private. This gives us multiple options to approach this:
nebari
package private, e.g.nebari._schema
rather thannebari.schema
. Since we aren't exposing anything from the main namespace this would effectively make everything private.nebari._internal
and move everything under that. This is whatpip
does._nebari
, but still provide the script under thenebari
name. This makes it a little awkward for invoking it through Python, i.e.python -m _nebari
. If this is something we want to support, we can also create a coexistingnebari
package that does nothing else but importing the CLI functionality from_nebari
. This is whatpytest
does.These are ordered in increasing order of my preference.
Alternatives or approaches considered (if any)
Instead of fixing our code to be private, we could also put a disclaimer in the documentation that we consider all internals private and thus there are no BC guarantees. However, we need to be honest with ourselves here. Although this would suffice from a governance stand point, we are making it easier for users to shoot themselves in the foot. And that is rarely a good thing.
User impact
If we want to adapt this proposal or something similar, we need to do it sooner than later. Since this change is BC breaking for everyone who is already importing our internals, we should do it as long as the user base is fairly small and thus even fewer people (hopefully none) are doing something we don't want for the the future.
Depending on how much disruption we anticipate, we could also go through a deprecation cycle with the prompt to get in touch with us in case a user depends on our internals. Maybe there is actually a use case for a public API?