Skip to content

Commit

Permalink
Merge pull request #14 from intersystems-community/do-6
Browse files Browse the repository at this point in the history
Simplify connection workflow
  • Loading branch information
gjsjohnmurray authored Jan 2, 2025
2 parents 516fc75 + 76a985a commit a279b6a
Show file tree
Hide file tree
Showing 18 changed files with 1,977 additions and 1,727 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This PR fixes #
148 changes: 79 additions & 69 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ name: CI
on:
push:
branches:
- main
- master
paths-ignore:
- ".vscode/**"
- ".github/**"
- "*.md"
- "**/*.md"
pull_request:
branches:
- main
- master
release:
types:
- released
Expand All @@ -22,28 +22,26 @@ concurrency:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
outputs:
taggedbranch: ${{ steps.find-branch.outputs.taggedbranch }}
include:
- platarch: win32-x64
ISC_PLATFORM: winx64
- platarch: linux-x64
ISC_PLATFORM: lnxubuntux64
- platarch: darwin-x64
ISC_PLATFORM: macx64
- platarch: darwin-arm64
ISC_PLATFORM: macos
steps:
- uses: actions/checkout@v3
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Find which branch the release tag points at
id: find-branch
if: github.event_name == 'release' && runner.os == 'Linux'
shell: bash
run: |
git fetch --depth=1 origin +refs/heads/*:refs/heads/*
set -x
TAGGEDBRANCH=$(git for-each-ref --points-at=${{github.sha}} --format='%(refname:lstrip=2)' refs/heads/)
echo "taggedbranch=$TAGGEDBRANCH" >> $GITHUB_OUTPUT
- name: Set an output
- name: Check out repository
uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set package name and version
id: set-version
if: runner.os == 'Linux'
run: |
set -x
VERSION=$(jq -r '.version' package.json | cut -d- -f1)
Expand All @@ -55,7 +53,7 @@ jobs:
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
echo "version=$VERSION" >> $GITHUB_OUTPUT
NAME=$(jq -r '.name' package.json)-$VERSION
NAME=$(jq -r '.name' package.json)-$VERSION-${{ matrix.platarch }}
echo "name=$NAME" >> $GITHUB_OUTPUT
tmp=$(mktemp)
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
Expand All @@ -65,105 +63,117 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 18
- run: npm install
- name: lint
if: runner.os == 'Linux-NOSUCH'
if: matrix.platarch == 'Linux-IGNORE'
run: npm run lint
- run: npm run compile
- name: npm test
if: matrix.platarch == 'Linux-IGNORE'
uses: coactions/setup-xvfb@v1
with:
run: npm run test
- name: Build package
if: runner.os == 'Linux'
run: |
npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
- uses: actions/upload-artifact@v4
if: (runner.os == 'Linux') && (github.event_name != 'release')
node -e "require('fs').cpSync('./intersystems-iris-native/bin/${{ matrix.ISC_PLATFORM }}/', './dist/', { recursive: true, filter: (f) => !f.endsWith('irisnative.node') })"
npx vsce package --target ${{ matrix.platarch }} -o ${{ steps.set-version.outputs.name }}.vsix
- name: Upload package
uses: actions/upload-artifact@v4
if: (github.event_name != 'release')
with:
name: ${{ steps.set-version.outputs.name }}.vsix
path: ${{ steps.set-version.outputs.name }}.vsix
- uses: actions/upload-artifact@v4
if: runner.os == 'Linux'
- name: Upload metadata
uses: actions/upload-artifact@v4
if: matrix.platarch == 'linux-x64'
with:
name: meta
path: |
meta.name
meta.version
path: meta.version
beta:
if: (github.event_name == 'push')
runs-on: ubuntu-latest
needs: build
if: success() && github.event_name == 'push'
steps:
- uses: actions/download-artifact@v4
- name: Download metadata
uses: actions/download-artifact@v4
with:
name: meta
path: .
- name: Set an output
- name: Set version output
id: set-version
if: runner.os == 'Linux'
run: |
set -x
echo "version=`cat meta.version`" >> $GITHUB_OUTPUT
echo "name=`cat meta.name`" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
- name: Download packages
uses: actions/download-artifact@v4
with:
name: ${{ steps.set-version.outputs.name }}.vsix
pattern: '**/*.vsix'
- name: Create Release
id: create-release
uses: softprops/action-gh-release@v1
if: runner.os == 'Linux'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.set-version.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
files: ${{ steps.set-version.outputs.name }}.vsix
files: '**/*.vsix'
token: ${{ secrets.GITHUB_TOKEN }}

