From e6d5c4edd0deb5116e9e8f9535e5a6166fda9846 Mon Sep 17 00:00:00 2001 From: Richard Franklin Date: Tue, 10 Sep 2024 13:04:56 -0700 Subject: [PATCH] preparing for distribution --- .github/workflows/pypi.yaml | 22 ++++++++++++++++++++++ .github/workflows/test-pypi.yaml | 25 +++++++++++++++++++++++++ README.md | 25 +++++++++++++++++++++++-- graphbook_huggingface/__init__.py | 2 +- hf.config.yaml | 2 ++ web/package.json | 3 ++- web/webpack.config.js | 2 +- 7 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pypi.yaml create mode 100644 .github/workflows/test-pypi.yaml create mode 100644 hf.config.yaml diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml new file mode 100644 index 0000000..08da3f0 --- /dev/null +++ b/.github/workflows/pypi.yaml @@ -0,0 +1,22 @@ +name: Publish Plugin to PyPI + +on: + workflow_dispatch: + +jobs: + pypi: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: | + pipx install poetry + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Build and Publish + run: | + cd web + npm install + npm run build + poetry build + poetry publish -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.TEST_PYPI_PASSWORD }} diff --git a/.github/workflows/test-pypi.yaml b/.github/workflows/test-pypi.yaml new file mode 100644 index 0000000..aafeb37 --- /dev/null +++ b/.github/workflows/test-pypi.yaml @@ -0,0 +1,25 @@ +name: Publish Plugin to Test PyPI + +on: + workflow_dispatch: + +jobs: + pypi: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: | + pipx install poetry + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Set up Test PyPI Repository + run: | + poetry config repositories.test-pypi https://test.pypi.org/legacy/ + - name: Build and Publish + run: | + cd web + npm install + npm run build + poetry build + poetry publish -r test-pypi -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.TEST_PYPI_PASSWORD }} diff --git a/README.md b/README.md index 1bdc1b7..a07087a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,23 @@ -# graphbook-huggingface -The huggingface plugin for Graphbook +

+ + Logo + + +

Graphbook Huggingface

+ +

+ A Huggingface Plugin to drag-and-drop models and datasets onto Graphbook workflows +

+

+ +This plugin contains a web panel for searching and drag-and-dropping models and datasets from [Huggingface Hub](https://huggingface.co/) onto their graphbook workflows. +It also contains the following nodes: + +* `HuggingfacePipeline` for model usage from transformers package +* `HuggingfaceDataset` for dataset usage from the datasets package +* `AssignModelOutputsToNotes` to assign HF model outputs to incoming Notes + +## Getting started +1. `pip install graphbook_huggingface` +1. `graphbook --config hf.config.yaml` + diff --git a/graphbook_huggingface/__init__.py b/graphbook_huggingface/__init__.py index d144fba..6729f45 100644 --- a/graphbook_huggingface/__init__.py +++ b/graphbook_huggingface/__init__.py @@ -7,4 +7,4 @@ export("HuggingfaceDataset", HuggingfaceDataset) export("AssignModelOutputsToNotes", AssignModelOutputsToNotes) -web(osp.realpath(osp.join(osp.dirname(__file__), "../web/dist/bundle.js"))) +web(osp.realpath(osp.join(osp.dirname(__file__), "./dist/bundle.js"))) diff --git a/hf.config.yaml b/hf.config.yaml new file mode 100644 index 0000000..0401d12 --- /dev/null +++ b/hf.config.yaml @@ -0,0 +1,2 @@ +plugins: + - graphbook_huggingface diff --git a/web/package.json b/web/package.json index e411069..c835580 100644 --- a/web/package.json +++ b/web/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build": "webpack --config webpack.config.js --mode development" + "build:dev": "webpack --config webpack.config.js --mode development", + "build": "webpack --config webpack.config.js --mode production" }, "author": "", "license": "ISC", diff --git a/web/webpack.config.js b/web/webpack.config.js index 33fbc82..c7c106e 100644 --- a/web/webpack.config.js +++ b/web/webpack.config.js @@ -1,7 +1,7 @@ module.exports = { entry: './src/main.tsx', output: { - filename: 'bundle.js', + filename: '../../graphbook_huggingface/dist/bundle.js', library: { type: 'module' },