Skip to content

Commit 8683c90

Browse files
Updates for uv (#283)
* Makefile, uv.lock and updated pyproject * remove poetry.lock * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pre-commit with uv actions * testing with uv action * install seaborn and matplotlib as dev dependencies * remove the poetry traces in pyproject.toml * update creation of book * testing requires now a checkout before * formatting of py files in package * formatting of py files in package * apply ruff * dispatch --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e09af58 commit 8683c90

38 files changed

+1473
-1441
lines changed

.github/workflows/book.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
name: "book"
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
4+
- push
85

96
jobs:
10-
test:
7+
marimo:
118
runs-on: "ubuntu-latest"
129
steps:
13-
- uses: cvxgrp/.github/actions/coverage@v1.4.0
10+
- name: Checkout [${{ github.repository }}]
11+
uses: actions/checkout@v4
12+
13+
- uses: cvxgrp/.github/actions/uv/marimo@v2.0.6
1414

15-
pdoc:
15+
test:
1616
runs-on: "ubuntu-latest"
1717
steps:
18-
- uses: cvxgrp/.github/actions/pdoc@v1.4.0
18+
- name: Checkout [${{ github.repository }}]
19+
uses: actions/checkout@v4
1920

21+
- uses: cvxgrp/.github/actions/uv/coverage@v2.0.6
2022

2123
jupyter:
2224
runs-on: "ubuntu-latest"
2325
steps:
24-
- uses: cvxgrp/.github/actions/jupyter@v1.4.0
26+
- name: Checkout [${{ github.repository }}]
27+
uses: actions/checkout@v4
28+
29+
- uses: cvxgrp/.github/actions/uv/jupyter@v2.0.6
2530

2631
book:
2732
runs-on: "ubuntu-latest"
28-
needs: [test, pdoc, jupyter]
33+
needs: [test, jupyter, marimo]
2934

3035
permissions:
3136
contents: write
3237

3338
steps:
34-
- uses: cvxgrp/.github/actions/book@v1.4.0
39+
- name: Checkout [${{ github.repository }}]
40+
uses: actions/checkout@v4
41+
42+
- uses: cvxgrp/.github/actions/book@v2.0.6

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ jobs:
1515

1616
# Steps represent a sequence of tasks that will be executed as part of the job
1717
steps:
18-
- uses: cvxgrp/.github/actions/test@v1.4.0
18+
- name: Checkout [${{ github.repository }}]
19+
uses: actions/checkout@v4
20+
21+
- uses: cvxgrp/.github/actions/uv/test@v2.0.9
1922
with:
2023
os: ${{ matrix.os }}
2124
python-version: ${{ matrix.python-version }}

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@ on:
77
jobs:
88
test:
99
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout [${{ github.repository }}]
12+
uses: actions/checkout@v4
13+
14+
- uses: cvxgrp/.github/actions/uv/coverage@v2.0.9
1015

16+
- name: Coveralls GitHub Action
17+
uses: coverallsapp/github-action@v2
18+
with:
19+
files: artifacts/tests/coverage/coverage.info
20+
format: lcov
21+
22+
deptry:
23+
runs-on: ubuntu-latest
1124
steps:
12-
- uses: cvxgrp/.github/actions/coverage@v1.4.0
25+
- name: Checkout [${{ github.repository }}]
26+
uses: actions/checkout@v4
1327

14-
# uncomment once the repo is public
15-
- name: Coveralls GitHub Action
16-
uses: coverallsapp/github-action@v2
17-
with:
18-
files: artifacts/tests/coverage/coverage.info
19-
format: lcov
28+
- uses: cvxgrp/.github/actions/uv/deptry@v2.0.9

.github/workflows/release.yml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,50 @@
1-
name: Upload Python Package
1+
name: Bump version and publish
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: [ "CI" ]
7+
types: [ completed ]
68

79
jobs:
8-
build:
10+
tag:
11+
permissions:
12+
contents: write
13+
14+
if: >
15+
github.event_name == 'workflow_dispatch' ||
16+
(github.event.workflow_run.conclusion == 'success' &&
17+
github.event.workflow_run.head_branch == 'main')
18+
919
runs-on: ubuntu-latest
20+
1021
steps:
11-
- uses: actions/checkout@v4
12-
- uses: cvxgrp/.github/actions/build@v1.4.0
22+
- name: Checkout [${{ github.repository }}]
23+
uses: actions/checkout@v4
1324

14-
deploy:
25+
- name: Generate Tag
26+
uses: cvxgrp/.github/actions/uv/tag@v2.0.9
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
publish:
31+
needs: tag
1532
runs-on: ubuntu-latest
16-
needs: build
1733
environment: release
1834

1935
permissions:
36+
contents: read
2037
# This permission is required for trusted publishing.
2138
id-token: write
2239

2340
steps:
24-
- uses: cvxgrp/.github/actions/publish@v1.4.0
41+
- name: Checkout [${{ github.repository }}]
42+
uses: actions/checkout@v4
43+
44+
- uses: actions/download-artifact@v4
45+
with:
46+
name: dist
47+
path: dist
48+
49+
- name: Publish to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1

.pre-commit-config.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ repos:
1111
hooks:
1212
- id: ruff
1313
args: [ --fix, --exit-non-zero-on-fix ]
14+
# Run the formatter
15+
- id: ruff-format
1416

1517
- repo: https://github.com/igorshubovych/markdownlint-cli
1618
rev: v0.44.0
1719
hooks:
18-
- id: markdownlint-fix
19-
args: [ "--ignore", "book/**/*.md" ]
20+
- id: markdownlint
2021

2122
- repo: https://github.com/asottile/pyupgrade
2223
rev: v3.19.1
@@ -31,3 +32,14 @@ repos:
3132

3233
- id: check-github-workflows
3334
args: ["--verbose"]
35+
36+
- repo: https://github.com/rhysd/actionlint
37+
rev: v1.7.7
38+
hooks:
39+
- id: actionlint
40+
args: [-ignore, SC]
41+
42+
- repo: https://github.com/abravalheri/validate-pyproject
43+
rev: v0.23
44+
hooks:
45+
- id: validate-pyproject

Makefile

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,47 @@
11
.DEFAULT_GOAL := help
22

3-
SHELL=/bin/bash
3+
venv:
4+
@curl -LsSf https://astral.sh/uv/install.sh | sh
5+
@uv venv --python='3.12'
46

5-
UNAME=$(shell uname -s)
67

78
.PHONY: install
8-
install: ## Install a virtual environment
9-
@poetry install -vv
9+
install: venv ## Install a virtual environment
10+
@uv pip install --upgrade pip
11+
@uv sync --all-extras --dev --frozen
12+
1013

1114
.PHONY: fmt
12-
fmt: ## Run autoformatting and linting
13-
@poetry run pip install pre-commit
14-
@poetry run pre-commit install
15-
@poetry run pre-commit run --all-files
15+
fmt: venv ## Run autoformatting and linting
16+
@uv pip install pre-commit
17+
@uv run pre-commit install
18+
@uv run pre-commit run --all-files
1619

17-
.PHONY: test
18-
test: install ## Run tests
19-
@poetry run pytest
2020

2121
.PHONY: clean
2222
clean: ## Clean up caches and build artifacts
2323
@git clean -X -d -f
2424

2525

26-
.PHONY: coverage
27-
coverage: install ## test and coverage
28-
@poetry run coverage run --source=cvx/. -m pytest
29-
@poetry run coverage report -m
30-
@poetry run coverage html
31-
32-
@if [ ${UNAME} == "Darwin" ]; then \
33-
open htmlcov/index.html; \
34-
elif [ ${UNAME} == "linux" ]; then \
35-
xdg-open htmlcov/index.html 2> /dev/null; \
36-
fi
37-
38-
3926
.PHONY: help
4027
help: ## Display this help screen
4128
@echo -e "\033[1mAvailable commands:\033[0m"
4229
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' | sort
4330

4431

45-
.PHONY: jupyter
46-
jupyter: install ## Run jupyter lab
47-
@poetry run pip install jupyterlab
48-
@poetry run jupyter lab
32+
.PHONY: marimo
33+
marimo: install ## Install Marimo
34+
@uv pip install marimo
35+
@uv run marimo edit book/marimo
4936

5037

51-
.PHONY: marimo
52-
marimo: install ## Run jupyter lab
53-
@poetry run pip install marimo
54-
@poetry run marimo edit book/marimo
38+
.PHONY: test
39+
test: install ## Run pytests
40+
@uv pip install pytest
41+
@uv run pytest tests
42+
43+
44+
.PHONY: jupyter
45+
jupyter: install ## Run jupyter lab
46+
@uv pip install jupyterlab
47+
@uv run jupyter lab

book/docs/index.md

Lines changed: 0 additions & 95 deletions
This file was deleted.

book/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../README.md

book/marimo/demo.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def _(__file__):
2525
@app.cell
2626
def _(path, pd):
2727
# Load historic price data of 20 stocks
28-
prices = pd.read_csv(
29-
path / "data" / "stock_prices.csv", header=0, index_col=0, parse_dates=True
30-
)
28+
prices = pd.read_csv(path / "data" / "stock_prices.csv", header=0, index_col=0, parse_dates=True)
3129
return (prices,)
3230

3331

@@ -52,9 +50,7 @@ def _(from_ewmas, pd, returns):
5250

5351
combinations = from_ewmas(returns, pairs, clip_at=4.2, mean=True)
5452

55-
weights = pd.DataFrame(
56-
{result.time: result.weights for result in combinations.solve(window=10)}
57-
).transpose()
53+
weights = pd.DataFrame({result.time: result.weights for result in combinations.solve(window=10)}).transpose()
5854
weights
5955
return combinations, pairs, weights
6056

0 commit comments

Comments
 (0)