-
Notifications
You must be signed in to change notification settings - Fork 116
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
[MNT] [DOC] use uv in build, add precommit, fix ruff style and typo #107
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx the PR!
Moving to uv
and adding pre-commit is a good idea.
Let's ensure the Pipeline is as simple and clean as possible.
Also, could you rename the PR to smth related to uv and pre-commit?
Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By experience, Makefile should only be used when you need to re-use long commands which is not our case.
I would be in favour of simplicity and readability by keeping the commands in the ymls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, please check
Makefile
Outdated
@@ -0,0 +1,46 @@ | |||
.PHONY: uv-download |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the action "astral-sh/setup-uv@v4" seems to be the preferred way:
https://docs.astral.sh/uv/guides/integration/github/#installation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was already done
Makefile
Outdated
uv venv | ||
ifeq ($(OS),Windows_NT) | ||
# Windows-specific virtual environment activation | ||
. .venv/Scripts/activate && uv pip install -e .[tests] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use "uv sync --dev", rename "tests" by "dev" in pyproject.toml and move it to the new "[dependency-groups]" instead of "[project.optional-dependencies]"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we are ready to move to [dependency-groups]:
The only one supporting it is https://hatch.pypa.io/latest/
but I wouldn't go that far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the toml, see if good enough now
.github/workflows/tests.yml
Outdated
@@ -28,17 +28,27 @@ jobs: | |||
- name: Upgrade pip | |||
run: python -m pip install --upgrade pip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't need that "Upgrade pip" anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.github/workflows/tests.yml
Outdated
@@ -28,17 +28,27 @@ jobs: | |||
- name: Upgrade pip | |||
run: python -m pip install --upgrade pip | |||
|
|||
- name: Install dependencies | |||
run: pip install ".[tests]" | |||
- name: Cache Python packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be done with https://docs.astral.sh/uv/guides/integration/github/#caching
- name: Enable caching
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you, done
pyproject.toml
Outdated
@@ -85,6 +86,12 @@ docs = [ | |||
"jupyterlite-pyodide-kernel", | |||
"nbformat", | |||
] | |||
dev = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's merge test
into dev
and move them (with docs) to the new "[dependency-groups]" (we don't need to build dev and docs from PyPI, just locally).
I don't think isort
is useful as sorting is now done in ruff
What's the reason to include pydocstyle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above on why not dependency-groups.
isort can go, did some experiments with pydocstyle, pushed by mistake
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #107 +/- ##
==========================================
- Coverage 99.07% 94.86% -4.21%
==========================================
Files 41 126 +85
Lines 3226 8083 +4857
==========================================
+ Hits 3196 7668 +4472
- Misses 30 415 +385 ☔ View full report in Codecov by Sentry. |
.github/workflows/docs.yml
Outdated
with: | ||
version: "latest" | ||
enable-cache: true | ||
cache-dependency-glob: "requirements**.txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requirements files are now legacy, they should be avoided (duplicate info with pyproject.toml).
I guess you did that because you want to avoid cache invalidation from uv each time unrelated change occurs in pyproject.toml. In that case, having more frequent invalidation would be better than re-introducing legacy files.
Let's drop this lien, "cache-dependency-glob" (the default will be pyproject.toml)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I still would like to have a requirements.in / uv.lock file to be used for both caching and releases:
https://docs.astral.sh/uv/guides/projects/#uvlock
uv.lock is a cross-platform lockfile that contains exact information about your project's dependencies. Unlike the pyproject.toml which is used to specify the broad requirements of your project, the lockfile contains the exact resolved versions that are installed in the project environment. This file should be checked into version control, allowing for consistent and reproducible installations across machines.
And removing this defaults to uv.lock, instead of the toml:
https://github.com/astral-sh/setup-uv/tree/v4/?tab=readme-ov-file#cache-dependency-glob
I have just fixed pushing the lock (uv lock)
.github/workflows/docs.yml
Outdated
run: pip install ".[docs]" | ||
run: | | ||
uv venv | ||
uv pip install ".[docs]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recommended way seems to be uv install --extras doc
, otherwise uv
still relies on pip.
Correct me if my understand is wrong.
I would also separate the virtual env setup in specific step:
- name: Set up virtual environment
run: uv venv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Note:
uv install
error: unrecognized subcommand 'install'
tip: a similar subcommand exists: 'uv pip install'
Usage: uv [OPTIONS]
For more information, try '--help'.
Locking seems to work (beside caching) without additional cli inputs:
uv pip install -r pyproject.toml --extra dev
Resolved 34 packages in 615ms
Prepared 34 packages in 11.91s
Installed 34 packages in 344ms
+ cfgv==3.4.0
+ clarabel==0.9.0
+ coverage==7.6.9
+ cvxpy==1.6.0
+ distlib==0.3.9
+ filelock==3.16.1
+ identify==2.6.3
+ iniconfig==2.0.0
+ joblib==1.4.2
+ nodeenv==1.9.1
+ numpy==2.2.1
+ osqp==0.6.7.post3
+ packaging==24.2
+ pandas==2.2.3
+ platformdirs==4.3.6
+ plotly==5.24.1
+ pluggy==1.5.0
+ pre-commit==4.0.1
+ pyscipopt==5.2.1
+ pytest==8.3.4
+ pytest-cov==6.0.0
+ python-dateutil==2.9.0.post0
+ pytz==2024.2
+ pyyaml==6.0.2
+ qdldl==0.1.7.post4
+ ruff==0.8.4
+ scikit-learn==1.6.0
+ scipy==1.14.1
+ scs==3.2.7
+ six==1.17.0
+ tenacity==9.0.0
+ threadpoolctl==3.5.0
+ tzdata==2024.2
+ virtualenv==20.28.0
.github/workflows/tests.yml
Outdated
with: | ||
version: "latest" | ||
enable-cache: true | ||
cache-dependency-glob: "requirements**.txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see same comment in docs.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, see above
.github/workflows/tests.yml
Outdated
run: ruff check --output-format=github | ||
run: | | ||
uv venv | ||
uv pip install -e ".[dev]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see same comment in docs.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, see above
.github/workflows/tests.yml
Outdated
|
||
- name: Run and write pytest | ||
run: pytest --cov=./ --cov-report=xml | ||
run: | | ||
uv run pytest --cov=./ --cov-report=xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is only one cmd line, not sure the "|" is needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pyproject.toml
Outdated
@@ -1,28 +1,19 @@ | |||
[build-system] | |||
requires = ["setuptools"] | |||
build-backend = "setuptools.build_meta" | |||
requires = ["hatchling"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed, let's keep setuptools for the moment (more flexible and stable). Let's monitor Hatchling to see if it becomes relevant to use it in the future (but we will need to properly test the build output before we integrate it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, ok, done
@@ -80,18 +88,11 @@ docs = [ | |||
"sphinx-prompt", | |||
"sphinxext.opengraph", | |||
"sphinx-sitemap", | |||
"sphinx-favicon", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what' the reason to remove sphinx-favicon
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate entry
requirements.in
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove (see comment in docs.yml)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
requirements.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove (see comment in docs.yml)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add "I005", # Explicitly ensure sorting of __all__
in [tool.ruff.lint] select.
This rule was deactivated in project.toml because of the other ones, but not in your initial pre-commit args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ruff failed
Cause: Failed to parse /Users/mattettam09/Desktop/code/skfolio/pyproject.toml
Cause: TOML parse error at line 121, column 1
|
121 | [tool.ruff.lint]
| ^^^^^^^^^^^^^^^^
Unknown rule selector: I005
.github/workflows/build.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, the build is done in the realise GitHub action, so it's more appropriate to keep the name as "tests".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
CONTRIBUTING.md
Outdated
|
||
or using **uv**: | ||
```shell | ||
$ uv pip install -r pyproject.toml --extra dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like also with uv
, install should be in editable mode: uv pip install -r pyproject.toml --editable . --extra dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONTRIBUTING.md
Outdated
```shell | ||
$ pip install --editable ".[docs]" | ||
$ cd docs | ||
$ sphinx-build . _build | ||
``` | ||
or using **uv**: | ||
```shell | ||
$ uv pip install -r pyproject.toml --extra docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv pip install -r pyproject.toml --editable . --extra docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, thx!
Reference Issues/PRs
What does this implement/fix? Explain your changes.
Does your contribution introduce a new dependency? If yes, which one?
What should a reviewer concentrate their feedback on?
Did you add any tests for the change?
Any other comments?
PR checklist
For all contributions
For new estimators
docs/api.rst
.examples
section.