Skip to content

Commit 501c73d

Browse files
authored
Migrate to UV (#217)
1 parent 7895e56 commit 501c73d

14 files changed

+5252
-2444
lines changed

.github/workflows/docs.yml

+15-32
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
python-version: [3.11]
25-
node-version: [18]
24+
python-version: [3.12]
25+
node-version: [20]
2626

2727
runs-on: ubuntu-latest
2828

@@ -52,41 +52,24 @@ jobs:
5252
just js-build
5353
5454
# ------------------------------------------------------------------------
55-
# Setup Python
55+
# Python
5656

57-
- name: Set up Python ${{ matrix.python-version }}
58-
uses: actions/setup-python@v5
59-
with:
60-
python-version: ${{ matrix.python-version }}
61-
62-
- uses: actions/cache@v4
63-
id: cached-python-env
64-
with:
65-
path: ${{ env.pythonLocation }}
66-
key: >
67-
python-env
68-
${{ runner.os }}
69-
python-${{ matrix.python-version }}
70-
${{ hashFiles('pyproject.toml') }}
71-
${{ hashFiles('requirements/*') }}
57+
- name: Set up uv
58+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
7259

73-
- name: Install dependencies
74-
# if: steps.cached-python-env.outputs.cache-hit != 'true'
75-
run: pip install -r requirements-dev.lock
76-
77-
- name: Install Hatch
78-
run: pip install --upgrade hatch
79-
80-
# ------------------------------------------------------------------------
81-
# Test
60+
- name: Set up Python ${{ matrix.python-version }}
61+
run: uv python install ${{ matrix.python-version }}
8262

83-
- name: Build package
84-
run: hatch build
63+
- name: Install the project
64+
run: uv sync --all-extras --dev
8565

86-
- name: Install package
66+
- name: Print Python info
8767
run: |
88-
pip install dist/*.tar.gz
89-
pip freeze
68+
uv run which python
69+
uv run python --version
70+
uv run which pip
71+
uv pip --version
72+
uv pip freeze
9073
9174
- name: Build demo docs
9275
run: |

.github/workflows/test.yml

+13-38
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
matrix:
2626
# os: [ubuntu-latest, windows-latest, macos-latest]
2727
python-version: [3.9, "3.10", 3.11, 3.12]
28-
node-version: [18]
28+
node-version: [20]
2929

3030
runs-on: ubuntu-latest
3131

@@ -57,51 +57,26 @@ jobs:
5757
# ------------------------------------------------------------------------
5858
# Python
5959

60-
- name: Set up Python ${{ matrix.python-version }}
61-
uses: actions/setup-python@v4
62-
with:
63-
python-version: ${{ matrix.python-version }}
60+
- name: Set up uv
61+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
6462

65-
- uses: actions/cache@v3
66-
id: cached-python-env
67-
with:
68-
path: ${{ env.pythonLocation }}
69-
key: >
70-
python
71-
${{ runner.os }}
72-
python-${{ matrix.python-version }}
73-
${{ hashFiles('pyproject.toml') }}
74-
${{ hashFiles('requirements*') }}
75-
76-
- name: Install dependencies
77-
if: steps.cached-python-env.outputs.cache-hit != 'true'
78-
run: pip install -r requirements-dev.lock
63+
- name: Set up Python ${{ matrix.python-version }}
64+
run: uv python install ${{ matrix.python-version }}
7965

80-
- name: Install Hatch
81-
run: pip install --upgrade hatch
66+
- name: Install the project
67+
run: uv sync --all-extras --dev
8268

8369
- name: Print Python info
8470
run: |
85-
which python
86-
python --version
87-
which pip
88-
pip --version
89-
pip freeze
90-
91-
# ------------------------------------------------------------------------
92-
# Test
93-
94-
- name: Build package
95-
run: hatch build
96-
97-
- name: Install package
98-
run: |
99-
pip install dist/*.tar.gz
100-
pip freeze
71+
uv run which python
72+
uv run python --version
73+
uv run which pip
74+
uv pip --version
75+
uv pip freeze
10176
10277
- name: Run tests
10378
run: |
104-
pytest .
79+
uv run pytest .
10580
just report
10681
10782
- name: Codecov

CONTRIBUTING.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
Requirements:
66

7-
- Python and rye
7+
- Python and uv
88
- NodeJS and pnpm
99

1010
Create Python env and activate it:
1111

1212
```shell
13-
rye sync
13+
uv sync
1414
```
1515

1616
## Dev cycle
@@ -25,8 +25,8 @@ Python:
2525

2626
Run `mkdocs` in one of the tests configurations:
2727

28-
- `cd mkdocs_jupyter/tests/mkdocs/`
29-
- `mkdocs serve -f material-with-nbs.yml`
28+
- `cd src/mkdocs_jupyter/tests/mkdocs/`
29+
- `uv run mkdocs serve -f material-with-nbs.yml`
3030

3131
Change styles and rebuild the site to see the changes
3232

@@ -45,11 +45,11 @@ just fmt
4545

4646
## JupyterLab styles
4747

48-
We use the JupyterLab styles with some minor modifications
48+
We start from the JupyterLab styles with some minor modifications
4949
to make them more integrated with the mkdocs themes.
5050

5151
We wrap those styles into the `.jupyter-wrapper` CSS class
52-
trying to not break the themes specific CSS.
52+
to try to adapt with mkdocs theme specific CSS.
5353

5454
To update the original styles:
5555

demo/docs/demo-script.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
text = "foo bar\t baz \tqux"
8888

8989
# %%
90-
re.split("\s+", text)
90+
re.split(r"\s+", text)
9191

9292
# %% language="latex"
9393
# \begin{align}

demo/docs/variational-inference-script.py

-5
Original file line numberDiff line numberDiff line change
@@ -301,17 +301,13 @@
301301
#
302302
# ### Let's Code
303303

304-
from pprint import pprint
305304

306-
import arviz as az
307305
import matplotlib.pyplot as plt
308306

309307
# +
310308
# Imports
311309
# %matplotlib inline
312310
import numpy as np
313-
import pandas as pd
314-
import pymc3 as pm
315311
import scipy as sp
316312
import tensorflow as tf
317313
import tensorflow_probability as tfp
@@ -320,7 +316,6 @@
320316
plt.style.use("seaborn-darkgrid")
321317

322318
from tensorflow_probability.python.mcmc.transformed_kernel import (
323-
make_transform_fn,
324319
make_transformed_log_prob,
325320
)
326321

demo/extras/styles.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from pygments import highlight
21
from pygments.formatters import HtmlFormatter
3-
from pygments.lexers import PythonLexer
42

53
print(HtmlFormatter(style="material").get_style_defs(".codehilite"))

js/src/styles/index.scss

+18-1
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,19 @@
5050
.jp-InputArea {
5151
width: 100%;
5252
}
53+
5354
.jp-Cell-inputArea {
5455
width: 100%;
5556
}
57+
5658
.jp-RenderedHTMLCommon {
5759
width: 100%;
5860
}
5961

62+
.jp-Collapser {
63+
display: none;
64+
}
65+
6066
// Markdown cells: Remove Input prompt
6167
.jp-Cell-inputWrapper .jp-InputPrompt {
6268
display: none;
@@ -132,12 +138,15 @@
132138
.jp-InputArea-editor {
133139
width: 1px;
134140
}
141+
135142
.jp-InputPrompt {
136143
overflow: unset;
137144
}
145+
138146
.jp-OutputPrompt {
139147
overflow: unset;
140148
}
149+
141150
.jp-RenderedText {
142151
font-size: var(--jp-code-font-size);
143152
}
@@ -166,10 +175,12 @@
166175
color: black;
167176
font-size: 12px;
168177
table-layout: fixed;
178+
169179
thead {
170180
border-bottom: 1px solid black;
171181
vertical-align: bottom;
172182
}
183+
173184
tr,
174185
th,
175186
td {
@@ -181,17 +192,21 @@
181192
max-width: none;
182193
border: none;
183194
}
195+
184196
th {
185197
font-weight: bold;
186198
}
199+
187200
tbody tr:nth-child(odd) {
188201
background: #f5f5f5;
189202
}
203+
190204
tbody tr:hover {
191205
background: rgba(66, 165, 245, 0.2);
192206
}
193207
}
194-
* + table {
208+
209+
*+table {
195210
margin-top: 1em;
196211
}
197212

@@ -263,9 +278,11 @@
263278
thead {
264279
border-bottom: 1px solid rgba(233, 235, 252, 0.12);
265280
}
281+
266282
tbody tr:nth-child(odd) {
267283
background: #222;
268284
}
285+
269286
tbody tr:hover {
270287
background: rgba(66, 165, 245, 0.2);
271288
}

0 commit comments

Comments
 (0)