---
title: Charmhub | Deploy Kubeflow Dashboard using Charmhub - The Open Operator Collection
description: Deploy the latest version of Kubeflow Dashboard as a Kubernetes Operator
  on any cloud.
url: https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar
---

# Kubeflow Dashboard

[Kubeflow Charmers](https://charmhub.io/publisher/ckfbot "View all packages from Kubeflow Charmers")

* [Kubeflow Charmers](https://charmhub.io/publisher/ckfbot "View all packages from Kubeflow Charmers")
* [Ai Ml](https://charmhub.io/?filter=ai-ml)
* [Big Data](https://charmhub.io/?filter=big-data)
* [Containers](https://charmhub.io/?filter=containers)

Platform:

1.10/stable 948

```
juju deploy kubeflow-dashboard --channel 1.10/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#drawer)

## charms.kubeflow\_dashboard.v0.kubeflow\_dashboard\_sidebar

* [*Docstrings*Docstrings](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar)
  [*Code*Source code](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.kubeflow_dashboard.v0.kubeflow_dashboard_sidebar
    ```

    [Download kubeflow\_dashboard\_sidebar.py](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar/download)
  + *Last updated* 28 Jun 2023
  + *Revision* Library version 0.1

#### KubeflowDashboardSidebar Library

This library implements data transfer for the kubeflow\_dashboard\_sidebar
interface used by Kubeflow Dashboard to implement the sidebar relation. This
relation enables applications to request a link on the Kubeflow Dashboard
sidebar dynamically.

To enable an application to add a link to Kubeflow Dashboard's sidebar, use
the KubeflowDashboardSidebarRequirer and SidebarItem classes included here as
shown below. No additional action is required within the charm. On
establishing the relation, the data will be sent to Kubeflow Dashboard to add
the link. The link will be removed if the relation is broken.

##### Getting Started

To get started using the library, fetch the library with `charmcraft`.

```
cd some-charm
charmcraft fetch-lib charms.kubeflow_dashboard.v0.kubeflow_dashboard_sidebar
```

Then in your charm, do:

```
from charms.kubeflow_dashboard.v0.kubeflow_dashboard_sidebar import (
    KubeflowDashboardSidebarRequirer,
    SidebarItem,
)
# ...

SIDEBAR_ITEMS = [
    SidebarItem(
        text="Example Relative Link",
        link="/relative-link",
        type="item",
        icon="assessment"
    ),
    SidebarItem(
        text="Example External Link",
        link="https://charmed-kubeflow.io/docs",
        type="item",
        icon="assessment"
    ),
]

class SomeCharm(CharmBase):
  def __init__(self, *args):
    # ...
    self.kubeflow_dashboard_sidebar = KubeflowDashboardSidebarRequirer(
        charm=self,
        relation_name="sidebar",  # use whatever you call the relation in your metadata.yaml
        SIDEBAR_ITEMS
    )
    # ...
```

---

Index

* [class SidebarItem](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#sidebaritem)
* [class KubeflowDashboardSidebarDataUpdatedEvent](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#kubeflowdashboardsidebardataupdatedevent)
* [class KubeflowDashboardidebarEvents](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#kubeflowdashboardidebarevents)
* [class KubeflowDashboardSidebarProvider](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#kubeflowdashboardsidebarprovider)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name,
    refresh\_event)](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#kubeflowdashboardsidebarprovider-__init__)
* + [def get\_sidebar\_items(
    self,
    omit\_breaking\_app)](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#kubeflowdashboardsidebarprovider-get_sidebar_items)
* + [def get\_sidebar\_items\_as\_json(
    self,
    omit\_breaking\_app)](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#kubeflowdashboardsidebarprovider-get_sidebar_items_as_json)
* [class KubeflowDashboardSidebarRequirer](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#kubeflowdashboardsidebarrequirer)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name,
    sidebar\_items,
    refresh\_event)](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#kubeflowdashboardsidebarrequirer-__init__)
* [def get\_name\_of\_breaking\_app(
  relation\_name
  )](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#get_name_of_breaking_app)
* [def sidebar\_items\_to\_json(
  sidebar\_items
  )](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_sidebar#sidebar_items_to_json)

#### class SidebarItem

Representation of a Kubeflow Dashboard sidebar entry.

Arguments

text

The text shown in the sidebar

link

The relative link within the host (eg: /runs, not http://.../runs)

type

A type of sidebar entry (typically, "item")

icon

An icon for the link, from
https://kevingleason.me/Polymer-Todo/bower\_components/iron-icons/demo/index.html

Description

See https://www.kubeflow.org/docs/components/central-dash/customizing-menu/ for more details.

#### class KubeflowDashboardSidebarDataUpdatedEvent

Description

Indicates the Kubeflow Dashboard Sidebar data was updated. None

#### class KubeflowDashboardidebarEvents

Description

Events for the Kubeflow Dashboard Sidebar library. None

#### class KubeflowDashboardSidebarProvider

Description

Relation manager for the Provider side of the Kubeflow Dashboard Sidebar relation.. None

Methods

KubeflowDashboardSidebarProvider.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str

,
refresh\_event
)

Relation manager for the Provider side of the Kubeflow Dashboard Sidebar relation.

Arguments

charm

Charm this relation is being used by

relation\_name

Name of this relation (from metadata.yaml)

refresh\_event

List of BoundEvents that this manager should handle. Use this to update
the data sent on this relation on demand.

Description

This relation manager subscribes to:

* on[relation\_name].relation\_changed
* any events provided in refresh\_event

This library emits:

* KubeflowDashboardSidebarDataUpdatedEvent:
  when data received on the relation is updated

TODO: Should this class automatically subscribe to events, or should it optionally do that.
The former is typical of charm libraries, the latter lets the user better control and
visibility on how it is used.

KubeflowDashboardSidebarProvider.
get\_sidebar\_items(

*self*

,
omit\_breaking\_app: bool
)

Returns a list of all SidebarItems from related Applications.

Arguments

omit\_breaking\_app

If True and this is called during a sidebar-relation-broken event,
the remote app's data will be omitted. For more context, see:
https://github.com/canonical/kubeflow-dashboard-operator/issues/124

Returns

List of SidebarItems defining the dashboard sidebar for all related applications.

KubeflowDashboardSidebarProvider.
get\_sidebar\_items\_as\_json(

*self*

,
omit\_breaking\_app: bool
)

Returns a JSON string of all SidebarItems from related Applications.

Arguments

omit\_breaking\_app

If True and this is called during a sidebar-relation-broken event,
the remote app's data will be omitted. For more context, see:
https://github.com/canonical/kubeflow-dashboard-operator/issues/124

Returns

JSON string of all SidebarItems for all related applications, each as dicts.

#### class KubeflowDashboardSidebarRequirer

Description

Relation manager for the Requirer side of the Kubeflow Dashboard Sidebar relation. None

Methods

KubeflowDashboardSidebarRequirer.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str

,
sidebar\_items

,
refresh\_event
)

Relation manager for the Requirer side of the Kubeflow Dashboard Sidebar relation.

Arguments

charm

Charm this relation is being used by

relation\_name

Name of this relation (from metadata.yaml)

sidebar\_items

List of SidebarItem objects to send over the relation

refresh\_event

List of BoundEvents that this manager should handle. Use this to update
the data sent on this relation on demand.

Description

This relation manager subscribes to:

* on.leader\_elected: because only the leader is allowed to provide this data, and
  relation\_created may fire before the leadership election
* on[relation\_name].relation\_created
* any events provided in refresh\_event

This library emits:

* (nothing)

TODO: Should this class automatically subscribe to events, or should it optionally do that.
The former is typical of charm libraries, the latter lets the user better control and
visibility on how it is used.

#### def get\_name\_of\_breaking\_app(relation\_name: str)

Returns breaking app name if called during RELATION\_NAME-relation-broken and the breaking app name is available. # noqa

Description

Else, returns None.

Relation type and app name are inferred from juju environment variables.

#### def sidebar\_items\_to\_json(sidebar\_items)

Description

Returns a list of SidebarItems as a JSON string. None
