relationalai.experimental.solvers.Provider
class Provider
The Provider
class is used to manage solver engines using the Python API.
Example
Section titled “Example”Create an instance of the Provider
class and use it to create a new solver engine:
from relationalai.experimental import solvers
# Create a Provider instance.provider = solvers.Provider()
# Create a solver engine named "my_solver_engine".provider.create_solver("my_solver_engine")
Methods
Section titled “Methods”The Provider
class has methods for viewing and managing solver engines and their jobs.
.__init__()
Section titled “.__init__()”Provider.__init__(self) -> None
Constructs a new Provider
instance.
For example:
from relationalai.experimental import solvers
# Create a Provider instance.provider = solvers.Provider()
.create_solver()
Section titled “.create_solver()”Provider.create_solver( name: str, size: str, settings: dict[str, Any] | None = None, auto_suspend_mins: int | None = None,) -> None
Instruct the RAI Native App to provision a new solver engine with the specified name
and size
, and block until the engine is ready.
Note that the name
is case-sensitive and must be unique across all solver engines in the RAI Native App.
The size
parameter specifies the instance family of the Snowflake SPCS compute pool on which the engine is hosted.
Currently, the following sizes are supported:
"HIGHMEM_X64_S"
"HIGHMEM_X64_M"
Use the optional settings
dictionary to enable or disable specific solver backends on the engine.
If None
, the following defaults are used:
{ "gurobi": False, # Disabled by default "highs": True, "ipopt": True, "minizinc": True,}
Open-source backends are all enabled by default.
Gurobi, which is commercial and requires a license, is disabled by default.
You can enable it by passing a dictionary with the "gurobi"
key set to True
:
from relationalai.experimental import solvers
# Create a Provider instance.provider = solvers.Provider()
# Create a new solver engine with Gurobi enabled.provider.create_solver("my_solver_engine", settings={"gurobi": True})
The optional auto_suspend_mins
specifies the number of minutes after which the engine should automatically suspend itself if it is idle.
If None
, the engine will auto-suspend after 60 minutes of inactivity.
Set to 0
to disable auto-suspend and keep the engine running indefinitely:
# Create a new solver engine that never suspends.provider.create_solver("my_solver_engine", auto_suspend_mins=0)
.create_solver_async()
Section titled “.create_solver_async()”Provider.create_solver_async( name: str, size: str, settings: dict[str, Any] | None = None, auto_suspend_mins: int | None = None,) -> None
Asynchronously instruct the RAI Native App to provision a new solver engine with the specified name
and size
.
This method returns immediately and does not block until the engine is ready.
The parameters are the same as for .create_solver()
.
.list_solvers()
Section titled “.list_solvers()”Provider.list_solvers( self, state: str | None = None) -> list[dict[str, Any]]
List all solver engines available in the RAI Native App.
If state
is specified, only engines in that state are returned.
Possible values for state
are:
"PENDING"
: The engine is being created and is not yet ready."READY"
: The engine is ready to use and can run jobs."SUSPENDED"
: The engine is suspended and not running.
The state
parameter is case-insensitive.
For example, to list all solver engines that are currently ready:
from pprint import pprint
from relationalai.experimental import solvers
# Create a Provider instance.provider = solvers.Provider()
# List all solver engines.pprint(provider.list_solvers(state="ready"))
Output:[{'auto_suspend_mins': 60, 'created_by': 'jl.picard@starfleet.org', 'created_on': datetime.datetime(2025, 6, 14, 15, 7, 5, 164000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>), 'id': '2150b30323a3', 'name': 'make_it_solve', 'size': 'HIGHMEM_X64_S', 'solvers': ['gurobi', 'minizinc'], 'state': 'READY', 'updated_on': datetime.datetime(2025, 6, 27, 4, 47, 40, 988000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>)}, {'auto_suspend_mins': 60, 'created_by': 'catherine.janeway@starfleet.org', 'created_on': datetime.datetime(2025, 6, 27, 5, 38, 32, 871000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>), 'id': 'ee88b24407c1', 'name': 'my_solver_engine', 'size': 'HIGHMEM_X64_S', 'solvers': ['highs', 'minizinc', 'ipopt'], 'state': 'READY',
.get_solver()
Section titled “.get_solver()”Provider.get_solver(name: str) -> dict[str, Any]
Get the details of the solver engine with the specified name
.
Returns a dictionary with the engine’s details, including its state, size, and settings.
For example:
from pprint import pprint
from relationalai.experimental import solvers
# Create a Provider instance.provider = solvers.Provider()
# Get details for a specific solver engine.pprint(provider.get_solver("my_solver_engine"))
{'auto_suspend_mins': 60, 'created_by': 'catherine.janeway@starfleet.org', 'created_on': datetime.datetime(2025, 6, 27, 5, 38, 32, 871000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>), 'id': 'ee88b24407c1', 'name': 'my_solver_engine', 'size': 'HIGHMEM_X64_S', 'solvers': ['highs', 'minizinc', 'ipopt'], 'state': 'READY', 'updated_on': datetime.datetime(2025, 6, 27, 5, 38, 32, 871000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>)}
.resume_solver_async()
Section titled “.resume_solver_async()”Provider.resume_solver_async(name: str) -> None
Resume the solver engine with the specified name
.
This method does not block and returns immediately.
If the engine is suspended, then it is resumed.
Otherwise, this method has no effect.
.delete_solver()
Section titled “.delete_solver()”Provider.delete_solver(name: str) -> None
Delete the solver engine with the specified name
.
Running jobs are cancelled and terminated.
For example, to delete a solver engine named "my_solver_engine"
:
from relationalai.experimental import solvers
# Create a Provider instance.provider = solvers.Provider()
# Delete the solver engine named "my_solver_engine".provider.delete_solver("my_solver_engine")
.list_jobs()
Section titled “.list_jobs()”Provider.list_jobs( self, state: str | None = None, limit: int | None = None) -> list[dict[str, Any]]
Returns a list of all jobs submitted to the solver engines in the RAI Native App. Each job is represented as a dictionary containing its details, such as job ID, state, and creation time. Jobs are sorted by creation time in descending order.
For example:
from pprint import pprint
from relationalai.experimental import solvers
# Create a Provider instance.provider = solvers.Provider()
# View all solver engine jobs across the RAI Native App.pprint(provider.list_jobs())
[{'created_by': 'jl.picard@starfleet.org', 'created_on': datetime.datetime(2025, 6, 27, 5, 46, 46, 887000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>), 'duration': 14836, 'engine': 'make_it_solve', 'finished_at': datetime.datetime(2025, 6, 27, 5, 47, 1, 723000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>), 'id': '01bd4f7a-0105-c8b9-0003-0acf0aaf4ca6', 'solver': 'minizinc', 'state': 'COMPLETED'}, {'created_by': 'catherine.janeway@starfleet.org', 'created_on': datetime.datetime(2025, 6, 27, 4, 19, 47, 432000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>), 'duration': 401, 'engine': 'my_solver_engine', 'finished_at': datetime.datetime(2025, 6, 27, 4, 19, 47, 833000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>), 'id': '01bd4f23-0105-c682-0003-0acf0aae4866', 'solver': 'highs', 'state': 'COMPLETED'}]
If the optional state
parameter is specified, only jobs in that state are returned.
Possible values for state
are:
"CREATED"
"QUEUED"
"RUNNING"
"COMPLETED"
"CANCELLED"
"FAILED"
The optional limit
parameter specifies the maximum number of jobs to return.
If None
, all jobs are returned.
.get_job()
Section titled “.get_job()”Provider.get_job(job_id: str) -> dict[str, Any]
Returns a dictionary containing the details of the job with the specified job_id
.
The dictionary includes information such as job state, creation time, and the solver engine it was submitted to.
For example:
from pprint import pprint
from relationalai.experimental import solvers
# Create a Provider instance.provider = solvers.Provider()
# View details for a specific job.pprint(provider.get_job("01bd4f23-0105-c682-0003-0acf0aae4866"))
{'created_by': 'catherine.janeway@starfleet.org', 'created_on': datetime.datetime(2025, 6, 27, 4, 19, 47, 432000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>), 'duration': 401, 'engine': 'my_solver_engine', 'finished_at': datetime.datetime(2025, 6, 27, 4, 19, 47, 833000, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>), 'id': '01bd4f23-0105-c682-0003-0acf0aae4866', 'solver': 'highs', 'state': 'COMPLETED'}
.cancel_job()
Section titled “.cancel_job()”Provider.cancel_job(job_id: str) -> None
Asynchronously cancels the job with the specified job_id
.
If the job is running, it is terminated.
If the job is already completed or cancelled, this method has no effect.