-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement python packaging (#42)
- Fix bug in gentun.algorithms - Add PR Lint check workflow - Add code lint check workflow - Automate CICD workflows for publishing - Add unit tests and coverage - Add repo badges - Add an index to the README - Create CONTRIBUTE.md
- Loading branch information
Showing
27 changed files
with
1,102 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "Code linter check and unit tests" | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
main: | ||
name: Check code formatting and run unit tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install flit | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install 'flit>=3.8.0' | ||
- name: Install project dependencies | ||
run: | | ||
flit install --deps develop --extras tensorflow,xgboost | ||
- name: Run isort | ||
run: | | ||
isort --check src/ | ||
isort --check tests/ | ||
- name: Run black | ||
run: | | ||
black --check src/ | ||
black --check tests/ | ||
- name: Run pytest | ||
run: | | ||
pytest | ||
- name: Run pylint | ||
run: | | ||
pylint src/ || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: "Generate Tag and Release" | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release: | ||
name: Create Tag and Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Get version from __init__.py | ||
id: get_version | ||
run: | | ||
VERSION=$(python -c "import re; content=open('src/gentun/__init__.py').read(); version=re.search(r'__version__ = \"(.*?)\"', content).group(1); print(version)") | ||
echo "::set-output name=version::$VERSION" | ||
- name: Create Tag | ||
run: | | ||
git tag v${{ steps.get_version.outputs.version }} | ||
git push origin v${{ steps.get_version.outputs.version }} | ||
- name: Generate Release Notes | ||
id: generate_release_notes | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const { data: releases } = await github.repos.listReleases({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
let releaseNotes; | ||
if (releases.length === 0) { | ||
releaseNotes = `Release of version ${{ steps.get_version.outputs.version }}\n\n` + | ||
`This is the first release.`; | ||
} else { | ||
const latestRelease = releases[0]; | ||
releaseNotes = `Release of version ${{ steps.get_version.outputs.version }}\n\n` + | ||
`Changes since last release:\n` + | ||
`${latestRelease.body}`; | ||
} | ||
return { releaseNotes }; | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: v${{ steps.get_version.outputs.version }} | ||
release_name: Release ${{ steps.get_version.outputs.version }} | ||
body: ${{ steps.generate_release_notes.outputs.releaseNotes }} | ||
draft: true | ||
prerelease: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: "Publish to PyPI" | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
name: Publish to PyPI | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install flit | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install 'flit>=3.8.0' | ||
- name: Build the package | ||
run: | | ||
flit build | ||
- name: Publish to PyPI | ||
env: | ||
FLIT_INDEX_URL: https://upload.pypi.org/legacy/ | ||
FLIT_USERNAME: __token__ | ||
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
run: | | ||
flit publish --repository pypi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: "Publish to Test PyPI" | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
publish: | ||
name: Publish to Test PyPI | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install flit | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install 'flit>=3.8.0' | ||
- name: Build the package | ||
run: | | ||
flit build | ||
- name: Publish to Test PyPI | ||
env: | ||
FLIT_INDEX_URL: https://test.pypi.org/legacy/ | ||
FLIT_USERNAME: __token__ | ||
FLIT_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
run: | | ||
flit publish --repository testpypi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Contributing | ||
|
||
When contributing to this repository, please first discuss the change you wish to make via issue, | ||
email, or any other method with the owners of this repository before making a change. | ||
|
||
Here are areas that can be improved in this library: | ||
|
||
- Add [genes](src/gentun/genes.py#L11-L47) and [models](src/gentun/models/base.py#L9-L25) to | ||
support more paper implementation | ||
- Add a method to share the training data between the controller node and workers | ||
- Add some type of proof-of-work validation for workers | ||
|
||
You can also help us speed up hyperparameter search by contributing your spare GPU time. | ||
|
||
There was a major refactor of this library in 2024, the old version is still available in | ||
the [`old` branch](https://github.com/gmontamat/gentun/tree/old). Some cool forks added | ||
features to this release. | ||
|
||
## Pull Request Process | ||
|
||
1. Ensure your branch is linted with `black` and `isort` using | ||
the [pyproject.toml](./pyproject.toml) configurations. | ||
2. Update the README.md with details of changes to the interface, this includes new environment | ||
variables, exposed ports, useful file locations and container parameters. | ||
3. Increase the version numbers in any examples files and the README.md to the new version that this | ||
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). | ||
4. Use [The Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) in | ||
your PR title and description. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
# gentun examples | ||
|
||
This directory contains examples of how to use the `gentun` package to optimize model hyperparameters. | ||
Be sure to download the required datasets using [the script provided](./get_datasets.sh) before testing these scripts. | ||
Be sure to [install the gentun package](../README.md#installation) and download the required datasets | ||
using [the script provided](./get_datasets.sh) before running these examples. | ||
|
||
## Sample distributed algorithm | ||
|
||
To run this example, [setup your Redis server](../README.md#redis-setup) in addition to the previous | ||
steps. Next, start the controller node: | ||
|
||
```python | ||
python sample_controller.py | ||
``` | ||
|
||
And, for evary worker node, start your worker code: | ||
|
||
```python | ||
python sample_worker.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.