Skip to content

Commit 239eca5

Browse files
authored
Merge pull request #1 from guardrails-ai/transformers-update
Initial Maintenance
2 parents bfad031 + 2c9a5f7 commit 239eca5

File tree

8 files changed

+2600
-1105
lines changed

8 files changed

+2600
-1105
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Notebook Execution and Error Check
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch: # This enables manual triggering
11+
12+
jobs:
13+
execute_notebooks:
14+
runs-on: LargeBois
15+
strategy:
16+
matrix:
17+
transformers_version: ["transformers==4.48.0", "transformers==4.56.1", "--upgrade transformers"]
18+
notebook: ["example.ipynb","Jsonformer_example.ipynb"]
19+
env:
20+
HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }}
21+
NLTK_DATA: /tmp/nltk_data
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ github.head_ref }}
27+
fetch-depth: 0
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: 3.12.x
32+
- name: Install dependencies
33+
run: |
34+
35+
# Setup Virtual Environment
36+
python3 -m venv ./.venv
37+
source .venv/bin/activate
38+
39+
# Install the current branch
40+
pip install ${{ matrix.transformers_version }}
41+
pip install .
42+
43+
# Install extra stuff for notebook runs
44+
pip install "huggingface_hub[cli]" jupyter nbconvert ipykernel torch accelerate bitsandbytes
45+
- name: Huggingface Hub Login
46+
run: |
47+
source .venv/bin/activate
48+
huggingface-cli login --token $HUGGINGFACE_API_KEY
49+
- name: Execute notebooks and check for errors
50+
run: |
51+
source .venv/bin/activate
52+
echo "Processing ${{ matrix.notebook }}..."
53+
# poetry run jupyter nbconvert --to notebook --execute "${{ matrix.notebook }}"
54+
jupyter nbconvert --to notebook --execute "${{ matrix.notebook }}"
55+
if [ $? -ne 0 ]; then
56+
echo "Error found in ${{ matrix.notebook }}"
57+
echo "Error in ${{ matrix.notebook }}. See logs for details." >> errors.txt
58+
exit 1
59+
fi
60+
61+
exit 0
62+

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release New PyPi Version
2+
3+
on:
4+
workflow_dispatch: # This event allows manual triggering
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@v5
13+
14+
- name: Setup Python
15+
uses: actions/setup-python@v6
16+
with:
17+
python-version: 3.13.x
18+
19+
- name: Poetry cache
20+
uses: actions/cache@v4
21+
with:
22+
path: ~/.cache/pypoetry
23+
key: poetry-cache
24+
25+
- name: Install Poetry
26+
uses: snok/install-poetry@v1
27+
28+
- name: Install dependencies
29+
run: poetry install --all-extras
30+
31+
- name: Upload to PyPI
32+
env:
33+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
34+
run: poetry publish --build -u __token__ -p $PYPI_PASSWORD

