|
| 1 | +export default `locals { |
| 2 | + coder_git_repos = [ |
| 3 | + "coder/coder", "coder/code-server", "coder/weno", "coder/preview" |
| 4 | + ] |
| 5 | + |
| 6 | + coder_ml_git_repos = [ |
| 7 | + "coder/ml-nexus", "coder/models" |
| 8 | + ] |
| 9 | + |
| 10 | + ml_framework_options = [ |
| 11 | + "None", # Some users may install their own |
| 12 | + "PyTorch", "TensorFlow", "JAX" |
| 13 | + ] |
| 14 | +} |
| 15 | +
|
| 16 | +# Repo Picker |
| 17 | +data "coder_parameter" "git_repo" { |
| 18 | + name = "Git Repo" |
| 19 | + description = "Select the repository to clone into your workspace." |
| 20 | + type = "string" |
| 21 | + form_type = "dropdown" |
| 22 | +
|
| 23 | + dynamic "option" { |
| 24 | + for_each = concat(local.coder_git_repos, local.coder_ml_git_repos) |
| 25 | + content { |
| 26 | + name = option.value |
| 27 | + value = option.value |
| 28 | + } |
| 29 | + } |
| 30 | +} |
| 31 | +
|
| 32 | +data "coder_parameter" "ml_framework" { |
| 33 | + # Show this parameter iff git_repo is one of the ML repos |
| 34 | + count = contains( |
| 35 | + local.coder_ml_git_repos, |
| 36 | + try(data.coder_parameter.git_repo.value, "") |
| 37 | + ) ? 1 : 0 |
| 38 | +
|
| 39 | + name = "ML Framework" |
| 40 | + description = "Select the primary ML framework for this project." |
| 41 | + type = "string" |
| 42 | + form_type = "dropdown" |
| 43 | +
|
| 44 | +
|
| 45 | + dynamic "option" { |
| 46 | + for_each = local.ml_framework_options |
| 47 | + content { |
| 48 | + value = replace(lower(option.value), " ", "") # e.g. "pytorch" |
| 49 | + name = option.value # e.g. "PyTorch" |
| 50 | + } |
| 51 | + } |
| 52 | +} |
| 53 | +
|
| 54 | +# Now, the ML framework selected by users working on ML projects |
| 55 | +# can be referenced during provisioning with: |
| 56 | +# |
| 57 | +# data.coder_parameter.ml_framework.value |
| 58 | +#` |
0 commit comments