Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4ae635e

Browse filesBrowse files
committed
feat: use uv for project management
1 parent f99752d commit 4ae635e
Copy full SHA for 4ae635e

5 files changed

+2,218-55Lines changed: 2218 additions & 55 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+7-11Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,19 @@ jobs:
99
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
1010
steps:
1111
- uses: actions/checkout@v4
12-
- name: Set up Python ${{ matrix.python-version }}
13-
uses: actions/setup-python@v5
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v5
1414
with:
1515
python-version: ${{ matrix.python-version }}
16-
cache: pip
17-
cache-dependency-path: setup.py
16+
enable-cache: true
1817
- name: Install dependencies
19-
run: |
20-
python -m pip install --upgrade pip
21-
pip install -e '.[MongoTrials, SparkTrials, ATPE, dev]'
22-
pip install pyspark
18+
run: uv sync --group dev
2319
- name: Test with pytest - Unit tests
2420
run: |
25-
python -m pytest ./hyperopt/tests/unit
21+
uv run pytest ./hyperopt/tests/unit
2622
- name: Test spark plugin - pin thread mode
2723
run: |
28-
PYSPARK_PIN_THREAD=true pytest hyperopt/tests/integration/test_spark.py
24+
PYSPARK_PIN_THREAD=true uv run pytest hyperopt/tests/integration/test_spark.py
2925
- name: Test spark plugin - non pin thread mode
3026
run: |
31-
PYSPARK_PIN_THREAD=false pytest hyperopt/tests/integration/test_spark.py
27+
PYSPARK_PIN_THREAD=false uv run pytest hyperopt/tests/integration/test_spark.py
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+31-34Lines changed: 31 additions & 34 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Install hyperopt from PyPI
2020

2121
```bash
2222
pip install hyperopt
23+
# or with uv
24+
uv add hyperopt
2325
```
2426

2527
to run your first example
@@ -57,6 +59,12 @@ If you're a developer and wish to contribute, please follow these steps.
5759

5860
### Setup (based on [this](https://scikit-learn.org/stable/developers/contributing.html#contributing-code))
5961

