> ## Documentation Index
> Fetch the complete documentation index at: https://wiki.latch.bio/llms.txt
> Use this file to discover all available pages before exploring further.

# Platform Widgets

> Platform widgets enable you to integrate and interact with other parts of the Latch platform directly within your plots and analysis workflows. These widgets provide seamless access to registry data, workflows, and file systems.

Platform widgets are specialized components that allow you to pull in and interact with other parts of the Latch platform directly within your plots and analysis workflows. These widgets serve as bridges between your visualizations and the broader platform ecosystem, enabling dynamic data integration and interactive workflows.

## Platform Integration Widgets

Below is a comprehensive list of platform widgets that enable integration with different parts of the Latch platform.

<AccordionGroup>
  <Accordion icon="table" title="Registry Table">
    The Registry Table output widget allows you to display and interact with registry tables in your notebook interface.

    ```python theme={null}
      from lplots.widgets.registry import w_registry_table_picker, w_registry_table

      registry_table_picker = w_registry_table_picker(
      label="Select table"
      )

      if (registry_table_picker.value is not None):
        table_id = registry_table_picker.value

        # Display a registry table
        table = w_registry_table(
            label="Sample Registry Table",
            table_id=table_id
        )
    ```

    You can also use the `w_registry_table_picker` widget to select a table from the registry, or supply a table id directly.

    ### Widget Parameters

    `label`: *string* required label displayed above the table

    `table_id`: *string* required identifier for the registry table to display

    `readonly`: *bool* optional, defaults to False. When True, the table is read-only

    `default`: *string | None* optional default table id

    `appearance`: *FormInputAppearance | None* optional appearance configuration

    `key`: *string* optional unique identifier for the widget

    ### Value

    The widget value returns a `RegistryTableValue` object with the following structure:

    ```python theme={null}
    class RegistryTableValue(TypedDict):
        table: Table
        selected_rows: list[Record]
    ```

    **Attributes:**

    * `table`: *Table* - The registry table object containing the data and metadata.

    * `selected_rows`: *list\[Record]* - A list of selected row records from the table. Returns an empty list if no rows are selected.

    The `Table` object provides access to the table's data, schema, and metadata, while `Record` objects represent individual rows with their field values and metadata. Learn more about the [Table API](/registry/sdk/table-objects) and [Record API](/registry/sdk/record-objects).

    ### Usage Notes

    * The registry table widget provides an interactive interface to view and interact with registry data
    * The widget returns a `RegistryTableValue` containing the table object
    * The table object can be accessed via the `value` property
  </Accordion>

  <Accordion icon="diagram-project" title="Workflow Output">
    The Workflow output widget allows you to launch and execute workflows directly from your notebook interface.

    ```python theme={null}
    from lplots.widgets.workflow import w_workflow

    # Launch a workflow with parameters
    workflow = w_workflow(
        label="Run Analysis",
        wf_name="my_analysis_workflow",
        params={
            "input_file": "latch://workspace/data/sample.fastq",
            "output_dir": "latch://workspace/results/"
        },
        version="v1.0"
    )

    execution = w.value

    if execution is not None:
        res = await execution.wait()
    ```

    ### Widget Parameters

    `label`: *string* required label for the workflow button

    `wf_name`: *string* required name of the workflow to execute

    `params`: *dict* required dictionary of parameters to pass to the workflow.

    `version`: *string | None* optional version of the workflow to use, defaults to the latest version

    `readonly`: *bool* optional, defaults to False. When True, the workflow button is disabled

    `key`: *string* optional unique identifier for the widget

    ### Class `CompletedExecution`

    The CompletedExecution dataclass represents the final state of an execution, whether it succeeded, failed, or was aborted.

    Attributes
    id (str): A unique identifier for the execution.

    output (dict\[str, Any]): A dictionary containing the processed output of the execution. This will be populated if the execution succeeded.

    ingress\_data (list\[LPath]): A list of LPath objects, representing data that was written to LData during the execution.

    status (ExecutionStatus): The final status of the execution

    ### Class `Execution`

    The Execution class represents an running or completed execution. It provides methods to poll the status of an execution and wait for its completion.

    Attributes
    id (str): A unique identifier for the execution.

    python\_outputs (dict\[str, type]): A dictionary mapping output names to their expected Python types. This is used when processing the execution's output.

    status (ExecutionStatus): The current status of the execution. Defaults to "UNDEFINED".

    outputs\_url (Union\[str, None]): The URL where the execution's outputs can be found, if available. Defaults to None.

    flytedb\_id (Union\[str, None]): The FlyteDB ID associated with the execution, if available. Defaults to None. This attribute is updated during polling.

    Methods
    poll(self) -> Generator\[None, Any, None]
    This is a generator method that continuously polls the status of the execution.

    wait(self) -> Union\[CompletedExecution, None]
    Asynchronous method that waits for the execution to complete and returns the execution outputs

    If the execution status is "FAILED" or "ABORTED", it retrieves the ingress\_data and returns a CompletedExecution object with an empty output dictionary.

    ### Usage Notes

    * The workflow widget creates a button that, when clicked, launches the specified workflow
    * The widget's `value()` method returns either an `Execution` object containing information about the launched workflow or `None` if no executions have been launched.
    * To retrieve the outputs of the execution, call the `Execution` object's asynchronous `wait` method which returns a `CompletedExecution` object.
  </Accordion>

  <Accordion icon="folder" title="Latch Data Browser">
    The LData Browser widget enables you to pull in and interact with files and directories from your Latch workspace directly within your plots. This widget creates a connection to the platform's file system, allowing users to browse and upload files.

    ```python theme={null}
    from lplots.widgets.ldata import w_ldata_browser

    # Pull in data from your workspace for analysis
    browser = w_ldata_browser(
        label="Browse Data Directory",
        dir="latch:///data/"
    )

    ldata_path = browser.value

    ```

    ### Widget Parameters

    `label`: *string* required label displayed above the browser

    `dir`: *string | LPath* required path to the directory to browse. Can be a string or LPath object "latch://\<workspace\_id>.account/\<path>" will only work for the corresponding workspace\_id, but "latch:///\<path>" will work for any workspace that has that path.

    `readonly`: *bool* optional, defaults to False. When True, the browser is read-only

    `appearance`: *FormInputAppearance | None* optional appearance configuration

    `key`: *string* optional unique identifier for the widget

    ### Value

    The widget value returns an `LPath` object representing the selected directory that can be integrated with your analysis. Learn more about the [LPath API](/workflows/sdk/python/working-with-files).

    ### Usage Notes

    * The Latch Data Browser widget provides an interactive interface to browse directory structures and pull in files from the platform
    * The widget automatically validates that the provided path is a valid directory
  </Accordion>
</AccordionGroup>

## Platform Widget Reactivity

Output widgets are reactive to changes in their source data. When the source plot or data is updated, the widget display will automatically update to reflect the changes.
