Skip to content

Commit

Permalink
Merge pull request #245 from vertica/release-prep
Browse files Browse the repository at this point in the history
Update extensions
  • Loading branch information
mail4umar authored Apr 15, 2024
2 parents aad20d9 + 3bf34ee commit 149afcd
Show file tree
Hide file tree
Showing 17 changed files with 500 additions and 60 deletions.
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,21 @@ vsql: ## Run a basic sanity test (optional -DQUERY="select 'whatever')
.PHONY: verticapylab-start
verticapylab-start: etc/VerticaPyLab.conf ## Start a jupyterlab
@source etc/VerticaPyLab.conf; \
if [[ $${TEST_MODE^^} == "YES" ]] ; then \
VERTICAPYLAB_IMG_VERSION=$(VERSION); \
if [[ $$(tr '[:lower:]' '[:upper:]'<<< $${TEST_MODE}) == "YES" ]] ; then \
VERTICAPYLAB_IMG_VERSION=$(VERSION); \
fi; \
if (($$(docker ps --no-trunc -q -f NAME="$$VERTICAPYLAB_CONTAINER_NAME" | wc -l)==0)); then \
if [[ -z $$(docker image ls -q "opentext/$$VERTICAPYLAB_IMG:$$VERTICAPYLAB_IMG_VERSION" 2>&1) ]]; then \
if [[ $${TEST_MODE^^} == "YES" ]] ; then \
if [[ $$(tr '[:lower:]' '[:upper:]'<<< $${TEST_MODE}) == "YES" ]] ; then \
echo "Building image opentext/$$VERTICAPYLAB_IMG:$$VERTICAPYLAB_IMG_VERSION"; \
TEST_MODE=yes $(MAKE) verticapylab-build; \
else \
$(MAKE) verticapylab-install || exit 1; \
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 Expand Up @@ -167,7 +165,7 @@ verticapylab-stop: ## Shut down the jupyterlab server and remove the container
.PHONY: verticapylab-uninstall
verticapylab-uninstall: ## Remove the verticapylab container and associated images.
@source etc/VerticaPyLab.conf; \
if [[ $${TEST_MODE^^} == "YES" ]] ; then \
if [[ $$(tr '[:lower:]' '[:upper:]'<<< $${TEST_MODE}) == "YES" ]] ; then \
VERTICAPYLAB_IMG_VERSION=$(VERSION); \
fi; \
docker stop "$$VERTICAPYLAB_CONTAINER_NAME" >/dev/null 2>&1; \
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
78 changes: 46 additions & 32 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,7 +55,49 @@ while getopts "p:c:i:h" opt; do
esac
done

if [[ ${TEST_MODE^^} == "YES" ]]; then
# 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

function openURL() {
container=$1
host=$2
URL=$(docker logs "$container" 2>&1 | grep -Eo 'http[s]?://[0-9.]+:8888/.*' | head -n 1 | sed "s/[0-9.]*:8888/$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
if [[ $OSTYPE == darwin* ]]; then # OSX uses different args for stat
OPEN_CMD=open
elif [[ $(uname -r) =~ WSL ]]; then
OPEN_CMD="$BIN/open"
else
OPEN_CMD=xdg-open
fi
# Open the correct url in browser. We know that the correct url is the second one.
# So even if in some cases a 3rd one is created this will not be affected
echo
echo "Waiting for url to open in browser..."
$OPEN_CMD "$URL" 2> /dev/null
if [[ $? -eq 0 ]]; then
echo
echo "If the link does not open or does not work, copy and paste this URL in browser:"
else
echo
echo "Copy and paste this URL in browser:"
fi
echo " $URL"
}

# If the container already exists, open the url in the browser
if docker exec -i "$VERTICAPYLAB_CONTAINER_NAME" true 2>/dev/null; then
echo "$VERTICAPYLAB_CONTAINER_NAME is already running"
openURL $VERTICAPYLAB_CONTAINER_NAME $url_host
exit 0
fi

if [[ $(tr '[:lower:]' '[:upper:]'<<< ${TEST_MODE}) == "YES" ]] ; then
VERTICAPYLAB_IMG_VERSION=$VERSION
fi

Expand Down Expand Up @@ -122,7 +164,7 @@ Host $VERTICA_HOST_NAME $SSH_CONFIG_EXTRA_HOSTNAME
User dbadmin
" | docker exec -i "$VERTICAPYLAB_CONTAINER_NAME" bash -c 'umask 077; mkdir -p $HOME/.ssh; cat >> $HOME/.ssh/config'

if [[ ${TEST_MODE^^} == "YES" ]]; then
if [[ $(tr '[:lower:]' '[:upper:]'<<< ${TEST_MODE}) == "YES" ]] ; then
trap ' tput setaf 1; echo "VerticaPy installation failed"; tput sgr0; ' EXIT

echo "Uninstalling old VerticaPy"
Expand All @@ -149,32 +191,4 @@ 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
if [[ $OSTYPE == darwin* ]]; then # OSX uses different args for stat
OPEN_CMD=open
elif [[ $(uname -r) =~ WSL ]]; then
OPEN_CMD="$BIN/open"
else
OPEN_CMD=xdg-open
fi
# Open the correct url in browser. We know that the correct url is the second one.
# So even if in some cases a 3rd one is created this will not be affected
echo
echo "Waiting for url to open in browser..."
$OPEN_CMD "$URL" 2> /dev/null
if [[ $? -eq 0 ]]; then
echo
echo "If the link does not open or does not work, copy and paste this URL in browser:"
else
echo
echo "Copy and paste this URL in browser:"
fi
echo " $URL"
openURL $VERTICAPYLAB_CONTAINER_NAME $url_host
2 changes: 1 addition & 1 deletion bin/verticapylab-build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi
# Load the configuration
source $CONFIG_FILE || abort $? "Cannot load config file $CONFIG_FILE"

if [[ ${TEST_MODE^^} == "YES" ]]; then
if [[ $(tr '[:lower:]' '[:upper:]'<<< ${TEST_MODE}) == "YES" ]] ; then
VERTICAPYLAB_IMG_VERSION=$VERSION
fi

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

0 comments on commit 149afcd

Please sign in to comment.