Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jwa: Expose a last-activity column #6544

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/crud-web-apps/jupyter/backend/apps/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
NOTEBOOK_TEMPLATE_YAML = os.path.join(
FILE_ABS_PATH, "yaml/notebook_template.yaml"
)
LAST_ACTIVITY_ANNOTATION = "notebooks.kubeflow.org/last-activity"

# The production configuration is mounted on the app's pod via a configmap
DEV_CONFIG = os.path.join(FILE_ABS_PATH, "yaml/spawner_ui_config.yaml")
Expand Down Expand Up @@ -113,6 +114,11 @@ def get_storage_class(vol):


# Functions for transforming the data from k8s api
def get_notebook_last_activity(notebook):
annotations = notebook["metadata"].get("annotations", {})
return annotations.get(LAST_ACTIVITY_ANNOTATION, "")


def notebook_dict_from_k8s_obj(notebook):
cntr = notebook["spec"]["template"]["spec"]["containers"][0]
server_type = None
Expand All @@ -125,6 +131,7 @@ def notebook_dict_from_k8s_obj(notebook):
"namespace": notebook["metadata"]["namespace"],
"serverType": server_type,
"age": helpers.get_uptime(notebook["metadata"]["creationTimestamp"]),
"last_activity": get_notebook_last_activity(notebook),
"image": cntr["image"],
"shortImage": cntr["image"].split("/")[-1],
"cpu": cntr["resources"]["requests"]["cpu"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ComponentValue,
TableConfig,
TABLE_THEME,
DateTimeValue,
} from 'kubeflow';
import { ServerTypeComponent } from './server-type/server-type.component';

Expand Down Expand Up @@ -73,6 +74,11 @@ export const defaultConfig: TableConfig = {
textAlignment: 'right',
value: new PropertyValue({ field: 'age', truncate: true }),
},
{
matHeaderCellDef: $localize`Last activity`,
matColumnDef: 'last_activity',
value: new DateTimeValue({ field: 'last_activity' }),
},
{
matHeaderCellDef: $localize`Image`,
matColumnDef: 'image',
Expand Down