Skip to content

Commit

Permalink
Apply black and ruff. (onnx#635)
Browse files Browse the repository at this point in the history
* Apply black and ruff.

Signed-off-by: Xavier Dupre <[email protected]>

* lint

Signed-off-by: Xavier Dupre <[email protected]>

* update ci

Signed-off-by: Xavier Dupre <[email protected]>

* fix req

Signed-off-by: Xavier Dupre <[email protected]>

* restore __init__.py

Signed-off-by: Xavier Dupre <[email protected]>

* ci

Signed-off-by: Xavier Dupre <[email protected]>

* requirements

Signed-off-by: Xavier Dupre <[email protected]>

* fix handle

Signed-off-by: Xavier Dupre <[email protected]>

* disable coremltools test

Signed-off-by: Xavier Dupre <[email protected]>

* fix missing import

Signed-off-by: Xavier Dupre <[email protected]>

* fix missing import

Signed-off-by: Xavier Dupre <[email protected]>

* import

Signed-off-by: Xavier Dupre <[email protected]>

---------

Signed-off-by: Xavier Dupre <[email protected]>
Signed-off-by: Xavier Dupré <[email protected]>
Signed-off-by: Xavier Dupre <[email protected]>
  • Loading branch information
xadupre committed Aug 1, 2023
1 parent 174e5d9 commit 2b70976
Show file tree
Hide file tree
Showing 261 changed files with 13,067 additions and 6,477 deletions.
66 changes: 0 additions & 66 deletions .azure-pipelines/linux-CI-nightly.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .azure-pipelines/linux-conda-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ jobs:
python -m pip install $(ONNXRT_PATH)
displayName: 'Install onnxruntime'
- script: |
pip install flake8
python -m flake8 ./onnxmltools
displayName: 'run flake8 check'
- script: |
pip install -e .
displayName: 'local installation'
Expand Down
64 changes: 0 additions & 64 deletions .azure-pipelines/win32-CI-nightly.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .azure-pipelines/win32-conda-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ jobs:
python -m pip install $(ONNXRT_PATH)
displayName: 'Install ort-nightly'
- script: |
call activate py$(python.version)
python -m flake8 ./onnxmltools
displayName: 'run flake8 check'
- script: |
call activate py$(python.version)
python -m pip install -e .
Expand Down
10 changes: 0 additions & 10 deletions .flake8

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/black-ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Black Format Checker
on: [push, pull_request]
jobs:
black-format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@193ee766ca496871f93621d6b58d57a6564ff81b # stable 23.7.0
with:
options: "--diff --check"
src: "."
ruff-format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/[email protected]
43 changes: 18 additions & 25 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,42 @@

# Configuration file for the Sphinx documentation builder.

import os
import sys
import shutil
import onnxmltools
import sphinx_readable_theme
import tabulate
import sphinx_gallery.gen_gallery




# -- Project information -----------------------------------------------------

project = 'onnxmltools'
copyright = '2018-2020, Microsoft'
author = 'Microsoft'
project = "onnxmltools"
copyright = "2018-2020, Microsoft"
author = "Microsoft"
version = onnxmltools.__version__
release = version

# -- General configuration ---------------------------------------------------

extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.imgmath',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
"sphinx.ext.intersphinx",
"sphinx.ext.imgmath",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
"sphinx.ext.autodoc",
'sphinx.ext.githubpages',
"sphinx.ext.githubpages",
"sphinx_gallery.gen_gallery",
'sphinx.ext.autodoc',
"sphinx.ext.autodoc",
]

templates_path = ['_templates']
source_suffix = ['.rst']
templates_path = ["_templates"]
source_suffix = [".rst"]

master_doc = 'index'
master_doc = "index"
language = "en"
exclude_patterns = []
pygments_style = 'default'
pygments_style = "default"

# -- Options for HTML output -------------------------------------------------

html_static_path = ['_static']
html_static_path = ["_static"]
html_theme = "readable"
html_theme_path = [sphinx_readable_theme.get_html_theme_path()]
html_logo = "ONNXMLTools_logo_main.png"
Expand All @@ -58,19 +51,19 @@
# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {"https://docs.python.org/": None}

# -- Options for Sphinx Gallery ----------------------------------------------

sphinx_gallery_conf = {
'examples_dirs': 'examples',
'gallery_dirs': 'auto_examples',
"examples_dirs": "examples",
"gallery_dirs": "auto_examples",
}

# -- Setup actions -----------------------------------------------------------


def setup(app):
# Placeholder to initialize the folder before
# generating the documentation.
return app

27 changes: 14 additions & 13 deletions docs/examples/plot_convert_h2o.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@
import os
import numpy
import onnx
from onnx.tools.net_drawer import GetPydotGraph, GetOpNodeProducer
import matplotlib.pyplot as plt
import sklearn
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import onnxruntime as rt
import h2o
from h2o.estimators.gbm import H2OGradientBoostingEstimator
import skl2onnx
import onnxmltools
from onnxconverter_common.data_types import FloatTensorType
import onnxmltools
from onnxmltools.convert import convert_h2o


iris = load_iris()
X, y = iris.data, iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y)
Expand All @@ -56,7 +57,7 @@
# Convert a model into ONNX
# +++++++++++++++++++++++++

initial_type = [('float_input', FloatTensorType([None, 4]))]
initial_type = [("float_input", FloatTensorType([None, 4]))]
onx = convert_h2o(pth, initial_types=initial_type)

h2o.cluster().shutdown()
Expand All @@ -68,31 +69,31 @@
sess = rt.InferenceSession(onx.SerializeToString())
input_name = sess.get_inputs()[0].name
label_name = sess.get_outputs()[0].name
pred_onx = sess.run(
[label_name], {input_name: X_test.astype(numpy.float32)})[0]
pred_onx = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]
print(pred_onx)

##################################
# Display the ONNX graph
# ++++++++++++++++++++++
#
# Finally, let's see the graph converted with *onnxmltools*.
import os
import matplotlib.pyplot as plt
from onnx.tools.net_drawer import GetPydotGraph, GetOpNodeProducer

pydot_graph = GetPydotGraph(
onx.graph, name=onx.graph.name, rankdir="TB",
onx.graph,
name=onx.graph.name,
rankdir="TB",
node_producer=GetOpNodeProducer(
"docstring", color="yellow", fillcolor="yellow", style="filled"))
"docstring", color="yellow", fillcolor="yellow", style="filled"
),
)
pydot_graph.write_dot("model.dot")

os.system('dot -O -Gdpi=300 -Tpng model.dot')
os.system("dot -O -Gdpi=300 -Tpng model.dot")

image = plt.imread("model.dot.png")
fig, ax = plt.subplots(figsize=(40, 20))
ax.imshow(image)
ax.axis('off')
ax.axis("off")


#################################
Expand Down
Loading

0 comments on commit 2b70976

Please sign in to comment.