Skip to content

Commit d98426d

Browse files
authored
Use python -m pip instead of the pip executable (#605)
* Use `n_features_in_` instead of `n_features_`. * use `python -m pip` instead of the `pip` executable
1 parent 961ea80 commit d98426d

18 files changed

+51
-51
lines changed

.github/workflows/pythonapp.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ jobs:
3030
- name: Lint with flake8
3131
run: |
3232
python -m pip install --upgrade pip
33-
pip install flake8
33+
python -m pip install flake8
3434
# stop the build if there are Python syntax errors or undefined names
3535
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3636
# The GitHub editor is 127 chars wide
3737
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
3838
# PyTorch for Mac has different pip syntax wrt Win and Linux.
3939
- name: Install pytorch 1.12.0 if mac
4040
if: ${{ matrix.os == 'macos-11' }}
41-
run: pip install torch==1.12.0
41+
run: python -m pip install torch==1.12.0
4242
- name: Install pytorch 1.12.0+cpu if not mac
4343
if: ${{ matrix.os != 'macos-11' }}
44-
run: pip install torch==1.12.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
44+
run: python -m pip install torch==1.12.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
4545
- name: Install basic dependencies
4646
run: |
47-
pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html
47+
python -m pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html
4848
# Compile (but not push) documentation only for one of the runs (Linux py3.8).
4949
- name: Generate Documentation
5050
if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-18.04' }}
@@ -54,7 +54,7 @@ jobs:
5454
find ../. -type f -exec sed -i 's/torch.__version__/"1.12.0"/g' {} +
5555
make sphinx-site -C website/
5656
# now refresh the code
57-
git checkout . && pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html
57+
git checkout . && python -m pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html
5858
- name: Run basic tests without extra
5959
run: pytest
6060
- name: Coverage on basic tests without extra
@@ -73,10 +73,10 @@ jobs:
7373
export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/opt/libomp/lib -L/usr/local/opt/libomp/lib -lomp"
7474
- name: Install extra dependencies
7575
run: |
76-
pip install .[extra,onnx,sparkml]
77-
pip install pandas
78-
- name: pip list
79-
run: pip list
76+
python -m pip install .[extra,onnx,sparkml]
77+
python -m pip install pandas
78+
- name: python -m pip list
79+
run: python -m pip list
8080
- uses: actions/cache@v1
8181
# TVM takes forever, we try to cache it.
8282
if: ${{ matrix.os != 'windows-2019' }}
@@ -129,8 +129,8 @@ jobs:
129129
working-directory: ../../../tvm/python
130130
run: |
131131
python setup.py install
132-
- name: pip list
133-
run: pip list
132+
- name: python -m pip list
133+
run: python -m pip list
134134
# We don't run pytest for Linux py3.8 since we do coverage for that case.
135135
- name: Test with pytest
136136
if: ${{ matrix.python-version != '3.8' || matrix.os != 'ubuntu-18.04' }}

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The simplest setup (assuming you have PyTorch already installed) is:
3535
mkdir hummingbird
3636
cd hummingbird
3737
git clone https://github.com/microsoft/hummingbird.git .
38-
pip install -e .[tests,extra]
38+
python -m pip install -e .[tests,extra]
3939
```
4040

4141
If you do not have pytorch installed, please [install it](https://pytorch.org/get-started/locally/) first.
@@ -51,7 +51,7 @@ For a light-weight, web-based experience, we provide the configuration ([.devcon
5151

5252
### Tools
5353
#### Pre-commit
54-
This project uses [pre-commit](https://pre-commit.com/) hooks. Run `pip install pre-commit` if you don't already have this in your machine. Afterward, run `pre-commit install` to install pre-commit into your git hooks.
54+
This project uses [pre-commit](https://pre-commit.com/) hooks. Run `python -m pip install pre-commit` if you don't already have this in your machine. Afterward, run `pre-commit install` to install pre-commit into your git hooks.
5555

5656
And before you commit, you can run it like this `pre-commit run --all-files` and should see output such as:
5757

@@ -84,7 +84,7 @@ flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
8484

8585
#### Coverage
8686

87-
For coverage, we use [coverage.py](https://coverage.readthedocs.io/en/coverage-5.0.4/) in our Github Actions. Run `pip install coverage` if you don't already have this, and any code you commit should generally not significantly impact coverage.
87+
For coverage, we use [coverage.py](https://coverage.readthedocs.io/en/coverage-5.0.4/) in our Github Actions. Run `python -m pip install coverage` if you don't already have this, and any code you commit should generally not significantly impact coverage.
8888

8989
We strive to not let check-ins decrease coverage. To run all unit tests:
9090
```

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN cd /home/hb-dev && git clone https://github.com/microsoft/hummingbird.git
1414
WORKDIR /home/hb-dev/hummingbird
1515

1616
# Install HB (Note: you may not need all of these packages and can remove some)
17-
RUN sudo pip install -e .[docs,tests,extra,onnx]
17+
RUN sudo python -m pip install -e .[docs,tests,extra,onnx]
1818

1919
# Install precommit hooks
2020
RUN pre-commit install

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ Hummingbird requires PyTorch >= 1.6.0. Please go [here](https://pytorch.org/) fo
7070

7171
Once PyTorch is installed, you can get Hummingbird from pip with:
7272
```
73-
pip install hummingbird-ml
73+
python -m pip install hummingbird-ml
7474
```
7575

7676
If you require the optional dependencies lightgbm and xgboost, you can use:
7777
```
78-
pip install hummingbird-ml[extra]
78+
python -m pip install hummingbird-ml[extra]
7979
```
8080

8181

TROUBLESHOOTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Running PyTorch on GPU:
44

5-
In order to run Hummingbird on PyTorch with GPU, you will need to `pip uninstall torch` and re-install pytorch using the CUDA version of your machine.
5+
In order to run Hummingbird on PyTorch with GPU, you will need to `python -m pip uninstall torch` and re-install pytorch using the CUDA version of your machine.
66

77
### Installation Issues with External Libraries:
88

hummingbird/ml/_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def lightgbm_installed():
120120
def assert_lightgbm_installed():
121121
assert (
122122
lightgbm_installed()
123-
), "To convert LightGBM models you need to install LightGBM (or `pip install hummingbird-ml[extra]`)."
123+
), "To convert LightGBM models you need to install LightGBM (or `python -m pip install hummingbird-ml[extra]`)."
124124

125125

126126
def xgboost_installed():
@@ -151,7 +151,7 @@ def xgboost_installed():
151151
def assert_xgboost_installed():
152152
assert (
153153
xgboost_installed()
154-
), "To convert XGBoost models you need to install XGBoost (or `pip install hummingbird-ml[extra]`)."
154+
), "To convert XGBoost models you need to install XGBoost (or `python -m pip install hummingbird-ml[extra]`)."
155155

