crab.core.models package

Contents

crab.core.models package#

Submodules#

crab.core.models.action module#

class crab.core.models.action.Action(*, name: str, entry: Callable, parameters: type[BaseModel], returns: type[BaseModel], description: str | None = None, kept_params: list[str] = [], env_name: str | None = None, local: bool = False)[source]#

Bases: BaseModel

The core operational unit within the Crab system.

This class stores parameters and return type definitions and can be easily converted into a JSON schema. It supports argument verification and includes a feature for retaining specific parameters.

name#

The name of the action.

Type:

str

entry#

The actual entry function of the action.

Type:

Callable

parameters#

Definition of input parameters.

Type:

type[BaseModel]

returns#

Definition of the return type. Note: The actual return type is specified by the returns attribute in this model.

Type:

type[BaseModel]

description#

A clear and concise description of the function’s purpose and behavior. Defaults to None.

Type:

str | None

kept_params#

Parameters retained for internal use by the Crab system, such as ‘env’ for storing the current environment. These parameters do not appear in the parameters field and are automatically injected at runtime. Defaults to an empty dictionary.

Type:

dict[str, Any]

env_name#

Specify the environment the action is associated with. Defualts to None.

Type:

Optinal[str]

description: str | None#
entry: Callable#
env_name: str | None#
classmethod from_function(func: Callable) Self[source]#

Generates an action from functions annotated by @action.

get_required_params() dict[str, FieldInfo][source]#
kept_params: list[str]#
local: bool#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'description': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'entry': FieldInfo(annotation=Callable, required=True), 'env_name': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'kept_params': FieldInfo(annotation=list[str], required=False, default=[]), 'local': FieldInfo(annotation=bool, required=False, default=False), 'name': FieldInfo(annotation=str, required=True), 'parameters': FieldInfo(annotation=type[BaseModel], required=True), 'returns': FieldInfo(annotation=type[BaseModel], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

name: str#
parameters: type[BaseModel]#
returns: type[BaseModel]#
run(**kwargs) Any[source]#

Varifies the action parameters then runes the action.

set_kept_param(**params) Self[source]#
to_openai_json_schema() dict[source]#

Gets openai json schema from an action

to_raw_action() dict[str, Any][source]#

Gets serialized action for remote execution

crab.core.models.action.ClosedAction#

The action type alias with no reuqired parameters

alias of Annotated[Action, AfterValidator(func=_check_no_param)]

crab.core.models.action.EMPTY_MODEL#

alias of Empty

crab.core.models.benchmark_interface module#

class crab.core.models.benchmark_interface.StepResult(*, truncated: bool, terminated: bool, action_returns: Any, evaluation_results: dict[str, Any], info: dict[str, Any])[source]#

Bases: BaseModel

action_returns: Any#
evaluation_results: dict[str, Any]#
info: dict[str, Any]#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'action_returns': FieldInfo(annotation=Any, required=True), 'evaluation_results': FieldInfo(annotation=dict[str, Any], required=True), 'info': FieldInfo(annotation=dict[str, Any], required=True), 'terminated': FieldInfo(annotation=bool, required=True), 'truncated': FieldInfo(annotation=bool, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

terminated: bool#
truncated: bool#

crab.core.models.config module#

class crab.core.models.config.BenchmarkConfig(*, name: str, tasks: list[Task], environments: list[EnvironmentConfig], default_env: str | None = None, multienv: bool = False, prompting_tools: dict[str, dict[str, Action]] = {}, root_action_space: list[Action] = [], step_limit: int = 30, common_setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] = [])[source]#

Bases: BaseModel

common_setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]]#
default_env: str | None#
environments: list[EnvironmentConfig]#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'common_setup': FieldInfo(annotation=list[Annotated[Action, AfterValidator]], required=False, default=[]), 'default_env': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'environments': FieldInfo(annotation=list[EnvironmentConfig], required=True), 'multienv': FieldInfo(annotation=bool, required=False, default=False), 'name': FieldInfo(annotation=str, required=True), 'prompting_tools': FieldInfo(annotation=dict[str, dict[str, Action]], required=False, default={}), 'root_action_space': FieldInfo(annotation=list[Action], required=False, default=[]), 'step_limit': FieldInfo(annotation=int, required=False, default=30), 'tasks': FieldInfo(annotation=list[Task], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