Jsonformer_example.ipynb

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
{
44
"cell_type": "markdown",
55
"metadata": {
6-
"id": "view-in-github",
7-
"colab_type": "text"
6+
"colab_type": "text",
7+
"id": "view-in-github"
88
},
99
"source": [
1010
"<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>"
@@ -22,8 +22,8 @@
2222
},
2323
"outputs": [
2424
{
25-
"output_type": "stream",
2625
"name": "stdout",
26+
"output_type": "stream",
2727
"text": [
2828
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
2929
"Requirement already satisfied: transformers in /usr/local/lib/python3.10/dist-packages (4.28.1)\n",
@@ -64,7 +64,7 @@
6464
},
6565
{
6666
"cell_type": "code",
67-
"execution_count": 2,
67+
"execution_count": 1,
6868
"metadata": {
6969
"colab": {
7070
"base_uri": "https://localhost:8080/"
@@ -74,8 +74,17 @@
7474
},
7575
"outputs": [
7676
{
77+
"name": "stderr",
7778
"output_type": "stream",
79+
"text": [
80+
"/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",
81+
" from .autonotebook import tqdm as notebook_tqdm\n",
82+
"W0915 16:52:21.949000 36819 torch/distributed/elastic/multiprocessing/redirects.py:29] NOTE: Redirects are currently not supported in Windows or MacOs.\n"
83+
]
84+
},
85+
{
7886
"name": "stdout",
87+
"output_type": "stream",
7988
"text": [
8089
"Loading model and tokenizer...\n",
8190
"Loaded model and tokenizer\n"
@@ -94,7 +103,7 @@
94103
},
95104
{
96105
"cell_type": "code",
97-
"execution_count": 6,
106+
"execution_count": 2,
98107
"metadata": {
99108
"colab": {
100109
"base_uri": "https://localhost:8080/"
@@ -104,40 +113,47 @@
104113
},
105114
"outputs": [
106115
{
116+
"name": "stderr",
107117
"output_type": "stream",
118+
"text": [
119+
"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"
120+
]
121+
},
122+
{
108123
"name": "stdout",
124+
"output_type": "stream",
109125
"text": [
110126
"Generating...\n",
111127
"{\n",
112128
" car: {\n",
113-
" make: \"audi\",\n",
114-
" model: \"model A8\",\n",
115-
" year: 2016.0,\n",
129+
" make: \u001b[32m\"Chevrolet\"\u001b[0m,\n",
130+
" model: \u001b[32m\"Corvette\"\u001b[0m,\n",
131+
" year: \u001b[32m2016.0\u001b[0m,\n",
116132
" colors: [\n",
117-
" \"blue\"\n",
133+
" \u001b[32m\"Red\"\u001b[0m\n",
118134
" ],\n",
119135
" features: {\n",
120136
" audio: {\n",
121-
" brand: \"sony\",\n",
122-
" speakers: 2.0,\n",
123-
" hasBluetooth: True\n",
137+
" brand: \u001b[32m\"Sony\"\u001b[0m,\n",
138+
" speakers: \u001b[32m2.0\u001b[0m,\n",
139+
" hasBluetooth: \u001b[32mTrue\u001b[0m\n",
124140
" },\n",
125141
" safety: {\n",
126-
" airbags: 2.0,\n",
127-
" parkingSensors: True,\n",
128-
" laneAssist: True\n",
142+
" airbags: \u001b[32m2.0\u001b[0m,\n",
143+
" parkingSensors: \u001b[32mTrue\u001b[0m,\n",
144+
" laneAssist: \u001b[32mTrue\u001b[0m\n",
129145
" },\n",
130146
" performance: {\n",
131-
" engine: \"4.0\",\n",
132-
" horsepower: 220.0,\n",
133-
" topSpeed: 220.0\n",
147+
" engine: \u001b[32m\"4.0\"\u001b[0m,\n",
148+
" horsepower: \u001b[32m220.0\u001b[0m,\n",
149+
" topSpeed: \u001b[32m220.0\u001b[0m\n",
134150
" }\n",
135151
" }\n",
136152
" },\n",
137153
" owner: {\n",
138-
" firstName: \"John\",\n",
139-
" lastName: \"Doe\",\n",
140-
" age: 40.0\n",
154+
" firstName: \u001b[32m\"John\"\u001b[0m,\n",
155+
" lastName: \u001b[32m\"Doe\"\u001b[0m,\n",
156+
" age: \u001b[32m40.0\u001b[0m\n",
141157
" }\n",
142158
"}\n"
143159
]
@@ -217,30 +233,40 @@
217233
},
218234
{
219235
"cell_type": "code",
220-
"source": [],
236+
"execution_count": null,
221237
"metadata": {
222238
"id": "0eA8hzFHA1jo"
223239
},
224-
"execution_count": null,
225-
"outputs": []
240+
"outputs": [],
241+
"source": []
226242
}
227243
],
228244
"metadata": {
229245
"accelerator": "GPU",
230246
"colab": {
247+
"include_colab_link": true,
231248
"machine_shape": "hm",
232-
"provenance": [],
233-
"include_colab_link": true
249+
"provenance": []
234250
},
235251
"gpuClass": "premium",
236252
"kernelspec": {
237-
"display_name": "Python 3",
253+
"display_name": ".venv",
254+
"language": "python",
238255
"name": "python3"
239256
},
240257
"language_info": {
241-
"name": "python"
258+
"codemirror_mode": {
259+
"name": "ipython",
260+
"version": 3
261+
},
262+
"file_extension": ".py",
263+
"mimetype": "text/x-python",
264+
"name": "python",
265+
"nbconvert_exporter": "python",
266+
"pygments_lexer": "ipython3",
267+
"version": "3.12.11"
242268
}
243269
},
244270
"nbformat": 4,
245271
"nbformat_minor": 0
246-
}
272+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,4 @@ poetry run python -m jsonformer.example
121121
## License
122122

123123
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.
124+

0 commit comments

Comments
 (0)