156156

157157
def tvm_installed():

notebooks/LGBM-ONNX-example.ipynb

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"cells": [
33
{
4+
"cell_type": "markdown",
5+
"metadata": {},
46
"source": [
57
"### This notebook shows how to convert from LGBM to ONNX"
6-
],
7-
"cell_type": "markdown",
8-
"metadata": {}
8+
]
99
},
1010
{
1111
"cell_type": "code",
@@ -14,7 +14,7 @@
1414
"outputs": [],
1515
"source": [
1616
"# Uncomment and run this cell if you need to install Hummingbird and ONNX\n",
17-
"#!pip install hummingbird_ml[extra,onnx]"
17+
"#!python -m pip install hummingbird_ml[extra,onnx]"
1818
]
1919
},
2020
{
@@ -42,14 +42,14 @@
4242
"metadata": {},
4343
"outputs": [
4444
{
45-
"output_type": "execute_result",
4645
"data": {
4746
"text/plain": [
4847
"LGBMClassifier()"
4948
]
5049
},
50+
"execution_count": 3,
5151
"metadata": {},
52-
"execution_count": 3
52+
"output_type": "execute_result"
5353
}
5454
],
5555
"source": [
@@ -64,8 +64,8 @@
6464
"metadata": {},
6565
"outputs": [
6666
{
67-
"output_type": "stream",
6867
"name": "stdout",
68+
"output_type": "stream",
6969
"text": [
7070
"Finished loading model, total used 100 iterations\n"
7171
]
@@ -84,8 +84,8 @@
8484
},
8585
"outputs": [
8686
{
87-
"output_type": "stream",
8887
"name": "stdout",
88+
"output_type": "stream",
8989
"text": [
9090
"502 ms ± 17.2 ms per loop (mean ± std. dev. of 3 runs, 1 loop each)\n"
9191
]
@@ -120,4 +120,4 @@
120120
},
121121
"nbformat": 4,
122122
"nbformat_minor": 2
123-
}
123+
}

notebooks/LGBM-ONNXML-example.ipynb

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"cells": [
33
{
4+
"cell_type": "markdown",
5+
"metadata": {},
46
"source": [
57
"### This notebook shows how to convert from LGBM to ONNX and provides an example of the ONNXML converter"
6-
],
7-
"cell_type": "markdown",
8-
"metadata": {}
8+
]
99
},
1010
{
1111
"cell_type": "code",
@@ -14,7 +14,7 @@
1414
"outputs": [],
1515
"source": [
1616
"# Uncomment and run this cell if you need to install Hummingbird and ONNX\n",
17-
"#!pip install hummingbird_ml[extra,onnx]"
17+
"#!python -m pip install hummingbird_ml[extra,onnx]"
1818
]
1919
},
2020
{
@@ -46,14 +46,14 @@
4646
"metadata": {},
4747
"outputs": [
4848
{
49-
"output_type": "execute_result",
5049
"data": {
5150
"text/plain": [
5251
"LGBMClassifier()"
5352
]
5453
},
54+
"execution_count": 3,
5555
"metadata": {},
56-
"execution_count": 3
56+
"output_type": "execute_result"
5757
}
5858
],
5959
"source": [
@@ -93,8 +93,8 @@
9393
},
9494
"outputs": [
9595
{
96-
"output_type": "stream",
9796
"name": "stdout",
97+
"output_type": "stream",
9898
"text": [
9999
"507 ms ± 16.8 ms per loop (mean ± std. dev. of 3 runs, 1 loop each)\n"
100100
]
@@ -129,4 +129,4 @@
129129
},
130130
"nbformat": 4,
131131
"nbformat_minor": 2
132-
}
132+
}

notebooks/LGBM-example.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"!pip install hummingbird_ml[extra]"
9+
"!python -m pip install hummingbird_ml[extra]"
1010
]
1111
},
1212
{

0 commit comments

Comments
 (0)