Skip to content

Commit

Permalink
V0.3.0 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmind authored Feb 24, 2024
1 parent 09cc69e commit 9860e75
Show file tree
Hide file tree
Showing 50 changed files with 3,902 additions and 426 deletions.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Expected Behavior


## Actual Behavior


## Steps to Reproduce the Problem

1.
1.
1.

## Specifications

- Version:
- Platform:
- Subsystem:
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Fixes #

## Proposed Changes

-
-
-
11 changes: 11 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Setup
description: Setup for project workflows
runs:
using: composite
steps:
- run: pipx install invoke poetry
shell: bash
- uses: actions/setup-python@v5
with:
python-version: 3.12
cache: poetry
15 changes: 15 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
pull_request:
branches:
- main
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: poetry install --with dev,checks,formats
- run: poetry run invoke checks
41 changes: 41 additions & 0 deletions .github/workflows/on-release-published.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
release:
types: [published]
env:
DOCKER_IMAGE: ghcr.io/fmind/mlops-python-package:latest
concurrency:
cancel-in-progress: true
group: on-release-published
jobs:
pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: poetry install --with docs
- run: poetry run invoke docs
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs/
branch: gh-pages
packages:
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: poetry run invoke packages
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
push: true
context: .
cache-to: type=gha
cache-from: type=gha
tags: ${{ env.DOCKER_IMAGE }}
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@
# Editor
/.idea/
/.vscode/
.ipynb_checkpoints/

# Environs
/.venv/
poetry.lock

# Notebooks
.ipynb_checkpoints/

# Project
/docs/*
/models/*
/outputs/*
!**/.gitkeep

Expand Down
3 changes: 0 additions & 3 deletions confs/inference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ job:
outputs:
KIND: ParquetWriter
path: outputs/predictions.parquet
deserializer:
KIND: JoblibModelDeserializer
path: models/model.joblib
3 changes: 0 additions & 3 deletions confs/training.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ job:
targets:
KIND: ParquetReader
path: data/targets.parquet
serializer:
KIND: JoblibModelSerializer
path: models/model.joblib
Empty file modified data/Readme.txt
100755 → 100644
Empty file.
Empty file modified data/hour.csv
100755 → 100644
Empty file.
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# https://docs.docker.com/compose/compose-file/
services:
mlflow:
image: ghcr.io/mlflow/mlflow:v2.10.2
ports:
- 5000:5000
environment:
- MLFLOW_HOST=0.0.0.0
command: mlflow server
1 change: 1 addition & 0 deletions mlops-python-package.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dchanco.vsc-invoke",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
Expand Down
Empty file removed models/.gitkeep
Empty file.
2,651 changes: 2,651 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[tool.poetry]
name = "bikes"
version = "0.1.0"
version = "0.3.0"
description = "Predict the number of bikes available."
repository = "https://github.com/fmind/mlops-python-package"
authors = ["Médéric HURIER <[email protected]>"]
Expand Down Expand Up @@ -32,37 +32,40 @@ pyarrow = "^15.0.0"
pydantic = "^2.5.3"
pydantic-settings = "^2.1.0"
scikit-learn = "^1.4.0"
mlflow-skinny = "^2.10.2"

[tool.poetry.group.dev.dependencies]
invoke = "^2.2.0"
ipykernel = "^6.29.0"
pre-commit = "^3.6.0"

[tool.poetry.group.checkers.dependencies]
[tool.poetry.group.docs.dependencies]
pdoc = "^13.1.1"

[tool.poetry.group.checks.dependencies]
coverage = "^7.4.1"
mypy = "^1.8.0"
pylint = "^3.0.3"
pytest = "^8.0.0"
pytest-cov = "^4.1.0"
pytest-xdist = "^3.5.0"
pandera = { extras = ["mypy"], version = "^0.18.0" }

[tool.poetry.group.notebooks.dependencies]
nbformat = "^5.9.2"

[tool.poetry.group.documenters.dependencies]
pdoc = "^13.1.1"

[tool.poetry.group.formatters.dependencies]
[tool.poetry.group.formats.dependencies]
black = "^24.1.1"
isort = "^5.13.2"

[tool.poetry.group.notebooks.dependencies]
ipykernel = "^6.29.0"
nbformat = "^5.9.2"

# CONFIGURATIONS

[tool.black]
line-length = 120

[tool.coverage.run]
branch = true
source = ["src"]

[tool.isort]
line_length = 120
Expand All @@ -74,7 +77,7 @@ ignore_missing_imports = true
plugins = ["pandera.mypy", "pydantic.mypy"]

[tool.pylint.MASTER]
disable = ['too-few-public-methods', 'too-many-arguments']
disable = ['too-few-public-methods', 'too-many-arguments', 'too-many-locals']
max-line-length = 120
extension-pkg-whitelist = "pydantic"

Expand Down
1 change: 1 addition & 0 deletions src/bikes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Predict the number of bikes available."""
56 changes: 46 additions & 10 deletions src/bikes/configs.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,72 @@
"""Parse and merge config files."""
"""Parse, merge, and convert YAML configs."""

# %% IMPORTS

import typing as T

from cloudpathlib import AnyPath
from omegaconf import DictConfig, ListConfig, OmegaConf

# %% TYPES

Config = ListConfig | DictConfig

# %% LOADERS
# %% PARSERS


def parse_file(path: str) -> Config:
"""Parse a config file from a path.
def parse_config(path: str) -> Config:
"""Load a config file."""
Args:
path (str): local or remote path.
Returns:
Config: representation of the config file.
"""
any_path = AnyPath(path)
# pylint: disable=no-member
text = any_path.read_text() # type: ignore
config = OmegaConf.create(text)
return config


def parse_configs(paths: list[str]) -> Config:
"""Load and merge config files."""
configs = map(parse_config, paths)
config = OmegaConf.merge(*configs)
return config
def parse_string(string: str) -> Config:
"""Parse the given config string.
Args:
string (str): configuration string.
Returns:
Config: representation of the config string.
"""
return OmegaConf.create(string)


# %% MERGERS


def merge_configs(configs: T.Sequence[Config]) -> Config:
"""Merge a list of config objects into one.
Args:
configs (list[Config]): list of config objects.
Returns:
Config: representation of the merged config objects.
"""
return OmegaConf.merge(*configs)


# %% CONVERTERS


def to_object(config: Config) -> object:
"""Convert a config to a python object."""
"""Convert a config object to a python object.
Args:
config (Config): representation of the config.
Returns:
object: conversion of the config to a python object.
"""
return OmegaConf.to_container(config, resolve=True)
Loading

0 comments on commit 9860e75

Please sign in to comment.