Api exposure callbacks by BSd3v · Pull Request #3347 · plotly/dash · GitHub
Skip to content

Api exposure callbacks#3347

Merged
T4rk1n merged 11 commits intoplotly:devfrom
BSd3v:api-exposure-callbacks
Sep 8, 2025
Merged

Api exposure callbacks#3347
T4rk1n merged 11 commits intoplotly:devfrom
BSd3v:api-exposure-callbacks

Conversation

@BSd3v
Copy link
Copy Markdown
Contributor

@BSd3v BSd3v commented Jun 27, 2025

This PR strives to allow callbacks to be exposed by the underlying server as an API by simply passing the callback a api_endpoint. The api will accept a body with the functional arguments provided as kwargs.

@BSd3v
Copy link
Copy Markdown
Contributor Author

BSd3v commented Jun 27, 2025

@gvwilson gvwilson added feature something new P2 considered for next cycle community community contribution labels Jul 3, 2025
Copy link
Copy Markdown
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look like a nice feature, just need to add a docstring to the new argument and a test.

@BSd3v
Copy link
Copy Markdown
Contributor Author

BSd3v commented Sep 1, 2025

@T4rk1n

Is there another way to setup the apis rather than calling app.setup_apis()

Copy link
Copy Markdown
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's only keep the GLOBAL_API_PATHS and use that for the registering.

Comment thread dash/_callback.py Outdated
)
callback_map = _kwargs.pop("callback_map", GLOBAL_CALLBACK_MAP)
callback_list = _kwargs.pop("callback_list", GLOBAL_CALLBACK_LIST)
callback_api_paths = _kwargs.pop("callback_api_paths", GLOBAL_API_PATHS)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's only have the global one, having two variables for the same functionality creates issue like #3419 and add complexity.

Comment thread dash/dash.py
def _setup_server(self):
if self._got_first_request["setup_server"]:
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's missing a call to setup_apis or is it meant to be called by the user?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Routes must be registered by the dev before the server is started, therefore it cant go here to automatically setup.

@T4rk1n T4rk1n merged commit bac3f36 into plotly:dev Sep 8, 2025
9 of 10 checks passed
@antonymilne
Copy link
Copy Markdown

antonymilne commented Sep 24, 2025

This seems very cool as a feature 🙌 But I can't think of where I would actually use it... As inspiration, please could you give some examples of where you think this would be useful?

@BSd3v
Copy link
Copy Markdown
Contributor Author

BSd3v commented Sep 24, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community community contribution feature something new P2 considered for next cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants