Skip to content

Commit

Permalink
Send message to open UI's create notebook modal instead of the extens… (
Browse files Browse the repository at this point in the history
#36)

* Send message to open UI's create notebook modal instead of the extension's

* Allow alpha versions and move publish to scripts folder

* Fix linting

* Get version from tag

* Update message action
  • Loading branch information
SarantopoulosKon authored Jun 21, 2023
1 parent cc39fca commit 3264a7a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 58 deletions.
28 changes: 11 additions & 17 deletions azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ stages:
displayName: 'Save npm token & install labextension dependencies'
env:
NPM_TOKEN: $(NPM_TOKEN)
- script: |
latestGitTag=$(git describe --tags --abbrev=0)
latestGitTag="${latestGitTag:1}"
npm version $latestGitTag --no-commit-hooks --no-git-tag-version
displayName: 'Update package.json version'
- script: jlpm run build:prod
displayName: 'Build jupyterlab extension'
env:
Expand All @@ -141,24 +148,11 @@ stages:
inputs:
pythonUploadServiceConnection: 'pypi-upload'

- script: python -m twine upload -r "pypi-upload" --config-file $(PYPIRC_PATH) --verbose dist/*.whl
displayName: 'Release to Pypi'

- script: |
currentVersion=$(./node_modules/.bin/git-tag-version)
latestGitTag=$(git describe --tags --abbrev=0)
latestGitTag="${latestGitTag:1}"
echo $currentVersion
echo $latestGitTag
if [[ $latestGitTag == *"beta"* ]];
then
echo "Publishing beta version";
yarn publish --new-version $latestGitTag --no-git-tag-version --access public --tag beta
else
echo "Publishing new version";
yarn publish --new-version $(./node_modules/.bin/git-tag-version) --no-git-tag-version --access public
fi
- script: ./scripts/publish.sh
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
NPM_TOKEN: $(NPM_TOKEN)
displayName: 'Release to npm'

- script: python -m twine upload -r "pypi-upload" --config-file $(PYPIRC_PATH) --verbose dist/*.whl
displayName: 'Release to Pypi'
21 changes: 21 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

LATEST_GIT_TAG=$(git describe --tags --abbrev=0)
# Remove "v" from the start of the tag e.g. v1.0.0 -> 1.0.0
LATEST_GIT_TAG="${LATEST_GIT_TAG:1}"
# Update package.json's version field
npm version $LATEST_GIT_TAG --no-commit-hooks --no-git-tag-version

echo "Updating package.json with version $LATEST_GIT_TAG"
if [[ $LATEST_GIT_TAG == *"beta"* ]];
then
echo "Publishing beta version $LATEST_GIT_TAG to npm";
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public --tag beta
elif [[ $LATEST_GIT_TAG == *"alpha"* ]];
then
echo "Publishing alpha version $LATEST_GIT_TAG to npm";
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public --tag alpha
else
echo "Publishing new version $LATEST_GIT_TAG to npm";
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public
fi
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@
# Get the package info from package.json
pkg_json = json.loads((HERE / "package.json").read_bytes())


npm_version = pkg_json["version"]

version = (
npm_version.replace("-alpha.", "a").replace("-beta.", "b").replace("-rc.", "rc")
)

setup_args = dict(
name=name,
use_scm_version={
"version_scheme": "guess-next-dev",
"local_scheme": "dirty-tag",
"write_to": "tiledb-prompt-options/version.py",
},
version=version,
setup_requires=[
"setuptools-scm>=1.5.4",
"setuptools-scm-git-archive",
Expand Down
37 changes: 1 addition & 36 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { v1, v2 } from '@tiledb-inc/tiledb-cloud';
import {
JupyterFrontEnd,
JupyterFrontEndPlugin,
Expand All @@ -7,12 +6,6 @@ import { IDocumentManager } from '@jupyterlab/docmanager';
import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
import { ILauncher } from '@jupyterlab/launcher';
import { IMainMenu } from '@jupyterlab/mainmenu';
import getTileDBAPI, { Versions } from './helpers/tiledbAPI';
import { showMainDialog } from './helpers/openDialogs';
import getOrgNamesWithWritePermissions from './helpers/getOrgNamesWithWritePermissions';

const { UserApi } = v1;
const { UserApi: UserApiV2 } = v2;

const extension: JupyterFrontEndPlugin<void> = {
activate,
Expand All @@ -34,35 +27,7 @@ function activate(
app.commands.addCommand(OPEN_COMMAND, {
caption: 'Prompt the user for TileDB notebook options',
execute: async () => {
const tileDBAPI = await getTileDBAPI(UserApi);
const tileDBAPIV2 = await getTileDBAPI(UserApiV2, Versions.v2);

const userResponse = await tileDBAPI.getUser();
const userData = userResponse.data;
const username = userData.username;
const credentialsResponse = await tileDBAPIV2.listCredentials(username);
const owners = [username];
const organizationsWithWritePermissions = getOrgNamesWithWritePermissions(
userData.organizations || []
);
const defaultS3Path =
userData.asset_locations?.notebooks?.path ||
userData.default_s3_path ||
's3://tiledb-user/notebooks';

owners.push(...organizationsWithWritePermissions);

showMainDialog({
owners,
credentials: credentialsResponse.data?.credentials || [],
defaultS3Path,
defaultS3CredentialName:
userData.asset_locations?.notebooks?.credentials_name ||
(userData.default_s3_path_credentials_name as any),
app,
docManager,
selectedOwner: userData.username,
});
window.parent.postMessage({ action: 'TILEDB_CREATE_NOTEBOOK' }, '*');
},
isEnabled: () => true,
label: 'TileDB Notebook',
Expand Down

0 comments on commit 3264a7a

Please sign in to comment.