Add support for extras to the labs CLI (#2288)

## Changes

Added support for extras / optional Python dependencies in the labs CLI.

Added new `extras` field under install.

Example:

```yaml
install:
  script: install.py
  extras: cli
```

Resolves: #2257 

## Tests

Manual test
This commit is contained in:
Marcin Wojtyczka 2025-02-05 14:24:15 +01:00 committed by GitHub
parent 5c90752797
commit 27caf413f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 0 deletions

View File

@ -32,6 +32,7 @@ type hook struct {
RequireDatabricksConnect bool `yaml:"require_databricks_connect,omitempty"`
MinRuntimeVersion string `yaml:"min_runtime_version,omitempty"`
WarehouseTypes whTypes `yaml:"warehouse_types,omitempty"`
Extras string `yaml:"extras,omitempty"`
}
func (h *hook) RequireRunningCluster() bool {
@ -258,6 +259,10 @@ func (i *installer) setupPythonVirtualEnvironment(ctx context.Context, w *databr
}
}
feedback <- "Installing Python library dependencies"
if i.Installer.Extras != "" {
// install main and optional dependencies
return i.installPythonDependencies(ctx, fmt.Sprintf(".[%s]", i.Installer.Extras))
}
return i.installPythonDependencies(ctx, ".")
}

View File

@ -42,6 +42,11 @@
},
"warehouse_types": {
"enum": [ "PRO", "CLASSIC", "TYPE_UNSPECIFIED" ]
},
"extras": {
"type": "string",
"pattern": "^([^,]+)(,([^,]+))*$",
"default": ""
}
}
},

View File

@ -8,6 +8,7 @@ install:
warehouse_types:
- PRO
script: install.py
extras: ""
entrypoint: main.py
min_python: 3.9
commands: