From 2d2b311d0e09f5dcce0b967b5ecdc8a5fc94fc96 Mon Sep 17 00:00:00 2001 From: Nicholas Reinicke Date: Mon, 23 Oct 2023 15:18:39 -0600 Subject: [PATCH] add github action for testing --- .github/workflows/test.yaml | 42 +++++++++++++++++++ .../estimators/estimator_interface.py | 1 - .../powertrain/estimators/sklearn/__init__.py | 2 +- .../trainers/sklearn_random_forest.py | 7 ++-- pyproject.toml | 5 +++ 5 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..342e4c2 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,42 @@ +name: test + +on: + push: + branches: [main] + pull_request: + +jobs: + test: + if: github.event.pull_request.merged == false + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + + env: + PYTHON: ${{ matrix.python-version }} + + steps: + - uses: actions/checkout@v3 + + - name: set up python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install package + run: | + pip install ".[dev]" + + - name: Run mypy + run: mypy . + + - name: Run black + run: | + black nrel tests --check + + - name: Python unit tests + run: | + pytest tests/ -v \ No newline at end of file diff --git a/nrel/routee/powertrain/estimators/estimator_interface.py b/nrel/routee/powertrain/estimators/estimator_interface.py index 7c20729..c3c31b8 100644 --- a/nrel/routee/powertrain/estimators/estimator_interface.py +++ b/nrel/routee/powertrain/estimators/estimator_interface.py @@ -7,7 +7,6 @@ from nrel.routee.powertrain.core.features import DataColumn, FeatureSet, TargetSet - class Estimator(ABC): @classmethod @abstractmethod diff --git a/nrel/routee/powertrain/estimators/sklearn/__init__.py b/nrel/routee/powertrain/estimators/sklearn/__init__.py index 2a18983..dab1975 100644 --- a/nrel/routee/powertrain/estimators/sklearn/__init__.py +++ b/nrel/routee/powertrain/estimators/sklearn/__init__.py @@ -1 +1 @@ -from .estimator import SKLearnEstimator \ No newline at end of file +from .estimator import SKLearnEstimator diff --git a/nrel/routee/powertrain/trainers/sklearn_random_forest.py b/nrel/routee/powertrain/trainers/sklearn_random_forest.py index 878c7c2..047c114 100644 --- a/nrel/routee/powertrain/trainers/sklearn_random_forest.py +++ b/nrel/routee/powertrain/trainers/sklearn_random_forest.py @@ -9,6 +9,7 @@ from nrel.routee.powertrain.estimators.onnx import ONNX_INPUT_NAME, ONNXEstimator from nrel.routee.powertrain.trainers.trainer import Trainer + class RandomForestTrainerOutput(Enum): ONNX = 1 @@ -54,11 +55,9 @@ def inner_train( if self.output_type == RandomForestTrainerOutput.ONNX: # convert to ONNX n_features = len(features.columns) - initial_type = [ - (ONNX_INPUT_NAME, FloatTensorType([None, n_features])) - ] + initial_type = [(ONNX_INPUT_NAME, FloatTensorType([None, n_features]))] onnx_model = to_onnx( - rf, + rf, initial_types=initial_type, ) diff --git a/pyproject.toml b/pyproject.toml index aa5c867..3cb9539 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,11 @@ dev = [ "boxsdk", "jupyter-book", "sphinx-book-theme", + "types-PyYAML", + "types-protobuf", + "types-python-dateutil", + "types-redis", + "types-requests" ] [project.urls]