Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
d6ebd063
Unverified
Commit
d6ebd063
authored
Feb 16, 2021
by
Nikita Titov
Committed by
GitHub
Feb 16, 2021
Browse files
[ci][python] run isort in CI linting job (#3990)
* run isort in CI linting job * workaround conda compatibility issues
parent
4ae59494
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
32 additions
and
43 deletions
+32
-43
.ci/get_workflow_status.py
.ci/get_workflow_status.py
+1
-0
.ci/test.sh
.ci/test.sh
+4
-3
.editorconfig
.editorconfig
+3
-0
.nuget/create_nuget.py
.nuget/create_nuget.py
+0
-2
python-package/lightgbm/__init__.py
python-package/lightgbm/__init__.py
+2
-4
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+1
-2
python-package/lightgbm/compat.py
python-package/lightgbm/compat.py
+1
-2
python-package/lightgbm/dask.py
python-package/lightgbm/dask.py
+6
-9
python-package/lightgbm/engine.py
python-package/lightgbm/engine.py
+1
-2
python-package/lightgbm/sklearn.py
python-package/lightgbm/sklearn.py
+4
-8
tests/python_package_test/test_engine.py
tests/python_package_test/test_engine.py
+2
-5
tests/python_package_test/test_sklearn.py
tests/python_package_test/test_sklearn.py
+7
-6
No files found.
.ci/get_workflow_status.py
View file @
d6ebd063
...
@@ -10,6 +10,7 @@ import json
...
@@ -10,6 +10,7 @@ import json
from
os
import
environ
from
os
import
environ
from
sys
import
argv
,
exit
from
sys
import
argv
,
exit
from
time
import
sleep
from
time
import
sleep
try
:
try
:
from
urllib
import
request
from
urllib
import
request
except
ImportError
:
except
ImportError
:
...
...
.ci/test.sh
View file @
d6ebd063
...
@@ -20,8 +20,8 @@ cd $BUILD_DIRECTORY
...
@@ -20,8 +20,8 @@ cd $BUILD_DIRECTORY
if
[[
$TASK
==
"check-docs"
]]
||
[[
$TASK
==
"check-links"
]]
;
then
if
[[
$TASK
==
"check-docs"
]]
||
[[
$TASK
==
"check-links"
]]
;
then
cd
$BUILD_DIRECTORY
/docs
cd
$BUILD_DIRECTORY
/docs
conda
install
-q
-y
-n
$CONDA_ENV
-c
conda-forge doxygen
conda
install
-q
-y
-n
$CONDA_ENV
-c
conda-forge doxygen
rstcheck
pip
install
--user
-r
requirements.txt
rstcheck
pip
install
--user
-r
requirements.txt
# check reStructuredText formatting
# check reStructuredText formatting
cd
$BUILD_DIRECTORY
/python-package
cd
$BUILD_DIRECTORY
/python-package
rstcheck
--report
warning
`
find
.
-type
f
-name
"*.rst"
`
||
exit
-1
rstcheck
--report
warning
`
find
.
-type
f
-name
"*.rst"
`
||
exit
-1
...
@@ -55,10 +55,11 @@ if [[ $TASK == "lint" ]]; then
...
@@ -55,10 +55,11 @@ if [[ $TASK == "lint" ]]; then
libxml2
\
libxml2
\
"r-xfun>=0.19"
\
"r-xfun>=0.19"
\
"r-lintr>=2.0"
"r-lintr>=2.0"
pip
install
--user
cpplint mypy
pip
install
--user
cpplint
isort
mypy
echo
"Linting Python code"
echo
"Linting Python code"
pycodestyle
--ignore
=
E501,W503
--exclude
=
./.nuget,./external_libs
.
||
exit
-1
pycodestyle
--ignore
=
E501,W503
--exclude
=
./.nuget,./external_libs
.
||
exit
-1
pydocstyle
--convention
=
numpy
--add-ignore
=
D105
--match-dir
=
"^(?!^external_libs|test|example).*"
--match
=
"(?!^test_|setup).*
\.
py"
.
||
exit
-1
pydocstyle
--convention
=
numpy
--add-ignore
=
D105
--match-dir
=
"^(?!^external_libs|test|example).*"
--match
=
"(?!^test_|setup).*
\.
py"
.
||
exit
-1
isort
.
--check-only
||
exit
-1
mypy
--ignore-missing-imports
python-package/
||
true
mypy
--ignore-missing-imports
python-package/
||
true
echo
"Linting R code"
echo
"Linting R code"
Rscript
${
BUILD_DIRECTORY
}
/.ci/lint_r_code.R
${
BUILD_DIRECTORY
}
||
exit
-1
Rscript
${
BUILD_DIRECTORY
}
/.ci/lint_r_code.R
${
BUILD_DIRECTORY
}
||
exit
-1
...
...
.editorconfig
View file @
d6ebd063
...
@@ -9,6 +9,9 @@ indent_size = 2
...
@@ -9,6 +9,9 @@ indent_size = 2
[*.{py,sh,js}]
[*.{py,sh,js}]
indent_size = 4
indent_size = 4
line_length = 120
skip = external_libs
known_first_party = lightgbm
# Placeholder files
# Placeholder files
[{*.gitkeep,__init__.py}]
[{*.gitkeep,__init__.py}]
...
...
.nuget/create_nuget.py
View file @
d6ebd063
...
@@ -3,10 +3,8 @@
...
@@ -3,10 +3,8 @@
import
datetime
import
datetime
import
os
import
os
import
sys
import
sys
from
distutils.file_util
import
copy_file
from
distutils.file_util
import
copy_file
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
source
=
sys
.
argv
[
1
]
source
=
sys
.
argv
[
1
]
current_dir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
current_dir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
...
...
python-package/lightgbm/__init__.py
View file @
d6ebd063
...
@@ -6,8 +6,7 @@ Contributors: https://github.com/microsoft/LightGBM/graphs/contributors.
...
@@ -6,8 +6,7 @@ Contributors: https://github.com/microsoft/LightGBM/graphs/contributors.
import
os
import
os
from
.basic
import
Booster
,
Dataset
,
register_logger
from
.basic
import
Booster
,
Dataset
,
register_logger
from
.callback
import
(
early_stopping
,
print_evaluation
,
record_evaluation
,
from
.callback
import
early_stopping
,
print_evaluation
,
record_evaluation
,
reset_parameter
reset_parameter
)
from
.engine
import
CVBooster
,
cv
,
train
from
.engine
import
CVBooster
,
cv
,
train
try
:
try
:
...
@@ -15,8 +14,7 @@ try:
...
@@ -15,8 +14,7 @@ try:
except
ImportError
:
except
ImportError
:
pass
pass
try
:
try
:
from
.plotting
import
(
create_tree_digraph
,
plot_importance
,
plot_metric
,
from
.plotting
import
create_tree_digraph
,
plot_importance
,
plot_metric
,
plot_split_value_histogram
,
plot_tree
plot_split_value_histogram
,
plot_tree
)
except
ImportError
:
except
ImportError
:
pass
pass
try
:
try
:
...
...
python-package/lightgbm/basic.py
View file @
d6ebd063
...
@@ -14,8 +14,7 @@ from typing import Any, Dict
...
@@ -14,8 +14,7 @@ from typing import Any, Dict
import
numpy
as
np
import
numpy
as
np
import
scipy.sparse
import
scipy.sparse
from
.compat
import
(
PANDAS_INSTALLED
,
concat
,
dt_DataTable
,
is_dtype_sparse
,
from
.compat
import
PANDAS_INSTALLED
,
concat
,
dt_DataTable
,
is_dtype_sparse
,
pd_DataFrame
,
pd_Series
pd_DataFrame
,
pd_Series
)
from
.libpath
import
find_lib_path
from
.libpath
import
find_lib_path
...
...
python-package/lightgbm/compat.py
View file @
d6ebd063
...
@@ -61,8 +61,7 @@ try:
...
@@ -61,8 +61,7 @@ try:
from
sklearn.preprocessing
import
LabelEncoder
from
sklearn.preprocessing
import
LabelEncoder
from
sklearn.utils.class_weight
import
compute_sample_weight
from
sklearn.utils.class_weight
import
compute_sample_weight
from
sklearn.utils.multiclass
import
check_classification_targets
from
sklearn.utils.multiclass
import
check_classification_targets
from
sklearn.utils.validation
import
(
assert_all_finite
,
check_array
,
from
sklearn.utils.validation
import
assert_all_finite
,
check_array
,
check_X_y
check_X_y
)
try
:
try
:
from
sklearn.exceptions
import
NotFittedError
from
sklearn.exceptions
import
NotFittedError
from
sklearn.model_selection
import
GroupKFold
,
StratifiedKFold
from
sklearn.model_selection
import
GroupKFold
,
StratifiedKFold
...
...
python-package/lightgbm/dask.py
View file @
d6ebd063
...
@@ -9,20 +9,17 @@ It is based on dask-lightgbm, which was based on dask-xgboost.
...
@@ -9,20 +9,17 @@ It is based on dask-lightgbm, which was based on dask-xgboost.
import
socket
import
socket
from
collections
import
defaultdict
from
collections
import
defaultdict
from
copy
import
deepcopy
from
copy
import
deepcopy
from
typing
import
Any
,
Callable
,
Dict
,
Iterable
,
List
,
Optional
,
Type
,
Union
,
Set
from
typing
import
Any
,
Callable
,
Dict
,
Iterable
,
List
,
Optional
,
Set
,
Type
,
Union
from
urllib.parse
import
urlparse
from
urllib.parse
import
urlparse
import
numpy
as
np
import
numpy
as
np
import
scipy.sparse
as
ss
import
scipy.sparse
as
ss
from
.basic
import
(
_LIB
,
LightGBMError
,
_choose_param_value
,
_ConfigAliases
,
from
.basic
import
_LIB
,
LightGBMError
,
_choose_param_value
,
_ConfigAliases
,
_log_warning
,
_safe_call
_log_warning
,
_safe_call
)
from
.compat
import
(
DASK_INSTALLED
,
PANDAS_INSTALLED
,
SKLEARN_INSTALLED
,
Client
,
LGBMNotFittedError
,
concat
,
from
.compat
import
(
DASK_INSTALLED
,
PANDAS_INSTALLED
,
SKLEARN_INSTALLED
,
dask_Array
,
dask_DataFrame
,
dask_Series
,
default_client
,
delayed
,
get_worker
,
pd_DataFrame
,
Client
,
LGBMNotFittedError
,
concat
,
dask_Array
,
pd_Series
,
wait
)
dask_DataFrame
,
dask_Series
,
default_client
,
delayed
,
from
.sklearn
import
LGBMClassifier
,
LGBMModel
,
LGBMRanker
,
LGBMRegressor
,
_lgbmmodel_doc_fit
,
_lgbmmodel_doc_predict
get_worker
,
pd_DataFrame
,
pd_Series
,
wait
)
from
.sklearn
import
(
LGBMClassifier
,
LGBMModel
,
LGBMRanker
,
LGBMRegressor
,
_lgbmmodel_doc_fit
,
_lgbmmodel_doc_predict
)
_DaskCollection
=
Union
[
dask_Array
,
dask_DataFrame
,
dask_Series
]
_DaskCollection
=
Union
[
dask_Array
,
dask_DataFrame
,
dask_Series
]
_DaskMatrixLike
=
Union
[
dask_Array
,
dask_DataFrame
]
_DaskMatrixLike
=
Union
[
dask_Array
,
dask_DataFrame
]
...
...
python-package/lightgbm/engine.py
View file @
d6ebd063
...
@@ -7,8 +7,7 @@ from operator import attrgetter
...
@@ -7,8 +7,7 @@ from operator import attrgetter
import
numpy
as
np
import
numpy
as
np
from
.
import
callback
from
.
import
callback
from
.basic
import
(
Booster
,
Dataset
,
LightGBMError
,
_ConfigAliases
,
from
.basic
import
Booster
,
Dataset
,
LightGBMError
,
_ConfigAliases
,
_InnerPredictor
,
_log_warning
_InnerPredictor
,
_log_warning
)
from
.compat
import
SKLEARN_INSTALLED
,
_LGBMGroupKFold
,
_LGBMStratifiedKFold
from
.compat
import
SKLEARN_INSTALLED
,
_LGBMGroupKFold
,
_LGBMStratifiedKFold
...
...
python-package/lightgbm/sklearn.py
View file @
d6ebd063
...
@@ -5,14 +5,10 @@ from inspect import signature
...
@@ -5,14 +5,10 @@ from inspect import signature
import
numpy
as
np
import
numpy
as
np
from
.basic
import
(
Dataset
,
LightGBMError
,
_choose_param_value
,
from
.basic
import
Dataset
,
LightGBMError
,
_choose_param_value
,
_ConfigAliases
,
_log_warning
_ConfigAliases
,
_log_warning
)
from
.compat
import
(
SKLEARN_INSTALLED
,
LGBMNotFittedError
,
_LGBMAssertAllFinite
,
_LGBMCheckArray
,
from
.compat
import
(
SKLEARN_INSTALLED
,
LGBMNotFittedError
,
_LGBMCheckClassificationTargets
,
_LGBMCheckSampleWeight
,
_LGBMCheckXY
,
_LGBMClassifierBase
,
_LGBMAssertAllFinite
,
_LGBMCheckArray
,
_LGBMComputeSampleWeight
,
_LGBMLabelEncoder
,
_LGBMModelBase
,
_LGBMRegressorBase
,
dt_DataTable
,
_LGBMCheckClassificationTargets
,
_LGBMCheckSampleWeight
,
_LGBMCheckXY
,
_LGBMClassifierBase
,
_LGBMComputeSampleWeight
,
_LGBMLabelEncoder
,
_LGBMModelBase
,
_LGBMRegressorBase
,
dt_DataTable
,
pd_DataFrame
)
pd_DataFrame
)
from
.engine
import
train
from
.engine
import
train
...
...
tests/python_package_test/test_engine.py
View file @
d6ebd063
...
@@ -11,11 +11,8 @@ import psutil
...
@@ -11,11 +11,8 @@ import psutil
import
pytest
import
pytest
from
scipy.sparse
import
csr_matrix
,
isspmatrix_csc
,
isspmatrix_csr
from
scipy.sparse
import
csr_matrix
,
isspmatrix_csc
,
isspmatrix_csr
from
sklearn.datasets
import
load_svmlight_file
,
make_multilabel_classification
from
sklearn.datasets
import
load_svmlight_file
,
make_multilabel_classification
from
sklearn.metrics
import
(
average_precision_score
,
log_loss
,
from
sklearn.metrics
import
average_precision_score
,
log_loss
,
mean_absolute_error
,
mean_squared_error
,
roc_auc_score
mean_absolute_error
,
mean_squared_error
,
from
sklearn.model_selection
import
GroupKFold
,
TimeSeriesSplit
,
train_test_split
roc_auc_score
)
from
sklearn.model_selection
import
(
GroupKFold
,
TimeSeriesSplit
,
train_test_split
)
import
lightgbm
as
lgb
import
lightgbm
as
lgb
...
...
tests/python_package_test/test_sklearn.py
View file @
d6ebd063
# coding: utf-8
# coding: utf-8
import
itertools
import
itertools
import
joblib
import
math
import
math
import
os
import
os
import
lightgbm
as
lg
b
import
jobli
b
import
numpy
as
np
import
numpy
as
np
import
pytest
import
pytest
from
pkg_resources
import
parse_version
from
pkg_resources
import
parse_version
from
sklearn
import
__version__
as
sk_version
from
sklearn
import
__version__
as
sk_version
from
sklearn.base
import
clone
from
sklearn.base
import
clone
from
sklearn.datasets
import
load_svmlight_file
,
make_multilabel_classification
from
sklearn.datasets
import
load_svmlight_file
,
make_multilabel_classification
from
sklearn.utils.estimator_checks
import
check_parameters_default_constructible
from
sklearn.metrics
import
log_loss
,
mean_squared_error
from
sklearn.metrics
import
log_loss
,
mean_squared_error
from
sklearn.model_selection
import
GridSearchCV
,
RandomizedSearchCV
,
train_test_split
from
sklearn.model_selection
import
GridSearchCV
,
RandomizedSearchCV
,
train_test_split
from
sklearn.multioutput
import
(
MultiOutputClassifier
,
Classifier
Chain
,
MultiOutputRegressor
,
from
sklearn.multioutput
import
ClassifierChain
,
MultiOutput
Classifier
,
MultiOutputRegressor
,
RegressorChain
RegressorChain
)
from
sklearn.utils.estimator_checks
import
check_parameters_default_constructible
from
sklearn.utils.validation
import
check_is_fitted
from
sklearn.utils.validation
import
check_is_fitted
import
lightgbm
as
lgb
from
.utils
import
load_boston
,
load_breast_cancer
,
load_digits
,
load_iris
,
load_linnerud
from
.utils
import
load_boston
,
load_breast_cancer
,
load_digits
,
load_iris
,
load_linnerud
sk_version
=
parse_version
(
sk_version
)
sk_version
=
parse_version
(
sk_version
)
if
sk_version
<
parse_version
(
"0.23"
):
if
sk_version
<
parse_version
(
"0.23"
):
import
warnings
import
warnings
from
sklearn.exceptions
import
SkipTestWarning
from
sklearn.exceptions
import
SkipTestWarning
from
sklearn.utils.estimator_checks
import
_yield_all_checks
,
SkipTest
from
sklearn.utils.estimator_checks
import
SkipTest
,
_yield_all_checks
else
:
else
:
from
sklearn.utils.estimator_checks
import
parametrize_with_checks
from
sklearn.utils.estimator_checks
import
parametrize_with_checks
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment