Typing & Metadata
Sieve allows you to type the inputs and outputs of functions deployed to the platform. Most of the pre-built functions have their input and output types listed on their API Guide page.
Function Typing
Sieve jobs can be run in 2 ways — via the API or the Python client. Some Python types may not be JSON-encodable and thus will not be supported by the API. For that reason, we limit the types supported out of the box to:
- All Python primitives (
str
,int
,float
,bool
,dict
,list
) - Sieve types (see SDK reference)
sieve.File
: a generic file object, used to pass references through Sieve functions
Aside: Untyped function handling
Aside: Untyped function handling
Inputs: If your function is not typed, we allow you to pass in any Python object via the client (and any JSON-encodable input from the API). For example, you can run an untyped function with a pandas.DataFrame
as input via Python, but this wouldn’t be possible from the API without implementing a custom JSON encoder/decoder in your function code.
Outputs: When fetching job outputs from the API, we automatically try to JSON encode your function’s return value. If your function is typed, we will use the type to determine how to encode the output. If your function is not typed, we will use the default JSON encoder. From the Python client, we always return the direct Python object.
Types allow Sieve to render auto-generated UIs that can be used to run these functions via the dashboard. You may also include Sphinx docs with each function to show descriptions with each of your inputs.
Here’s an example of a typed function with a description for the input:
Calling this function can be done in a few ways:
You may also view this function in the dashboard and upload files for the sieve.File
input directly, making it easy to share with others on your team.
Metadata
Sieve also lets you add other metadata including a description, README, and more. This is particularly useful for functions that you want to share with others or make public. Here’s a quick example:
For more information on any of these features and more, check out our Sieve function SDK reference here.