Custom Runtimes
Customize your Riza runtime environment using the API.
In this guide, we’ll create a custom Riza runtime environment with access to
the Markdown Python package, which converts
Markdown to HTML. After building this runtime, you can use it with the
Execute Code endpoint so that any Python
code you send to Riza can import the markdown
package.
You can create custom runtimes manually from the Riza Dashboard, but in this guide, we’ll use the API to programmatically create and manage custom runtimes.
Set up
Before getting started, you’ll need an API key from the Riza Dashboard. Export it as an environment variable within your shell:
Create a custom runtime
You can create a custom runtime with a single request to the Create Runtime endpoint. The required parameters are “name”, “language” and “manifest_file”, which is a simple PyPi requirements file declaring your dependencies.
The resulting runtime object you receive from the API will look like this. Take note of the id
and revision_id
parameters, which we’ll use in future steps.
Each custom runtime will have one or more associated revisions. The first revision is automatically created when you create a runtime.
You’ll have a new revision_id
each time you update your dependencies, while the runtime id
will remain the same.
Wait for the custom runtime to build
Building a custom runtime is not instant. It will likely take a few minutes. Polling the
status
parameter on the runtime object will tell you when a build is finished and
whether it succeeded or failed.
The code below makes a request to look up the status of a custom runtime build.
In a real-world setting you’d make several of these requests periodically until
the resulting status is either "succeeded"
or "failed"
.
You can also monitor the status of your runtime builds in the Riza Dashboard.
Use the custom runtime once ready
Assuming the custom runtime build succeeds, you can now use it to run code that imports the Markdown package.
You’ll need the runtime revision ID from the first step to use the runtime with the Execute Code endpoint.
Next steps
Check out the Create Runtime Revision endpoint if you need to add or remove dependencies.
And if you have questions or issues please drop them in Discord.