Deploy#
lit.sdk.services.deploy
#
This module defines the Deploy class, an abstract subclass of Service, which represents a deployment service.
The class provides methods for managing deployment actions such as starting, stopping, restarting, and checking the status of the deploy.
It also includes abstract methods for adding and removing models from the deploy.
__doc__ = '\nThis module defines the `Deploy` class, an abstract subclass of `Service`, which represents a deployment service.\nThe class provides methods for managing deployment actions such as starting, stopping, restarting, and checking the status of the deploy.\nIt also includes abstract methods for adding and removing models from the deploy.\n'
module
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__file__ = '/opt/lit-platform/lit-lib/src/lit/sdk/services/deploy.cpython-312-x86_64-linux-gnu.so'
module
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__name__ = 'lit.sdk.services.deploy'
module
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__package__ = 'lit.sdk.services'
module
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__test__ = {'Deploy.start (line 45)': '\n Starts the deploy.\n\n Returns:\n ServiceActionStatus: A dictionary containing the status of the operation.\n\n Raises:\n LitServiceError: If the deploy failed to start.\n\n Examples:\n >>> deploy = SomeDeploySubclass("contoso", "deploy_name")\n >>> deploy.start()\n {\'status\': \'SUCCESS\', \'message\': \'Deploy started successfully.\'}\n ', 'Deploy.stop (line 63)': '\n Stops the deploy.\n\n Returns:\n ServiceActionStatus: A dictionary containing the status of the operation.\n\n Raises:\n LitServiceError: If the deploy failed to stop.\n\n Examples:\n >>> deploy = SomeDeploySubclass("contoso", "deploy_name")\n >>> deploy.stop()\n {\'status\': \'SUCCESS\', \'message\': \'Deploy stopped successfully.\'}\n ', 'Deploy.restart (line 81)': '\n Restarts the deploy.\n\n Returns:\n ServiceActionStatus: A dictionary containing the status of the operation.\n\n Raises:\n LitServiceError: If the deploy failed to restart.\n\n Examples:\n >>> deploy = SomeDeploySubclass("contoso", "deploy_name")\n >>> deploy.restart()\n {\'status\': \'SUCCESS\', \'message\': \'Deploy restarted successfully.\'}\n ', 'Deploy.status (line 99)': '\n Retrieves the status of the deploy.\n\n Returns:\n ServiceStatus: A dictionary containing the current status of the deploy.\n\n Raises:\n LitServiceError: If the deploy failed to be queried.\n\n Examples:\n >>> deploy = SomeDeploySubclass("contoso", "deploy_name")\n >>> deploy.status()\n {\'name\': \'deploy_name\', \'active\': \'active\', \'status\': \'running\', \'started\': \'Wed 2024-07-24 13:32:23 CDT\', \'pid\': 3687984, \'tasks\': 5, \'memory\': \'3.3G\'}\n ', 'Deploy.add_model (line 117)': '\n Adds a vaulted model to the deploy.\n\n Args:\n model (str): The name of the model to add.\n\n Returns:\n (ServiceActionStatus): a dictionary containing status of operation.\n\n Examples:\n >>> deploy = Deploy("contoso", "my_deploy")\n >>> deploy.add_model("my_model")\n {\'status\': \'SUCCESS\', \'message\': \'model my_model added to deploy my_deploy.\'}\n ', 'Deploy.remove_model (line 141)': '\n Removes a vaulted model from the deploy.\n\n Args:\n model (str): The name of the model to remove.\n\n Returns:\n (ServiceActionStatus): a dictionary containing status of operation.\n\n Examples:\n >>> deploy = Deploy("contoso", "my_deploy")\n >>> deploy.remove_model("my_model")\n {\'status\': \'SUCCESS\', \'message\': \'model my_model removed from deploy my_deploy.\'}\n ', 'get_deployments (line 166)': 'Gets a list of the available deployments.\n\n Args:\n team (str): The name of the team.\n\n Returns:\n (list[Deploy]): List of available deployments.\n\n Examples:\n >>> get_deploys("contoso")\n [Deploy(team=\'contoso\', name=\'test\')]\n '}
module
#
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
Deploy
#
Bases: lit.sdk.services.service.Service
Represents a model deployment service worker.
__abstractmethods__ = frozenset()
class
#
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__annotations__ = {'team': 'str', 'name': 'str'}
class
#
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__doc__ = 'Represents a model deployment service worker.'
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__ = 'lit.sdk.services.deploy'
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__init__(team, name)
method descriptor
#
Initializes a new instance of Deploy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team
|
str
|
The name of the team that owns the Deploy. |
required |
name
|
str
|
The name of the Deploy. |
required |
add_model(model)
method descriptor
#
Adds a vaulted model to the deploy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
The name of the model to add. |
required |
Returns:
| Type | Description |
|---|---|
ServiceActionStatus
|
a dictionary containing status of operation. |
Examples:
remove_model(model)
method descriptor
#
Removes a vaulted model from the deploy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
The name of the model to remove. |
required |
Returns:
| Type | Description |
|---|---|
ServiceActionStatus
|
a dictionary containing status of operation. |
Examples:
LitServiceError
#
Bases: lit.sdk.errors.LitError
A custom exception class for Lit service errors.
__annotations__ = {}
class
#
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__doc__ = 'A custom exception class for Lit service errors.'
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__ = 'lit.sdk.errors'
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__init__(*args, code=None)
method descriptor
#
Initializes a new instance of LitServiceError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
Variable number of arguments to pass to the base class constructor. |
required |
code
|
int | None
|
The error code. Defaults to None. |
None
|
Service
#
Bases: abc.ABC
Abstract base class for managing services.
__abstractmethods__ = frozenset({'stop', 'restart', 'status', 'start'})
class
#
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__annotations__ = {'team': 'str', 'name': 'str'}
class
#
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__doc__ = 'Abstract base class for managing services.'
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__ = 'lit.sdk.services.service'
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__weakref__
property
#
list of weak references to the object
__init__(team, name)
method descriptor
#
Initializes a new instance of Service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team
|
str
|
The name of the team that owns the service. |
required |
name
|
str
|
The name of the service. |
required |
restart()
method descriptor
#
Restarts the service.
Returns:
| Name | Type | Description |
|---|---|---|
ServiceActionStatus |
ServiceActionStatus
|
A dictionary containing the status of the operation. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by a subclass. |
Examples:
start()
method descriptor
#
Starts the service.
Returns:
| Name | Type | Description |
|---|---|---|
ServiceActionStatus |
ServiceActionStatus
|
A dictionary containing the status of the operation. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by a subclass. |
Examples:
status()
method descriptor
#
Retrieves the status of the service.
Returns:
| Name | Type | Description |
|---|---|---|
ServiceStatus |
ServiceStatus
|
A dictionary containing the current status of the service. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by a subclass. |
Examples:
stop()
method descriptor
#
Stops the service.
Returns:
| Name | Type | Description |
|---|---|---|
ServiceActionStatus |
ServiceActionStatus
|
A dictionary containing the status of the operation. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by a subclass. |
Examples:
ServiceActionStatus
#
Bases: builtins.dict
Represents the status of a service action.
Examples:
>>> action_status: ServiceActionStatus = {
... "status": "SUCCESS",
... "message": "Service started successfully."
... }
__annotations__ = {'status': ForwardRef("Literal['SUCCESS', 'ERROR']", module='lit.sdk.services.service'), 'message': ForwardRef('str', module='lit.sdk.services.service')}
class
#
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__doc__ = 'Represents the status of a service action.\n\n Examples:\n >>> action_status: ServiceActionStatus = {\n ... "status": "SUCCESS",\n ... "message": "Service started successfully."\n ... }\n '
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__ = 'lit.sdk.services.service'
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__optional_keys__ = frozenset()
class
#
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__orig_bases__ = (<function TypedDict at 0x7fef89f62e80>,)
class
#
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__required_keys__ = frozenset({'status', 'message'})
class
#
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__total__ = True
class
#
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
__weakref__
property
#
list of weak references to the object
ServiceStatus
#
Bases: builtins.dict
Represents the status of a service.
Examples:
>>> service_status: ServiceStatus = {
... "name": "my_service",
... "active": "active",
... "status": "running",
... "started": "Wed 2024-07-24 13:32:23 CDT",
... "pid": 3687984,
... "tasks": 5,
... "memory": "3.3G"
... }
__annotations__ = {'name': ForwardRef('str', module='lit.sdk.services.service'), 'active': ForwardRef('str', module='lit.sdk.services.service'), 'status': ForwardRef('str', module='lit.sdk.services.service'), 'started': ForwardRef('str', module='lit.sdk.services.service'), 'pid': ForwardRef('int', module='lit.sdk.services.service'), 'tasks': ForwardRef('int', module='lit.sdk.services.service'), 'memory': ForwardRef('str', module='lit.sdk.services.service')}
class
#
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__doc__ = 'Represents the status of a service.\n\n Examples:\n >>> service_status: ServiceStatus = {\n ... "name": "my_service",\n ... "active": "active",\n ... "status": "running",\n ... "started": "Wed 2024-07-24 13:32:23 CDT",\n ... "pid": 3687984,\n ... "tasks": 5,\n ... "memory": "3.3G"\n ... }\n '
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__ = 'lit.sdk.services.service'
class
#
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__optional_keys__ = frozenset()
class
#
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__orig_bases__ = (<function TypedDict at 0x7fef89f62e80>,)
class
#
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__required_keys__ = frozenset({'active', 'name', 'pid', 'started', 'status', 'tasks', 'memory'})
class
#
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__total__ = True
class
#
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
__weakref__
property
#
list of weak references to the object
lit_error_handler(error_type=LitError)
method descriptor
#
A decorator function that catches and re-raises exceptions with a custom error type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error_type
|
Type[LitError]
|
The type of exception to raise. Defaults to LitError. |
LitError
|
Returns:
| Type | Description |
|---|---|
Callable
|
A wrapper function that catches exceptions and raises the specified error type. |
Examples:
>>> @lit_error_handler()
... def raises_error():
... assert False
...
>>> raises_error()
Traceback (most recent call last):
File "/opt/lit/src/lit/sdk/errors.py", line 130, in wrapper
File "<stdin>", line 3, in raises_error
AssertionError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/lit/src/lit/sdk/errors.py", line 132, in wrapper
lit.sdk.errors.LitError: An error occurred in function 'raises_error'