4dn-dcic / utils

various util modules shared amongst several projects in our organization
MIT License
4 stars 1 forks source link

env_xxx refactor (compatible) #197

Closed netsettler closed 2 years ago

netsettler commented 2 years ago

This PR only changes the structure of some files (in a way that makes other diffs hard). It does not change functionality that exists already.

Basically, this will divide EnvManager into a lower level EnvBase class (in env_basic.py) and an EnvManager class (in env_manager.py) that inherits from EnvBase. What makes this a compatible change is that, having emptied out the previous contents of env_base.py into these two other files, I then re-import EnvManager back into env_base.py so that anything doing from dcicutils.env_base import EnvManager can still find it.

Aside to @dmichaels-harvard, who might not be familiar with this technique, the exported function in this file is entirely a no-op that I invented. The file contents that are now:

from dcicutils.misc_utils import exported
from .env_manager import EnvManager

exported(EnvManager)  # It used to live here

would work just as well if env_base.py only contained:

from .env_manager import EnvManager

but it would be harder to see what was going on. PyCharm and other linters would think the import was unused, but that's because they don't scan other files for

from dcicutils.env_base import EnvManager

I would prefer to make the incompatible change that would break this, and I'll make a layered PR that offers that change instead so you can choose that, but that will create cascade work in other repos in order to take this change.

netsettler commented 2 years ago

This PR was superseded by utils PR #198.