Servers and clients¶
serve
¶
serve(
algorithm: Union[Algorithm, MultiAlgorithm, Callable],
*args,
**kwargs,
) -> None
Serve an algorithm, algorithm collection, or plain Python function over HTTP.
Starts a FastAPI server (with uvicorn) and blocks until it is stopped. Run it from a Python script, not from a Jupyter notebook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm
|
Algorithm, MultiAlgorithm, or callable
|
The algorithm or collection to serve. A plain Python function is converted to an algorithm. |
required |
*args
|
Passed to the server: |
()
|
|
**kwargs
|
Passed to the server: |
()
|
Examples:
Client
¶
Bases: AlgorithmRunner
Client to connect to algorithm servers.
A client implements the shared
AlgorithmRunner interface, so the same
code can run an algorithm locally or on a server. Computations requested with
run() are executed on the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_url
|
str
|
Address of the algorithm server, e.g. |
None
|
name
|
str
|
A name identifying the client. |
"client"
|
Attributes:
| Name | Type | Description |
|---|---|---|
server_url |
str
|
Address of the algorithm server. |
algorithms |
list of str
|
The names of the algorithms available on the server. |
Examples:
connect
¶
Connect to an algorithm server and list its algorithms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_url
|
str
|
Address of the algorithm server, e.g. |
required |
The other methods of clients are described in the shared interface.