multienv: bool#
name: str#
prompting_tools: dict[str, dict[str, Action]]#
root_action_space: list[Action]#
step_limit: int#
tasks: list[Task]#
class crab.core.models.config.EnvironmentConfig(*, name: str, action_space: list[Action], observation_space: list[Annotated[Action, AfterValidator(func=_check_no_param)]], description: str = '', reset: Action | None = None, remote_url: str | None = None, extra_attributes: dict[str, Any] = {})[source]#

Bases: BaseModel

action_space: list[Action]#
description: str#
extra_attributes: dict[str, Any]#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'action_space': FieldInfo(annotation=list[Action], required=True), 'description': FieldInfo(annotation=str, required=False, default=''), 'extra_attributes': FieldInfo(annotation=dict[str, Any], required=False, default={}), 'name': FieldInfo(annotation=str, required=True), 'observation_space': FieldInfo(annotation=list[Annotated[Action, AfterValidator]], required=True), 'remote_url': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'reset': FieldInfo(annotation=Union[Action, NoneType], required=False, default=None)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

name: str#
observation_space: list[Annotated[Action, AfterValidator(func=_check_no_param)]]#
remote_url: str | None#
reset: Action | None#
class crab.core.models.config.VMEnvironmentConfig(*, inside_environment: EnvironmentConfig, remote_url: str = 'http://192.168.0.0:8000')[source]#

Bases: BaseModel

inside_environment: EnvironmentConfig#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'inside_environment': FieldInfo(annotation=EnvironmentConfig, required=True), 'remote_url': FieldInfo(annotation=str, required=False, default='http://192.168.0.0:8000')}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

remote_url: str#

crab.core.models.evaluator module#

class crab.core.models.evaluator.Evaluator(*, name: str, entry: Callable, parameters: type[BaseModel], returns: type[BaseModel], description: str | None = None, kept_params: list[str] = [], env_name: str | None = None, local: bool = False, require_submit: bool = False)[source]#

Bases: Action

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'description': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'entry': FieldInfo(annotation=Callable, required=True), 'env_name': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'kept_params': FieldInfo(annotation=list[str], required=False, default=[]), 'local': FieldInfo(annotation=bool, required=False, default=False), 'name': FieldInfo(annotation=str, required=True), 'parameters': FieldInfo(annotation=type[BaseModel], required=True), 'require_submit': FieldInfo(annotation=bool, required=False, default=False), 'returns': FieldInfo(annotation=type[BaseModel], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

classmethod must_return_bool(v: type[BaseModel]) type[BaseModel][source]#
require_submit: bool#

crab.core.models.task module#

class crab.core.models.task.GeneratedTask(*, description: str, tasks: list[SubTaskInstance], adjlist: str, id: str = None)[source]#

Bases: BaseModel

adjlist: str#
description: str#
id: str#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'adjlist': FieldInfo(annotation=str, required=True), 'description': FieldInfo(annotation=str, required=True), 'id': FieldInfo(annotation=str, required=False, default_factory=uuid4), 'tasks': FieldInfo(annotation=list[SubTaskInstance], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

tasks: list[SubTaskInstance]#
class crab.core.models.task.SubTask(*, id: str, description: str, attribute_dict: dict[str, list[str] | str], output_type: str, output_generator: Callable[[Any], str] | Literal['manual'] | None = None, evaluator_generator: Callable[[Any], DiGraph] | None = None, setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)] = [], teardown: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)] = [], extra_action: list[Action] = [])[source]#

Bases: BaseModel

attribute_dict: dict[str, list[str] | str]#
description: str#
evaluator_generator: Callable[[Any], DiGraph] | None#
classmethod expand_attribute_type(attribute_dict: dict[str, list[str] | str]) dict[str, list[str]][source]#
extra_action: list[Action]#
id: str#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'attribute_dict': FieldInfo(annotation=dict[str, Union[list[str], str]], required=True), 'description': FieldInfo(annotation=str, required=True), 'evaluator_generator': FieldInfo(annotation=Union[Callable[list, DiGraph], NoneType], required=False, default=None), 'extra_action': FieldInfo(annotation=list[Action], required=False, default=[]), 'id': FieldInfo(annotation=str, required=True), 'output_generator': FieldInfo(annotation=Union[Callable[list, str], Literal['manual'], NoneType], required=False, default=None), 'output_type': FieldInfo(annotation=str, required=True), 'setup': FieldInfo(annotation=Union[list[Annotated[Action, AfterValidator]], Annotated[Action, AfterValidator]], required=False, default=[]), 'teardown': FieldInfo(annotation=Union[list[Annotated[Action, AfterValidator]], Annotated[Action, AfterValidator]], required=False, default=[])}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

