Skip to content
Roboto
Esc
↑↓navigate↵open⌘Jpreview
On this page

roboto.action_runtime.action_input

Submodules

Package Contents

ActionInput

class roboto.action_runtime.action_input.ActionInput#View Source

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 collections.abc.Sequence[tuple[roboto.domain.files.File, pathlib.Path | None]] = [] #

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()

classmethod from_record(record, roboto_client)#View Source

Create an ActionInput instance from its serialized representation.

Parameters

Return type

ActionInput.get_topics_by_name()

get_topics_by_name(topic_name)#View Source

Return any topics in this ActionInput that have the provided name.

Parameters

topic_name str

Topic 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 collections.abc.Sequence[roboto.experimental.sessions.Session] = [] #

Sessions passed as input data to an action invocation.

ActionInput.topics

topics collections.abc.Sequence[roboto.domain.topics.Topic] = [] #

Topics passed as input data to an action invocation.

ActionInputRecord

class roboto.action_runtime.action_input.ActionInputRecord(/, **data)#View Source

Bases: pydantic.BaseModel

Serializable representation of an ActionInput.

Parameters

data Any

Attributes

ActionInputRecord.files

files collections.abc.Sequence[tuple[roboto.domain.files.FileRecord, pathlib.Path | None]] = None #

ActionInputRecord.sessions

sessions collections.abc.Sequence[roboto.experimental.sessions.SessionRecord] = None #

ActionInputRecord.topics

topics collections.abc.Sequence[roboto.domain.topics.TopicRecord] = None #

ActionInputResolver

class roboto.action_runtime.action_input.ActionInputResolver(file_resolver, session_resolver, topic_resolver, file_service)#View Source

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.

ActionInputResolver.from_env()

classmethod from_env(roboto_client=None, roboto_search=None)#View Source

Parameters

roboto_client Optional[roboto.http.RobotoClient]
roboto_search Optional[roboto.roboto_search.RobotoSearch]

ActionInputResolver.resolve_input_spec()

resolve_input_spec(input_spec, download=False, download_path=None)#View Source

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 specification containing data selectors. See InvocationInput for more detail.

download bool

If True, download all resolved files to local disk. Defaults to False.

download_path Optional[pathlib.Path]

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 empty

Resolve 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 paths

Resolve 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 records

DEFAULT_INPUT_FILE

roboto.action_runtime.action_input.DEFAULT_INPUT_FILE#View Source

InputFileResolver

class roboto.action_runtime.action_input.InputFileResolver(roboto_client=None, roboto_search=None)#View Source

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.http.RobotoClient]
roboto_search Optional[roboto.roboto_search.RobotoSearch]

InputFileResolver.resolve()

resolve(selector)#View Source

Looks up the files one selector names.

A dataset_id narrows the lookup only alongside paths; every other field ignores it, with a warning.

InputFileResolver.resolve_all()

resolve_all(file_selectors)#View Source

Parameters

file_selectors collections.abc.Sequence[roboto.domain.actions.FileSelector]

Return type

Attributes

InputFileResolver.roboto_client

roboto_client = None #
roboto_search #

InputSessionResolver

class roboto.action_runtime.action_input.InputSessionResolver(roboto_client=None, roboto_search=None)#View Source

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.http.RobotoClient]
roboto_search Optional[roboto.roboto_search.RobotoSearch]

InputSessionResolver.resolve()

resolve(session_selector)#View Source

Looks up the sessions one selector names. A dataset_id on the selector is ignored, with a warning.

InputSessionResolver.resolve_all()

resolve_all(session_selectors)#View Source

Parameters

session_selectors collections.abc.Sequence[roboto.domain.actions.DataSelector]

Attributes

InputSessionResolver.roboto_client

roboto_client = None #
roboto_search #

InputTopicResolver

class roboto.action_runtime.action_input.InputTopicResolver(roboto_client=None, roboto_search=None)#View Source

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.http.RobotoClient]
roboto_search Optional[roboto.roboto_search.RobotoSearch]

InputTopicResolver.resolve()

resolve(topic_selector)#View Source

Looks up the topics one selector names. A dataset_id on the selector is ignored, with a warning.

Parameters

InputTopicResolver.resolve_all()

resolve_all(topic_selectors)#View Source

Parameters

topic_selectors collections.abc.Sequence[roboto.domain.actions.DataSelector]

Attributes

InputTopicResolver.roboto_client

roboto_client = None #
roboto_search #

Was this page helpful?