Skip to content

Commit

Permalink
Update extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
roypaulin committed Apr 11, 2024
1 parent 5bde0bc commit cacfa5f
Show file tree
Hide file tree
Showing 16 changed files with 465 additions and 30 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ verticapylab-start: etc/VerticaPyLab.conf ## Start a jupyterlab
fi; \
fi; \
docker container rm "$$VERTICAPYLAB_CONTAINER_NAME" >/dev/null 2>&1; \
bin/verticapylab; \
else \
echo "$$VERTICAPYLAB_CONTAINER_NAME is already running"; \
fi
fi; \
bin/verticapylab;

# this builds the image from the python base image for the purposes of
# testing it locally before pushing it to dockerhub
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ A Vertica database. To get a simple single-node Vertica CE database, see the [Ve
```
make verticapylab-start
```
Note: If the container already exists, this command will simply display the link to access verticapylab
2. Open the displayed link in a browser.
3. To stop the container:
Expand Down
23 changes: 16 additions & 7 deletions bin/verticapylab
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function usage {
exit 1
}

while getopts "p:c:i:h" opt; do
while getopts "p:c:v:i:h" opt; do
case ${opt} in
h)
usage
Expand All @@ -55,6 +55,21 @@ while getopts "p:c:i:h" opt; do
esac
done

# Get the basic URL and remap the hostname and port
if [[ $VERTICAPYLAB_BIND_ADDRESS == 0.0.0.0 ]]; then
url_host=$(hostname)
else
url_host="$VERTICAPYLAB_BIND_ADDRESS"
fi

if docker exec -i "$VERTICAPYLAB_CONTAINER_NAME" true 2>/dev/null; then
echo "$VERTICAPYLAB_CONTAINER_NAME is already running"
URL=$(docker logs "$VERTICAPYLAB_CONTAINER_NAME" 2>&1 | grep -Eo 'http[s]?://[0-9.]+:8888/.*' | head -n 1 | sed "s/[0-9.]*:8888/$url_host:$VERTICAPYLAB_PORT/")
echo "Copy and paste this URL in browser:"
echo " $URL"
exit 0
fi

if [[ ${TEST_MODE^^} == "YES" ]]; then
VERTICAPYLAB_IMG_VERSION=$VERSION
fi
Expand Down Expand Up @@ -149,12 +164,6 @@ while ! docker logs -n 5 "$VERTICAPYLAB_CONTAINER_NAME" 2>&1 | grep 'Or copy and
sleep 1
done

# Get the basic URL and remap the hostname and port
if [[ $VERTICAPYLAB_BIND_ADDRESS == 0.0.0.0 ]]; then
url_host=$(hostname)
else
url_host="$VERTICAPYLAB_BIND_ADDRESS"
fi
URL=$(docker logs "$VERTICAPYLAB_CONTAINER_NAME" 2>&1 | grep -Eo 'http[s]?://[0-9.]+:8888/.*' | head -n 1 | sed "s/[0-9.]*:8888/$url_host:$VERTICAPYLAB_PORT/")
# This checks the kernel name to set the correct command to open the link in browser,
# because Linux systems will use xdg-open while MacOs will use open
Expand Down
43 changes: 40 additions & 3 deletions docker-verticapy/extensions-v2/vertica_tools/src/icon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { LabIcon } from '@jupyterlab/ui-components';

import verticapyIconSvg from '../style/verticapy.svg';
import queryIconSvg from '../style/query.svg';
import vsqlIconSvg from '../style/icons/vsql.svg';
import verticapyIconSvg from '../style/icons/verticapy.svg';
import queryIconSvg from '../style/icons/query.svg';
import admintoolsIconSvg from '../style/icons/admintools.svg';
import course1IconSvg from '../style/icons/course1.svg';
import grafanaIconSvg from '../style/icons/grafana-icon.svg';
import rocketIconSvg from '../style/icons/rocket.svg';
import verticaIconSvg from '../style/icons/vertica2.svg';

export const verticaIcon = new LabIcon({
name: 'vertica:verticaicon',
svgstr: verticaIconSvg
});

