Skip to content

Commit

Permalink
Merge pull request #2 from gizatechxyz/feature/add-ci
Browse files Browse the repository at this point in the history
Add CI files for auto zkml
  • Loading branch information
alejandromartinezgotor authored May 16, 2024
2 parents 2ce8c44 + a074ad2 commit eafc971
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 22 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/onpush.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Giza CI

on:
pull_request:
types: [ opened, synchronize ]
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

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 dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry config virtualenvs.create false
poetry install --all-extras
- name: Lint with ruff
run: |
poetry run ruff auto_zkml
- name: Pre-commit check
run: |
poetry run pre-commit run --all-files
- name: Testing
run: |
poetry run pytest --cov=auto_zkml --cov-report term-missing
40 changes: 40 additions & 0 deletions .github/workflows/onrelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry config virtualenvs.create false
poetry install
- name: Lint with ruff
run: |
poetry run ruff auto_zkml
- name: Build dist
run: poetry build
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.GIZA_AUTOZKML_PYPI_TOKEN }}
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,3 @@ repos:
entry: ruff
language: system
files: "py$"
- id: mypy
name: mypy
entry: mypy
language: system
files: "py$"
4 changes: 2 additions & 2 deletions auto_zkml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from giza_mlutils.model_reducer import mcr
from giza_mlutils.serializer.serialize import serialize_model
from auto_zkml.model_reducer import mcr
from auto_zkml.serializer.serialize import serialize_model

__all__ = ["mcr", "serialize_model"]

Expand Down
12 changes: 6 additions & 6 deletions auto_zkml/model_reducer.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from skopt import gp_minimize
from skopt.utils import use_named_args

from giza_mlutils.model_toolkit.data_transformer import DataTransformer
from giza_mlutils.model_toolkit.feature_models_space import FeatureSpaceConstants
from giza_mlutils.model_toolkit.metrics import check_metric_optimization
from giza_mlutils.model_toolkit.model_evaluator import ModelEvaluator
from giza_mlutils.model_toolkit.model_info import ModelParameterExtractor
from giza_mlutils.model_toolkit.model_trainer import ModelTrainer
from auto_zkml.model_toolkit.data_transformer import DataTransformer
from auto_zkml.model_toolkit.feature_models_space import FeatureSpaceConstants
from auto_zkml.model_toolkit.metrics import check_metric_optimization
from auto_zkml.model_toolkit.model_evaluator import ModelEvaluator
from auto_zkml.model_toolkit.model_info import ModelParameterExtractor
from auto_zkml.model_toolkit.model_trainer import ModelTrainer


def mcr(model, X_train, y_train, X_eval, y_eval, eval_metric, transform_features=False):
Expand Down
4 changes: 2 additions & 2 deletions auto_zkml/model_toolkit/data_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

from giza_mlutils.model_toolkit.custom_transformers.customPCA import CustomPCA
from giza_mlutils.model_toolkit.custom_transformers.customRFE import CustomRFE
from auto_zkml.model_toolkit.custom_transformers.customPCA import CustomPCA
from auto_zkml.model_toolkit.custom_transformers.customRFE import CustomRFE


class DataTransformer(BaseEstimator, TransformerMixin):
Expand Down
1 change: 0 additions & 1 deletion auto_zkml/model_toolkit/model_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class ModelParameterExtractor:
# TODO: creo que se puede cambiar por un método solo por tipo de algoritmo.
def __init__(self):
self.model_extractors_by_name = {
"XGBRegressor": self.extract_params_from_xgb,
Expand Down
1 change: 0 additions & 1 deletion auto_zkml/model_toolkit/model_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def train_catboost(
params["eval_metric"] = eval_metric
model = self.model_class(**params)

# Entrenamiento con parámetros específicos de fit
model.fit(X_train, y_train, eval_set=[(X_eval, y_eval)])

return model
Expand Down
4 changes: 2 additions & 2 deletions auto_zkml/serializer/serialize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from giza_mlutils.model_toolkit.model_info import ModelParameterExtractor
from giza_mlutils.serializer import lgbm, xg
from auto_zkml.model_toolkit.model_info import ModelParameterExtractor
from auto_zkml.serializer import lgbm, xg


def serialize_model(model, output_path):
Expand Down
84 changes: 83 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ruff = "^0.1.11"
black = "^23.12.1"
isort = "^5.13.2"
ipykernel = "^6.29.0"
pytest-cov = "^5.0.0"

[build-system]
requires = ["poetry-core"]
Expand Down
4 changes: 2 additions & 2 deletions tutorials/serialize_my_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"## How to serialize my model\n",
"\n",
"Giza_mlutils offers various functionalities that help us have a model with the necessary characteristics to be transpilable, and therefore, able to generate proofs of its inferences.\n",
"auto_zkml offers various functionalities that help us have a model with the necessary characteristics to be transpilable, and therefore, able to generate proofs of its inferences.\n",
"In this case, we will talk about the serialization process, which involves saving your model in a format that can be interpreted by other Giza tools.\n",
"\n",
"Currently, the two supported models are XGBoost and LightGBM for both classification and regression. It is preferable that the training is done using the scikit-learn API.\n",
Expand Down Expand Up @@ -123,7 +123,7 @@
"metadata": {},
"source": [
"That simple! We now have our models saved in the correct format to use the rest of the Giza stack! But not so fast...\n",
"In this example, the models are very simple (few trees and shallow depth), but for other problems, the optimal architecture might be much more complex and not compatible with our current technology. In this case, we will have to use another of the functionalities offered by Giza_mlutils beforehand: our model_complexity_reducer.\n",
"In this example, the models are very simple (few trees and shallow depth), but for other problems, the optimal architecture might be much more complex and not compatible with our current technology. In this case, we will have to use another of the functionalities offered by auto_zkml beforehand: our model_complexity_reducer.\n",
"\n",
"To understand how the model_complexity_reducer (mcr) works, in this same folder you will find the notebook reduce_model_complexity.ipynb with a detailed explanation of its operation and how to run it before serializing your model."
]
Expand Down

0 comments on commit eafc971

Please sign in to comment.