Skip to content

Commit

Permalink
Merge pull request #665 from axsaucedo/template_creation_init
Browse files Browse the repository at this point in the history
Template creation with cookiecutter for base project initialisation
  • Loading branch information
axsaucedo authored Jul 14, 2022
2 parents 723cb83 + c9bf822 commit a46b948
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mlserver/cli/init_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import subprocess
from ..logging import logger


def init_cookiecutter_project(template: str):
rc = subprocess.call(["which", "cookiecutter"])
if rc == 0:
cmd = f"cookiecutter {template}"
subprocess.run(cmd, check=True, shell=True)
else:
logger.error(
"The cookiecutter command is not found. \n\n"
"Please install with 'pip install cookiecutter' and retry"
)
13 changes: 13 additions & 0 deletions mlserver/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from functools import wraps

from .init_project import init_cookiecutter_project

from ..server import MLServer
from ..logging import logger, configure_logger
from ..utils import install_uvloop_event_loop
Expand Down Expand Up @@ -58,6 +60,17 @@ async def build(folder: str, tag: str, no_cache: bool = False):
logger.info(f"Successfully built custom Docker image with tag {tag}")


@root.command("init")
# TODO: Update to have template(s) in the SeldonIO org
@click.option("-t", "--template", default="https://github.com/EthicalML/sml-security/")
@click_async
async def init_project(template: str):
"""
Generate a base project template
"""
init_cookiecutter_project(template)


@root.command("dockerfile")
@click.argument("folder", nargs=1)
@click.option("-i", "--include-dockerignore", is_flag=True)
Expand Down

0 comments on commit a46b948

Please sign in to comment.