Skip to content

Conversation

chriso
Copy link
Contributor

@chriso chriso commented Mar 22, 2024

This PR changes the import scheme so that the construction of local and remote endpoints is clearer.

For remote endpoints:

from dispatch.remote import Endpoint

remote = Endpoint(url)

@remote.function
def my_remote_func(): ...

For local endpoints (e.g. using FastAPI):

from fastapi import FastAPI
from dispatch.fastapi import Endpoint

app = FastAPI()
dispatch = Endpoint(app)

@dispatch.function
def my_local_func(): ...

Previously you had from dispatch.fastapi import Dispatch for local endpoints, and from dispatch import Registry for remote endpoints (#134).

With this PR we avoid using the ambiguous Dispatch and Registry names, and the ambiguous top-level namespace (from dispatch import $thing).

I've maintained backward compatibility by creating a dispatch.fastapi.{Dispatch => Endpoint} alias (so from dispatch.fastapi import Dispatch continues to work).

@chriso chriso self-assigned this Mar 22, 2024
@chriso chriso closed this Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants