From b2cb69198825bba3a9611984509ca895a7ecc286 Mon Sep 17 00:00:00 2001 From: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com> Date: Mon, 16 Oct 2023 10:36:01 +0200 Subject: [PATCH] Add alias for mlops-stack template URL (#869) ## Changes Allows users to initialize mlops-stack by running `bundle init mlops-stack` ## Tests Manually ``` shreyas.goenka@THW32HFW6T playground % cli bundle init Template to use [default-python]: mlops-stack Project Name [my-mlops-project]: ^C shreyas.goenka@THW32HFW6T playground % cli bundle init mlops-stack Project Name [my-mlops-project]: ^C ``` --- cmd/bundle/init.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/bundle/init.go b/cmd/bundle/init.go index 3038cb7a..3625b7a9 100644 --- a/cmd/bundle/init.go +++ b/cmd/bundle/init.go @@ -18,6 +18,10 @@ var gitUrlPrefixes = []string{ "git@", } +var aliasedTemplates = map[string]string{ + "mlops-stack": "https://github.com/databricks/mlops-stack", +} + func isRepoUrl(url string) bool { result := false for _, prefix := range gitUrlPrefixes { @@ -68,6 +72,11 @@ func newInitCommand() *cobra.Command { } } + // Expand templatePath if it's an alias for a known template + if _, ok := aliasedTemplates[templatePath]; ok { + templatePath = aliasedTemplates[templatePath] + } + if !isRepoUrl(templatePath) { // skip downloading the repo because input arg is not a URL. We assume // it's a path on the local file system in that case