Skip to content

Commit

Permalink
Migrate to UV (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfrg authored Sep 4, 2024
1 parent 7895e56 commit 501c73d
Show file tree
Hide file tree
Showing 14 changed files with 5,252 additions and 2,444 deletions.
47 changes: 15 additions & 32 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.11]
node-version: [18]
python-version: [3.12]
node-version: [20]

runs-on: ubuntu-latest

Expand Down Expand Up @@ -52,41 +52,24 @@ jobs:
just js-build
# ------------------------------------------------------------------------
# Setup Python
# Python

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v4
id: cached-python-env
with:
path: ${{ env.pythonLocation }}
key: >
python-env
${{ runner.os }}
python-${{ matrix.python-version }}
${{ hashFiles('pyproject.toml') }}
${{ hashFiles('requirements/*') }}
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install dependencies
# if: steps.cached-python-env.outputs.cache-hit != 'true'
run: pip install -r requirements-dev.lock

- name: Install Hatch
run: pip install --upgrade hatch

# ------------------------------------------------------------------------
# Test
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Build package
run: hatch build
- name: Install the project
run: uv sync --all-extras --dev

- name: Install package
- name: Print Python info
run: |
pip install dist/*.tar.gz
pip freeze
uv run which python
uv run python --version
uv run which pip
uv pip --version
uv pip freeze
- name: Build demo docs
run: |
Expand Down
51 changes: 13 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
matrix:
# os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.9, "3.10", 3.11, 3.12]
node-version: [18]
node-version: [20]

runs-on: ubuntu-latest

Expand Down Expand Up @@ -57,51 +57,26 @@ jobs:
# ------------------------------------------------------------------------
# Python

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

- uses: actions/cache@v3
id: cached-python-env
with:
path: ${{ env.pythonLocation }}
key: >
python
${{ runner.os }}
python-${{ matrix.python-version }}
${{ hashFiles('pyproject.toml') }}
${{ hashFiles('requirements*') }}
- name: Install dependencies
if: steps.cached-python-env.outputs.cache-hit != 'true'
run: pip install -r requirements-dev.lock
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install Hatch
run: pip install --upgrade hatch
- name: Install the project
run: uv sync --all-extras --dev

- name: Print Python info
run: |
which python
python --version
which pip
pip --version
pip freeze
# ------------------------------------------------------------------------
# Test

- name: Build package
run: hatch build

- name: Install package
run: |
pip install dist/*.tar.gz
pip freeze
uv run which python
uv run python --version
uv run which pip
uv pip --version
uv pip freeze
- name: Run tests
run: |
pytest .
uv run pytest .
just report
- name: Codecov
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

Requirements:

- Python and rye
- Python and uv
- NodeJS and pnpm

Create Python env and activate it:

```shell
rye sync
uv sync
```

## Dev cycle
Expand All @@ -25,8 +25,8 @@ Python:

Run `mkdocs` in one of the tests configurations:

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

Change styles and rebuild the site to see the changes

Expand All @@ -45,11 +45,11 @@ just fmt

## JupyterLab styles

We use the JupyterLab styles with some minor modifications
We start from the JupyterLab styles with some minor modifications
to make them more integrated with the mkdocs themes.

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

To update the original styles:

Expand Down
2 changes: 1 addition & 1 deletion demo/docs/demo-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
text = "foo bar\t baz \tqux"

# %%
re.split("\s+", text)
re.split(r"\s+", text)

# %% language="latex"
# \begin{align}
Expand Down
5 changes: 0 additions & 5 deletions demo/docs/variational-inference-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,13 @@
#
# ### Let's Code

from pprint import pprint

import arviz as az
import matplotlib.pyplot as plt

# +
# Imports
# %matplotlib inline
import numpy as np
import pandas as pd
import pymc3 as pm
import scipy as sp
import tensorflow as tf
import tensorflow_probability as tfp
Expand All @@ -320,7 +316,6 @@
plt.style.use("seaborn-darkgrid")

from tensorflow_probability.python.mcmc.transformed_kernel import (
make_transform_fn,
make_transformed_log_prob,
)

Expand Down
2 changes: 0 additions & 2 deletions demo/extras/styles.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.lexers import PythonLexer

print(HtmlFormatter(style="material").get_style_defs(".codehilite"))
19 changes: 18 additions & 1 deletion js/src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@
.jp-InputArea {
width: 100%;
}

.jp-Cell-inputArea {
width: 100%;
}

.jp-RenderedHTMLCommon {
width: 100%;
}

.jp-Collapser {
display: none;
}

// Markdown cells: Remove Input prompt
.jp-Cell-inputWrapper .jp-InputPrompt {
display: none;
Expand Down Expand Up @@ -132,12 +138,15 @@
.jp-InputArea-editor {
width: 1px;
}

.jp-InputPrompt {
overflow: unset;
}

.jp-OutputPrompt {
overflow: unset;
}

.jp-RenderedText {
font-size: var(--jp-code-font-size);
}
Expand Down Expand Up @@ -166,10 +175,12 @@
color: black;
font-size: 12px;
table-layout: fixed;

thead {
border-bottom: 1px solid black;
vertical-align: bottom;
}

tr,
th,
td {
Expand All @@ -181,17 +192,21 @@
max-width: none;
border: none;
}

th {
font-weight: bold;
}

tbody tr:nth-child(odd) {
background: #f5f5f5;
}

tbody tr:hover {
background: rgba(66, 165, 245, 0.2);
}
}
* + table {

*+table {
margin-top: 1em;
}

Expand Down Expand Up @@ -263,9 +278,11 @@
thead {
border-bottom: 1px solid rgba(233, 235, 252, 0.12);
}

tbody tr:nth-child(odd) {
background: #222;
}

tbody tr:hover {
background: rgba(66, 165, 245, 0.2);
}
Expand Down
Loading

0 comments on commit 501c73d

Please sign in to comment.