publish:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release' && needs.build.outputs.taggedbranch == 'main'
if: success() && github.event_name == 'release'
steps:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- run: npm install -g @vscode/vsce
- name: Download packages
uses: actions/download-artifact@v4
- name: Attach packages to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.release.tag_name }}
files: '**/*.vsix'
body: See CHANGELOG for details
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to VS Code Marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
if: env.VSCE_PAT != null
run: vsce publish --packagePath $(find . -iname "*.vsix" -type f)
- name: Publish to Open VSX Registry
env:
OVSX_PAT: ${{ secrets.OVSX_TOKEN }}
if: env.OVSX_PAT != null
timeout-minutes: 5
run: find . -iname "*.vsix" -type f -exec npx ovsx publish {} \;
bump_version:
runs-on: ubuntu-latest
needs: [build, publish]
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v3
- name: Check out repository
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.TOKEN }}
- uses: actions/download-artifact@v4
ref: master
- name: Download metadata
uses: actions/download-artifact@v4
with:
name: meta
path: .
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Prepare build
id: set-version
node-version: 18
- name: Create commit
run: |
VERSION=`cat meta.version`
NEXT_VERSION=`cat meta.version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
echo "name=`cat meta.name`" >> $GITHUB_OUTPUT
tmp=$(mktemp)
git config --global user.name 'ProjectBot'
git config --global user.email '[email protected]'
jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
git add package.json
git commit -m 'auto bump version with release'
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
npm install
jq 'del(.enableProposedApi,.enabledApiProposals)' package.json > "$tmp" && mv "$tmp" package.json
git commit -m 'auto bump version with release [skip ci]'
git push
- name: Build package
run: |
npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
- name: Upload Release Asset
id: upload-release-asset
uses: softprops/action-gh-release@v1
if: runner.os == 'Linux'
with:
tag_name: ${{ github.event.release.tag_name }}
files: ${{ steps.set-version.outputs.name }}.vsix
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to VSCode Marketplace
run: |
[ -n "${{ secrets.VSCE_TOKEN }}" ] && \
npx vsce publish --packagePath ${{ steps.set-version.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"mapped": false
},
"objectscript.conn": {
"active": true
"active": false
},
}
53 changes: 29 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# intersystems-community.iris-jupyter-server

This VS Code extension is an alpha-quality proof of concept. It leverages [Microsoft's Jupyter extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter) to bring the notebook paradigm to developers working with InterSystems IRIS servers, both local and remote.
This VS Code extension leverages [Microsoft's Jupyter extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter) to bring the notebook paradigm to developers working with InterSystems IRIS servers, both local and remote.

## Getting Started

1. Install the extension. This will also install the Jupyter and ObjectScript extension packs if you don't already have them.
2. Use [InterSystems Server Manager](https://marketplace.visualstudio.com/items?itemName=intersystems-community.servermanager) to define a connection to an IRIS server.
> **Note:** IRIS developers who already use the `objectscript.conn` settings object and don't want to adopt Server Manager should consult a later section of this document for information applicable to them.
> **Note:** IRIS developers who already use the `objectscript.conn` settings object and don't want to adopt Server Manager's `intersystems.servers` object for their server definitions are not required to do so. However `objectscript.conn` must contain values for `username` and `password`. Switching to use Server Manager would mean that plaintext password could be avoided.
3. From VS Code's `File` menu select `New File...`. This option is also available on the Welcome page.
4. When a quickpick appears, choose `Jupyter Notebook`.
5. Click the `Detecting Kernels` button in the upper right of the notebook.
6. In the quickpick titled "Select Kernel" choose `Existing Jupyter Server...`.
7. In the next quickpick ("Select a Jupyter Server") choose `Enter the URL of the running Jupyter server`.
8. Enter `http://localhost:50773/`_servername_`:`_namespace_`?token=1` when prompted. Replace _servername_ with the name of the Server Manager definition you previously created. Replace _namespace_ with the target namespace on that server. Do not omit the colon between these two elements. For example `http://localhost:50773/iris231:USER?token=1`
9. On the next prompt ("Change Server Display Name") enter a suitable name, for example `IRIS231 USER`. Don't leave this blank, else the display name will default to `localhost`, meaning you won't be able to distinguish between entries you create for different **_servername_:_namespace_** combinations.
10. When you connect to a namespace for the first time you will be asked to allow the installation of a support class named `PolyglotKernel.CodeExecutor`. Choose `Yes`.
5. Click the button in the upper right of the notebook captioned `Detecting Kernels` or `Select Kernel`.
6. If the next picker is titled 'Select Kernel' choose `IRIS Notebook Servers...`. Otherwise choose `Select Another Kernel...`, then choose `IRIS Notebook Servers...` from that picker.
7. The first time you use the extension you will be taken directly to the next step below (#8). On subsequent uses you are asked to "Select a Jupyter Server" and can pick a previously-used _server:NAMESPACE_ entry, then proceed at step #11 below. Alternatively choose `Add IRIS Notebook Host...` and proceed at step #8.
8. On the "Choose IRIS Server" quickpick, choose your target.
9. On the next quickpick choose your target namespace.
10. When you connect a notebook to a namespace for the first time you will be asked to allow the installation of a support class named `PolyglotKernel.CodeExecutor`. Choose `Yes`.
> **Tip:** To avoid having to load this class into other namespaces on the same server you can add a %ALL package mapping of the `PolyglotKernel` package to the default code database of the namespace you initially connected to.
11. On the kernel selector, choose the `IRIS ObjectScript INT` kernel.
12. The kernel indicator in the upper right of the notebook will display your choice, and the initial notebook cell will show the corresponding language (ObjectScript INT) in the lower right corner.
Expand Down Expand Up @@ -44,29 +44,34 @@ print('Hello world')

> **Note:** Cells of a Polyglot IRIS notebook are not language-aware, so they lack syntax coloring, completions etc. The so-called 'cell magics' tell the server-side code executor class which language to run, but the Jupyter notebook extension is not currently able to use them to vary the cell language in the editor.
## Use With `objectscript.conn`

If you already use the `objectscript.conn` settings object to connect VS Code to your IRIS server, you can reference that connection definition in your Jupyter Server URL.

- Enter `http://localhost:50773/:?token=1` to connect to the namespace set in the `ns` property of your `objectscript.conn` settings object.
- Enter `http://localhost:50773/:`_namespace_`?token=1` to connect to a different namespace.

Your `objectscript.conn` must have one of the following formats:
- `{ "active": true, "host": "xxx", "port": nn, "username": "uuu", "password": "***", "ns": "YYY" }`
- `{ "active": true, "server": "xxx", "ns": "YYY" }`

The first format requires a password to be stored as plaintext. The second format avoids this risk by leveraging Server Manager's secure credential storage.

Both formats may optionally specify `"https": true`.

## Other Resources

The [Jupyter PowerToys](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.vscode-jupyter-powertoys) extension adds a Kernels view to a dedicated Jupyter view container. Access this from its activity bar icon to explore remote servers, kernelspecs and active kernels (sessions).

## Configuration Settings
The optional `iris-jupyter-server.port` setting defines the local port to listen on. Default is 50773.

The `iris-jupyter-server.hosts` settings object contains the _server:NAMESPACE_ entries that you defined as you connected for the first time.

For example:

```json
"iris-jupyter-server.hosts": {
"irislatest:USER": {
"enabled": true
},
"iris231:USER": {
"enabled": true
},
"doh-vvm:USER": {
"enabled": true
}
},
```

## Known Issues

1. The InterSystems IRIS Node Native API connectivity we use operates only in synchronous mode. Consequently the output from a long-running cell does not stream, so you have to wait for all the work to complete before you see any results for the cell.
2. The Jupyter Server proxy launched by the extension always listens on port 50773.

## Feedback

Expand Down
2 changes: 1 addition & 1 deletion intersystems-iris-native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (process.platform == "win32" && process.arch == "x64") {
}
} else if (process.platform == "linux") {
let distro = getLinuxDistro()
logChannel.debug('platform = ' + process.platform + ': ' + distro + ': ' + process.arch);
console.log('intersystems-iris-native:index.js(linux): platform = ' + process.platform + ': ' + distro + ': ' + process.arch);
if (distro == 'ubuntu') {
if (process.arch == "x64") {
native = require('./bin/lnxubuntux64/irisnative.node');
Expand Down
2 changes: 1 addition & 1 deletion irisapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ARG IMAGE=containers.intersystems.com/intersystems/iris-community:2022.3.0.606.0
ARG IMAGE=containers.intersystems.com/intersystems/iris-community:2023.1.0.229.0
ARG IMAGE=containers.intersystems.com/intersystems/iris-community:2024.2

FROM $IMAGE

Expand Down
Loading

0 comments on commit a279b6a

Please sign in to comment.