Skip to content

Commit 9449d67

Browse files
committed
docs: add docstrings to extension setup helper functions
Signed-off-by: Sofia Donato Ferreira <[email protected]>
1 parent c68d4fe commit 9449d67

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/sophys/cli/core/magics/__init__.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ def render_custom_magics(ipython, consider_blacklist: bool = True):
110110

111111

112112
def setup_remote_session_handler(ipython, address: str, *, disable_authentication: bool = False):
113+
"""
114+
Properly configure the manager for remote session tokens.
115+
116+
This will also immediately ask for user credentials for authentication, if it
117+
is enabled, and will update the local cache of devices and plan names upon
118+
successful connection and authentication.
119+
120+
Parameters
121+
----------
122+
address : str
123+
The HTTP address of httpserver we're connecting to.
124+
disable_authentication : bool, optional
125+
Controls whether we'll ask user credentials and keep session tokens on
126+
HTTP requests. This will only work properly if httpserver is configured for that.
127+
Disabled by default.
128+
"""
113129
_remote_session_handler = RemoteSessionHandler(address, disable_authentication=disable_authentication)
114130
_remote_session_handler.start()
115131

@@ -133,6 +149,36 @@ def setup_plan_magics(
133149
post_submission_callbacks: list[callable] | None = None,
134150
exception_handlers: dict[type(Exception), callable] | None = None,
135151
):
152+
"""
153+
Configure plan magics for the application.
154+
155+
Parameters
156+
----------
157+
ipython : InteractiveShellApp
158+
The IPython instance of this application.
159+
sophys_name : str
160+
Name of this extension, as its shorthand (i.e. xyz in sophys-xyz).
161+
plan_whitelist : PlanWhitelist
162+
Whitelist object of plans allowed to be created magics for, and their
163+
configurations.
164+
mode_of_operation : ModeOfOperation
165+
Whether we're in local or remote mode.
166+
post_submission_callbacks : list of callables, optional
167+
Functions to call right after submitting a plan successfully. This
168+
allows us to provide custom feedback and additional behavior to the
169+
user.
170+
171+
These callables can also return a boolean indicating whether the
172+
submission actually failed or was successful.
173+
exception_handler : dict of Exception types to callables, optional
174+
Functions to call when different exceptions are raised by the plan
175+
submission code. This can handle errors in a way specific to the
176+
environment being used.
177+
178+
The callbacks receive the original exception object, and the local
179+
namespace, and return an object of ExceptionHandlerReturnValue
180+
indicating how to proceed.
181+
"""
136182
from .plan_magics import register_magic_for_plan, get_plans, RealMagics
137183

138184
if post_submission_callbacks is None:

0 commit comments

Comments
 (0)