Login
zenml.login
ZenML login utilities.
Modules
credentials
ZenML login credentials models.
Classes
APIToken
Bases: BaseModel
Cached API Token.
expired: bool
property
Check if the token is expired.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the token is expired, False otherwise. |
expires_at_with_leeway: Optional[datetime]
property
Get the token expiration time with leeway.
Returns:
Type | Description |
---|---|
Optional[datetime]
|
The token expiration time with leeway. |
ServerCredentials
Bases: BaseModel
Cached Server Credentials.
api_hyperlink: str
property
Get the hyperlink to the ZenML OpenAPI dashboard for this workspace.
Returns:
Type | Description |
---|---|
str
|
The hyperlink to the ZenML OpenAPI dashboard for this workspace. |
auth_status: str
property
Get the authentication status.
Returns:
Type | Description |
---|---|
str
|
The authentication status. |
dashboard_hyperlink: str
property
Get the hyperlink to the ZenML dashboard for this workspace.
Returns:
Type | Description |
---|---|
str
|
The hyperlink to the ZenML dashboard for this workspace. |
dashboard_organization_url: str
property
Get the URL to the ZenML Pro dashboard for this workspace's organization.
Returns:
Type | Description |
---|---|
str
|
The URL to the ZenML Pro dashboard for this workspace's organization. |
dashboard_url: str
property
Get the URL to the ZenML dashboard for this server.
Returns:
Type | Description |
---|---|
str
|
The URL to the ZenML dashboard for this server. |
expires_at: str
property
Get the expiration time of the token as a string.
Returns:
Type | Description |
---|---|
str
|
The expiration time of the token as a string. |
expires_in: str
property
Get the time remaining until the token expires.
Returns:
Type | Description |
---|---|
str
|
The time remaining until the token expires. |
id: str
property
Get the server identifier.
Returns:
Type | Description |
---|---|
str
|
The server identifier. |
is_available: bool
property
Check if the server is available (running and authenticated).
Returns:
Type | Description |
---|---|
bool
|
True if the server is available, False otherwise. |
organization_hyperlink: str
property
Get the hyperlink to the ZenML Pro dashboard for this server's organization.
Returns:
Type | Description |
---|---|
str
|
The hyperlink to the ZenML Pro dashboard for this server's |
str
|
organization. |
organization_id_hyperlink: str
property
Get the hyperlink to the ZenML Pro dashboard for this workspace's organization using its ID.
Returns:
Type | Description |
---|---|
str
|
The hyperlink to the ZenML Pro dashboard for this workspace's |
str
|
organization using its ID. |
organization_name_hyperlink: str
property
Get the hyperlink to the ZenML Pro dashboard for this server's organization using its name.
Returns:
Type | Description |
---|---|
str
|
The hyperlink to the ZenML Pro dashboard for this server's |
str
|
organization using its name. |
server_id_hyperlink: str
property
Get the hyperlink to the ZenML dashboard for this server using its ID.
Returns:
Type | Description |
---|---|
str
|
The hyperlink to the ZenML dashboard for this server using its ID. |
server_name_hyperlink: str
property
Get the hyperlink to the ZenML dashboard for this server using its name.
Returns:
Type | Description |
---|---|
str
|
The hyperlink to the ZenML dashboard for this server using its name. |
type: ServerType
property
update_server_info(server_info: Union[ServerModel, WorkspaceRead]) -> None
Update with server information received from the server itself or from a ZenML Pro workspace descriptor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_info
|
Union[ServerModel, WorkspaceRead]
|
The server information to update with. |
required |
Source code in src/zenml/login/credentials.py
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 |
|
ServerType
Functions
credentials_store
ZenML login credentials store support.
Classes
CredentialsStore()
Login credentials store.
This is a singleton object that maintains a cache of all API tokens and API keys that are configured for the ZenML servers that the client connects to throughout its lifetime.
The cache is persistent and it is backed by a credentials.yaml
YAML file
kept in the global configuration location. The Credentials Store cache is
populated mainly in the following ways:
1. when the user runs `zenml login` to authenticate to a ZenML Pro
server, the ZenML Pro API token fetched from the web login flow is
stored in the Credentials Store.
2. when the user runs `zenml login` to authenticate to a regular ZenML
server with the web login flow, the ZenML server API token fetched
through the web login flow is stored in the Credentials Store
3. when the user runs `zenml login` to authenticate to any ZenML server
using an API key, the API key is stored in the Credentials Store
4. when the REST zen store is initialized, it starts up not yet
authenticated. Then, if/when it needs to authenticate or re-authenticate
to the remote server, it will use whatever form of credentials it finds
in the Credentials Store, in order of priority:
* if it finds an API token that is not expired (e.g. authorized
device API tokens fetched through the web login flow or short-lived
session API tokens fetched through some other means of
authentication), it will use that to authenticate
* for ZenML servers that use an API key to authenticate, it will use
that to fetch a short-lived ZenML Pro server API token that it also
stores in the Credentials Store
* for ZenML Pro servers, it exchanges the longer-lived ZenML Pro API
token into a short lived ZenML Pro server API token
Alongside credentials, the Credentials Store is also used to store
additional server information:
* ZenML Pro workspace information populated by the zenml login
command
* ZenML server information populated by the REST zen store by fetching
the server's information endpoint after authenticating
Initializes the login credentials store with values loaded from the credentials YAML file.
CredentialsStore is a singleton class: only one instance can exist. Calling this constructor multiple times will always yield the same instance.
Source code in src/zenml/login/credentials_store.py
88 89 90 91 92 93 94 95 96 |
|
can_login(server_url: str) -> bool
Check if credentials to login to the given server exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which to check the authentication. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the credentials store contains credentials that can be used |
bool
|
to login to the given server URL, False otherwise. |
Source code in src/zenml/login/credentials_store.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
check_and_reload_from_file() -> None
Check if the credentials file has been modified and reload it if necessary.
Source code in src/zenml/login/credentials_store.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
clear_all_pro_tokens(pro_api_url: Optional[str] = None) -> List[ServerCredentials]
Delete all tokens from the store for ZenML Pro servers connected to a given API server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pro_api_url
|
Optional[str]
|
The URL of the ZenML Pro API server. |
None
|
Returns:
Type | Description |
---|---|
List[ServerCredentials]
|
A list of the credentials that were cleared. |
Source code in src/zenml/login/credentials_store.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
clear_credentials(server_url: str) -> None
Delete all credentials from the store for a specific server URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which to delete the credentials. |
required |
Source code in src/zenml/login/credentials_store.py
631 632 633 634 635 636 637 638 639 640 641 |
|
clear_pro_credentials(pro_api_url: str) -> None
Delete the token from the store for a ZenML Pro API server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pro_api_url
|
str
|
The URL of the ZenML Pro API server. |
required |
Source code in src/zenml/login/credentials_store.py
336 337 338 339 340 341 342 |
|
clear_token(server_url: str) -> None
Delete a token from the store for a specific server URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which to delete the token. |
required |
Source code in src/zenml/login/credentials_store.py
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 |
|
get_api_key(server_url: str) -> Optional[str]
Retrieve an API key from the credentials store for a specific server URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which to retrieve the API key. |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
The stored API key if it exists, None otherwise. |
Source code in src/zenml/login/credentials_store.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
|
get_credentials(server_url: str) -> Optional[ServerCredentials]
Retrieve the credentials for a specific server URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which to retrieve the credentials. |
required |
Returns:
Type | Description |
---|---|
Optional[ServerCredentials]
|
The stored credentials if they exist, None otherwise. |
Source code in src/zenml/login/credentials_store.py
281 282 283 284 285 286 287 288 289 290 291 |
|
get_instance() -> Optional[CredentialsStore]
classmethod
Get the singleton instance of the CredentialsStore.
Returns:
Type | Description |
---|---|
Optional[CredentialsStore]
|
The singleton instance of the CredentialsStore. |
Source code in src/zenml/login/credentials_store.py
119 120 121 122 123 124 125 126 |
|
get_password(server_url: str) -> Tuple[Optional[str], Optional[str]]
Retrieve the username and password from the credentials store for a specific server URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which to retrieve the username and password. |
required |
Returns:
Type | Description |
---|---|
Tuple[Optional[str], Optional[str]]
|
The stored username and password if they exist, None otherwise. |
Source code in src/zenml/login/credentials_store.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
get_pro_credentials(pro_api_url: str, allow_expired: bool = False) -> Optional[ServerCredentials]
Retrieve a valid token from the credentials store for a ZenML Pro API server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pro_api_url
|
str
|
The URL of the ZenML Pro API server. |
required |
allow_expired
|
bool
|
Whether to allow expired tokens to be returned. The default behavior is to return None if a token does exist but is expired. |
False
|
Returns:
Type | Description |
---|---|
Optional[ServerCredentials]
|
The stored credentials if they exist and are not expired, None otherwise. |
Source code in src/zenml/login/credentials_store.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
get_pro_token(pro_api_url: str, allow_expired: bool = False) -> Optional[APIToken]
Retrieve a valid token from the credentials store for a ZenML Pro API server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pro_api_url
|
str
|
The URL of the ZenML Pro API server. |
required |
allow_expired
|
bool
|
Whether to allow expired tokens to be returned. The default behavior is to return None if a token does exist but is expired. |
False
|
Returns:
Type | Description |
---|---|
Optional[APIToken]
|
The stored token if it exists and is not expired, None otherwise. |
Source code in src/zenml/login/credentials_store.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
get_token(server_url: str, allow_expired: bool = False) -> Optional[APIToken]
Retrieve a valid token from the credentials store for a specific server URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which to retrieve the token. |
required |
allow_expired
|
bool
|
Whether to allow expired tokens to be returned. The default behavior is to return None if a token does exist but is expired. |
False
|
Returns:
Type | Description |
---|---|
Optional[APIToken]
|
The stored token if it exists and is not expired, None otherwise. |
Source code in src/zenml/login/credentials_store.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
has_valid_authentication(url: str) -> bool
Check if a valid authentication credential for the given server URL is stored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The server URL for which to check the authentication. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if a valid token or API key is stored, False otherwise. |
Source code in src/zenml/login/credentials_store.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
|
has_valid_pro_authentication(pro_api_url: str) -> bool
Check if a valid token for a ZenML Pro API server is stored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pro_api_url
|
str
|
The URL of the ZenML Pro API server. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if a valid token is stored, False otherwise. |
Source code in src/zenml/login/credentials_store.py
389 390 391 392 393 394 395 396 397 398 |
|
list_credentials(type: Optional[ServerType] = None) -> List[ServerCredentials]
Get all credentials stored in the credentials store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type
|
Optional[ServerType]
|
Optional server type to filter the credentials by. |
None
|
Returns:
Type | Description |
---|---|
List[ServerCredentials]
|
A list of all credentials stored in the credentials store. |
Source code in src/zenml/login/credentials_store.py
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
|
reset_instance(store: Optional[CredentialsStore] = None) -> None
classmethod
Reset the singleton instance of the CredentialsStore.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
store
|
Optional[CredentialsStore]
|
Optional instance of the CredentialsStore to set as the singleton instance. If None, a new instance will be created. |
None
|
Source code in src/zenml/login/credentials_store.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
set_api_key(server_url: str, api_key: str) -> None
Store an API key in the credentials store for a specific server URL.
If an API token or a password is already stored for the server URL, they will be replaced by the API key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which the token is to be stored. |
required |
api_key
|
str
|
The API key to store. |
required |
Source code in src/zenml/login/credentials_store.py
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
set_bare_token(server_url: str, token: str) -> APIToken
Store a bare API token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which the token is to be stored. |
required |
token
|
str
|
The token to store. |
required |
Returns:
Name | Type | Description |
---|---|---|
APIToken |
APIToken
|
The stored token. |
Source code in src/zenml/login/credentials_store.py
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
|
set_password(server_url: str, username: str, password: str) -> None
Store a username and password in the credentials store for a specific server URL.
If an API token is already stored for the server URL, it will be replaced by the username and password.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which the token is to be stored. |
required |
username
|
str
|
The username to store. |
required |
password
|
str
|
The password to store. |
required |
Source code in src/zenml/login/credentials_store.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
|
set_token(server_url: str, token_response: OAuthTokenResponse, is_zenml_pro: bool = False) -> APIToken
Store an API token received from an OAuth2 server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which the token is to be stored. |
required |
token_response
|
OAuthTokenResponse
|
Token response received from an OAuth2 server. |
required |
is_zenml_pro
|
bool
|
Whether the token is for a ZenML Pro server. |
False
|
Returns:
Name | Type | Description |
---|---|---|
APIToken |
APIToken
|
The stored token. |
Source code in src/zenml/login/credentials_store.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
|
update_server_info(server_url: str, server_info: Union[ServerModel, WorkspaceRead]) -> None
Update the server information stored for a specific server URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server_url
|
str
|
The server URL for which the server information is to be updated. |
required |
server_info
|
Union[ServerModel, WorkspaceRead]
|
Updated server information. |
required |
Source code in src/zenml/login/credentials_store.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
|
Functions
get_credentials_store() -> CredentialsStore
Get the global credentials store instance.
Returns:
Type | Description |
---|---|
CredentialsStore
|
The global credentials store instance. |
Source code in src/zenml/login/credentials_store.py
664 665 666 667 668 669 670 |
|
Modules
pro
ZenML Pro client.
Modules
client
ZenML Pro client.
ZenMLProClient(url: str, api_token: Optional[APIToken] = None)
ZenML Pro client.
Initialize the ZenML Pro client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of the ZenML Pro API server. |
required |
api_token
|
Optional[APIToken]
|
The API token to use for authentication. If not provided, the token is fetched from the credentials store. |
None
|
Raises:
Type | Description |
---|---|
AuthorizationException
|
If no API token is provided and no token is found in the credentials store. |
Source code in src/zenml/login/pro/client.py
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 |
|
api_token: str
property
Get the API token.
Returns:
Type | Description |
---|---|
str
|
The API token. |
organization: OrganizationClient
property
session: requests.Session
property
Authenticate to the ZenML Pro API server.
Returns:
Type | Description |
---|---|
Session
|
A requests session with the authentication token. |
workspace: WorkspaceClient
property
delete(path: str, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Json
Make a DELETE request to the given endpoint path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the endpoint. |
required |
params
|
Optional[Dict[str, Any]]
|
The query parameters to pass to the endpoint. |
None
|
kwargs
|
Any
|
Additional keyword arguments to pass to the request. |
{}
|
Returns:
Type | Description |
---|---|
Json
|
The response body. |
Source code in src/zenml/login/pro/client.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
get(path: str, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Json
Make a GET request to the given endpoint path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the endpoint. |
required |
params
|
Optional[Dict[str, Any]]
|
The query parameters to pass to the endpoint. |
None
|
kwargs
|
Any
|
Additional keyword arguments to pass to the request. |
{}
|
Returns:
Type | Description |
---|---|
Json
|
The response body. |
Source code in src/zenml/login/pro/client.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
patch(path: str, body: Optional[BaseRestAPIModel] = None, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Json
Make a PATCH request to the given endpoint path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the endpoint. |
required |
body
|
Optional[BaseRestAPIModel]
|
The body to send. |
None
|
params
|
Optional[Dict[str, Any]]
|
The query parameters to pass to the endpoint. |
None
|
kwargs
|
Any
|
Additional keyword arguments to pass to the request. |
{}
|
Returns:
Type | Description |
---|---|
Json
|
The response body. |
Source code in src/zenml/login/pro/client.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
post(path: str, body: BaseRestAPIModel, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Json
Make a POST request to the given endpoint path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the endpoint. |
required |
body
|
BaseRestAPIModel
|
The body to send. |
required |
params
|
Optional[Dict[str, Any]]
|
The query parameters to pass to the endpoint. |
None
|
kwargs
|
Any
|
Additional keyword arguments to pass to the request. |
{}
|
Returns:
Type | Description |
---|---|
Json
|
The response body. |
Source code in src/zenml/login/pro/client.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
put(path: str, body: Optional[BaseRestAPIModel] = None, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Json
Make a PUT request to the given endpoint path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the endpoint. |
required |
body
|
Optional[BaseRestAPIModel]
|
The body to send. |
None
|
params
|
Optional[Dict[str, Any]]
|
The query parameters to pass to the endpoint. |
None
|
kwargs
|
Any
|
Additional keyword arguments to pass to the request. |
{}
|
Returns:
Type | Description |
---|---|
Json
|
The response body. |
Source code in src/zenml/login/pro/client.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
raise_on_expired_api_token() -> None
Raise an exception if the API token has expired.
Raises:
Type | Description |
---|---|
AuthorizationException
|
If the API token has expired. |
Source code in src/zenml/login/pro/client.py
126 127 128 129 130 131 132 133 134 135 136 |
|
constants
ZenML Pro login constants.
models
ZenML Pro base models.
BaseRestAPIModel
Bases: BaseModel
Base class for all REST API models.
organization
ZenML Pro organization client.
client
ZenML Pro organization client.
OrganizationClient(client: ZenMLProClient)
Organization management client.
Initialize the organization client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
ZenMLProClient
|
ZenML Pro client. |
required |
Source code in src/zenml/login/pro/organization/client.py
31 32 33 34 35 36 37 38 39 40 |
|
get(id_or_name: Union[UUID, str]) -> OrganizationRead
Get an organization by id or name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_name
|
Union[UUID, str]
|
Id or name of the organization to retrieve. |
required |
Returns:
Type | Description |
---|---|
OrganizationRead
|
An organization. |
Source code in src/zenml/login/pro/organization/client.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
list(offset: int = 0, limit: int = 20) -> List[OrganizationRead]
async
List organizations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
int
|
Query offset. |
0
|
limit
|
int
|
Query limit. |
20
|
Returns:
Type | Description |
---|---|
List[OrganizationRead]
|
List of organizations. |
Source code in src/zenml/login/pro/organization/client.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
models
ZenML Pro organization models.
OrganizationRead
utils
ZenML Pro login utils.
get_troubleshooting_instructions(url: str) -> str
Get troubleshooting instructions for a given ZenML Pro server URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
ZenML Pro server URL |
required |
Returns:
Type | Description |
---|---|
str
|
Troubleshooting instructions |
Source code in src/zenml/login/pro/utils.py
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 |
|
workspace
ZenML Pro workspace client.
client
ZenML Pro workspace client.
WorkspaceClient(client: ZenMLProClient)
Workspace management client.
Initialize the workspace client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
ZenMLProClient
|
ZenML Pro client. |
required |
Source code in src/zenml/login/pro/workspace/client.py
31 32 33 34 35 36 37 38 39 40 |
|
get(id: UUID) -> WorkspaceRead
Get a workspace by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
UUID
|
Id. of the workspace to retrieve. |
required |
Returns:
Type | Description |
---|---|
WorkspaceRead
|
A workspace. |
Source code in src/zenml/login/pro/workspace/client.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
list(offset: int = 0, limit: int = 20, workspace_name: Optional[str] = None, url: Optional[str] = None, organization_id: Optional[UUID] = None, status: Optional[WorkspaceStatus] = None, member_only: bool = False) -> List[WorkspaceRead]
List workspaces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
int
|
Offset to use for filtering. |
0
|
limit
|
int
|
Limit used for filtering. |
20
|
workspace_name
|
Optional[str]
|
Workspace name to filter by. |
None
|
url
|
Optional[str]
|
Workspace service URL to filter by. |
None
|
organization_id
|
Optional[UUID]
|
Organization ID to filter by. |
None
|
status
|
Optional[WorkspaceStatus]
|
Filter for only workspaces with this status. |
None
|
member_only
|
bool
|
If True, only list workspaces where the user is a member (i.e. users that can connect to the workspace). |
False
|
Returns:
Type | Description |
---|---|
List[WorkspaceRead]
|
List of workspaces. |
Source code in src/zenml/login/pro/workspace/client.py
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 |
|
models
ZenML Pro workspace models.
WorkspaceRead
Bases: BaseRestAPIModel
Pydantic Model for viewing a Workspace.
dashboard_organization_url: str
property
Get the URL to the ZenML Pro dashboard for this workspace's organization.
Returns:
Type | Description |
---|---|
str
|
The URL to the ZenML Pro dashboard for this workspace's organization. |
dashboard_url: str
property
Get the URL to the ZenML Pro dashboard for this workspace.
Returns:
Type | Description |
---|---|
str
|
The URL to the ZenML Pro dashboard for this workspace. |
organization_id: UUID
property
Get the organization id.
Returns:
Type | Description |
---|---|
UUID
|
The organization id. |
organization_name: str
property
Get the organization name.
Returns:
Type | Description |
---|---|
str
|
The organization name. |
url: Optional[str]
property
Get the ZenML server URL.
Returns:
Type | Description |
---|---|
Optional[str]
|
The ZenML server URL, if available. |
version: Optional[str]
property
Get the ZenML service version.
Returns:
Type | Description |
---|---|
Optional[str]
|
The ZenML service version. |
WorkspaceStatus
Bases: StrEnum
Enum that represents the desired state or status of a workspace.
These values can be used in two places:
- in the
desired_state
field of a workspace object, to indicate the desired state of the workspace (with the exception ofPENDING
andFAILED
which are not valid values fordesired_state
) - in the
status
field of a workspace object, to indicate the current state of the workspace
ZenMLServiceConfiguration
ZenMLServiceRead
ZenMLServiceStatus
server_info
ZenML server information retrieval.
Classes
Functions
get_server_info(url: str) -> Optional[ServerModel]
Retrieve server information from a remote ZenML server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of the ZenML server. |
required |
Returns:
Type | Description |
---|---|
Optional[ServerModel]
|
The server information or None if the server info could not be fetched. |
Source code in src/zenml/login/server_info.py
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 |
|
web_login
ZenML OAuth2 device authorization grant client support.
Classes
Functions
web_login(url: Optional[str] = None, verify_ssl: Optional[Union[str, bool]] = None, pro_api_url: Optional[str] = None) -> APIToken
Implements the OAuth2 Device Authorization Grant flow.
This function implements the client side of the OAuth2 Device Authorization Grant flow as defined in https://tools.ietf.org/html/rfc8628, with the following customizations:
- the unique ZenML client ID (
user_id
in the global config) is used as the OAuth2 client ID value - additional information is added to the user agent header to be used by users to identify the ZenML client
Upon completion of the flow, the access token is saved in the credentials store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
Optional[str]
|
The URL of the OAuth2 server. If not provided, the ZenML Pro API server is used by default. |
None
|
verify_ssl
|
Optional[Union[str, bool]]
|
Whether to verify the SSL certificate of the OAuth2 server. If a string is passed, it is interpreted as the path to a CA bundle file. |
None
|
pro_api_url
|
Optional[str]
|
The URL of the ZenML Pro API server. If not provided, the default ZenML Pro API server URL is used. |
None
|
Returns:
Type | Description |
---|---|
APIToken
|
The response returned by the OAuth2 server. |
Raises:
Type | Description |
---|---|
AuthorizationException
|
If an error occurred during the authorization process. |
Source code in src/zenml/login/web_login.py
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 202 203 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 |
|