output_generator: Callable[[Any], str] | Literal['manual'] | None#
output_type: str#
setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)]#
teardown: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)]#
class crab.core.models.task.SubTaskInstance(*, task: SubTask, attribute: dict[str, Any], output: str | None = None, id: str = None)[source]#

Bases: BaseModel

attribute: dict[str, Any]#
dump_model() dict[str, Any][source]#
id: str#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'attribute': FieldInfo(annotation=dict[str, Any], required=True), 'id': FieldInfo(annotation=str, required=False, default_factory=uuid4), 'output': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'task': FieldInfo(annotation=SubTask, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

output: str | None#
task: SubTask#
class crab.core.models.task.Task(*, id: str, description: str, evaluator: DiGraph | Evaluator, setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)] = [], teardown: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)] = [], extra_action: list[Action] = [])[source]#

Bases: BaseModel

classmethod change_evaluator_to_graph(evaluator: DiGraph | Evaluator) str[source]#
description: str#
evaluator: DiGraph | Evaluator#
extra_action: list[Action]#
id: str#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'description': FieldInfo(annotation=str, required=True), 'evaluator': FieldInfo(annotation=Union[DiGraph, Evaluator], required=True), 'extra_action': FieldInfo(annotation=list[Action], required=False, default=[]), 'id': FieldInfo(annotation=str, required=True), 'setup': FieldInfo(annotation=Union[list[Annotated[Action, AfterValidator]], Annotated[Action, AfterValidator]], required=False, default=[]), 'teardown': FieldInfo(annotation=Union[list[Annotated[Action, AfterValidator]], Annotated[Action, AfterValidator]], required=False, default=[])}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)]#
teardown: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)]#
classmethod to_list(action: Action | list[Action]) list[Action][source]#

Module contents#

class crab.core.models.Action(*, name: str, entry: Callable, parameters: type[BaseModel], returns: type[BaseModel], description: str | None = None, kept_params: list[str] = [], env_name: str | None = None, local: bool = False)[source]#

Bases: BaseModel

The core operational unit within the Crab system.

This class stores parameters and return type definitions and can be easily converted into a JSON schema. It supports argument verification and includes a feature for retaining specific parameters.

name#

The name of the action.

Type:

str

entry#

The actual entry function of the action.

Type:

Callable

parameters#

Definition of input parameters.

Type:

type[BaseModel]

returns#

Definition of the return type. Note: The actual return type is specified by the returns attribute in this model.

Type:

type[BaseModel]

description#

A clear and concise description of the function’s purpose and behavior. Defaults to None.

Type:

str | None

kept_params#

Parameters retained for internal use by the Crab system, such as ‘env’ for storing the current environment. These parameters do not appear in the parameters field and are automatically injected at runtime. Defaults to an empty dictionary.

Type:

dict[str, Any]

env_name#

Specify the environment the action is associated with. Defualts to None.

Type:

Optinal[str]

description: str | None#
entry: Callable#
env_name: str | None#
classmethod from_function(func: Callable) Self[source]#

Generates an action from functions annotated by @action.

get_required_params() dict[str, FieldInfo][source]#
kept_params: list[str]#
local: bool#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'description': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'entry': FieldInfo(annotation=Callable, required=True), 'env_name': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'kept_params': FieldInfo(annotation=list[str], required=False, default=[]), 'local': FieldInfo(annotation=bool, required=False, default=False), 'name': FieldInfo(annotation=str, required=True), 'parameters': FieldInfo(annotation=type[BaseModel], required=True), 'returns': FieldInfo(annotation=type[BaseModel], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

name: str#
parameters: type[BaseModel]#
returns: type[BaseModel]#
run(**kwargs) Any[source]#

Varifies the action parameters then runes the action.

set_kept_param(**params) Self[source]#
to_openai_json_schema() dict[source]#

Gets openai json schema from an action

to_raw_action() dict[str, Any][source]#

Gets serialized action for remote execution

class crab.core.models.ActionOutput(*, name: str, arguments: dict[str, Any], env: str | None = None)[source]#

Bases: BaseModel

arguments: dict[str, Any]#
env: str | None#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'arguments': FieldInfo(annotation=dict[str, Any], required=True), 'env': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'name': FieldInfo(annotation=str, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

name: str#
class crab.core.models.BackendOutput(*, message: str | None, action_list: list[ActionOutput] | None)[source]#

