Skip to content

Commit 30679d7

Browse files
committed
Add a note about providing stable interfaces
upon transferring code between packages.
1 parent 66b5906 commit 30679d7

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

stack/transferring-code.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ the following procedure should be used:
2525
#. Merge the transfer branch back to the regular issue branch using
2626
``--no-ff`` to preserve the transfer branch name in the merge commit.
2727

28+
#. Make the appropriate changes to support continued import of public interfaces from the origin
29+
repository with a deprecation warning. See :ref:`providing-stable-interfaces` for more details.
30+
2831
#. In the destination repository:
2932

3033
#. Create the usual ``tickets/DM-XXXX`` issue branch.
@@ -70,3 +73,52 @@ See `RFC-33`_ for the motivation and discussion behind this policy.
7073

7174
.. _RFC-33: https://jira.lsstcorp.org/browse/rfc-33
7275
.. _DM Stack Package History: https://confluence.lsstcorp.org/display/DM/DM+Stack+Package+History
76+
77+
78+
.. _providing-stable-interfaces:
79+
80+
Providing Stable Interfaces
81+
===========================
82+
83+
Transferring code between packages is a breaking change and stable interfaces should be provided on a
84+
best-effort basis to support external users.
85+
If the origin repository is downstream of the destination (as is typically the case),
86+
this can be achieved by importing code from the destination repository with an alias,
87+
trivially repackaging it following the deprecation procedure described in
88+
:doc:`Deprecating Interfaces <deprecating-interfaces>`.
89+
90+
As an example, if a Python class ``ConfigurableAction`` is moved from package ``analysis_tools`` (downstream) to ``pex_config`` (upstream),
91+
92+
.. code-block:: python
93+
94+
from lsst.pex.config import ConfigurableAction as ConfigurableActionNew
95+
from depecated.sphinx import deprecated
96+
97+
__all__ = ["ConfigurableAction"]
98+
99+
@deprecated(reason="Moved to lsst.pex.config",
100+
version="v22.0",
101+
category=FutureWarning)
102+
class ConfigurableAction(ConfigurableActionNew):
103+
pass
104+
105+
In the relative less common case of moving code downstream, the following pattern can be used:
106+
107+
.. code-block:: python
108+
109+
import warnings
110+
111+
try:
112+
from lsst.drp.tasks.assemble_coadd import * # noqa: F401, F403
113+
except ImportError as error:
114+
error.msg += ". Please import the coaddition tasks from drp_tasks package."
115+
raise error
116+
finally:
117+
warnings.warn("lsst.pipe.tasks.assembleCoadd is deprecated and will be removed after v27; "
118+
"Please use lsst.drp.tasks.assemble_coadd instead.",
119+
DeprecationWarning,
120+
stacklevel=2
121+
)
122+
123+
This allows the code to be imported from the old location (with a deprecation warning) with a fully built
124+
version of the Science Pipelines, but does not introduces cyclic dependencies during the build process.

0 commit comments

Comments
 (0)