From 6eed08d1ba7c58b20570f270c0e350a9ee42b5f2 Mon Sep 17 00:00:00 2001 From: publicmatt Date: Sat, 6 Apr 2024 15:48:29 -0700 Subject: [PATCH] fix project_slug error. replace ml_pipeline with project_name or module_name from config --- cookiecutter.json | 5 ++- {{cookiecutter.project_name}}/.env.example | 7 ++++ .../LICENCE | 0 .../Makefile | 40 +++++++++++-------- .../README.md | 0 .../docs/.gitignore | 0 .../docs/book.toml | 2 +- .../docs/src/SUMMARY.md | 0 .../docs/src/chapter_1.md | 0 .../docs/src/index.md | 0 .../pyproject.toml | 7 ++-- .../requirements.txt | 0 .../test/.env.test | 0 .../test/test_cnn.py | 6 +++ .../test/test_inputs.py | 4 +- .../{{cookiecutter.module_name}}/__init__.py | 2 +- .../{{cookiecutter.module_name}}/__main__.py | 5 +++ .../app/__init__.py | 11 +++++ .../{{cookiecutter.module_name}}/batch.py | 0 .../{{cookiecutter.module_name}}/cli.py | 14 +++---- .../{{cookiecutter.module_name}}/common.py | 0 .../config/app.toml | 0 .../config/config.toml | 0 .../config/data.toml | 0 .../config/model.toml | 0 .../config/paths.toml | 2 +- .../config/training.toml | 0 .../data/__init__.py | 2 +- .../data/dataset.py | 2 +- .../{{cookiecutter.module_name}}/data/make.py | 0 .../data/spark.py | 0 .../features/make.py | 0 .../model/__init__.py | 0 .../{{cookiecutter.module_name}}/model/cnn.py | 0 .../model/linear.py | 0 .../notebooks/features.ipynb | 0 .../notebooks/main.ipynb | 35 ++-------------- .../training/__init__.py | 0 .../training/pipeline.py | 10 ++--- .../training/runner.py | 0 .../test/test_cnn.py | 6 --- .../{{cookiecutter.module_name}}/__main__.py | 5 --- .../app/__init__.py | 11 ----- 43 files changed, 81 insertions(+), 95 deletions(-) create mode 100644 {{cookiecutter.project_name}}/.env.example rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/LICENCE (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/Makefile (52%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/README.md (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/docs/.gitignore (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/docs/book.toml (66%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/docs/src/SUMMARY.md (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/docs/src/chapter_1.md (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/docs/src/index.md (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/pyproject.toml (90%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/requirements.txt (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/test/.env.test (100%) create mode 100644 {{cookiecutter.project_name}}/test/test_cnn.py rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/test/test_inputs.py (85%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/__init__.py (88%) create mode 100644 {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/__main__.py create mode 100644 {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/app/__init__.py rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/batch.py (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/cli.py (66%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/common.py (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/config/app.toml (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/config/config.toml (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/config/data.toml (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/config/model.toml (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/config/paths.toml (53%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/config/training.toml (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/data/__init__.py (94%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/data/dataset.py (97%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/data/make.py (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/data/spark.py (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/features/make.py (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/model/__init__.py (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/model/cnn.py (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/model/linear.py (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/notebooks/features.ipynb (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/notebooks/main.ipynb (60%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/training/__init__.py (100%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/training/pipeline.py (84%) rename {{{cookiecutter.project_slug}} => {{cookiecutter.project_name}}}/{{cookiecutter.module_name}}/training/runner.py (100%) delete mode 100644 {{cookiecutter.project_slug}}/test/test_cnn.py delete mode 100644 {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/__main__.py delete mode 100644 {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/app/__init__.py diff --git a/cookiecutter.json b/cookiecutter.json index 17f03a5..a05b75d 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -4,5 +4,8 @@ "module_name": "{{ cookiecutter.repo_name }}", "author_name": "Your name (or your organization/company/team)", "description": "A short description of the project.", - "open_source_license": ["MIT", "BSD-3-Clause", "No license file"] + "open_source_license": ["MIT", "BSD-3-Clause", "No license file"], + "_copy_without_render": [ + "docs/book" + ] } diff --git a/{{cookiecutter.project_name}}/.env.example b/{{cookiecutter.project_name}}/.env.example new file mode 100644 index 0000000..c82f639 --- /dev/null +++ b/{{cookiecutter.project_name}}/.env.example @@ -0,0 +1,7 @@ +MODEL__IN_CHANNELS=1 +MODEL__NUM_CLASSES=10 +DATA__TRAIN_PATH=/path/to/{{cookiecutter.project_name}}/data/mnist_train.csv +DATA__TEST_PATH=/path/to/{{cookiecutter.project_name}}/data/mnist_test.csv +PATHS__APP=/path/to/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/ +PATHS__ROOT=/path/to/{{cookiecutter.project_name}}/ +PATHS__DATA=/path/to/{{cookiecutter.project_name}}/data/ diff --git a/{{cookiecutter.project_slug}}/LICENCE b/{{cookiecutter.project_name}}/LICENCE similarity index 100% rename from {{cookiecutter.project_slug}}/LICENCE rename to {{cookiecutter.project_name}}/LICENCE diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_name}}/Makefile similarity index 52% rename from {{cookiecutter.project_slug}}/Makefile rename to {{cookiecutter.project_name}}/Makefile index 26749c8..0a4e50d 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_name}}/Makefile @@ -1,30 +1,36 @@ -APP_NAME=ml_pipeline +APP_NAME={{cookiecutter.module_name}} PYTHON=.venv/bin/python3 INTERPRETER=/usr/bin/python3 .PHONY: help test -all: run +all: help init: ## create a venv $(INTERPRETER) -m venv .venv - -run: ## run the pipeline (train) - $(PYTHON) -m $(APP_NAME) pipeline:train - -data: ## download the mnist data - $(PYTHON) -m $(APP_NAME) data:download - # wget https://pjreddie.com/media/files/mnist_train.csv -O data/mnist_train.csv - # wget https://pjreddie.com/media/files/mnist_test.csv -O data/mnist_test.csv - -test: - find . -iname "*.py" | entr -c pytest - -serve: - $(PYTHON) -m $(APP_NAME) app:serve + cp .env.example .env install: $(PYTHON) -m pip install -r requirements.txt +data: ## download the mnist data + $(PYTHON) -m $(APP_NAME) data:download + +run: ## run the pipeline (train) + $(PYTHON) -m $(APP_NAME) pipeline:train + +serve: ## start fastapi uvicorn server + $(PYTHON) -m $(APP_NAME) app:serve + +docs: ## serve the mdbook docs directory + mdbook serve docs + +test: ## run pytest tests + $(PYTHON) -m pytest + +test-watch: ## run pytest on .py changes + find . -iname "*.py" | entr -c $(PYTHON) -m pytest + help: ## display this help message - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + @echo "available commands:" + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36mmake %-30s\033[0m %s\n", $$1, $$2}' diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_name}}/README.md similarity index 100% rename from {{cookiecutter.project_slug}}/README.md rename to {{cookiecutter.project_name}}/README.md diff --git a/{{cookiecutter.project_slug}}/docs/.gitignore b/{{cookiecutter.project_name}}/docs/.gitignore similarity index 100% rename from {{cookiecutter.project_slug}}/docs/.gitignore rename to {{cookiecutter.project_name}}/docs/.gitignore diff --git a/{{cookiecutter.project_slug}}/docs/book.toml b/{{cookiecutter.project_name}}/docs/book.toml similarity index 66% rename from {{cookiecutter.project_slug}}/docs/book.toml rename to {{cookiecutter.project_name}}/docs/book.toml index a2e22b1..048c604 100644 --- a/{{cookiecutter.project_slug}}/docs/book.toml +++ b/{{cookiecutter.project_name}}/docs/book.toml @@ -3,4 +3,4 @@ authors = ["publicmatt"] language = "en" multilingual = false src = "src" -title = "ml_pipeline" +title = "{{cookiecutter.project_name}}" diff --git a/{{cookiecutter.project_slug}}/docs/src/SUMMARY.md b/{{cookiecutter.project_name}}/docs/src/SUMMARY.md similarity index 100% rename from {{cookiecutter.project_slug}}/docs/src/SUMMARY.md rename to {{cookiecutter.project_name}}/docs/src/SUMMARY.md diff --git a/{{cookiecutter.project_slug}}/docs/src/chapter_1.md b/{{cookiecutter.project_name}}/docs/src/chapter_1.md similarity index 100% rename from {{cookiecutter.project_slug}}/docs/src/chapter_1.md rename to {{cookiecutter.project_name}}/docs/src/chapter_1.md diff --git a/{{cookiecutter.project_slug}}/docs/src/index.md b/{{cookiecutter.project_name}}/docs/src/index.md similarity index 100% rename from {{cookiecutter.project_slug}}/docs/src/index.md rename to {{cookiecutter.project_name}}/docs/src/index.md diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_name}}/pyproject.toml similarity index 90% rename from {{cookiecutter.project_slug}}/pyproject.toml rename to {{cookiecutter.project_name}}/pyproject.toml index f0859a0..f81ad1d 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_name}}/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [project] -name = "ml_pipeline" +name = "{{cookiecutter.project_name}}" version = "0.1.0" authors = [ {name = "publicmatt", email = "git@publicmatt.com"}, @@ -18,7 +18,6 @@ dependencies = [ "numpy==1.26.4", "pytest==8.1.1", "pytest-cov==5.0.0", - "python-dotenv==1.0.1", "requests==2.31.0", "torch==2.2.2", "torchvision=0.17.2", @@ -37,11 +36,11 @@ repository = "https://example.com/my_project/repo" documentation = "https://example.com/my_project/docs" [tool.setuptools] -packages = ["ml_pipeline"] +packages = ["{{cookiecutter.module_name}}"] [tool.pytest.ini_options] # Run tests in parallel using pytest-xdist -addopts = "--cov=ml_pipeline --cov-report=term" +addopts = "--cov={{cookiecutter.module_name}} --cov-report=term" # Specify the paths to look for tests testpaths = [ "test", diff --git a/{{cookiecutter.project_slug}}/requirements.txt b/{{cookiecutter.project_name}}/requirements.txt similarity index 100% rename from {{cookiecutter.project_slug}}/requirements.txt rename to {{cookiecutter.project_name}}/requirements.txt diff --git a/{{cookiecutter.project_slug}}/test/.env.test b/{{cookiecutter.project_name}}/test/.env.test similarity index 100% rename from {{cookiecutter.project_slug}}/test/.env.test rename to {{cookiecutter.project_name}}/test/.env.test diff --git a/{{cookiecutter.project_name}}/test/test_cnn.py b/{{cookiecutter.project_name}}/test/test_cnn.py new file mode 100644 index 0000000..af406f1 --- /dev/null +++ b/{{cookiecutter.project_name}}/test/test_cnn.py @@ -0,0 +1,6 @@ +from {{cookiecutter.module_name}} import config +from {{cookiecutter.module_name}}.model.cnn import VGG11 + +def test_in_channels(): + assert config.model.name == 'vgg11' + diff --git a/{{cookiecutter.project_slug}}/test/test_inputs.py b/{{cookiecutter.project_name}}/test/test_inputs.py similarity index 85% rename from {{cookiecutter.project_slug}}/test/test_inputs.py rename to {{cookiecutter.project_name}}/test/test_inputs.py index bfe30e6..59144fa 100644 --- a/{{cookiecutter.project_slug}}/test/test_inputs.py +++ b/{{cookiecutter.project_name}}/test/test_inputs.py @@ -1,5 +1,5 @@ -from ml_pipeline.data.dataset import MnistDataset -from ml_pipeline import config +from {{cookiecutter.module_name}}.data.dataset import MnistDataset +from {{cookiecutter.module_name}} import config from pathlib import Path import pytest diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/__init__.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/__init__.py similarity index 88% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/__init__.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/__init__.py index 0ded6a6..78f7611 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/__init__.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/__init__.py @@ -5,7 +5,7 @@ pwd = Path(__file__).parent config_path = pwd / 'config' root_path = pwd.parent config = ConfigurationSet( - config_from_env(prefix="ML_PIPELINE", separator="__", lowercase_keys=True), + config_from_env(prefix="{{cookiecutter.module_name.upper()}}", separator="__", lowercase_keys=True), config_from_dotenv(root_path / ".env", read_from_file=True, lowercase_keys=True, interpolate=True, interpolate_type=1), config_from_toml(config_path / "training.toml", read_from_file=True), config_from_toml(config_path / "data.toml", read_from_file=True), diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/__main__.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/__main__.py new file mode 100644 index 0000000..7759e60 --- /dev/null +++ b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/__main__.py @@ -0,0 +1,5 @@ +from {{cookiecutter.module_name}}.cli import cli + +if __name__ == "__main__": + cli() + diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/app/__init__.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/app/__init__.py new file mode 100644 index 0000000..29735ee --- /dev/null +++ b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/app/__init__.py @@ -0,0 +1,11 @@ +from {{cookiecutter.module_name}} import config +from fastapi import FastAPI, Response +import logging +import uvicorn + +app = FastAPI() + +logger = logging.getLogger(__name__) + +def run(): + uvicorn.run("{{cookiecutter.module_name}}.app:app", host=config.app.host, port=config.app.port, proxy_headers=True) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/batch.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/batch.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/batch.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/batch.py diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/cli.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/cli.py similarity index 66% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/cli.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/cli.py index 0cdc6ec..b2a5d77 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/cli.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/cli.py @@ -4,38 +4,38 @@ import click @click.version_option() def cli(): """ - ml_pipeline: a template for building, training and running pytorch models. + build, train and run machine learning models. """ @cli.command("pipeline:train") def pipeline_train(): """run the training pipeline with train data""" - from ml_pipeline.training import pipeline + from {{cookiecutter.module_name}}.training import pipeline pipeline.run(evaluate=False) @cli.command("pipeline:evaluate") def pipeline_evaluate(): """run the training pipeline with test data""" - from ml_pipeline.training import pipeline + from {{cookiecutter.module_name}}.training import pipeline pipeline.run(evaluate=True) @cli.command("app:serve") def app_serve(): """run the api server pipeline with pretrained model""" - from ml_pipeline import app + from {{cookiecutter.module_name}} import app app.run() @cli.command("data:download") def data_download(): """download the train and test data""" - from ml_pipeline import data - from ml_pipeline import config + from {{cookiecutter.module_name}} import data + from {{cookiecutter.module_name}} import config from pathlib import Path data.download(Path(config.paths.data)) @cli.command("data:debug") def data_debug(): """debug the dataset class""" - from ml_pipeline.data import dataset + from {{cookiecutter.module_name}}.data import dataset dataset.debug() diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/common.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/common.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/common.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/common.py diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/app.toml b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/app.toml similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/app.toml rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/app.toml diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/config.toml b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/config.toml similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/config.toml rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/config.toml diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/data.toml b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/data.toml similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/data.toml rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/data.toml diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/model.toml b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/model.toml similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/model.toml rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/model.toml diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/paths.toml b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/paths.toml similarity index 53% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/paths.toml rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/paths.toml index aa3e756..8ba09a9 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/paths.toml +++ b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/paths.toml @@ -1,4 +1,4 @@ [paths] repo = "/path/to/root" -app = "/path/to/root/ml_pipeline" +app = "/path/to/root/{{cookiecutter.module_name}}" data = "/path/to/root/data" diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/training.toml b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/training.toml similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/config/training.toml rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/config/training.toml diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/__init__.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/__init__.py similarity index 94% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/__init__.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/__init__.py index b77bf36..ef2e3f9 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/__init__.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/__init__.py @@ -1,7 +1,7 @@ from pathlib import Path import requests import logging -from ml_pipeline import config +from {{cookiecutter.module_name}} import config logger = logging.getLogger(__name__) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/dataset.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/dataset.py similarity index 97% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/dataset.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/dataset.py index f0bd601..4e764cf 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/dataset.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/dataset.py @@ -5,7 +5,7 @@ import csv import torch from pathlib import Path from typing import Tuple -from ml_pipeline import config, logger +from {{cookiecutter.module_name}} import config, logger class MnistDataset(Dataset): diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/make.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/make.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/make.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/make.py diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/spark.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/spark.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/data/spark.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/data/spark.py diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/features/make.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/features/make.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/features/make.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/features/make.py diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/model/__init__.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/model/__init__.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/model/__init__.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/model/__init__.py diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/model/cnn.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/model/cnn.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/model/cnn.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/model/cnn.py diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/model/linear.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/model/linear.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/model/linear.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/model/linear.py diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/notebooks/features.ipynb b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/notebooks/features.ipynb similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/notebooks/features.ipynb rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/notebooks/features.ipynb diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/notebooks/main.ipynb b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/notebooks/main.ipynb similarity index 60% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/notebooks/main.ipynb rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/notebooks/main.ipynb index 16c4c9e..8f8dace 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/notebooks/main.ipynb +++ b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/notebooks/main.ipynb @@ -8,7 +8,7 @@ "outputs": [], "source": [ "# Now you can import your package\n", - "import ml_pipeline" + "import {{cookiecutter.module_name}}" ] }, { @@ -18,7 +18,7 @@ "metadata": {}, "outputs": [], "source": [ - "from ml_pipeline.data.dataset import MnistDataset" + "from {{cookiecutter.module_name}}.data.dataset import MnistDataset" ] }, { @@ -28,38 +28,9 @@ "metadata": {}, "outputs": [], "source": [ - "from ml_pipeline import config" + "from {{cookiecutter.module_name}} import config" ] }, - { - "cell_type": "code", - "execution_count": 5, - "id": "c8ce7920-c056-44ac-93df-b25bae870592", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "config" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "83293ef7-37b3-452f-8de5-13bee633d099", - "metadata": {}, - "outputs": [], - "source": [] - } ], "metadata": { "kernelspec": { diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/training/__init__.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/training/__init__.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/training/__init__.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/training/__init__.py diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/training/pipeline.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/training/pipeline.py similarity index 84% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/training/pipeline.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/training/pipeline.py index ae58dd6..54306c0 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/training/pipeline.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/training/pipeline.py @@ -1,8 +1,8 @@ from torch.utils.data import DataLoader from torch.optim import AdamW -from ml_pipeline.training.runner import Runner -from ml_pipeline import config, logger +from {{cookiecutter.module_name}}.training.runner import Runner +from {{cookiecutter.module_name}} import config, logger def run(evaluate=False): @@ -30,8 +30,8 @@ def run(evaluate=False): logger.info(f"{step}") def get_model(name='vgg11'): - from ml_pipeline.model.linear import DNN - from ml_pipeline.model.cnn import VGG11 + from {{cookiecutter.module_name}}.model.linear import DNN + from {{cookiecutter.module_name}}.model.cnn import VGG11 if name == 'vgg11': return VGG11(config.data.in_channels, config.data.num_classes) else: @@ -43,7 +43,7 @@ def get_model(name='vgg11'): def get_dataset(evaluate=False): # Usage - from ml_pipeline.data.dataset import MnistDataset + from {{cookiecutter.module_name}}.data.dataset import MnistDataset from torchvision import transforms csv_file_path = config.data.train_path if not evaluate else config.data.test_path transform = transforms.Compose([ diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/training/runner.py b/{{cookiecutter.project_name}}/{{cookiecutter.module_name}}/training/runner.py similarity index 100% rename from {{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/training/runner.py rename to {{cookiecutter.project_name}}/{{cookiecutter.module_name}}/training/runner.py diff --git a/{{cookiecutter.project_slug}}/test/test_cnn.py b/{{cookiecutter.project_slug}}/test/test_cnn.py deleted file mode 100644 index df2073c..0000000 --- a/{{cookiecutter.project_slug}}/test/test_cnn.py +++ /dev/null @@ -1,6 +0,0 @@ -from ml_pipeline import config -from ml_pipeline.model.cnn import VGG11 - -def test_in_channels(): - assert config.model.name == 'vgg11' - diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/__main__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/__main__.py deleted file mode 100644 index 41976c0..0000000 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/__main__.py +++ /dev/null @@ -1,5 +0,0 @@ -from ml_pipeline.cli import cli - -if __name__ == "__main__": - cli() - diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/app/__init__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/app/__init__.py deleted file mode 100644 index 33e214b..0000000 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/app/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from ml_pipeline import config -from fastapi import FastAPI, Response -import logging -import uvicorn - -app = FastAPI() - -logger = logging.getLogger(__name__) - -def run(): - uvicorn.run("ml_pipeline.app:app", host=config.app.host, port=config.app.port, proxy_headers=True)