Bases: BaseModel

action_list: list[ActionOutput] | None#
message: str | None#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'action_list': FieldInfo(annotation=Union[list[ActionOutput], NoneType], required=True), 'message': FieldInfo(annotation=Union[str, NoneType], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

class crab.core.models.BenchmarkConfig(*, name: str, tasks: list[Task], environments: list[EnvironmentConfig], default_env: str | None = None, multienv: bool = False, prompting_tools: dict[str, dict[str, Action]] = {}, root_action_space: list[Action] = [], step_limit: int = 30, common_setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] = [])[source]#

Bases: BaseModel

common_setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]]#
default_env: str | None#
environments: list[EnvironmentConfig]#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'common_setup': FieldInfo(annotation=list[Annotated[Action, AfterValidator]], required=False, default=[]), 'default_env': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'environments': FieldInfo(annotation=list[EnvironmentConfig], required=True), 'multienv': FieldInfo(annotation=bool, required=False, default=False), 'name': FieldInfo(annotation=str, required=True), 'prompting_tools': FieldInfo(annotation=dict[str, dict[str, Action]], required=False, default={}), 'root_action_space': FieldInfo(annotation=list[Action], required=False, default=[]), 'step_limit': FieldInfo(annotation=int, required=False, default=30), 'tasks': FieldInfo(annotation=list[Task], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

multienv: bool#
name: str#
prompting_tools: dict[str, dict[str, Action]]#
root_action_space: list[Action]#
step_limit: int#
tasks: list[Task]#
class crab.core.models.EnvironmentConfig(*, name: str, action_space: list[Action], observation_space: list[Annotated[Action, AfterValidator(func=_check_no_param)]], description: str = '', reset: Action | None = None, remote_url: str | None = None, extra_attributes: dict[str, Any] = {})[source]#

Bases: BaseModel

action_space: list[Action]#
description: str#
extra_attributes: dict[str, Any]#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'action_space': FieldInfo(annotation=list[Action], required=True), 'description': FieldInfo(annotation=str, required=False, default=''), 'extra_attributes': FieldInfo(annotation=dict[str, Any], required=False, default={}), 'name': FieldInfo(annotation=str, required=True), 'observation_space': FieldInfo(annotation=list[Annotated[Action, AfterValidator]], required=True), 'remote_url': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'reset': FieldInfo(annotation=Union[Action, NoneType], required=False, default=None)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

name: str#
observation_space: list[Annotated[Action, AfterValidator(func=_check_no_param)]]#
remote_url: str | None#
reset: Action | None#
class crab.core.models.Evaluator(*, name: str, entry: Callable, parameters: type[BaseModel], returns: type[BaseModel], description: str | None = None, kept_params: list[str] = [], env_name: str | None = None, local: bool = False, require_submit: bool = False)[source]#

Bases: Action

description: str | None#
entry: Callable#
env_name: str | None#
kept_params: list[str]#
local: bool#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'description': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'entry': FieldInfo(annotation=Callable, required=True), 'env_name': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'kept_params': FieldInfo(annotation=list[str], required=False, default=[]), 'local': FieldInfo(annotation=bool, required=False, default=False), 'name': FieldInfo(annotation=str, required=True), 'parameters': FieldInfo(annotation=type[BaseModel], required=True), 'require_submit': FieldInfo(annotation=bool, required=False, default=False), 'returns': FieldInfo(annotation=type[BaseModel], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

classmethod must_return_bool(v: type[BaseModel]) type[BaseModel][source]#
name: str#
parameters: type[BaseModel]#
require_submit: bool#
returns: type[BaseModel]#
class crab.core.models.GeneratedTask(*, description: str, tasks: list[SubTaskInstance], adjlist: str, id: str = None)[source]#

Bases: BaseModel

adjlist: str#
description: str#
id: str#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'adjlist': FieldInfo(annotation=str, required=True), 'description': FieldInfo(annotation=str, required=True), 'id': FieldInfo(annotation=str, required=False, default_factory=uuid4), 'tasks': FieldInfo(annotation=list[SubTaskInstance], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

tasks: list[SubTaskInstance]#
crab.core.models.Message#

alias of tuple[str, MessageType]

class crab.core.models.MessageType(value)[source]#

Bases: IntEnum

An enumeration.

IMAGE_JPG_BASE64 = 1#
TEXT = 0#
class crab.core.models.StepResult(*, truncated: bool, terminated: bool, action_returns: Any, evaluation_results: dict[str, Any], info: dict[str, Any])[source]#

