|
3 | 3 | """ |
4 | 4 | import os |
5 | 5 | import sys |
6 | | - |
7 | 6 | import click |
8 | 7 | import logging |
9 | 8 | import coloredlogs |
|
14 | 13 | from mlcube.parser import (CliParser, MLCubeDirectory) |
15 | 14 | from mlcube.platform import Platform |
16 | 15 | from mlcube.runner import Runner |
| 16 | +from mlcube.shell import Shell |
17 | 17 | from mlcube.system_settings import SystemSettings |
18 | 18 | from mlcube.validate import Validate |
19 | 19 |
|
@@ -271,5 +271,24 @@ def _check_tuple(_tuple: t.Tuple, _name: t.Text, _expected_size: int, _expected_ |
271 | 271 | logger.error("Command failed, command = '%s' error = '%s'", ' '.join(sys.argv), str(e)) |
272 | 272 |
|
273 | 273 |
|
| 274 | +@cli.command(name='create', |
| 275 | + help='Create a new MLCube using cookiecutter.') |
| 276 | +def create() -> None: |
| 277 | + """ Create a new MLCube using cookiecutter template. |
| 278 | + - MLCube cookiecutter: https://github.com/mlcommons/mlcube_cookiecutter |
| 279 | + - Example: https://mlcommons.github.io/mlcube/tutorials/create-mlcube/ |
| 280 | + """ |
| 281 | + mlcube_cookiecutter_url = 'https://github.com/mlcommons/mlcube_cookiecutter' |
| 282 | + try: |
| 283 | + from cookiecutter.main import cookiecutter |
| 284 | + proj_dir: t.Text = cookiecutter(mlcube_cookiecutter_url) |
| 285 | + if proj_dir and os.path.isfile(os.path.join(proj_dir, 'mlcube.yaml')): |
| 286 | + Shell.run('mlcube', 'describe', '--mlcube', proj_dir) |
| 287 | + except ImportError: |
| 288 | + print("Cookiecutter library not found.") |
| 289 | + print("\tInstall it: pip install cookiecutter") |
| 290 | + print(f"\tMore details: {mlcube_cookiecutter_url}") |
| 291 | + |
| 292 | + |
274 | 293 | if __name__ == "__main__": |
275 | 294 | cli() |
0 commit comments