roboto.action_runtime.action_input
Submodules
Package Contents
ActionInput
Resolved references to input data an Action was given to operate on.
To use, access via get_input().
Usage
From within an Action, list files passed as input and check their size:
context = InvocationContext.from_env()
action_input = context.get_input()
for file, local_path in action_input.files:
print(f"{file.file_id} is {local_path.stat().st_size} bytes")Attributes
ActionInput.files
Files passed as input data to an action invocation.
A file is represented as a tuple of (File, Optional[Path]) where: - File exposes metadata about the file and useful file operations - Optional[Path] is the local file path if the file has been downloaded
ActionInput.from_record()
Create an ActionInput instance from its serialized representation.
Parameters
record ActionInputRecordroboto_client roboto.Return type
ActionInput.get_topics_by_name()
Return any topics in this ActionInput that have the provided name.
Parameters
topic_name strTopic name to look for.
Returns
A list of matching Topic instances from self.topics. If no topics have the provided name, the list will be empty. Otherwise, there will be one or more topics in the list, depending on the topic selectors provided to the action invocation.
Attributes
ActionInput.sessions
Sessions passed as input data to an action invocation.
ActionInput.topics
Topics passed as input data to an action invocation.
ActionInputRecord
Bases: pydantic.BaseModel
Serializable representation of an ActionInput.
Parameters
data AnyAttributes
ActionInputRecord.files
ActionInputRecord.sessions
ActionInputRecord.topics
ActionInputResolver
Resolves the action invocation input spec to concrete Roboto entities.
The entities are packaged together in an ActionInput instance, which is available to action code via ActionRuntime.
Parameters
file_service roboto.ActionInputResolver.from_env()
Parameters
roboto_client Optional[roboto.roboto_search Optional[roboto.Return type
ActionInputResolver.resolve_input_spec()
Resolve the input spec’s file, session, and topic selectors to the entities they match.
When the spec asks for files, sessions, or topics and none match, that category comes back empty with a logged warning rather than an error.
Parameters
input_spec roboto.Input specification containing data selectors. See InvocationInput for more detail.
download boolIf True, download all resolved files to local disk. Defaults to False.
download_path Optional[pathlib.Directory path where files should be downloaded. If not provided and download=True, a temporary directory will be created. Ignored if download=False.
Returns
ActionInputRecord containing:
- files: List of (FileRecord, Optional[Path]) tuples. Path is None if download=False, otherwise contains the local path where the file was downloaded.
- sessions: List of SessionRecord instances.
- topics: List of TopicRecord instances.
Usage
Resolve files using a RoboQL query without downloading:
input_spec = InvocationInput.file_query('dataset_id = "ds_abc123" AND path LIKE "%.mcap"')
result = resolver.resolve_input_spec(input_spec)
# result.files contains (FileRecord, None) tuples
# result.topics is emptyResolve and download files to a specific directory:
input_spec = InvocationInput.file_query('dataset_id = "ds_abc123" AND path LIKE "%.mcap"')
result = resolver.resolve_input_spec(input_spec, download=True, download_path=Path("/tmp/data"))
# result.files contains (FileRecord, Path) tuples with local pathsResolve both files and topics:
input_spec = InvocationInput(
files=FileSelector(query='dataset_id = "ds_abc123" AND path LIKE "%.mcap"'),
topics=DataSelector(names=["battery_status", "gps"]),
)
result = resolver.resolve_input_spec(input_spec)
# result.files contains file records
# result.topics contains topic recordsDEFAULT_INPUT_FILE
InputFileResolver
Looks up the files an action invocation runs on, from the file selectors declared as its inputs.
A selector names files by ID, by name, by path within a dataset, or with a RoboQL query; every field it populates is looked up and the matches are returned together. resolve_all returns each file once, while resolve repeats a file that matches on more than one field.
A query, names or paths goes through file search, which does not return links yet, so it never selects a link. A link named in ids is returned, and ActionInputResolver downloads the version of its target that the link pins.
Parameters
roboto_client Optional[roboto.roboto_search Optional[roboto.InputFileResolver.resolve()
Looks up the files one selector names.
A dataset_id narrows the lookup only alongside paths; every other field ignores it, with a warning.
Parameters
selector roboto.Return type
InputFileResolver.resolve_all()
Parameters
file_selectors collections.Return type
InputSessionResolver
Looks up the sessions an action invocation runs on, from the session selectors declared as its inputs.
A selector names sessions by ID, by name, or with a RoboQL query; every field it populates is looked up and the matches are returned together. resolve_all returns each session once, while resolve repeats a session that matches on more than one field.
Parameters
roboto_client Optional[roboto.roboto_search Optional[roboto.InputSessionResolver.resolve()
Looks up the sessions one selector names. A dataset_id on the selector is ignored, with a warning.
Parameters
session_selector roboto.Return type
InputSessionResolver.resolve_all()
Parameters
session_selectors collections.Return type
InputTopicResolver
Looks up the topics an action invocation runs on, from the topic selectors declared as its inputs.
A selector names topics by ID, by name, or with a RoboQL query; every field it populates is looked up and the matches are returned together. resolve_all returns each topic once, while resolve repeats a topic that matches on more than one field.
Parameters
roboto_client Optional[roboto.roboto_search Optional[roboto.InputTopicResolver.resolve()
Looks up the topics one selector names. A dataset_id on the selector is ignored, with a warning.
Parameters
topic_selector roboto.Return type
InputTopicResolver.resolve_all()
Parameters
topic_selectors collections.Return type