|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from abc import abstractmethod |
| 4 | +from collections.abc import Mapping, Sized |
| 5 | + |
| 6 | +from typing_extensions import ( |
| 7 | + Any, |
| 8 | + List, |
| 9 | + Literal, |
| 10 | + Protocol, |
| 11 | + SupportsIndex, |
| 12 | + TypedDict, |
| 13 | + overload, |
| 14 | + runtime_checkable, |
| 15 | +) |
| 16 | + |
| 17 | +MatchingType = Literal["any", "exact", "none"] |
| 18 | +"""Directions for how environments are considered for selection. |
| 19 | +
|
| 20 | + - any: The image may be selected by Connect if not defined in the bundle manifest. |
| 21 | + - exact: The image must be defined in the bundle manifest |
| 22 | + - none: Never use this environment |
| 23 | +""" |
| 24 | + |
| 25 | + |
| 26 | +class Installation(TypedDict): |
| 27 | + """Interpreter installation in an execution environment.""" |
| 28 | + |
| 29 | + path: str |
| 30 | + """The absolute path to the interpreter's executable.""" |
| 31 | + |
| 32 | + version: str |
| 33 | + """The semantic version of the interpreter.""" |
| 34 | + |
| 35 | + |
| 36 | +class Installations(TypedDict): |
| 37 | + """Interpreter installations in an execution environment.""" |
| 38 | + |
| 39 | + installations: List[Installation] |
| 40 | + """Interpreter installations in an execution environment.""" |
| 41 | + |
| 42 | + |
| 43 | +class Environment(Mapping[str, Any]): |
| 44 | + @abstractmethod |
| 45 | + def destroy(self) -> None: |
| 46 | + """Destroy the environment. |
| 47 | +
|
| 48 | + Warnings |
| 49 | + -------- |
| 50 | + This operation is irreversible. |
| 51 | +
|
| 52 | + Note |
| 53 | + ---- |
| 54 | + This action requires administrator privileges. |
| 55 | + """ |
| 56 | + |
| 57 | + @abstractmethod |
| 58 | + def update( |
| 59 | + self, |
| 60 | + *, |
| 61 | + title: str, |
| 62 | + description: str | None = ..., |
| 63 | + matching: MatchingType | None = ..., |
| 64 | + supervisor: str | None = ..., |
| 65 | + python: Installations | None = ..., |
| 66 | + quarto: Installations | None = ..., |
| 67 | + r: Installations | None = ..., |
| 68 | + tensorflow: Installations | None = ..., |
| 69 | + ) -> None: |
| 70 | + """Update the environment. |
| 71 | +
|
| 72 | + Parameters |
| 73 | + ---------- |
| 74 | + title : str |
| 75 | + A human-readable title. |
| 76 | + description : str | None, optional, not required |
| 77 | + A human-readable description. |
| 78 | + matching : MatchingType, optional, not required |
| 79 | + Directions for how the environment is considered for selection |
| 80 | + supervisor : str | None, optional, not required |
| 81 | + Path to the supervisor script. |
| 82 | + python : Installations, optional, not required |
| 83 | + The Python installations available in this environment |
| 84 | + quarto : Installations, optional, not required |
| 85 | + The Quarto installations available in this environment |
| 86 | + r : Installations, optional, not required |
| 87 | + The R installations available in this environment |
| 88 | + tensorflow : Installations, optional, not required |
| 89 | + The Tensorflow installations available in this environment |
| 90 | +
|
| 91 | + Note |
| 92 | + ---- |
| 93 | + This action requires administrator privileges. |
| 94 | + """ |
| 95 | + |
| 96 | + |
| 97 | +@runtime_checkable |
| 98 | +class Environments(Sized, Protocol): |
| 99 | + @overload |
| 100 | + def __getitem__(self, index: SupportsIndex) -> Environment: ... |
| 101 | + |
| 102 | + @overload |
| 103 | + def __getitem__(self, index: slice) -> List[Environment]: ... |
| 104 | + |
| 105 | + def create( |
| 106 | + self, |
| 107 | + *, |
| 108 | + title: str, |
| 109 | + name: str, |
| 110 | + cluster_name: str | Literal["Kubernetes"], |
| 111 | + matching: MatchingType = "any", |
| 112 | + description: str | None = ..., |
| 113 | + supervisor: str | None = ..., |
| 114 | + python: Installations | None = ..., |
| 115 | + quarto: Installations | None = ..., |
| 116 | + r: Installations | None = ..., |
| 117 | + tensorflow: Installations | None = ..., |
| 118 | + ) -> Environment: |
| 119 | + """Create an environment. |
| 120 | +
|
| 121 | + Parameters |
| 122 | + ---------- |
| 123 | + title : str |
| 124 | + A human-readable title. |
| 125 | + name : str |
| 126 | + The container image name used for execution in this environment. |
| 127 | + cluster_name : str | Literal["Kubernetes"] |
| 128 | + The cluster identifier for this environment. Defaults to "Kubernetes" when Off-Host-Execution is enabled. |
| 129 | + description : str, optional |
| 130 | + A human-readable description. |
| 131 | + matching : MatchingType |
| 132 | + Directions for how the environment is considered for selection, by default is "any". |
| 133 | + supervisor : str, optional |
| 134 | + Path to the supervisor script |
| 135 | + python : Installations, optional |
| 136 | + The Python installations available in this environment |
| 137 | + quarto : Installations, optional |
| 138 | + The Quarto installations available in this environment |
| 139 | + r : Installations, optional |
| 140 | + The R installations available in this environment |
| 141 | + tensorflow : Installations, optional |
| 142 | + The Tensorflow installations available in this environment |
| 143 | +
|
| 144 | + Returns |
| 145 | + ------- |
| 146 | + Environment |
| 147 | +
|
| 148 | + Note |
| 149 | + ---- |
| 150 | + This action requires administrator privileges. |
| 151 | + """ |
| 152 | + ... |
| 153 | + |
| 154 | + def find(self, guid: str, /) -> Environment: ... |
| 155 | + |
| 156 | + def find_by( |
| 157 | + self, |
| 158 | + *, |
| 159 | + id: str = ..., # noqa: A002 |
| 160 | + guid: str = ..., |
| 161 | + created_time: str = ..., |
| 162 | + updated_time: str = ..., |
| 163 | + title: str = ..., |
| 164 | + name: str = ..., |
| 165 | + description: str | None = ..., |
| 166 | + cluster_name: str | Literal["Kubernetes"] = ..., |
| 167 | + environment_type: str | Literal["Kubernetes"] = ..., |
| 168 | + matching: MatchingType = ..., |
| 169 | + supervisor: str | None = ..., |
| 170 | + python: Installations | None = ..., |
| 171 | + quarto: Installations | None = ..., |
| 172 | + r: Installations | None = ..., |
| 173 | + tensorflow: Installations | None = ..., |
| 174 | + ) -> Environment | None: |
| 175 | + """Find the first record matching the specified conditions. |
| 176 | +
|
| 177 | + There is no implied ordering, so if order matters, you should specify it yourself. |
| 178 | +
|
| 179 | + Parameters |
| 180 | + ---------- |
| 181 | + id : str |
| 182 | + The numerical identifier. |
| 183 | + guid : str |
| 184 | + The unique identifier. |
| 185 | + created_time : str |
| 186 | + The timestamp (RFC3339) when the environment was created. |
| 187 | + updated_time : str |
| 188 | + The timestamp (RFC3339) when the environment was updated. |
| 189 | + title : str |
| 190 | + A human-readable title. |
| 191 | + name : str |
| 192 | + The container image name used for execution in this environment. |
| 193 | + description : str, optional |
| 194 | + A human-readable description. |
| 195 | + cluster_name : str | Literal["Kubernetes"] |
| 196 | + The cluster identifier for this environment. Defaults to "Kubernetes" when Off-Host-Execution is enabled. |
| 197 | + environment_type : str | Literal["Kubernetes"] |
| 198 | + The cluster environment type. Defaults to "Kubernetes" when Off-Host-Execution is enabled. |
| 199 | + matching : MatchingType |
| 200 | + Directions for how the environment is considered for selection. |
| 201 | + supervisor : str, optional |
| 202 | + Path to the supervisor script |
| 203 | + python : Installations, optional |
| 204 | + The Python installations available in this environment |
| 205 | + quarto : Installations, optional |
| 206 | + The Quarto installations available in this environment |
| 207 | + r : Installations, optional |
| 208 | + The R installations available in this environment |
| 209 | + tensorflow : Installations, optional |
| 210 | + The Tensorflow installations available in this environment |
| 211 | +
|
| 212 | + Returns |
| 213 | + ------- |
| 214 | + Environment | None |
| 215 | +
|
| 216 | + Note |
| 217 | + ---- |
| 218 | + This action requires administrator or publisher privileges. |
| 219 | + """ |
| 220 | + ... |
0 commit comments