Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/uv #179

Merged
merged 21 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Create and activate virtual environment
run: |
uv venv
echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
uv pip install 'setuptools[pkg_resources]'
uv pip install -e ".[test]"

- name: Run tests with coverage
run: |
uv pip install pytest-cov
pytest -s tests/ --cov=numerblox --cov-report term-missing

- name: Build wheel
run: |
uv pip install build
python -m build --wheel

- name: Install built wheel
run: |
uv pip install dist/*.whl
34 changes: 22 additions & 12 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,44 @@ on:
- master

jobs:
build:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

coverage:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
python-version: ['3.12']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Create and activate virtual environment
run: |
uv venv
echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry config virtualenvs.create false --local
poetry install
uv pip install 'setuptools[pkg_resources]'
uv pip install -e ".[test]"
- name: Run tests
run: |
poetry run pytest -s tests/ --cov=numerblox --cov-report term-missing --cov-report=xml
uv pip install pytest pytest-cov
pytest -s tests/ --cov=numerblox --cov-report term-missing --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
directory: ./coverage/reports/
files: ./coverage.xml
fail_ci_if_error: false
verbose: true
files: ./coverage.xml

22 changes: 16 additions & 6 deletions .github/workflows/deploy-mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,30 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.12'

- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Create and activate virtual environment
run: |
uv venv
echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
pip install poetry
poetry install
uv pip install 'setuptools[pkg_resources]'
uv pip install mkdocs mkdocs-material

- name: Build the MkDocs site
run: poetry run mkdocs build
run: mkdocs build

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
51 changes: 0 additions & 51 deletions .github/workflows/poetry.yml

This file was deleted.

2 changes: 0 additions & 2 deletions docs/numerframe.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ X, y = df.get_feature_target_pair(multi_target=True)

# Fetch data for specified eras
X, y = df.get_era_batch(eras=['0001', '0002'])
# Optionally get Tensorflow tensors for NN training
X, y = nf.get_era_batch(eras=['0001', '0002'], convert_to_tf=True)

# Since every operation returns a NumerFrame they can be chained.
# An example chained operation is getting features and targets for the last 2 eras.
Expand Down
24 changes: 11 additions & 13 deletions examples/end_to_end.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
}
],
"source": [
"from xgboost import XGBRegressor\n",
"from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor\n",
"from sklearn.compose import ColumnTransformer, make_column_transformer\n",
"from sklearn.model_selection import TimeSeriesSplit\n",
"from sklearn.pipeline import make_pipeline\n",
"from sklearn.compose import make_column_transformer, ColumnTransformer\n",
"from numerblox.preprocessing import GroupStatsPreProcessor\n",
"from numerblox.meta import CrossValEstimator, make_meta_pipeline\n",
"from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor\n",
"from xgboost import XGBRegressor\n",
"\n",
"from numerblox.ensemble import NumeraiEnsemble, PredictionReducer\n",
"from numerblox.neutralizers import FeatureNeutralizer"
"from numerblox.meta import CrossValEstimator, make_meta_pipeline\n",
"from numerblox.neutralizers import FeatureNeutralizer\n",
"from numerblox.preprocessing import GroupStatsPreProcessor"
]
},
{
Expand Down Expand Up @@ -623,13 +624,10 @@
],
"source": [
"# Preprocessing\n",
"gpp = GroupStatsPreProcessor(groups=['sunshine', 'rain'])\n",
"gpp = GroupStatsPreProcessor(groups=[\"sunshine\", \"rain\"])\n",
"fncv3_selector = ColumnSelector(fncv3_cols)\n",
"\n",
"preproc_pipe = ColumnTransformer([\n",
" ('gpp', gpp, X.columns.tolist()),\n",
" ('fncv3_selector', fncv3_selector, fncv3_cols)\n",
" ])\n",
"preproc_pipe = ColumnTransformer([(\"gpp\", gpp, X.columns.tolist()), (\"fncv3_selector\", fncv3_selector, fncv3_cols)])\n",
"\n",
"# Model\n",
"xgb = DecisionTreeRegressor()\n",
Expand Down Expand Up @@ -708,7 +706,7 @@
"outputs": [],
"source": [
"model = DecisionTreeClassifier()\n",
"crossval1 = CrossValEstimator(estimator=model, cv=TimeSeriesSplit(n_splits=3), predict_func='predict_proba')\n",
"crossval1 = CrossValEstimator(estimator=model, cv=TimeSeriesSplit(n_splits=3), predict_func=\"predict_proba\")\n",
"pred_rud = PredictionReducer(n_models=3, n_classes=5)\n",
"ens2 = NumeraiEnsemble(donate_weighted=True)\n",
"neut2 = FeatureNeutralizer(proportion=0.5)\n",
Expand Down Expand Up @@ -1808,7 +1806,7 @@
"pipes = []\n",
"for i in range(3):\n",
" model = XGBRegressor()\n",
" crossval = CrossValEstimator(estimator=model, cv=TimeSeriesSplit(n_splits=5), predict_func='predict')\n",
" crossval = CrossValEstimator(estimator=model, cv=TimeSeriesSplit(n_splits=5), predict_func=\"predict\")\n",
" pipe = make_pipeline(crossval)\n",
" pipes.append(pipe)\n",
"\n",
Expand Down
Loading
Loading