62+
This project uses [uv](https://docs.astral.sh/uv/) for dependency management. Install it first if you haven’t:
63+
64+
```bash
65+
curl -LsSf https://astral.sh/uv/install.sh | sh
66+
```
67+
6068
1. Create an account on GitHub if you do not already have one.
6169

6270
2. Fork the project repository: click on the ‘Fork’ button near the top of the page. This creates a copy of the code under your account on the GitHub user account. For more details on how to fork a repository see [this guide](https://help.github.com/articles/fork-a-repo/).
@@ -68,79 +76,68 @@ If you're a developer and wish to contribute, please follow these steps.
6876
cd hyperopt
6977
```
7078

71-
4. Create environment with:
72-
`$ python3 -m venv my_env` or `$ python -m venv my_env`
73-
or with conda:
74-
`$ conda create -n my_env python=3`
79+
4. Install all dependencies (uv creates and manages the virtual environment automatically):
7580

76-
5. Activate the environment:
77-
`$ source my_env/bin/activate`
78-
or with conda:
79-
`$ conda activate my_env`
80-
81-
6. Install dependencies for extras (you'll need these to run pytest):
82-
Linux/UNIX:
83-
`$ pip install -e '.[MongoTrials, SparkTrials, ATPE, dev]'`
84-
85-
or Windows:
86-
87-
```cmd
88-
pip install -e .[MongoTrials]
89-
pip install -e .[SparkTrials]
90-
pip install -e .[ATPE]
91-
pip install -e .[dev]
81+
```bash
82+
uv sync --group dev
9283
```
9384

94-
7. Add the upstream remote. This saves a reference to the main hyperopt repository, which you can use to keep your repository synchronized with the latest changes:
85+
5. Add the upstream remote. This saves a reference to the main hyperopt repository, which you can use to keep your repository synchronized with the latest changes:
9586

96-
`$ git remote add upstream https://github.com/hyperopt/hyperopt.git`
87+
```bash
88+
git remote add upstream https://github.com/hyperopt/hyperopt.git
89+
```
9790

9891
You should now have a working installation of hyperopt, and your git repository properly configured. The next steps now describe the process of modifying code and submitting a PR:
9992

100-
8. Synchronize your master branch with the upstream master branch:
93+
6. Synchronize your master branch with the upstream master branch:
10194

10295
```bash
10396
git checkout master
10497
git pull upstream master
10598
```
10699

107-
9. Create a feature branch to hold your development changes:
100+
7. Create a feature branch to hold your development changes:
108101

109-
`$ git checkout -b my_feature`
102+
```bash
103+
git checkout -b my_feature
104+
```
110105

111106
and start making changes. Always use a feature branch. It’s good practice to never work on the master branch!
112107

113-
10. We recommend to use [Black](https://github.com/psf/black) to format your code before submitting a PR which is installed automatically in step 6.
108+
8. We recommend to use [Black](https://github.com/psf/black) to format your code before submitting a PR, which is installed automatically in step 4.
114109

115-
11. Then, once you commit ensure that git hooks are activated (Pycharm for example has the option to omit them). This can be done using [pre-commit](https://pre-commit.com/), which is installed automatically in step 6, as follows:
110+
9. Then, once you commit ensure that git hooks are activated (Pycharm for example has the option to omit them). This can be done using [pre-commit](https://pre-commit.com/), which is installed automatically in step 4, as follows:
116111

117112
```bash
118-
pre-commit install
113+
uv run pre-commit install
119114
```
120115

121116
This will run black automatically when you commit on all files you modified, failing if there are any files requiring to be blacked. In case black does not run execute the following:
122117

123118
```bash
124-
black {source_file_or_directory}
119+
uv run black {source_file_or_directory}
125120
```
126121

127-
12. Develop the feature on your feature branch on your computer, using Git to do the version control. When you’re done editing, add changed files using git add and then git commit:
122+
10. Develop the feature on your feature branch on your computer, using Git to do the version control. When you’re done editing, add changed files using git add and then git commit:
128123

129124
```bash
130125
git add modified_files
131126
git commit -m "my first hyperopt commit"
132127
```
133128

134-
13. The tests for this project use [PyTest](https://docs.pytest.org/en/latest/) and can be run by calling `pytest`.
129+
11. The tests for this project use [PyTest](https://docs.pytest.org/en/latest/) and can be run with:
135130

136-
14. Record your changes in Git, then push the changes to your GitHub account with:
131+
```bash
132+
uv run pytest
133+
```
134+
135+
12. Record your changes in Git, then push the changes to your GitHub account with:
137136

138137
```bash
139138
git push -u origin my_feature
140139
```
141140

142-
Note that dev dependencies require python 3.6+.
143-
144141
## Algorithms
145142

146143
Currently three algorithms are implemented in hyperopt:
Collapse file

‎pyproject.toml‎

Copy file name to clipboardExpand all lines: pyproject.toml
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,20 @@ dependencies = [
4545
SparkTrials = ["pyspark", "py4j"]
4646
MongoTrials = ["pymongo>=4.0.0"]
4747
ATPE = ["lightgbm", "scikit-learn"]
48-
dev = ["black", "pre-commit", "pytest", "packaging"]
48+
49+
[dependency-groups]
50+
testing = [
51+
"pytest",
52+
"hyperopt[SparkTrials,MongoTrials,ATPE]" # install witl all deps when testing
53+
]
54+
lint = [
55+
"mypy",
56+
]
57+
dev = [
58+
{include-group = "testing"},
59+
{include-group = "lint"},
60+
"pre-commit",
61+
]
4962

5063
[project.urls]
5164
Homepage = "https://hyperopt.github.io/hyperopt"
@@ -65,3 +78,11 @@ hyperopt = ["atpe_models/**"]
6578

6679
[tool.setuptools.dynamic]
6780
version = { attr = "hyperopt.__version__" }
81+
82+
[tool.pytest.ini_options]
83+
norecursedirs = [
84+
"dist",
85+
"build",
86+
".venv",
87+
".nox",
88+
]
Collapse file

‎setup.py‎

Copy file name to clipboardExpand all lines: setup.py
-9Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.