diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e69de29..0000000 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6319ece..e64920d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,14 +10,14 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Install dependencies run: | + python -m pip install --upgrade pip pip install pre-commit - pre-commit install - name: Run pre-commit run: pre-commit run --all-files @@ -27,18 +27,23 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | + python -m pip install --upgrade pip pip install -e ".[dev]" - name: Run tests run: | - pytest tests/ --cov=fit --cov-report=xml - - name: Upload coverage - uses: codecov/codecov-action@v3 \ No newline at end of file + pytest tests/ --cov=fit --cov-report=xml --cov-report=term + - name: Upload coverage to Codecov + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + fail_ci_if_error: false \ No newline at end of file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index e69de29..0000000 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e69de29..d68aad8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + - name: Run tests + run: pytest tests/ + + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install build twine + - name: Build package + run: python -m build + - name: Check package + run: twine check dist/* + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist/ + + release: + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: dist + path: dist/ + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: dist/* + generate_release_notes: true \ No newline at end of file diff --git a/.gitignore b/.gitignore index b69c7d6..f91e592 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ logs venv mnist_model.pkl *.png -fit.egg-info \ No newline at end of file +fit.egg-info +test \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1ddaf42..6dd2857 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,29 +1,34 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files - - id: debug-statements - - id: check-merge-conflict + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: debug-statements + - id: check-merge-conflict -- repo: https://github.com/psf/black - rev: 23.3.0 + - repo: https://github.com/psf/black + rev: 23.12.1 hooks: - - id: black - args: [--line-length=80] + - id: black + args: [--line-length=88] -- repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + - repo: https://github.com/pycqa/isort + rev: 5.13.2 hooks: - - id: flake8 - args: [--max-line-length=80] - additional_dependencies: [flake8-docstrings] + - id: isort + args: [--profile=black] -- repo: https://github.com/pycqa/isort - rev: 5.12.0 + - repo: https://github.com/pycqa/flake8 + rev: 6.1.0 hooks: - - id: isort - args: [--profile=black] + - id: flake8 + args: [--max-line-length=88] + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.8.0 + hooks: + - id: mypy + additional_dependencies: [types-PyYAML] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2a37baa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM python:3.11-slim + +# Set environment variables +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONPATH=/app + +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + && rm -rf /var/lib/apt/lists/* + +# Copy and install Python dependencies +COPY pyproject.toml ./ +RUN pip install --no-cache-dir -e ".[dev,examples]" + +# Copy source code +COPY . . + +# Create non-root user +RUN useradd --create-home --shell /bin/bash fit +RUN chown -R fit:fit /app +USER fit + +# Default command +CMD ["python", "-m", "pytest", "tests/"] \ No newline at end of file diff --git a/configs/default.yaml b/configs/default.yaml index e69de29..94660b2 100644 --- a/configs/default.yaml +++ b/configs/default.yaml @@ -0,0 +1,21 @@ +# FIT Library Configuration +# Override any setting by creating your own config file or using environment variables + +# Core settings +model: + dtype: "float32" + seed: 42 + +# Training defaults +training: + epochs: 100 + batch_size: 32 + learning_rate: 0.001 + early_stopping: + patience: 10 + min_delta: 1e-4 + +# Logging +logging: + level: "INFO" + log_dir: "./logs" \ No newline at end of file diff --git a/configs/models/mlp.yaml b/configs/models/mlp.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/configs/training/mnist.yaml b/configs/training/mnist.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/configs/training/xor.yaml b/configs/training/xor.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3515001 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,51 @@ +version: '3.8' + +services: + # Main development environment + fit: + build: . + volumes: + - .:/app + - fit_cache:/home/fit/.cache + environment: + - PYTHONPATH=/app + command: bash + + # Run tests + test: + build: . + volumes: + - .:/app + command: python -m pytest tests/ -v + + # Jupyter notebook server + jupyter: + build: . + volumes: + - .:/app + - fit_cache:/home/fit/.cache + ports: + - "8888:8888" + environment: + - JUPYTER_ENABLE_LAB=yes + command: > + jupyter lab + --ip=0.0.0.0 + --port=8888 + --no-browser + --allow-root + --ServerApp.token='' + --ServerApp.password='' + --ServerApp.allow_origin='*' + + # Development with hot reload + dev: + build: . + volumes: + - .:/app + - fit_cache:/home/fit/.cache + environment: + - PYTHONPATH=/app + stdin_open: true + tty: true + command: bash diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 9d3f3ed..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM python:3.9-slim - -WORKDIR /app - -COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt - -COPY . . -RUN pip install -e . - -# Default command runs tests -CMD ["python", "-m", "pytest", "tests/"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index 532fc33..0000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '3' - -services: - fit-ml: - build: . - volumes: - - .:/app - command: bash -c "pip install -e . && python -m pytest tests/" - - jupyter: - build: . - volumes: - - .:/app - ports: - - "8888:8888" - command: jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.token='' --NotebookApp.password='' diff --git a/pyproject.toml b/pyproject.toml index f7dc18c..08d945e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,31 +11,36 @@ license = {text = "MIT"} authors = [{name = "Ɓukasz Bielaszewski", email = "lukaszbielaszewskibiz@gmail.com"}] requires-python = ">=3.9" dependencies = [ - "numpy>=1.20.0", + "numpy>=1.21.0", + "pyyaml>=6.0", ] classifiers = [ - "Development Status :: Delta", - "Intended Audience :: Developers, New Users into Machine Learning", + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] [project.optional-dependencies] dev = [ - "pytest>=6.0.0", - "pytest-cov>=2.12.0", - "flake8>=3.9.0", - "black>=21.5b2", + "pytest>=7.0.0", + "pytest-cov>=4.0.0", + "black>=23.0.0", + "isort>=5.12.0", + "flake8>=6.0.0", + "mypy>=1.0.0", ] examples = [ - "matplotlib>=3.4.0", + "matplotlib>=3.5.0", "jupyter>=1.0.0", "notebook>=6.4.0", - "scikit-learn>=0.24.0", - "pandas>=1.2.0", + "scikit-learn>=1.1.0", + "pandas>=1.4.0", ] [project.urls] @@ -46,12 +51,16 @@ Repository = "https://github.com/Klus3kk/fit" include = ["fit*"] [tool.black] -line-length = 70 +line-length = 88 [tool.isort] profile = "black" -[tool.mypy] # type checker -python_version = "3.8" +[tool.mypy] +python_version = "3.9" warn_return_any = true -disallow_untyped_defs = true \ No newline at end of file +disallow_untyped_defs = true + +[tool.pytest.ini_options] +testpaths = ["tests"] +addopts = ["--cov=fit"] \ No newline at end of file