-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from arvinsingh/microservices
Microservices
- Loading branch information
Showing
8 changed files
with
136 additions
and
41 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,33 @@ | ||
|
||
name: Build application | ||
description: This action builds the application | ||
|
||
runs: | ||
|
||
using: 'composite' | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-in-project: true # for caching dependencies | ||
|
||
- name: Load cached virtualenv | ||
uses: actions/cache@v2 | ||
id: cache-poetry-dependencies | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- name: Install dependencies using Poetry | ||
if: steps.cache-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: poetry run make install | ||
shell: bash |
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,25 @@ | ||
|
||
name: Lint workflow | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build application | ||
uses: ./.github/actions/build-application | ||
|
||
- name: Lint with Flake8 | ||
run: poetry run make check |
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,18 @@ | ||
from loguru import logger | ||
|
||
from config import model_settings | ||
from model.pipeline.model import build_model | ||
|
||
|
||
class ModelBuilderService: | ||
|
||
def __init__(self): | ||
self.model_path = model_settings.model_path | ||
self.model_name = model_settings.model_name | ||
|
||
def load_model(self): | ||
logger.info( | ||
f'Building the model file at ' | ||
f'{self.model_path}/{self.model_name}', | ||
) | ||
build_model() |
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 @@ | ||
from pathlib import Path | ||
import pickle as pkl | ||
|
||
from loguru import logger | ||
|
||
from config import model_settings | ||
|
||
|
||
class ModelInferenceService: | ||
|
||
def __init__(self): | ||
self.model = None | ||
self.model_path = model_settings.model_path | ||
self.model_name = model_settings.model_name | ||
|
||
def load_model(self): | ||
logger.info( | ||
f'Checking for existing model file at ' | ||
f'{self.model_path}/{self.model_name}', | ||
) | ||
model_path = Path( | ||
f'{self.model_path}/{self.model_name}', | ||
) | ||
|
||
if not model_path.exists(): | ||
raise FileNotFoundError( | ||
f'Model file {self.model_name} does not exist!', | ||
) | ||
|
||
logger.info(f'Loading existing model -> {model_path}') | ||
with open(model_path, 'rb') as model_file: | ||
self.model = pkl.load(model_file) | ||
|
||
def predict(self, input_parameters): | ||
logger.info('Making predictions') | ||
return self.model.predict([input_parameters]) |
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
from loguru import logger | ||
|
||
from model.model_builder import ModelBuilderService | ||
|
||
|
||
@logger.catch | ||
def main(): | ||
logger.info('Running builder application') | ||
ml_svc = ModelBuilderService() | ||
ml_svc.train_model() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
File renamed without changes.