orangeqs.juice.schemas.tasks#
Task schemas for services.
Module Contents#
Classes#
Ping a service to check if it is responsive. |
|
Sleep synchronously (block) for a given duration. |
|
Sleep asynchronously for a given duration. |
|
Base class for executing code in an IPython kernel. |
|
Run raw code in an IPython kernel. |
|
Sleep asynchronously in an IPython kernel. |
|
Dry-run the rebuild of the environment of a service. |
|
Configuration for the task servers of OrangeQS Juice services. |
|
Configurations for the task servers of OrangeQS Juice services. |
API#
- class orangeqs.juice.schemas.tasks.Ping(/, **data: Any)#
Bases:
orangeqs.juice.task.TaskPing a service to check if it is responsive.
Returns the same message back.
- class orangeqs.juice.schemas.tasks.SleepSync(/, **data: Any)#
Bases:
orangeqs.juice.task.TaskSleep synchronously (block) for a given duration.
- class orangeqs.juice.schemas.tasks.SleepAsync(/, **data: Any)#
Bases:
orangeqs.juice.task.TaskSleep asynchronously for a given duration.
- class orangeqs.juice.schemas.tasks.IPythonTask(/, **data: Any)#
Bases:
orangeqs.juice.task.TaskBase class for executing code in an IPython kernel.
Must be subclassed with the
codeproperty implemented.Returns the result of the executed code cell or an error message if execution fails. If the code executes successfully, returns
{"status": "ok", "result": result}. If the result is not JSON serializable, usesrepr(result)instead. If an error before or during execution of the cell, returns{"status": "error", "ename": "<Exception class>", "evalue": "<Exception value>"}instead.Examples#
from pydantic import computed_field class HelloFromIPython(IPythonTask): name: str @computed_field @property def code(self) -> str: return f"print('Hello, {self.name}!')"
Note that the order of the decorators matters here!
Return a set of field names to exclude from the display name.
- abstract property code: str#
Return the code to execute based on the task payload.
This should be a computed property implemented by subclasses. It must be decorated with
computed_field()andproperty(), in that order. SeeIPythonTaskfor an example.
- classmethod type() str#
Return the unique name of the task type.
Always returns
"IPythonTask"to ensure all IPython tasks are routed to the same handler.
- class orangeqs.juice.schemas.tasks.RawIPython(/, **data: Any)#
Bases:
orangeqs.juice.schemas.tasks.IPythonTaskRun raw code in an IPython kernel.
This task should not be subclassed, see
IPythonTaskinstead.
- class orangeqs.juice.schemas.tasks.AsyncSleepIPython(/, **data: Any)#
Bases:
orangeqs.juice.schemas.tasks.IPythonTaskSleep asynchronously in an IPython kernel.
- class orangeqs.juice.schemas.tasks.RebuildEnvironmentDryRun(/, **data: Any)#
Bases:
orangeqs.juice.task.TaskDry-run the rebuild of the environment of a service.
This runs a dry-run of the
uv sync --dry-runcommand to show what changes would be made to the environment without actually applying them.Returns a
tuple[bool, list[str]]where the boolean indicates whether the dry-run was successful, and the list of strings contains the output lines from the dry-run.
- class orangeqs.juice.schemas.tasks.TaskServerConfig(/, **data: Any)#
Bases:
orangeqs.juice.settings.BaseConfigurableConfiguration for the task servers of OrangeQS Juice services.
- ip: str#
None
IP address the task server listens on, or the hostname that resolves to an IP address.
- port: orangeqs.juice.schemas.common.PortNumber#
5120
Port number the task server listens on.
- class orangeqs.juice.schemas.tasks.TaskServerConfigs(/, **data: Any)#
Bases:
orangeqs.juice.settings.ConfigurableConfigurations for the task servers of OrangeQS Juice services.
Task servers in OrangeQS Juice services use the default configuration if not configured here.
- services: dict[str, orangeqs.juice.schemas.tasks.TaskServerConfig]#
‘Field(…)’
Task server configuration for all services.
- for_service(service_name: str) orangeqs.juice.schemas.tasks.TaskServerConfig#
Return the task server configuration for a given service.
If the service is not configured, returns a default configuration with the IP set to
juice-{service_name}.Parameters#
service_name (str): The name of the service.
Returns#
(TaskServerConfig): The task server configuration for the service.