Skip to content

As a User, I would like HydroTools to expose public api tooling at the subpackage level #177

@aaraney

Description

@aaraney

Currently, we are a little loose with the way we organize our "public" apis'. For example, in hydrotools's metrics subpackage, a user must do the following to access the "public" functions:

from hydrotools.metrics import metrics

mean_se = metrics.mean_squared_error(...)

This can lead to confusion when "non-public" methods are exposed in subpackage submodules alongside "public" methods:

from hydrotools.events.event_detection import decomposition as ev

# likely incorrect api call
events = ev.event_boundaries(...)

The aforementioned user story is from @Castronova's experience (please chime in with further context as you see fit).

This movement to flatter python package structures is apparent in many large python libraries (e.g. pandas). With this in mind, my point is not to just copy what others are doing even if these practices are becoming idiomatic. Instead, I would like to talk about the pros and cons of moving towards flattening subpackage structures to expose api's at the subpackage level.

Given our scientific audience, I want to avoid introducing ambiguity into what someone might infer a method does. For example:

from hydrotools import events as ev

# This is ambiguous about the method of event detection being used.
events = ev.event_detection(...)

the above code snippet is not clear enough IMO. However, I think there is a middle ground where we adhere to scientific integrity and maximize usability.

from hydrotools import events as ev

# I think this toes the line between specificity and usability well
events = ev.decomposition(...)

Much of what I am trying to describe sklearn concretizes in their package layout. There is an initial categorization in their subpackage structure (this mirrors ours) with the majority of "public" methods being exposed in a flat structure at the subpackage level.

I don't want to talk implementation detail (yet, if required), but instead I'd rather hear what others think and where you all deem it appropriate and inappropriate. Im looking forward to hearing your thoughts.

Pinging a few people who might want to provide feedback (@jarq6c, @hellkite500, @christophertubbs, @amaes3owp, @ZacharyWills, @jameshalgren)

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions