-
Notifications
You must be signed in to change notification settings - Fork 180
AIR CLI Integration: Scaffold experimental AIR CLI command package #5564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
riddhibhagwat-db
wants to merge
2
commits into
main
Choose a base branch
from
air-integration-m0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,29 @@ | ||
|
|
||
| === help | ||
| >>> [CLI] experimental air --help | ||
| Run and manage AI runtime training workloads on Databricks serverless GPU compute. | ||
|
|
||
| This command set is the Go port of the standalone Python "air" CLI. It is | ||
| experimental and may change in future versions. | ||
|
|
||
| Usage: | ||
| databricks experimental air [command] | ||
|
|
||
| Available Commands: | ||
| cancel Cancel one or more runs | ||
| get Show details for a run | ||
| list List recent runs | ||
| logs Stream or fetch logs for a run | ||
| register-image Mirror a Docker image into the workspace registry | ||
| run Submit a training workload from a YAML config | ||
|
|
||
| Flags: | ||
| -h, --help help for air | ||
|
|
||
| Global Flags: | ||
| --debug enable debug logging | ||
| -o, --output type output type: text or json (default text) | ||
| -p, --profile string ~/.databrickscfg profile | ||
| -t, --target string bundle target to use (if applicable) | ||
|
|
||
| Use "databricks experimental air [command] --help" for more information about a command. |
This file contains hidden or 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,5 @@ | ||
| # Pin the command tree so any change to a subcommand or its short description | ||
| # shows up as a diff here. | ||
|
|
||
| title "help" | ||
| trace $CLI experimental air --help |
This file contains hidden or 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,3 @@ | ||
| # --help prints without authenticating, so no server stubs are needed. | ||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = [] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 @@ | ||
|
|
||
| === run | ||
| >>> [CLI] experimental air run | ||
| Error: `air run` is not implemented yet | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| === get | ||
| >>> [CLI] experimental air get 123 | ||
| Error: `air get` is not implemented yet | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| === list | ||
| >>> [CLI] experimental air list | ||
| Error: `air list` is not implemented yet | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| === logs | ||
| >>> [CLI] experimental air logs 123 | ||
| Error: `air logs` is not implemented yet | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| === cancel | ||
| >>> [CLI] experimental air cancel 123 | ||
| Error: `air cancel` is not implemented yet | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| === register-image | ||
| >>> [CLI] experimental air register-image my-image:latest | ||
| Error: `air register-image` is not implemented yet | ||
|
|
||
| Exit code: 1 |
This file contains hidden or 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,19 @@ | ||
| # Each stub must fail with "not implemented"; errcode records the exit code. | ||
|
|
||
| title "run" | ||
| errcode trace $CLI experimental air run | ||
|
|
||
| title "get" | ||
| errcode trace $CLI experimental air get 123 | ||
|
|
||
| title "list" | ||
| errcode trace $CLI experimental air list | ||
|
|
||
| title "logs" | ||
| errcode trace $CLI experimental air logs 123 | ||
|
|
||
| title "cancel" | ||
| errcode trace $CLI experimental air cancel 123 | ||
|
|
||
| title "register-image" | ||
| errcode trace $CLI experimental air register-image my-image:latest | ||
This file contains hidden or 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,3 @@ | ||
| # Stubs fail locally before any API call, so no server stubs needed. | ||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = [] |
This file contains hidden or 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 hidden or 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 @@ | ||
| package aircmd | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // New returns the root command for the experimental AI runtime CLI. | ||
| // | ||
| // Milestone 0: scaffolds the command group with every subcommand registered as a | ||
| // stub (not yet implemented), pending the port from the Python `air` CLI. | ||
| func New() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "air", | ||
| Short: "Run and manage AI runtime training workloads", | ||
| Long: `Run and manage AI runtime training workloads on Databricks serverless GPU compute. | ||
|
|
||
| This command set is the Go port of the standalone Python "air" CLI. It is | ||
| experimental and may change in future versions.`, | ||
| } | ||
|
|
||
| cmd.AddCommand(newRunCommand()) | ||
| cmd.AddCommand(newGetCommand()) | ||
| cmd.AddCommand(newListCommand()) | ||
| cmd.AddCommand(newLogsCommand()) | ||
| cmd.AddCommand(newCancelCommand()) | ||
| cmd.AddCommand(newRegisterImageCommand()) | ||
|
|
||
| return cmd | ||
| } | ||
|
|
||
| // notImplemented returns the placeholder error used by milestone-0 stubs. | ||
| func notImplemented(name string) error { | ||
| return fmt.Errorf("`air %s` is not implemented yet", name) | ||
| } |
This file contains hidden or 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,22 @@ | ||
| package aircmd | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| // TestNewRegistersAllSubcommands asserts the `air` command wires up every | ||
| // expected subcommand, so none is accidentally dropped from New. | ||
| func TestNewRegistersAllSubcommands(t *testing.T) { | ||
| registered := make(map[string]bool) | ||
| for _, c := range New().Commands() { | ||
| registered[c.Name()] = true | ||
| } | ||
|
|
||
| want := []string{"run", "get", "list", "logs", "cancel", "register-image"} | ||
| for _, name := range want { | ||
| assert.True(t, registered[name], "subcommand %q is not registered", name) | ||
| } | ||
| assert.Len(t, registered, len(want), "unexpected number of subcommands") | ||
| } |
This file contains hidden or 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,39 @@ | ||
| package aircmd | ||
|
|
||
| import ( | ||
| "github.com/databricks/cli/cmd/root" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newCancelCommand() *cobra.Command { | ||
| var ( | ||
| all bool | ||
| yes bool | ||
| ) | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "cancel [RUN_ID...]", | ||
| Short: "Cancel one or more runs", | ||
| Long: `Cancel one or more runs by ID, or cancel all of your active runs with --all.`, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return notImplemented("cancel") | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().BoolVar(&all, "all", false, "Cancel all of your active runs") | ||
| cmd.Flags().BoolVarP(&yes, "yes", "y", false, "Skip the confirmation prompt") | ||
|
|
||
| // Require exactly one of: one or more RUN_IDs, or --all. Cobra parses flags | ||
| // before running this, so `all` reflects the user's input. | ||
| cmd.Args = func(cmd *cobra.Command, args []string) error { | ||
| switch { | ||
| case all && len(args) > 0: | ||
| return &root.InvalidArgsError{Command: cmd, Message: "cannot combine RUN_ID arguments with --all"} | ||
| case !all && len(args) == 0: | ||
| return &root.InvalidArgsError{Command: cmd, Message: "provide at least one RUN_ID, or use --all"} | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| return cmd | ||
| } |
This file contains hidden or 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,19 @@ | ||
| package aircmd | ||
|
|
||
| import ( | ||
| "github.com/databricks/cli/cmd/root" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newGetCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "get RUN_ID", | ||
| Args: root.ExactArgs(1), | ||
| Short: "Show details for a run", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return notImplemented("get") | ||
| }, | ||
| } | ||
|
|
||
| return cmd | ||
| } |
This file contains hidden or 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,31 @@ | ||
| package aircmd | ||
|
|
||
| import ( | ||
| "github.com/databricks/cli/cmd/root" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newListCommand() *cobra.Command { | ||
| var ( | ||
| limit int | ||
| active bool | ||
| allUsers bool | ||
| filters []string | ||
| ) | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "list", | ||
| Args: root.NoArgs, | ||
| Short: "List recent runs", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return notImplemented("list") | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().IntVar(&limit, "limit", 20, "Maximum number of runs to show") | ||
| cmd.Flags().BoolVar(&active, "active", false, "Show only active runs") | ||
| cmd.Flags().BoolVar(&allUsers, "all-users", false, "Show runs from all users") | ||
| cmd.Flags().StringArrayVar(&filters, "filter", nil, "Filter runs, e.g. experiment=foo* (repeatable)") | ||
|
|
||
| return cmd | ||
| } |
This file contains hidden or 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,34 @@ | ||
| package aircmd | ||
|
|
||
| import ( | ||
| "github.com/databricks/cli/cmd/root" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newLogsCommand() *cobra.Command { | ||
| var ( | ||
| node int | ||
| lines int | ||
| retry int | ||
| downloadTo string | ||
| review bool | ||
| ) | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "logs RUN_ID", | ||
| Args: root.ExactArgs(1), | ||
| Short: "Stream or fetch logs for a run", | ||
| Long: `Stream logs from an active run, or fetch logs from a completed run.`, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return notImplemented("logs") | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().IntVar(&node, "node", 0, "Fetch logs from this node") | ||
| cmd.Flags().IntVar(&lines, "lines", 10000, "For completed runs, print the last N lines") | ||
| cmd.Flags().IntVar(&retry, "retry", -1, "View logs from a specific retry attempt; -1 means latest") | ||
| cmd.Flags().StringVar(&downloadTo, "download-to", "", "Download all logs to this directory instead of printing") | ||
| cmd.Flags().BoolVar(&review, "review", false, "Download logs from all nodes and filter for error signatures") | ||
|
|
||
| return cmd | ||
| } |
This file contains hidden or 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 @@ | ||
| package aircmd | ||
|
|
||
| import ( | ||
| "github.com/databricks/cli/cmd/root" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newRegisterImageCommand() *cobra.Command { | ||
| var ( | ||
| scope string | ||
| key string | ||
| interactiveAuth bool | ||
| tagPolicy string | ||
| timeoutMinutes int | ||
| ) | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "register-image IMAGE_URL", | ||
| Args: root.ExactArgs(1), | ||
| Short: "Mirror a Docker image into the workspace registry", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return notImplemented("register-image") | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().StringVar(&scope, "scope", "", "Databricks secret scope holding registry credentials") | ||
| cmd.Flags().StringVar(&key, "key", "", "Databricks secret key holding registry credentials") | ||
| cmd.Flags().BoolVar(&interactiveAuth, "interactive-authenticate", false, "Prompt for registry credentials and store them as a secret") | ||
| cmd.Flags().StringVar(&tagPolicy, "tag-policy", "auto", "Image resolution policy: auto or latest") | ||
| cmd.Flags().IntVar(&timeoutMinutes, "timeout-minutes", 60, "Timeout to wait for the image to become available") | ||
|
|
||
| return cmd | ||
| } |
This file contains hidden or 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 @@ | ||
| package aircmd | ||
|
|
||
| import ( | ||
| "github.com/databricks/cli/cmd/root" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newRunCommand() *cobra.Command { | ||
| var ( | ||
| file string | ||
| watch bool | ||
| overrides []string | ||
| dryRun bool | ||
| idempotencyKey string | ||
| ) | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "run", | ||
| Args: root.NoArgs, | ||
| Short: "Submit a training workload from a YAML config", | ||
| Long: `Submit a training workload to Databricks serverless GPU compute. | ||
|
|
||
| The workload is described by a YAML config file (see --file).`, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return notImplemented("run") | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().StringVarP(&file, "file", "f", "", "Path to the workload YAML config") | ||
| cmd.Flags().BoolVar(&watch, "watch", false, "Stream logs until the run completes") | ||
| cmd.Flags().StringArrayVar(&overrides, "override", nil, "Override a YAML field, e.g. compute.num_accelerators=8 (repeatable)") | ||
| cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Validate the config without submitting") | ||
| cmd.Flags().StringVar(&idempotencyKey, "idempotency-key", "", "Return the existing run if this key was already used") | ||
|
|
||
| return cmd | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.