export const verticapyIcon = new LabIcon({
name: 'vertica:verticapyicon',
Expand All @@ -11,4 +22,30 @@ export const verticapyIcon = new LabIcon({
export const queryIcon = new LabIcon({
name: 'vertica:queryicon',
svgstr: queryIconSvg
});
});

export const admintoolsIcon = new LabIcon({
name: 'vertica:admintools',
svgstr: admintoolsIconSvg
});

export const vsqlIcon = new LabIcon({
name: 'vertica:vsql',
svgstr: vsqlIconSvg
});

export const course1Icon = new LabIcon({
name: 'vertica:course1',
svgstr: course1IconSvg
});

export const grafanaIcon = new LabIcon({
name: 'grafana:grafanaicon',
svgstr: grafanaIconSvg
});

export const rocketIcon = new LabIcon({
name: 'grafana:rocketicon',
svgstr: rocketIconSvg
});

92 changes: 87 additions & 5 deletions docker-verticapy/extensions-v2/vertica_tools/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,33 @@ import { ICommandPalette, MainAreaWidget } from '@jupyterlab/apputils';
import { IMainMenu } from '@jupyterlab/mainmenu';
import { ITranslator } from '@jupyterlab/translation';
import { launcherIcon, addIcon } from '@jupyterlab/ui-components';

import { toArray } from '@lumino/algorithm';
import { Widget } from '@lumino/widgets';

import { Launcher } from './launcher';
import { verticapyIcon, queryIcon } from './icon'
import { Launcher, VERTICAPY_UI, VERTICAPY_LESSONS, VERTICA } from './launcher';
import { verticapyIcon, queryIcon, course1Icon, grafanaIcon, rocketIcon } from './icon';

namespace CommandIDs {
export const createNew = 'launcher:create';
export const openConnect = "launcher:connect";
export const openQprof = "launcher:qprof";
export const openCourseDSE = 'launcher:open-dse';
export const openHelp = 'launcher:open-help';
export const openGrafanaExplorer = 'launcher:explorer';
export const openVerticaPerformanceDashboard = 'launcher:perf'
}

/**
* constants used by grafana commands
*/

namespace Grafana {
// 'PORT' will be overridden by the actual port used by the grafana container
export const port = "3000";

export const explorerPathName = "explore";

export const perfDashboardPathName = "d/vertica-perf/vertica-performance-dashboard";
}

const extension: JupyterFrontEndPlugin<ILauncher> = {
Expand Down Expand Up @@ -97,6 +113,48 @@ const extension: JupyterFrontEndPlugin<ILauncher> = {
}
});

commands.addCommand(CommandIDs.openCourseDSE, {
label: 'Data Science Essentials',
icon: course1Icon,
execute: (args: any) => {
window.open('/voila/render/demos/enablement/Data%20Science%20Essentials/Data_Science_Essentials.ipynb?', '_blank');
}
});

commands.addCommand(CommandIDs.openHelp, {
label: 'Documentation',
icon: verticapyIcon,
execute: (args: any) => {
window.open('https://www.vertica.com/python/', '_blank');
}
});

let grafanaUrl = new URL(window.location.href);
grafanaUrl.port = Grafana.port;
// Create grafana explorer and vertica performance dashboard urls
let explorerUrl = new URL(grafanaUrl.href);
let perfDashboardUrl = new URL(grafanaUrl.href);
explorerUrl.pathname = Grafana.explorerPathName;
perfDashboardUrl.pathname = Grafana.perfDashboardPathName;

commands.addCommand(CommandIDs.openGrafanaExplorer, {
label: 'Grafana',
caption: 'Open Grafana',
icon: grafanaIcon,
execute: (args: any) => {
window.open(explorerUrl.href, '_blank');
}
});

commands.addCommand(CommandIDs.openVerticaPerformanceDashboard, {
label: 'Performance',
caption: 'Open Performance Dashboard',
icon: rocketIcon,
execute: (args: any) => {
window.open(perfDashboardUrl.href, '_blank');
}
});

// Add the command to the palette
if (palette) {
palette.addItem({
Expand All @@ -107,13 +165,37 @@ const extension: JupyterFrontEndPlugin<ILauncher> = {

model.add({
command: CommandIDs.openConnect,
category: 'VerticaPy UI',
category: VERTICAPY_UI,
rank: 1
});

model.add({
command: CommandIDs.openQprof,
category: 'VerticaPy UI',
category: VERTICAPY_UI,
rank: 2
});

model.add({
command: CommandIDs.openCourseDSE,
category: VERTICAPY_LESSONS,
rank: 1
});

model.add({
command: CommandIDs.openHelp,
category: VERTICAPY_LESSONS,
rank: 2
});

model.add({
command: CommandIDs.openGrafanaExplorer,
category: VERTICA,
rank: 1
});

model.add({
command: CommandIDs.openVerticaPerformanceDashboard,
category: VERTICA,
rank: 2
});

Expand Down
24 changes: 14 additions & 10 deletions docker-verticapy/extensions-v2/vertica_tools/src/launcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ import { LabIcon } from '@jupyterlab/ui-components';
import { each } from '@lumino/algorithm';

import * as React from 'react';
import verticaIconSvg from '../style/verticapy.svg';

export const verticaIcon = new LabIcon({
name: 'vertica:vertica',
svgstr: verticaIconSvg
});
import { verticapyIcon, verticaIcon } from './icon';

/**
* The known categories of launcher items and their default ordering.
*/
const VERTICA_CATEGORY = 'VerticaPy UI';
// const VERTICAPY_LESSONS = 'VerticaPy Lessons';
export const VERTICAPY_UI = 'VerticaPy UI';
export const VERTICAPY_LESSONS = 'VerticaPy Lessons';
export const VERTICA = 'Vertica'


export class Launcher extends JupyterlabLauncher {
Expand Down Expand Up @@ -75,7 +71,9 @@ export class Launcher extends JupyterlabLauncher {
const categories: React.ReactElement<any>[] = [];

const knownCategories = [
VERTICA_CATEGORY,
VERTICAPY_UI,
VERTICAPY_LESSONS,
VERTICA,
this._translator.__('Notebook'),
this._translator.__('Console'),
this._translator.__('Other')
Expand All @@ -86,7 +84,13 @@ export class Launcher extends JupyterlabLauncher {
each(knownCategories, (category, index) => {
React.Children.forEach(launcherCategories, cat => {
if (cat.key === category) {
if (cat.key === VERTICA_CATEGORY) {
if (cat.key === VERTICAPY_UI) {
cat = this.replaceCategoryIcon(cat, verticapyIcon);
}
if (cat.key === VERTICAPY_LESSONS) {
cat = this.replaceCategoryIcon(cat, verticapyIcon);
}
if (cat.key === VERTICA) {
cat = this.replaceCategoryIcon(cat, verticaIcon);
}
categories.push(cat);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cacfa5f

Please sign in to comment.