Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to uv #622

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "ci"

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]


jobs:
test:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
env:
MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434

strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
- uses: cvxgrp/.github/actions/uv/test@main
with:
python-version: ${{ matrix.python-version }}
15 changes: 8 additions & 7 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
Expand All @@ -30,8 +30,9 @@ jobs:
run: |
pip install pytest pytest-cov
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
fail_ci_if_error: true

# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# files: ./coverage.xml
# fail_ci_if_error: true
46 changes: 0 additions & 46 deletions .github/workflows/main.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: pre-commit

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
#pre-commit:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: pre-commit/[email protected]
# with:
# extra_args: '--verbose --all-files'

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cvxgrp/.github/actions/uv/coverage@main
with:
source-folder: 'pypfopt'



deptry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cvxgrp/.github/actions/uv/deptry@main
with:
source-folder: 'pypfopt'
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ dist
.eggs

artifacts

53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace

#- repo: https://github.com/psf/black
# rev: 24.10.0
# hooks:
# - id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.8.4'
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]

# this will result in massive changes, let's delay
## Run the formatter
#- id: ruff-format


- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
hooks:
- id: check-github-workflows
args: ["--verbose"]

- repo: https://github.com/rhysd/actionlint
rev: v1.7.5
hooks:
- id: actionlint
args: [-ignore, SC]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
hooks:
- id: validate-pyproject

# some work is needed to align the Markdown files with the "standard"
#- repo: https://github.com/igorshubovych/markdownlint-cli
# rev: v0.43.0
# hooks:
# - id: markdownlint-fix
# args: [ "--ignore", "book/**/*.md" ]
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.DEFAULT_GOAL := help

SHELL=/bin/bash

UNAME=$(shell uname -s)

.PHONY: install
install: ## Install a virtual environment with all extras
@curl -LsSf https://astral.sh/uv/install.sh | sh
@uv venv
@uv sync -vv --all-extras


.PHONY: fmt
fmt: install ## Run autoformatting and linting
@uv pip install pre-commit
@uv run pre-commit install
@uv run pre-commit run --all-files


.PHONY: test
test: install ## Run tests
@uv run pytest


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


.PHONY: coverage
coverage: install ## test and coverage
@uv run coverage run --source=cvx/. -m pytest
@uv run coverage report -m
@uv run coverage html

@if [ ${UNAME} == "Darwin" ]; then \
open htmlcov/index.html; \
elif [ ${UNAME} == "linux" ]; then \
xdg-open htmlcov/index.html 2> /dev/null; \
fi


.PHONY: help
help: ## Display this help screen
@echo -e "\033[1mAvailable commands:\033[0m"
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' | sort


.PHONY: deptry
deptry: install ## run deptry
@uv pip install deptry
@uv run deptry -vv pypfopt


.PHONY: jupyter
jupyter: install ## Run jupyter lab in the cookbook folder
@uv pip install jupyterlab nodejs
@uv run jupyter lab
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ while to set up, but it lets you try out the cookbook recipes without having to

_Note: macOS users will need to install [Command Line Tools](https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/)._

_Note: if you are on windows, you first need to installl C++. ([download](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16), [install instructions](https://drive.google.com/file/d/0B4GsMXCRaSSIOWpYQkstajlYZ0tPVkNQSElmTWh1dXFaYkJr/view))_
_Note: if you are on windows, you first need to install C++. ([download](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16), [install instructions](https://drive.google.com/file/d/0B4GsMXCRaSSIOWpYQkstajlYZ0tPVkNQSElmTWh1dXFaYkJr/view))_

This project is available on PyPI, meaning that you can just:

Expand Down Expand Up @@ -211,7 +211,7 @@ Discrete allocation: {'GOOG': 1, 'AAPL': 4, 'FB': 12, 'BABA': 4, 'BBY': 2,
Funds remaining: $11.89
```

_Disclaimer: nothing about this project constitues investment advice, and the author bears no responsibiltiy for your subsequent investment decisions. Please refer to the [license](https://github.com/robertmartin8/PyPortfolioOpt/blob/master/LICENSE.txt) for more information._
_Disclaimer: nothing about this project constitutes investment advice, and the author bears no responsibiltiy for your subsequent investment decisions. Please refer to the [license](https://github.com/robertmartin8/PyPortfolioOpt/blob/master/LICENSE.txt) for more information._

## An overview of classical portfolio optimization methods

Expand Down
4 changes: 2 additions & 2 deletions .dockerignore → docker/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Environments
.env
.venv
../.venv
env/
venv/
ENV/
env.bak/
venv.bak/

*/__pycache__
*/*.pyc
*/*.pyc
3 changes: 0 additions & 3 deletions docs/About.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@ lie in the implementation. At the same time, I realised that existing open-sourc
for several reasons, and that people 'out there' might benefit from a
well-documented and intuitive API. This is what motivated the development of
PyPortfolioOpt.



Loading
Loading