Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/examples_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Notebook Execution and Error Check

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: # This enables manual triggering

jobs:
execute_notebooks:
runs-on: LargeBois
strategy:
matrix:
transformers_version: ["transformers==4.48.0", "transformers==4.56.1", "--upgrade transformers"]
notebook: ["example.ipynb","Jsonformer_example.ipynb"]
env:
HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }}
NLTK_DATA: /tmp/nltk_data
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12.x
- name: Install dependencies
run: |

# Setup Virtual Environment
python3 -m venv ./.venv
source .venv/bin/activate

# Install the current branch
pip install ${{ matrix.transformers_version }}
pip install .

# Install extra stuff for notebook runs
pip install "huggingface_hub[cli]" jupyter nbconvert ipykernel torch accelerate bitsandbytes
- name: Huggingface Hub Login
run: |
source .venv/bin/activate
huggingface-cli login --token $HUGGINGFACE_API_KEY
- name: Execute notebooks and check for errors
run: |
source .venv/bin/activate
echo "Processing ${{ matrix.notebook }}..."
# poetry run jupyter nbconvert --to notebook --execute "${{ matrix.notebook }}"
jupyter nbconvert --to notebook --execute "${{ matrix.notebook }}"
if [ $? -ne 0 ]; then
echo "Error found in ${{ matrix.notebook }}"
echo "Error in ${{ matrix.notebook }}. See logs for details." >> errors.txt
exit 1
fi

exit 0

34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release New PyPi Version

on:
workflow_dispatch: # This event allows manual triggering

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v5

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: 3.13.x

- name: Poetry cache
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: poetry-cache

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: poetry install --all-extras

- name: Upload to PyPI
env:
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: poetry publish --build -u __token__ -p $PYPI_PASSWORD
84 changes: 55 additions & 29 deletions Jsonformer_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"<a href=\"https://colab.research.google.com/github/1rgs/jsonformer/blob/main/Jsonformer_example.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
Expand All @@ -22,8 +22,8 @@
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Requirement already satisfied: transformers in /usr/local/lib/python3.10/dist-packages (4.28.1)\n",
Expand Down Expand Up @@ -64,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand All @@ -74,8 +74,17 @@
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/calebcourier/Projects/jsonformer/.venv/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n",
"W0915 16:52:21.949000 36819 torch/distributed/elastic/multiprocessing/redirects.py:29] NOTE: Redirects are currently not supported in Windows or MacOs.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading model and tokenizer...\n",
"Loaded model and tokenizer\n"
Expand All @@ -94,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand All @@ -104,40 +113,47 @@
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Generating...\n",
"{\n",
" car: {\n",
" make: \"audi\",\n",
" model: \"model A8\",\n",
" year: 2016.0,\n",
" make: \u001b[32m\"Chevrolet\"\u001b[0m,\n",
" model: \u001b[32m\"Corvette\"\u001b[0m,\n",
" year: \u001b[32m2016.0\u001b[0m,\n",
" colors: [\n",
" \"blue\"\n",
" \u001b[32m\"Red\"\u001b[0m\n",
" ],\n",
" features: {\n",
" audio: {\n",
" brand: \"sony\",\n",
" speakers: 2.0,\n",
" hasBluetooth: True\n",
" brand: \u001b[32m\"Sony\"\u001b[0m,\n",
" speakers: \u001b[32m2.0\u001b[0m,\n",
" hasBluetooth: \u001b[32mTrue\u001b[0m\n",
" },\n",
" safety: {\n",
" airbags: 2.0,\n",
" parkingSensors: True,\n",
" laneAssist: True\n",
" airbags: \u001b[32m2.0\u001b[0m,\n",
" parkingSensors: \u001b[32mTrue\u001b[0m,\n",
" laneAssist: \u001b[32mTrue\u001b[0m\n",
" },\n",
" performance: {\n",
" engine: \"4.0\",\n",
" horsepower: 220.0,\n",
" topSpeed: 220.0\n",
" engine: \u001b[32m\"4.0\"\u001b[0m,\n",
" horsepower: \u001b[32m220.0\u001b[0m,\n",
" topSpeed: \u001b[32m220.0\u001b[0m\n",
" }\n",
" }\n",
" },\n",
" owner: {\n",
" firstName: \"John\",\n",
" lastName: \"Doe\",\n",
" age: 40.0\n",
" firstName: \u001b[32m\"John\"\u001b[0m,\n",
" lastName: \u001b[32m\"Doe\"\u001b[0m,\n",
" age: \u001b[32m40.0\u001b[0m\n",
" }\n",
"}\n"
]
Expand Down Expand Up @@ -217,30 +233,40 @@
},
{
"cell_type": "code",
"source": [],
"execution_count": null,
"metadata": {
"id": "0eA8hzFHA1jo"
},
"execution_count": null,
"outputs": []
"outputs": [],
"source": []
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"include_colab_link": true,
"machine_shape": "hm",
"provenance": [],
"include_colab_link": true
"provenance": []
},
"gpuClass": "premium",
"kernelspec": {
"display_name": "Python 3",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@ poetry run python -m jsonformer.example
## License

Jsonformer is released under the MIT License. You are free to use, modify, and distribute this software for any purpose, commercial or non-commercial, as long as the original copyright and license notice are included.

Loading