---
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_links
---

# 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_links#drawer)

## charms.kubeflow\_dashboard.v0.kubeflow\_dashboard\_links

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

    Fetch library

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

    [Download kubeflow\_dashboard\_links.py](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links/download)
  + *Last updated* 22 Jul 2024
  + *Revision* Library version 0.3

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

To enable an application to add a link to Kubeflow Dashboard, use
the KubeflowDashboardLinksRequirer and DashboardLink 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 links. The links 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_links
```

Then in your charm, do:

```
from charms.kubeflow_dashboard.v0.kubeflow_dashboard_links import (
    KubeflowDashboardLinksRequirer,
    DashboardLink,
)
# ...

DASHBOARD_LINKS = [
    DashboardLink(
        text="Example Relative Link",
        link="/relative-link",
        type="item",
        icon="assessment",
        location="sidebar",
    ),
    DashboardLink(
        text="Example External Link",
        link="https://charmed-kubeflow.io/docs",
        type="item",
        icon="assessment",
        location="sidebar-external"
    ),
]

class SomeCharm(CharmBase):
  def __init__(self, *args):
    # ...
    self.kubeflow_dashboard_links = KubeflowDashboardLinksRequirer(
        charm=self,
        relation_name="links",  # use whatever you call the relation in your metadata.yaml
        DASHBOARD_LINKS
    )
    # ...
```

---

Index

* [class DashboardLink](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#dashboardlink)
* + [def \_\_post\_init\_\_(
    self)](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#dashboardlink-__post_init__)
* [class KubeflowDashboardLinksUpdatedEvent](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#kubeflowdashboardlinksupdatedevent)
* [class KubeflowDashboardLinksEvents](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#kubeflowdashboardlinksevents)
* [class KubeflowDashboardLinksProvider](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#kubeflowdashboardlinksprovider)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name,
    refresh\_event)](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#kubeflowdashboardlinksprovider-__init__)
* + [def get\_dashboard\_links(
    self,
    omit\_breaking\_app,
    location)](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#kubeflowdashboardlinksprovider-get_dashboard_links)
* + [def get\_dashboard\_links\_as\_json(
    self,
    omit\_breaking\_app,
    location)](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#kubeflowdashboardlinksprovider-get_dashboard_links_as_json)
* [class KubeflowDashboardLinksRequirer](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#kubeflowdashboardlinksrequirer)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name,
    dashboard\_links,
    refresh\_event)](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#kubeflowdashboardlinksrequirer-__init__)
* [def get\_name\_of\_breaking\_app(
  relation\_name
  )](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#get_name_of_breaking_app)
* [def dashboard\_links\_to\_json(
  dashboard\_links
  )](https://charmhub.io/kubeflow-dashboard/libraries/kubeflow_dashboard_links#dashboard_links_to_json)

#### class DashboardLink

Representation of a Kubeflow Dashboard Link entry.

Arguments

text

The text shown for the link

link

The link (a relative link for `location=menu` or `location=quick`, eg: `/mlflow`,
or a full URL for other locations, eg: http://my-website.com)

type

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

icon

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

location

Link's location on the dashboard. One of `menu`, `external`, `quick`,
and `documentation`.

Description

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

Methods

DashboardLink.
\_\_post\_init\_\_(

*self*
)

Description

Validate that location is one of the accepted values. None

#### class KubeflowDashboardLinksUpdatedEvent

Description

Indicates the Kubeflow Dashboard link data was updated. None

#### class KubeflowDashboardLinksEvents

Description

Events for the Kubeflow Dashboard Links library. None

#### class KubeflowDashboardLinksProvider

Description

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

Methods

KubeflowDashboardLinksProvider.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str

,
refresh\_event
)

Relation manager for the Provider side of the Kubeflow Dashboard Links 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:

* KubeflowDashboardLinksUpdatedEvent:
  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.

KubeflowDashboardLinksProvider.
get\_dashboard\_links(

*self*

,
omit\_breaking\_app: bool

,
location
)

Returns a list of all DashboardItems from related Applications.

Arguments

omit\_breaking\_app

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

location

If specified, return only links with this location. Else, returns all links.

Returns

List of DashboardLinks defining the dashboard links for all related applications.

KubeflowDashboardLinksProvider.
get\_dashboard\_links\_as\_json(

*self*

,
omit\_breaking\_app: bool

,
location
)

Returns a JSON string of all DashboardItems from related Applications.

Arguments

omit\_breaking\_app

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

location

If specified, return only links with this location. Else, returns all links.

Returns

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

#### class KubeflowDashboardLinksRequirer

Description

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

Methods

KubeflowDashboardLinksRequirer.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str

,
dashboard\_links

,
refresh\_event
)

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

Arguments

charm

Charm this relation is being used by

relation\_name

Name of this relation (from metadata.yaml)

dashboard\_links

List of DashboardLink 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 dashboard\_links\_to\_json(dashboard\_links)

Description

Returns a list of SidebarItems as a JSON string. None
