Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ETH-PEACH-Lab/datascience-visualisa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
mchami02 committed Aug 24, 2024
2 parents e331aca + 5601f28 commit 28b740e
Show file tree
Hide file tree
Showing 25 changed files with 609 additions and 419 deletions.
4 changes: 2 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ author_name: My Name
has_binder: true
has_settings: false
kind: frontend
labextension_name: jupyterlab_apod
labextension_name: cluster_viz
project_short_description: ' Show a random NASA Astronomy Picture of the Day in a
JupyterLab panel
'
python_name: jupyterlab_apod
python_name: cluster_viz
repository: ''
test: true

14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
python -m pip install .[test]
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyterlab_apod.*OK"
jupyter labextension list 2>&1 | grep -ie "cluster_viz.*OK"
python -m jupyterlab.browser_check
- name: Package the extension
Expand All @@ -50,13 +50,13 @@ jobs:
pip install build
python -m build
pip uninstall -y "jupyterlab_apod" jupyterlab
pip uninstall -y "cluster_viz" jupyterlab
- name: Upload extension packages
uses: actions/upload-artifact@v4
with:
name: extension-artifacts
path: dist/jupyterlab_apod*
path: dist/cluster_viz*
if-no-files-found: error

test_isolated:
Expand All @@ -79,11 +79,11 @@ jobs:
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install "jupyterlab>=4.0.0,<5" jupyterlab_apod*.whl
pip install "jupyterlab>=4.0.0,<5" cluster_viz*.whl
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyterlab_apod.*OK"
jupyter labextension list 2>&1 | grep -ie "cluster_viz.*OK"
python -m jupyterlab.browser_check --no-browser-test
integration-tests:
Expand All @@ -109,7 +109,7 @@ jobs:
- name: Install the extension
run: |
set -eux
python -m pip install "jupyterlab>=4.0.0,<5" jupyterlab_apod*.whl
python -m pip install "jupyterlab>=4.0.0,<5" cluster_viz*.whl
- name: Install dependencies
working-directory: ui-tests
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: jupyterlab_apod-playwright-tests
name: cluster_viz-playwright-tests
path: |
ui-tests/test-results
ui-tests/playwright-report
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ jobs:
- name: Upload Distributions
uses: actions/upload-artifact@v4
with:
name: jupyterlab_apod-releaser-dist-${{ github.run_number }}
name: cluster_viz-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ backend/api_key.txt
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
jupyterlab_apod/labextension
cluster_viz/labextension
# Version file is handled by hatchling
jupyterlab_apod/_version.py
cluster_viz/_version.py
/secrets
# Integration tests
ui-tests/test-results/
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ node_modules
**/lib
**/package.json
!/package.json
jupyterlab_apod
cluster_viz
backend
18 changes: 18 additions & 0 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Using the GitHub Container Registry for Deployment

1. Create a personal token: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

```
docker login ghcr.io --username github-account
[Paste your GitHub token on this prompt]
```
2. Build the image for the server
```
docker image build --platform linux/amd64 -t cluster-jupyter .
```

2. Tag and push your Docker images
```
docker tag cluster-jupyter ghcr.io/eth-peach-lab/datascience-visualisation/cluster-jupyter:latest
docker push ghcr.io/eth-peach-lab/datascience-visualisation/cluster-jupyter:latest
```
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM quay.io/jupyter/minimal-notebook:hub-5.1.0
USER root
RUN pip install --no-cache -U cluster_viz
EXPOSE 8000
EXPOSE 8888
USER ${NB_USER}
CMD ["/bin/bash","-c", "jupyterhub-singleuser"]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# jupyterlab_apod
# cluster_Viz

[![Github Actions Status](/workflows/Build/badge.svg)](/actions/workflows/build.yml)

Expand All @@ -16,15 +16,15 @@
To install the extension, execute:

```bash
pip install jupyterlab_apod
pip install cluster_viz
```

## Uninstall

To remove the extension, execute:

```bash
pip uninstall jupyterlab_apod
pip uninstall cluster_viz
```

## Contributing
Expand All @@ -39,7 +39,7 @@ The `jlpm` command is JupyterLab's pinned version of

