adalib.lab
¶
The Lab sub-package exposes the core integrations of the user's Lab environment in AdaLab.
Functions¶
build_image_from_git ¶
build_image_from_git(git_url, file_path, image_name, image_tag, image_type, branch='', build_args={}, commit='', git_creds={}, project_name='', timeout=3600)
Build a container image from a container file in a Git repository.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
git_url |
str
|
full URL of Git repository containing the container file |
required |
file_path |
str
|
path to the container file in the Git repository |
required |
image_name |
str
|
the name of the target image |
required |
image_tag |
str
|
the tag of the target image |
required |
image_type |
str
|
the type of the image |
required |
branch |
str
|
the branch of the Git repository to use, defaults to default |
''
|
build_args |
dict[str, str]
|
additional build arguments to pass build process, defaults to {} |
{}
|
commit |
str
|
the commit hash of the Git repository to use, defaults to "" |
''
|
git_creds |
dict[str, str]
|
credentials to authenticate to the Git repository. For SSH, use keys "PRIVATE_KEY_FILE" and "PASSWORD". For HTTPS, use keys "USERNAME" and "PASSWORD". |
{}
|
project_name |
str
|
the name of the project to link the image to, defaults to image_name |
''
|
timeout |
int
|
the maximum time (in seconds) to wait for the build to complete, defaults to 3600 |
3600
|
Returns:
Type | Description |
---|---|
int
|
the run ID of the build process |
Source code in adalib/lab/lab.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
build_image_from_lab ¶
build_image_from_lab(file_path, image_name, image_tag, image_type, project_name='', build_args={}, timeout=3600)
Build a container image from a container file in the Lab.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
path to the container file in the Lab |
required |
image_name |
str
|
the name of the target image |
required |
image_tag |
str
|
the tag of the target image |
required |
image_type |
str
|
the type of the image |
required |
project_name |
str
|
the name of the project to link the image to, defaults to image_name |
''
|
build_args |
dict[str, str]
|
additional build arguments to pass build process, defaults to {} |
{}
|
timeout |
int
|
the maximum time (in seconds) to wait for the build to complete, defaults to 3600 |
3600
|
Returns:
Type | Description |
---|---|
int
|
the run ID of the build process |
Source code in adalib/lab/lab.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
convert_token_to_value ¶
Convert a Lab Configuration token into the true decrypted value from the user input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token |
str
|
the token to convert |
required |
Returns:
Type | Description |
---|---|
str
|
the true decrypted value of the token |
Source code in adalib/lab/lab.py
delete_files ¶
Delete files or folders in the user's Lab environment.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
paths |
list[str]
|
paths to the files to delete, relative to the user's home directory |
required |
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in adalib/lab/lab.py
download_file ¶
Download a file from the user's Lab environment and save it to a specific location.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
path to the file in the Lab environment, including file name and extension, relative to the user's home directory (/home/ |
required |
target_path |
str
|
path to save the file to, including file name and extension, relative to the current working directory |
required |
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in adalib/lab/lab.py
get_available_kernels ¶
Get a list of available kernel images in the Harbor registry.
Use the example Jupyter Notebook to test this function or build upon it.
Returns:
Type | Description |
---|---|
list
|
a list of available kernels |
Source code in adalib/lab/lab.py
get_build_logs ¶
Get the build or system logs of an image build process.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
build_id |
int
|
the run ID of the build process |
required |
source |
str
|
the source of the logs, either "build" or "system", defaults to "build" |
'build'
|
Returns:
Type | Description |
---|---|
list
|
build logs |
Source code in adalib/lab/lab.py
get_build_status ¶
Get the status of a build process.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
build_id |
int
|
the run ID of the build process |
required |
Returns:
Type | Description |
---|---|
str
|
the status of the build process |
Source code in adalib/lab/lab.py
get_config_options ¶
Get the available Lab configuration options for the user.
Use the example Jupyter Notebook to test this function or build upon it.
Returns:
Type | Description |
---|---|
list
|
list of existing Lab configuration options |
Source code in adalib/lab/lab.py
get_installed_kernels ¶
Get a list of the kernels that are installed in the user's Lab environment.
Use the example Jupyter Notebook to test this function or build upon it.
Returns:
Type | Description |
---|---|
list
|
a list of installed kernels |
Source code in adalib/lab/lab.py
get_kernel_metadata_id ¶
Get the metadata ID of the object corresponding to a specific kernel image.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kernel_name |
str
|
the name of the repository containing the kernel image |
required |
kernel_tag |
str
|
the tag of the kernel image |
required |
Returns:
Type | Description |
---|---|
int
|
the metadata ID of the kernel image |
Source code in adalib/lab/lab.py
get_lab_files ¶
Get a list of the files under a directory in the user's Lab environment.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
path to list the files from, relative to the user's home directory (/home/ |
required |
Returns:
Type | Description |
---|---|
list
|
files in the directory |
Source code in adalib/lab/lab.py
get_lab_images ¶
Get a list of container images present in the user's Lab environment.
Use the example Jupyter Notebook to test this function or build upon it.
Returns:
Type | Description |
---|---|
list
|
a list of available images |
Source code in adalib/lab/lab.py
get_lab_logs ¶
Get the logs of the user's Lab environment.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
from_date |
str
|
the start date for the logs, in ISO format (YYYY-MM-DDTHH:mm:ss+HH:mm), defaults to "" |
''
|
to_date |
str
|
the end date for the logs, in ISO format (YYYY-MM-DDTHH:mm:ss+HH:mm), defaults to "" |
''
|
source |
str
|
the source of the logs, either "user" or "system", defaults to "user" |
'user'
|
Returns:
Type | Description |
---|---|
list
|
Lab logs |
Source code in adalib/lab/lab.py
get_lab_status ¶
Get configuration and status information about the user's Lab environment.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metrics |
bool
|
whether to fetch Lab metrics, defaults to True |
True
|
options |
bool
|
whether to fetch Lab options, defaults to True |
True
|
Returns:
Type | Description |
---|---|
dict
|
Lab information |
Source code in adalib/lab/lab.py
install_kernel ¶
Install a kernel into the user's Lab environment.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata_id |
int
|
the metadata ID of the kernel to install |
required |
name |
str
|
name to be given to the installed kernel |
required |
include_notebook |
bool
|
whether to include a dummy notebook file with the kernel, defaults to True |
True
|
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in adalib/lab/lab.py
move_file ¶
Move a file or folder in the user's Lab environment. Note that this operation can also be used to rename a file or folder.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
old_path |
str
|
path to the file to move, including file name and extension, relative to the user's home directory |
required |
new_path |
str
|
new path to save the file to, including file name and extension, relative to the user's home directory |
required |
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in adalib/lab/lab.py
stop_lab ¶
Stop the user's Lab environment.
Use the example Jupyter Notebook to test this function or build upon it.
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in adalib/lab/lab.py
uninstall_kernel ¶
Uninstall a kernel from the user's Lab environment.
Use the example Jupyter Notebook to test this function or build upon it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the name of the kernel to uninstall |
required |
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in adalib/lab/lab.py
who_am_i ¶
Get information about the current user.
Use the example Jupyter Notebook to test this function or build upon it.
Returns:
Type | Description |
---|---|
dict
|
information about the current user |