Bases: BaseModel

action_returns: Any#
evaluation_results: dict[str, Any]#
info: dict[str, Any]#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'action_returns': FieldInfo(annotation=Any, required=True), 'evaluation_results': FieldInfo(annotation=dict[str, Any], required=True), 'info': FieldInfo(annotation=dict[str, Any], required=True), 'terminated': FieldInfo(annotation=bool, required=True), 'truncated': FieldInfo(annotation=bool, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

terminated: bool#
truncated: bool#
class crab.core.models.SubTask(*, id: str, description: str, attribute_dict: dict[str, list[str] | str], output_type: str, output_generator: Callable[[Any], str] | Literal['manual'] | None = None, evaluator_generator: Callable[[Any], DiGraph] | None = None, setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)] = [], teardown: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)] = [], extra_action: list[Action] = [])[source]#

Bases: BaseModel

attribute_dict: dict[str, list[str] | str]#
description: str#
evaluator_generator: Callable[[Any], DiGraph] | None#
classmethod expand_attribute_type(attribute_dict: dict[str, list[str] | str]) dict[str, list[str]][source]#
extra_action: list[Action]#
id: str#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'attribute_dict': FieldInfo(annotation=dict[str, Union[list[str], str]], required=True), 'description': FieldInfo(annotation=str, required=True), 'evaluator_generator': FieldInfo(annotation=Union[Callable[list, DiGraph], NoneType], required=False, default=None), 'extra_action': FieldInfo(annotation=list[Action], required=False, default=[]), 'id': FieldInfo(annotation=str, required=True), 'output_generator': FieldInfo(annotation=Union[Callable[list, str], Literal['manual'], NoneType], required=False, default=None), 'output_type': FieldInfo(annotation=str, required=True), 'setup': FieldInfo(annotation=Union[list[Annotated[Action, AfterValidator]], Annotated[Action, AfterValidator]], required=False, default=[]), 'teardown': FieldInfo(annotation=Union[list[Annotated[Action, AfterValidator]], Annotated[Action, AfterValidator]], required=False, default=[])}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

output_generator: Callable[[Any], str] | Literal['manual'] | None#
output_type: str#
setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)]#
teardown: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)]#
class crab.core.models.SubTaskInstance(*, task: SubTask, attribute: dict[str, Any], output: str | None = None, id: str = None)[source]#

Bases: BaseModel

attribute: dict[str, Any]#
dump_model() dict[str, Any][source]#
id: str#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'attribute': FieldInfo(annotation=dict[str, Any], required=True), 'id': FieldInfo(annotation=str, required=False, default_factory=uuid4), 'output': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'task': FieldInfo(annotation=SubTask, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

output: str | None#
task: SubTask#
class crab.core.models.Task(*, id: str, description: str, evaluator: DiGraph | Evaluator, setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)] = [], teardown: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)] = [], extra_action: list[Action] = [])[source]#

Bases: BaseModel

classmethod change_evaluator_to_graph(evaluator: DiGraph | Evaluator) str[source]#
description: str#
evaluator: DiGraph | Evaluator#
extra_action: list[Action]#
id: str#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'description': FieldInfo(annotation=str, required=True), 'evaluator': FieldInfo(annotation=Union[DiGraph, Evaluator], required=True), 'extra_action': FieldInfo(annotation=list[Action], required=False, default=[]), 'id': FieldInfo(annotation=str, required=True), 'setup': FieldInfo(annotation=Union[list[Annotated[Action, AfterValidator]], Annotated[Action, AfterValidator]], required=False, default=[]), 'teardown': FieldInfo(annotation=Union[list[Annotated[Action, AfterValidator]], Annotated[Action, AfterValidator]], required=False, default=[])}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

setup: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)]#
teardown: list[Annotated[Action, AfterValidator(func=_check_no_param)]] | Annotated[Action, AfterValidator(func=_check_no_param)]#
classmethod to_list(action: Action | list[Action]) list[Action][source]#
class crab.core.models.VMEnvironmentConfig(*, inside_environment: EnvironmentConfig, remote_url: str = 'http://192.168.0.0:8000')[source]#

Bases: BaseModel

inside_environment: EnvironmentConfig#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'inside_environment': FieldInfo(annotation=EnvironmentConfig, required=True), 'remote_url': FieldInfo(annotation=str, required=False, default='http://192.168.0.0:8000')}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

remote_url: str#