```bash
# Clone the repo to your local environment
# Change directory to the jupyterlab_apod directory
# Change directory to the cluster_viz directory
# Install package in development mode
pip install -e "."
# Link your development version of the extension with JupyterLab
Expand Down Expand Up @@ -68,12 +68,12 @@ jupyter lab build --minimize=False
### Development uninstall

```bash
pip uninstall jupyterlab_apod
pip uninstall cluster_viz
```

In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
folder is located. Then you can remove the symlink named `jupyterlab_apod` within that folder.
folder is located. Then you can remove the symlink named `cluster_viz` within that folder.

### Testing the extension

Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Making a new release of jupyterlab_apod
# Making a new release of cluster_viz

The extension can be published to `PyPI` and `npm` manually or using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser).

Expand Down
2 changes: 1 addition & 1 deletion binder/environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# a mybinder.org-ready environment for demoing jupyterlab_apod
# a mybinder.org-ready environment for demoing cluster_viz
# this environment may also be used locally on Linux/MacOS/Windows, e.g.
#
# conda env update --file binder/environment.yml
Expand Down
4 changes: 2 additions & 2 deletions binder/postBuild
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
""" perform a development install of jupyterlab_apod
""" perform a development install of cluster_viz
On Binder, this will run _after_ the environment has been fully created from
the environment.yml in this directory.
Expand Down Expand Up @@ -43,5 +43,5 @@ _("jupyter", "server", "extension", "list")
_("jupyter", "labextension", "list")


print("JupyterLab with jupyterlab_apod is ready to run with:\n")
print("JupyterLab with cluster_viz is ready to run with:\n")
print("\tjupyter lab\n")
4 changes: 2 additions & 2 deletions jupyterlab_apod/__init__.py → cluster_viz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
# in editable mode with pip. It is highly recommended to install
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
import warnings
warnings.warn("Importing 'jupyterlab_apod' outside a proper installation.")
warnings.warn("Importing 'cluster_viz' outside a proper installation.")
__version__ = "dev"


def _jupyter_labextension_paths():
return [{
"src": "labextension",
"dest": "jupyterlab_apod"
"dest": "cluster_viz"
}]
4 changes: 2 additions & 2 deletions install.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packageManager": "python",
"packageName": "jupyterlab_apod",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_apod"
"packageName": "cluster_viz",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package cluster_viz"
}
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "jupyterlab_apod",
"version": "0.1.0",
"name": "cluster_viz",
"version": "0.2.1",
"description": "Show a random NASA Astronomy Picture of the Day in a JupyterLab panel",
"keywords": [
"jupyter",
"jupyterlab",
"jupyterlab-extension"
],
"homepage": "",
"homepage": "https://github.com/ETH-PEACH-Lab/datascience-visualisation",
"bugs": {
"url": "/issues"
"url": "https://github.com/ETH-PEACH-Lab/datascience-visualisation/issues"
},
"license": "BSD-3-Clause",
"author": "My Name",
Expand All @@ -23,7 +23,7 @@
"style": "style/index.css",
"repository": {
"type": "git",
"url": ".git"
"url": "https://github.com/ETH-PEACH-Lab/datascience-visualisation"
},
"scripts": {
"build": "jlpm build:lib && jlpm build:labextension:dev",
Expand All @@ -35,7 +35,7 @@
"clean": "jlpm clean:lib",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf jupyterlab_apod/labextension jupyterlab_apod/_version.py",
"clean:labextension": "rimraf cluster_viz/labextension cluster_viz/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
Expand Down Expand Up @@ -119,7 +119,7 @@
},
"jupyterlab": {
"extension": true,
"outputDir": "jupyterlab_apod/labextension",
"outputDir": "cluster_viz/labextension",
"sharedPackages": {
"@jupyter-widgets/base": {
"bundled": false,
Expand Down
19 changes: 10 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version>=0
build-backend = "hatchling.build"

[project]
name = "jupyterlab_apod"
name = "cluster_viz"
readme = "README.md"
homepage = "https://github.com/ETH-PEACH-Lab/datascience-visualisation" # Add your repository or website URL here
license = { file = "LICENSE" }
requires-python = ">=3.8"
classifiers = [
Expand Down Expand Up @@ -33,24 +34,24 @@ source = "nodejs"
fields = ["description", "authors", "urls"]

[tool.hatch.build.targets.sdist]
artifacts = ["jupyterlab_apod/labextension"]
artifacts = ["cluster_viz/labextension"]
exclude = [".github", "binder"]

[tool.hatch.build.targets.wheel.shared-data]
"jupyterlab_apod/labextension" = "share/jupyter/labextensions/jupyterlab_apod"
"install.json" = "share/jupyter/labextensions/jupyterlab_apod/install.json"
"cluster_viz/labextension" = "share/jupyter/labextensions/cluster_viz"
"install.json" = "share/jupyter/labextensions/cluster_viz/install.json"

[tool.hatch.build.hooks.version]
path = "jupyterlab_apod/_version.py"
path = "cluster_viz/_version.py"

[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.5"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"jupyterlab_apod/labextension/static/style.js",
"jupyterlab_apod/labextension/package.json",
"cluster_viz/labextension/static/style.js",
"cluster_viz/labextension/package.json",
]
skip-if-exists = ["jupyterlab_apod/labextension/static/style.js"]
skip-if-exists = ["cluster_viz/labextension/static/style.js"]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
Expand All @@ -60,7 +61,7 @@ npm = ["jlpm"]
build_cmd = "install:extension"
npm = ["jlpm"]
source_dir = "src"
build_dir = "jupyterlab_apod/labextension"
build_dir = "cluster_viz/labextension"

[tool.jupyter-releaser.options]
version_cmd = "hatch version"
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/jupyterlab_apod.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Example of [Jest](https://jestjs.io/docs/getting-started) unit tests
*/

describe('jupyterlab_apod', () => {
describe('cluster_viz', () => {
it('should be tested', () => {
expect(1 + 1).toEqual(2);
});
Expand Down
5 changes: 3 additions & 2 deletions src/backend/Clusterers/clusterer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ def embed_cell(self, code_str: str, desc_str: str) -> list[float]:
list[float]: A list representing the embedded vector of the code snippet and its description.
"""

code_embedding = self._process_code(code_str)
# code_embedding = self._process_code(code_str)
desc_embedding = self._process_summary(desc_str)
return torch.mean(torch.stack([code_embedding, desc_embedding]), dim=0).detach().numpy().reshape(-1).tolist()
# return torch.mean(torch.stack([code_embedding, desc_embedding]), dim=0).detach().numpy().reshape(-1).tolist()
return desc_embedding.detach().numpy().reshape(-1).tolist()


def cluster(self, data: dict, classes: list[str]) -> dict:
Expand Down
Loading

0 comments on commit 28b740e

Please sign in to comment.