Skip to content

Commit

Permalink
first commit for the new project.
Browse files Browse the repository at this point in the history
  • Loading branch information
Santi Miranda committed Sep 30, 2024
0 parents commit 114d443
Show file tree
Hide file tree
Showing 122 changed files with 21,183 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
github-actions:
patterns:
- "*"
110 changes: 110 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Tests

on:
push:
branches: [main]
pull_request:
release:
types: [created]

permissions:
contents: read

jobs:
lint-and-format:
name: Lint, format, test example
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
id: setup-uv
with:
enable-cache: true
version: "0.4.14"
github-token: ${{ secrets.GITHUB_TOKEN }}
# Note that astral-sh/setup-uv will automatically use a separate cache key for each host architecture and platform.
- name: Install Python 3.10
uses: uv python install 3.10
- name: Install the project
run: uv sync --all-extras --no-progress
- name: run example
run: uv example.py

tensorflow:
name: single backend test across python versions.
runs-on: ubuntu-latest

strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
fail-fast: false

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
id: setup-uv
with:
enable-cache: true
version: "0.4.14"

- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{matrix.python-version}}

- name: Install the project
run: uv sync --all-extras --no-progress
- name: Do something if the cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "Cache was restored"

- name: Test with PyTest
env:
KERAS_BACKEND: "tensorflow" # not needed, but for the future.
run: |
uv run -- pytest --cov=keras_tuner --cov-report xml:coverage.xml
- name: Codecov
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true # optional (default = false)
files: ./coverage.xml # optional
name: keras_tuner # optional
token: ${{ secrets.GITHUB_TOKEN }} # required
verbose: true # optional (default = false)


# test-multibackend:
# name: Multibackend, multi-python test.
# runs-on: ubuntu-latest

# strategy:
# matrix:
# python-version:
# - "3.10"
# - "3.11"
# - "3.12"
# backend: [tensorflow, jax, torch]
# fail-fast: false

# steps:
# - uses: actions/checkout@v4

# - name: Install uv
# uses: astral-sh/setup-uv@v2

# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# with:
# python-version: ${{matrix.python-version}}
# - name: Install the project
# run: uv sync --all-extras --dev

# - name: Test with PyTest
# env:
# KERAS_BACKEND: ${{ matrix.backend }}
# run: uv run -- pytest
21 changes: 21 additions & 0 deletions .github/workflows/git-cliff-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate a changelog
uses: orhun/git-cliff-action@v3
with:
config: cliff.toml
args: --verbose
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: pre-commit/[email protected]
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cov.xml
*.swp
.idea
*.pyc
.pytest_cache
*.egg-info

#VS Code files and container
.vscode/
.devcontainer/

build/
dist/
bigquery/
export/
logs/
Keras_Tuner.egg-info/
results/
tmp/
.ipynb_checkpoints/
*_tutorial_results/
tmp.py
.coverage
.coverage.*
htmlcov
old_code/
docs/sources
.venv
dist
hello
**/*.h5
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0 # Use the ref you want to point at
hooks:
- id: check-json
- id: check-toml
- id: check-yaml
- id: mixed-line-ending
- id: end-of-file-fixer
- id: trailing-whitespace
- id: name-tests-test
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.5
hooks:
# Run the linter.
- id: ruff
args: [check, --select, I, --fix]
# Run the formatter.
- id: ruff-format
# args: [--config, format.line-ending = 'lf']
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
77 changes: 77 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
## Setup Environment

First, fork the repository.

There are 3 different options:

1. **GitHub Codespaces**,
2. **VS Code & Remote-Containers**.
3. **Locally in a venv**

### Option 1: GitHub Codespace

When you open your fork on a Codespace, it automatically installs all needed (including extensions like Ruff and Pyright.)

_You can start developing._

### Option 2: VS Code & Local-Containers

Open VS Code.
Install the `Dev-Containers` extension.
Press `F1` key. Enter `Dev-Containers: Open Folder in Container` to open the repository root folder. The environment is already setup there.

You can use this remotely as well.

### Option 3: Local copy

Once you clone your fork, it's recommended here that you use `venv` and develop within a virtual environment, as described below.

`cd` into your `keras-tuner` folder and run commands below.

```bash
python3.11 -m venv .venv && source .venv/bin/activate && sh .devcontainer/setup.sh
```

## Run Tests

You can use the `python -m pytest path/to/file` to run the tests.

## Code Style

We use `ruff` and `pyright` both have VSCode extensions.
Just search in VSCode Extensions and install them.

Also `shell/lint_format.sh` can format the code.

It's useful to have this settings in your JSON-workspace:

```json
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
}
},
```

## Pull Request Guide

Before you submit a pull request, check that it meets these guidelines:

1. Is this the first pull request that you're making with GitHub? If so, read the guide [Making a pull request to an open-source project](https://github.com/gabrieldemarmiesse/getting_started_open_source).

2. Include "resolves #issue_number" in the description of the pull request if applicable and briefly describe your contribution.

3. For the case of bug fixes, add new test cases which would fail before your bug fix.

## Rebuilding Protos

If you make changes to any `.proto` file, you'll have to rebuild the generated
`*_pb2.py` files. To do this, run these commands from the root directory of this
project:

```bash
pip install grpcio-tools &&\
python -m grpc_tools.protoc --python_out=. --grpc_python_out=. --proto_path=. keras_tuner/protos/keras_tuner.proto &&\
python -m grpc_tools.protoc --python_out=. --grpc_python_out=. --proto_path=. keras_tuner/protos/service.proto
```
Loading

0 comments on commit 114d443

Please sign in to comment.