Models

The models module provides data models and types used throughout the CLI for representing applications, workloads, configurations, and other entities.

Generic Models

Common generic models and base classes.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.generic.instance_classproperty(fget)[source]

Bases: Generic[T]

Property that works on instances and classes.

Parameters:

fget (Callable[..., T])

__init__(fget)[source]

Initialize instance-class property.

Parameters:

fget (Callable[[...], T])

Return type:

None

__get__(owner_self, owner_cls)[source]

Get descriptor.

Return type:

TypeVar(T)

Parameters:
  • owner_self (Any)

  • owner_cls (Any)

class kelvin.sdk.lib.models.generic.OSInfo[source]

Bases: object

is_posix: bool = True
temp_dir = '/tmp'
class kelvin.sdk.lib.models.generic.Dependency(dependency)[source]

Bases: object

Parameters:

dependency (str)

name: str
version: str
property is_ksos_core_component: bool
property pretty_name: str
class kelvin.sdk.lib.models.generic.KPath(*args, **kwargs)[source]

Bases: PosixPath

raise_if_has_files()[source]

Raise an exception if the path contains files.

Raises:

ValueError – if the path contains files

delete_dir()[source]

A simple wrapper around the deletion of a directory.

Returns

KPath

the same KPath object

create_dir(parents=True, exist_ok=True, **kwargs)[source]

Create a directory.

Parameters:
  • parents (bool, optional) – create parents if not exist. Defaults to True.

  • exist_ok (bool, optional) – raise if exist not ok. Defaults to True.

read_yaml_all(verbose=True)[source]

Load the content of the specified yaml_file into a dictionary.

Return type:

Iterator

Parameters:

verbose (bool)

Parameters

verbosebool

indicates whether it should be verbose about the read content

Returns

Generator

a dictionary containing the yaml data.

read_yaml(context=None, delimiter_style=DelimiterStyle.BRACE, verbose=True)[source]

Load the content of the specified yaml_file into a dictionary.

Return type:

Dict[str, Any]

Parameters:

Parameters

contextOptional[Mapping[str, Any]]

context variable used to render the template.

delimiter_styleDelimiterStyle

the delimiter used to render the template.

verbosebool

Indicates whether it should log the path of the read file.

Returns

Dict[str, Any]

a dictionary containing the yaml data.

write_yaml(yaml_data)[source]

Write the provided yaml data to a file.

Parameters

yaml_datadict

the yaml data to write into the file

Returns

Parameters:

yaml_data (dict)

complete_path()[source]
Return type:

KPath

read_content()[source]

Read content from the provided file.

write_content(content)[source]

Write the provided data to the file.

Parameters

contentstr

the data to write into the file

Returns

KPath

the same KPath object

Parameters:

content (str)

read_json()[source]

Read json content from the provided file.

Return type:

dict

Returns

dict

the file’s content as json

write_json(content)[source]

Parameters

contentAny

the json data to write into the file

Returns

KPath

the same KPath object

Parameters:

content (Any)

dir_content()[source]

Retrieve the list of files contained inside the folder.

Return type:

List[str]

Returns

List[str]

the list of all the files inside the container

clone_into(path)[source]

Clones the current file into the newly provided path.

Parameters

pathKPath

the path to clone the current file into

Returns

KPath

the same KPath object

Parameters:

path (KPath)

clone_dir_into(path)[source]

Clones the current directory into the newly provided dir path.

Parameters

pathKPath

the path to clone the current directory into

Returns

KPath

the same KPath object

Parameters:

path (KPath)

remove()[source]

A simple remove wrapper for KPath

Returns

KPath

the same KPath object

class kelvin.sdk.lib.models.generic.KSDKModel(**data)[source]

Bases: BaseModel

Extends Pydantic BaseModel with a few additional functionalities.

to_file(path, sort_keys=True)[source]

Auxiliary method to output the contents of the current model into a file

Parameters

pathKPath

the path to output the contents to.

sort_keysbool

orders the yaml by key alphabetically.

Returns

KPath

the same KSDKModel

Parameters:
classmethod from_yaml(path)[source]

Create a model instance from a yaml file.

Return type:

Self

Parameters:

path (KPath)

Parameters

pathKPath

the path to load the contents from.

Returns

Self

the model instance

output_schema(output_file_path)[source]

Output the current model’s schema to the specified file.

Return type:

bool

Parameters:

output_file_path (KPath)

Parameters

output_file_path : the file to output the schema into

Returns

bool

a boolean indicating whether or not the schema was successfully output.

class kelvin.sdk.lib.models.generic.KSDKSettings(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, **values)[source]

Bases: KSDKModel, BaseSettings

Parameters:
class Config[source]

Bases: object

classmethod customise_sources(init_settings, env_settings, file_secret_settings)[source]

Set the priority of inputs

Return type:

Tuple[Callable[[BaseSettings], Dict[str, Any]], ...]

Parameters:
class kelvin.sdk.lib.models.generic.GenericObject(data)[source]

Bases: object

A simple generic object used to wrap-up dictionaries into a class. Uses reflection to set data dynamically.

Parameters:

data (Mapping)

to_dict()[source]
Return type:

dict

kelvin.sdk.lib.models.generic.render_template(content, context, delimiter_style)[source]

Render content with context.

Return type:

str

Parameters:

Parameters

contentstr

the content to render the template

contextMapping[str, Any]

the context to render the content with

delimiter_styleDelimiterStyle

the delimiter style of the rendering operation

Returns

str

the rendered template in a string

Types

Type definitions and enumerations used across the SDK.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.types.BaseEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

classmethod as_list()[source]
Return type:

List[str]

property value_as_str: str
class kelvin.sdk.lib.models.types.DelimiterStyle(*values)[source]

Bases: BaseEnum

ANGULAR = ('<+', '+>')
BRACE = ('{{', '}}')
class kelvin.sdk.lib.models.types.EmbeddedFiles(*values)[source]

Bases: BaseEnum

EMPTY_FILE = 'empty_file'
DOCKERIGNORE = '.dockerignore'
KELVIN_PYTHON_APP_GITIGNORE = '.gitignore'
KELVIN_PYTHON_APP_PYPROJECT = 'pyproject.toml'
KELVIN_PYTHON_APP_DOCKERFILE = 'kelvin_python_app_dockerfile'
BRIDGE_PYTHON_APP_DOCKERFILE = 'bridge_python_app_dockerfile'
DEFAULT_DATATYPE_TEMPLATE = 'datatype.yml'
class kelvin.sdk.lib.models.types.FileType(*values)[source]

Bases: BaseEnum

ROOT = 'root'
APP = 'app'
CONFIGURATION = 'configuration'
BUILD = 'build'
DATA = 'data'
DATATYPE = 'datatype'
DOCS = 'docs'
TESTS = 'tests'
WHEELS = 'wheels'
SCHEMAS = 'schemas'
AGENT = 'agent'
GITHUB = 'github'
class kelvin.sdk.lib.models.types.LogColor(*values)[source]

Bases: BaseEnum

COLORED = 'colored'
COLORLESS = 'colorless'
class kelvin.sdk.lib.models.types.LogType(*values)[source]

Bases: BaseEnum

KSDK = 'KSDK'
JSON = 'JSON'
class kelvin.sdk.lib.models.types.StatusDataSource(*values)[source]

Bases: BaseEnum

CACHE = 'cache'
LIVE = 'live'
class kelvin.sdk.lib.models.types.ShellType(*values)[source]

Bases: BaseEnum

BASH = 'bash'
ZSH = 'zsh'
FISH = 'fish'
class kelvin.sdk.lib.models.types.VersionStatus(*values)[source]

Bases: BaseEnum

UNSUPPORTED = 1
OUT_OF_DATE = 2
UP_TO_DATE = 3
class kelvin.sdk.lib.models.types.WorkloadFileType(*values)[source]

Bases: BaseEnum

CSV = 'csv'
JSON = 'json'
YAML = 'yaml'
static parse_file_type(file_type, file)[source]
Return type:

WorkloadFileType

Parameters:
  • file_type (str | None)

  • file (Path)

Operation Models

Models for representing operation results and responses.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.operation.OperationResponse(**data)[source]

Bases: KSDKModel

Parameters:
success: bool
data: Any
log: Any | str
stream: BinaryIO | CancellableStream | None
class Config[source]

Bases: object

arbitrary_types_allowed = True
print()[source]
Return type:

None

Docker Models

Models for Docker-related configurations and data.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.ksdk_docker.KSDKDockerVolume(**data)[source]

Bases: KSDKModel

Parameters:
  • source_file_path (KPath)

  • container_file_path (str)

  • content (str)

source_file_path: KPath
container_file_path: str
content: str
class kelvin.sdk.lib.models.ksdk_docker.KSDKNetworkConfiguration(**data)[source]

Bases: KSDKModel

Parameters:
  • network_name (str)

  • network_driver (str)

network_name: str
network_driver: str
class kelvin.sdk.lib.models.ksdk_docker.KSDKDockerAuthentication(**data)[source]

Bases: KSDKModel

Parameters:
  • registry_url (str)

  • registry_port (str)

  • username (str)

  • password (str)

registry_url: str
registry_port: str
username: str
password: str
property full_registry_url: str
property docker_client_credentials: dict
class kelvin.sdk.lib.models.ksdk_docker.DockerPort(**data)[source]

Bases: KSDKModel

Parameters:
  • Type (str)

  • PrivatePort (str)

  • PublicPort (str)

port_type: str
private_port: str
public_port: str
property port_mapping: str
class kelvin.sdk.lib.models.ksdk_docker.DockerMount(**data)[source]

Bases: KSDKModel

Parameters:
mount_type: str
source: str
destination: str
mode: str
rw: str
bind_propagation: str
property pretty_display_format: str
class kelvin.sdk.lib.models.ksdk_docker.DockerContainer(**data)[source]

Bases: KSDKModel

Parameters:
id: str
container_names: List[str] | None
image_name: str
running: bool
status: str
labels: dict | None
ip_address: str | None
mounts: List[DockerMount] | None
ports: List[DockerPort]
property container_status_for_display: str
property container_ports_for_display: str
property container_mounts_for_display: str
static get_docker_container_object(raw_container_object)[source]

From a raw container object provided by the Docker API, yield a valid DockerContainer Object for better data handling.

Return type:

DockerContainer

Parameters:

raw_container_object (dict)

Parameters

raw_container_objectdict

a raw container data object provided by the Docker Client API

Returns

DockerContainer

the final object that contains all the its simplified variables

class kelvin.sdk.lib.models.ksdk_docker.DockerImage(**data)[source]

Bases: KSDKModel

Parameters:
id: str
parent_id: str
tags: List[str]
created: int
labels: dict | None
size: int | None
property readable_created_date: str
static get_docker_image_object(raw_image_object)[source]

From a raw image object provided by the Docker API, yield a valid DockerImage Object for better data handling.

Return type:

DockerImage

Parameters:

raw_image_object (dict)

Parameters

raw_image_objectdict

a raw image data object provided by the Docker Client API

Returns

DockerImage

the final object that contains all the its simplified variables

class kelvin.sdk.lib.models.ksdk_docker.DockerImageName(**data)[source]

Bases: KSDKModel

Docker image name parser >>> image = DockerImageName.parse(‘alpha.kelvininc.com:5000/someapp:1.0.0@sha256:14bf…’) >>> image DockerImageName(hostname=’alpha.kelvininc.com:5000’, name=’someapp’, tag=’1.0.0’, digest=’sha256:14bf…’)

Parameters:
  • hostname (str | None)

  • name (str)

  • raw_name (str)

  • version (str | None)

  • digest (str | None)

hostname: str | None
name: str
raw_name: str
version: str | None
digest: str | None
classmethod parse(name)[source]
Return type:

DockerImageName

Parameters:

name (str)

property name_with_version: str
property repository_image_name: str
property repository_image_name_without_version: str
property container_name: str
class kelvin.sdk.lib.models.ksdk_docker.DockerNetwork(**data)[source]

Bases: KSDKModel

Parameters:
name: str
id: str
driver: str
created: str
class kelvin.sdk.lib.models.ksdk_docker.DockerProgressEntry(**data)[source]

Bases: KSDKModel

Parameters:
  • id (str | None)

  • status (str | None)

  • progress (str | None)

id: str | None
status: str | None
progress: str | None

Global Configuration

Models for SDK global configuration settings.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.ksdk_global_configuration.GenericMetadataEntry(**data)[source]

Bases: KSDKModel

Parameters:
  • url (str | None)

  • path (str | None)

  • realm (str | None)

  • port (str | None)

  • client_id (str | None)

url: str | None
path: str | None
realm: str | None
port: str | None
client_id: str | None
class kelvin.sdk.lib.models.ksdk_global_configuration.DockerMetadataEntry(**data)[source]

Bases: GenericMetadataEntry

Parameters:
  • url (str | None)

  • path (str | None)

  • realm (str | None)

  • port (str | None)

  • client_id (str | None)

property full_docker_registry_url: str
class kelvin.sdk.lib.models.ksdk_global_configuration.SchemaMetadataEntry(**data)[source]

Bases: GenericMetadataEntry

Parameters:
  • url (str | None)

  • path (str | None)

  • realm (str | None)

  • port (str | None)

  • client_id (str | None)

  • minimum_spec_version (str)

  • latest_spec_version (str)

minimum_spec_version: str
latest_spec_version: str
class kelvin.sdk.lib.models.ksdk_global_configuration.ComponentsMetadataEntry(**data)[source]

Bases: GenericMetadataEntry

Parameters:
  • url (str | None)

  • path (str | None)

  • realm (str | None)

  • port (str | None)

  • client_id (str | None)

  • kelvin_broker (str)

  • kelvin_studio (str)

  • kelvin_python_app_builder (str)

  • kelvin_python_app_runner (str)

  • kelvin_python_app_runner_slim (str)

  • kelvin_control_change_manager (str)

kelvin_broker: str
kelvin_studio: str
kelvin_python_app_builder: str
kelvin_python_app_runner: str
kelvin_python_app_runner_slim: str
kelvin_control_change_manager: str
get_runner_docker_image_for_lang(reduced_size=True, app_lang=None)[source]
Return type:

str

Parameters:
get_builder_docker_image_for_lang(app_lang=None)[source]
Return type:

str

Parameters:

app_lang (ApplicationLanguage | None)

class Config[source]

Bases: object

allow_population_by_field_name = True
class kelvin.sdk.lib.models.ksdk_global_configuration.SDKMetadataEntry(**data)[source]

Bases: GenericMetadataEntry

Parameters:
docker_minimum_version: str | None
ksdk_minimum_version: str
ksdk_latest_version: str
components: ComponentsMetadataEntry
class kelvin.sdk.lib.models.ksdk_global_configuration.CompanyMetadata(**data)[source]

Bases: KSDKModel

Parameters:
authentication: GenericMetadataEntry
docker: DockerMetadataEntry
documentation: GenericMetadataEntry
sdk: SDKMetadataEntry
kelvin_schema: SchemaMetadataEntry
get_min_and_latest_schema_versions()[source]

Return the latest schema version from the metadata.

Return type:

Tuple[str, str]

Returns

Tuple[str, str]

the tuple including both minimum and latest versions allowed from the schema.

class kelvin.sdk.lib.models.ksdk_global_configuration.KelvinSDKEnvironmentVariables(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, **values)[source]

Bases: KSDKSettings

Parameters:
ksdk_version_warning: bool
ksdk_colored_logs: bool
ksdk_debug: bool
class Config[source]

Bases: object

extra = 'allow'
fields = {'ksdk_colored_logs': {'description': 'If disabled, all logs will be output in the default OS color, ready to be captured.', 'env': 'KSDK_COLORED_LOGS'}, 'ksdk_debug': {'description': 'If enabled, display debug information for errors.', 'env': 'KSDK_DEBUG'}, 'ksdk_version_warning': {'description': 'If outdated, KSDK will warn the user. If the minimum version is not respected, it will block any operation until upgrade.', 'env': 'KSDK_VERSION_WARNING'}}
classmethod invalid_value(value)[source]
Return type:

Any

Parameters:

value (Any)

property descriptions: dict
property private_fields: list
class kelvin.sdk.lib.models.ksdk_global_configuration.KelvinSDKConfiguration(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, **values)[source]

Bases: KSDKSettings

Parameters:
last_metadata_refresh: float
current_url: str
current_user: str
ksdk_current_version: str
ksdk_minimum_version: str
ksdk_latest_version: str
configurations: KelvinSDKEnvironmentVariables
classmethod validate_configurations(v)[source]
Return type:

KelvinSDKEnvironmentVariables

Parameters:

v (Any)

property versions: dict
reset()[source]
Return type:

Any

classmethod from_file(ksdk_config_file_path)[source]
Return type:

Any

Parameters:

ksdk_config_file_path (KPath)

classmethod from_default_config()[source]
Return type:

KelvinSDKConfiguration

class kelvin.sdk.lib.models.ksdk_global_configuration.KelvinSDKGlobalConfiguration(**data)[source]

Bases: KSDKSettings

Parameters:
ksdk_config_dir_path: KPath
kelvin_sdk: KelvinSDKConfiguration
property ksdk_temp_dir_path: KPath

Return the path to the KSDK’s temporary directory. Usually hosted under ~/.config/kelvin/temp/

Returns

KPath

The KPath object to the temporary directory.

property ksdk_schema_dir_path: KPath

Return the path to the app schema hosting directory. Usually hosted under ~/.config/kelvin/schemas/

Returns

KPath

The KPath object to the app schema directory.

property ksdk_config_file_path: KPath

Return the complete path to the ksdk config file. Usually hosted under ~/.config/kelvin/ksdk.yaml

Returns

KPath

The KPath object to the ksdk configuration file.

property ksdk_client_config_file_path: KPath

Return the complete path to the ksdk client config file. Usually hosted under ~/.config/kelvin/client.yaml

Returns

KPath

The KPath object to the ksdk client configuration file.

property ksdk_history_file_path: KPath

Return the complete path to the ksdk history log file. Usually hosted under ~/.config/kelvin/ksdk_history.log

Returns

KPath

The KPath object to the ksdk history log file.

commit_ksdk_configuration()[source]
Return type:

KelvinSDKGlobalConfiguration

reset_ksdk_configuration()[source]
Return type:

Any

set_configuration(configuration, value)[source]
Return type:

bool

Parameters:
  • configuration (str)

  • value (Any)

unset_configuration(configuration)[source]
Return type:

bool

Parameters:

configuration (str)

Application Models

Models for representing different types of Kelvin applications.

Common

Shared models and utilities for application types.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.apps.common.LoggingLevel(*values)[source]

Bases: BaseEnum

TRACE = 'TRACE'
DEBUG = 'DEBUG'
INFO = 'INFO'
WARN = 'WARN'
ERROR = 'ERROR'
class kelvin.sdk.lib.models.apps.common.Storage(*values)[source]

Bases: BaseEnum

none = 'none'
node = 'node'
node_and_cloud = 'node-and-cloud'
class kelvin.sdk.lib.models.apps.common.Protocol(*values)[source]

Bases: BaseEnum

OPCUA = 'OPCUA'
MQTT = 'MQTT'
ROC = 'ROC'
MODBUS = 'MODBUS'
class kelvin.sdk.lib.models.apps.common.Access(*values)[source]

Bases: BaseEnum

RO = 'RO'
RW = 'RW'
class kelvin.sdk.lib.models.apps.common.Stage(*values)[source]

Bases: BaseEnum

map = 'map'
class kelvin.sdk.lib.models.apps.common.Version[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?$')
__lt__(other)[source]

Less than comparison.

Return type:

bool

Parameters:

other (str)

class kelvin.sdk.lib.models.apps.common.NonEmptyString[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^.+$')
class kelvin.sdk.lib.models.apps.common.NameDNS[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^[a-z]([-a-z0-9]*[a-z0-9])?$')
class kelvin.sdk.lib.models.apps.common.Identifier[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^[a-zA-Z]\\w*$')
class kelvin.sdk.lib.models.apps.common.Port[source]

Bases: StrictInt

gt: int | None = 0
le: int | None = 65535
class kelvin.sdk.lib.models.apps.common.PortName[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^[a-z]([-a-z0-9]*[a-z0-9])?$')
class kelvin.sdk.lib.models.apps.common.PythonEntryPoint[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^[a-zA-Z]\\w*(\\.[a-zA-Z]\\w*)*(:[a-zA-Z]\\w*)?$')
class kelvin.sdk.lib.models.apps.common.DottedIdentifier[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^([a-z][a-z0-9_]+\\.)+[a-z][a-z0-9_]+$')
class kelvin.sdk.lib.models.apps.common.Name[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^[a-z0-9]([-_.a-z0-9]*[a-z0-9])?$')
class kelvin.sdk.lib.models.apps.common.Credentials(**data)[source]

Bases: KSDKModel

Parameters:
  • username (str)

  • password (str)

username: str
password: str
class kelvin.sdk.lib.models.apps.common.Authentication(**data)[source]

Bases: KSDKModel

Parameters:
type: str
credentials: Credentials
class kelvin.sdk.lib.models.apps.common.Mqtt(**data)[source]

Bases: KSDKModel

Parameters:
ip: str
port: Port
authentication: Authentication | None
static default_mqtt_configuration(ip_address)[source]
Return type:

dict

Parameters:

ip_address (str)

class kelvin.sdk.lib.models.apps.common.DataType(**data)[source]

Bases: KSDKModel

Parameters:
name: DottedIdentifier
version: Version
path: str | None
property name_with_version: str
class kelvin.sdk.lib.models.apps.common.EnvironmentVar(**data)[source]

Bases: KSDKModel

Parameters:
name: Identifier
value: str | None
class kelvin.sdk.lib.models.apps.common.Images(**data)[source]

Bases: KSDKModel

Parameters:
  • runner (str | None)

  • builder (str | None)

runner: str | None
builder: str | None
class kelvin.sdk.lib.models.apps.common.ApplicationLanguage(*values)[source]

Bases: BaseEnum

python = 'python'
get_extension()[source]
Return type:

str

class kelvin.sdk.lib.models.apps.common.PythonLanguageType(**data)[source]

Bases: KSDKModel

Parameters:
class Config[source]

Bases: object

extra = 'allow'
entry_point: PythonEntryPoint
requirements: str | None
flavour: str | None
property app_file_system_name: str
get_flavour()[source]
Return type:

Optional[ApplicationFlavour]

requirements_file_path(app_dir_path)[source]

When provided with an application dir, yield the complete requirements.txt absolute file path

Return type:

Optional[KPath]

Parameters:

app_dir_path (KPath)

Parameters

app_dir_pathKPath

the application’s directory path

Returns

KPath

the complete path to the requirements.txt file considering the application’s directory.

requirements_available(app_dir_path)[source]

Indicates whether requirements are available within the requirements.txt file

Return type:

Tuple[bool, Optional[KPath]]

Parameters:

app_dir_path (KPath)

Parameters

app_dir_pathKPath

the application’s directory path

Returns

Tuple[bool, Optional[KPath]]

A tuple containing (left) a bool indicating there are requirements and (right) the path to the file

class kelvin.sdk.lib.models.apps.common.Language(**data)[source]

Bases: KSDKModel

Parameters:
type: ApplicationLanguage
python: PythonLanguageType | None

Kelvin App

Models for Kelvin application configurations.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.apps.kelvin_app.DeviceTypeName(*values)[source]

Bases: BaseEnum

asset = 'asset'
component = 'component'
part = 'part'
sensor = 'sensor'
enterprise = 'enterprise'
site = 'site'
area = 'area'
productionline = 'production-line'
processcell = 'process-cell'
productionunit = 'production-unit'
storageunit = 'storage-unit'
class kelvin.sdk.lib.models.apps.kelvin_app.AssetsEntry(**data)[source]

Bases: KSDKModel

Parameters:
name: NonEmptyString | None
properties: Any | None
parameters: Any | None
metrics: Any | None
class kelvin.sdk.lib.models.apps.kelvin_app.MetricInfo(**data)[source]

Bases: KSDKModel

Parameters:
node_names: List[NameDNS] | None
workload_names: List[NameDNS] | None
asset_names: List[Name] | None
names: List[Name] | None
class kelvin.sdk.lib.models.apps.kelvin_app.Metric(**data)[source]

Bases: KSDKModel

Parameters:
name: Name
data_type: str
class kelvin.sdk.lib.models.apps.kelvin_app.MetricInput(**data)[source]

Bases: Metric

Parameters:
sources: List[MetricInfo] | None
class kelvin.sdk.lib.models.apps.kelvin_app.MetricOutput(**data)[source]

Bases: Metric

Parameters:
targets: List[MetricInfo] | None
storage: Storage | None
retain: bool | None
control_change: bool | None
class kelvin.sdk.lib.models.apps.kelvin_app.KelvinAppType(**data)[source]

Bases: KSDKModel

Parameters:
logging_level: LoggingLevel | None
images: Images | None
assets: List[AssetsEntry] | None
global_: MetricInfo | None
system_packages: List[str] | None
mqtt: Mqtt | None
language: Language
data_types: List[DataType] | None
inputs: List[MetricInput] | None
outputs: List[MetricOutput] | None
configuration: Any | None

Bridge App

Models for Bridge application configurations.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.apps.bridge_app.MetricsMapEntry(**data)[source]

Bases: KSDKModel

Parameters:
name: Name
asset_name: NonEmptyString
data_type: str
access: Access | None
storage: Storage | None
configuration: Any | None
retain: bool | None
class kelvin.sdk.lib.models.apps.bridge_app.BridgeAppType(**data)[source]

Bases: KSDKModel

Parameters:
protocol: Protocol | None
logging_level: LoggingLevel | None
images: Images | None
system_packages: List[str] | None
mqtt: Mqtt | None
language: Language
data_types: List[DataType] | None
metrics_map: List[MetricsMapEntry]
configuration: Any

Docker App

Models for Docker-based application configurations.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.apps.docker_app.DockerAppType(**data)[source]

Bases: KSDKModel

Parameters:
dockerfile: str
context: str
args: List[str] | None

KSDK App Configuration

Models for KSDK application configuration files.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.apps.ksdk_app_configuration.Encoding(*values)[source]

Bases: BaseEnum

utf_8 = 'utf-8'
ascii = 'ascii'
latin_1 = 'latin_1'
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.Info(**data)[source]

Bases: KSDKModel

Parameters:
name: NameDNS
version: Version
title: str
description: str
property app_name_with_version: str
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.ProjectType(*values)[source]

Bases: str, Enum

app = 'app'
importer = 'importer'
exporter = 'exporter'
docker = 'docker'
kelvin = 'kelvin'
legacy_docker = 'legacy_docker'
bridge = 'bridge'
kelvin_legacy = 'kelvin_legacy'
classmethod app_types_as_str()[source]

Applications supported by the schema in a string list for enumeration purposes

Return type:

List[str]

Returns

project_class_name()[source]
Return type:

str

app_type_on_config()[source]
Return type:

str

class kelvin.sdk.lib.models.apps.ksdk_app_configuration.ApplicationFlavour(*values)[source]

Bases: BaseEnum

default = 'default'
pubsub = 'pubsub'
mlflow = 'mlflow'
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.App(**data)[source]

Bases: KSDKModel

Parameters:
type: ProjectType
kelvin: KelvinAppType | None
bridge: BridgeAppType | None
docker: DockerAppType | None
property app_type_configuration: KelvinAppType | BridgeAppType | None
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.Memory[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^[0-9]+(\\.[0-9]+)?(K|M|G|Ki|Mi|Gi)$')
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.CPU[source]

Bases: StrictStr

regex: str | Pattern[str] | None = re.compile('^[0-9]+(\\.[0-9]+)?(m|)$')
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.SystemResources(**data)[source]

Bases: KSDKModel

Parameters:
memory: Memory | None
cpu: CPU | None
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.Resources(**data)[source]

Bases: KSDKModel

Parameters:
limits: SystemResources | None
requests: SystemResources | None
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.PortMappingType(*values)[source]

Bases: BaseEnum

host = 'host'
service = 'service'
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.ExternalPort[source]

Bases: StrictInt

gt: int | None = 30000
le: int | None = 32767
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.PortMappingService(**data)[source]

Bases: KSDKModel

Parameters:
container_port: Port | None
port: Port
exposed: bool | None
exposed_port: ExternalPort | None
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.PortMappingHostPort(**data)[source]

Bases: KSDKModel

Parameters:

port (Port)

port: Port
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.PortMapping(**data)[source]

Bases: KSDKModel

Parameters:
name: PortName
type: PortMappingType
host: PortMappingHostPort | None
service: PortMappingService | None
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.VolumeType(*values)[source]

Bases: BaseEnum

text = 'text'
host = 'host'
persistent = 'persistent'
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.VolumeText(**data)[source]

Bases: KSDKModel

Parameters:
data: str
base64: bool | None
encoding: Encoding | None
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.VolumeHost(**data)[source]

Bases: KSDKModel

Parameters:

source (str)

source: str
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.Volume(**data)[source]

Bases: KSDKModel

Parameters:
name: NameDNS | None
target: str
type: VolumeType
text: VolumeText | None
host: VolumeHost | None
persistent: Any | None
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.System(**data)[source]

Bases: KSDKModel

Parameters:
resources: Resources | None
privileged: bool | None
environment_vars: List[EnvironmentVar] | None
ports: List[PortMapping] | None
volumes: List[Volume] | None
class kelvin.sdk.lib.models.apps.ksdk_app_configuration.Environment(**data)[source]

Bases: KSDKModel

Parameters:
node_name: NameDNS | None
workload_name: NameDNS | None
static default_environment_configuration(node_name, app_name)[source]
Return type:

dict

Parameters:
  • node_name (str)

  • app_name (str)

class kelvin.sdk.lib.models.apps.ksdk_app_configuration.KelvinAppConfiguration(**data)[source]

Bases: KSDKModel

Parameters:
spec_version: Version
environment: Environment | None
info: Info
system: System | None
app: App

KSDK App Setup

Models for KSDK application setup and initialization.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.apps.ksdk_app_setup.TemplateFile(**data)[source]

Bases: KSDKModel

Parameters:
name: str
content: Template
options: Dict[str, Any]
class Config[source]

Bases: object

arbitrary_types_allowed = True
class kelvin.sdk.lib.models.apps.ksdk_app_setup.File(**data)[source]

Bases: KSDKModel

Parameters:
file: KPath
content: str
executable: bool
create()[source]
Return type:

bool

classmethod content_exists(v)[source]
Return type:

Any

Parameters:

v (str)

Bases: KSDKModel

Parameters:
target_path: str
create()[source]

Create a symbolic link pointing to target_path.

Returns True if the symlink was created, False if it was skipped or failed.

Return type:

bool

class kelvin.sdk.lib.models.apps.ksdk_app_setup.Directory(**data)[source]

Bases: KSDKModel

Parameters:
directory: KPath
files: List[File]
create()[source]
Return type:

bool

exists()[source]
Return type:

bool

path()[source]
Return type:

str

class kelvin.sdk.lib.models.apps.ksdk_app_setup.ProjectCreationParametersObject(**data)[source]

Bases: KSDKModel

Parameters:
app_dir: str
app_name: str
app_version: str
app_description: str
app_type: ProjectType
app_flavour: ApplicationFlavour
kelvin_app_lang: ApplicationLanguage
classmethod single_app_name(value)[source]
Return type:

str

Parameters:

value (Any)

get_entrypoint()[source]
Return type:

str

get_language_block(requirements=None)[source]
Return type:

dict

Parameters:

requirements (str | None)

class kelvin.sdk.lib.models.apps.ksdk_app_setup.Inout(**data)[source]

Bases: KSDKModel

Parameters:
name: str
type: str
class kelvin.sdk.lib.models.apps.ksdk_app_setup.MLFlowProjectCreationParametersObject(**data)[source]

Bases: ProjectCreationParametersObject

Parameters:
inputs: List[Inout]
outputs: List[Inout]
class kelvin.sdk.lib.models.apps.ksdk_app_setup.ProjectBuildingObject(**data)[source]

Bases: KSDKModel

Parameters:
fresh_build: bool
build_for_upload: bool
app_name: str
app_version: str
app_type: str
app_config_file_path: KPath
app_config_raw: Dict
app_config_model: KelvinAppConfiguration | None
app_dir_path: KPath
app_build_dir_path: KPath
docker_image_labels: dict
docker_image_name: str
docker_registry: str
build_args: Dict[str, str] | None
archs: List[str]
property full_docker_image_name: str
class kelvin.sdk.lib.models.apps.ksdk_app_setup.KelvinAppBuildingObject(**data)[source]

Bases: ProjectBuildingObject

Parameters:
  • fresh_build (bool)

  • build_for_upload (bool)

  • app_name (str)

  • app_version (str)

  • app_type (str)

  • app_config_file_path (KPath)

  • app_config_raw (Dict)

  • app_config_model (KelvinAppConfiguration | None)

  • app_dir_path (KPath)

  • app_build_dir_path (KPath)

  • docker_image_labels (dict)

  • docker_image_name (str)

  • docker_registry (str)

  • build_args (Dict[str, str] | None)

  • archs (List[str])

  • dockerfile_path (KPath)

  • docker_build_context_path (KPath)

  • kelvin_app_builder_image (str)

  • kelvin_app_runner_image (str)

  • reduced_size_kelvin_app_runner_image (bool)

  • docker_image_version (str)

  • app_datatype_dir_path (KPath | None)

  • build_for_datatype_compilation (bool)

  • upload_datatypes (bool)

dockerfile_path: KPath
docker_build_context_path: KPath
kelvin_app_builder_image: str
kelvin_app_runner_image: str
reduced_size_kelvin_app_runner_image: bool
docker_image_version: str
app_datatype_dir_path: KPath | None
build_for_datatype_compilation: bool
upload_datatypes: bool
get_wheels_dir()[source]
Return type:

Optional[str]

get_dockerfile_template()[source]

From the current application build object, yield the correct dockerfile template.

Return type:

EmbeddedFiles

Returns

EmbeddedFiles

the correct dockerfile template name.

get_dockerfile_run_command()[source]
Return type:

Tuple[Optional[str], Optional[str]]

class kelvin.sdk.lib.models.apps.ksdk_app_setup.BridgeAppBuildingObject(**data)[source]

Bases: KelvinAppBuildingObject

Parameters:
  • fresh_build (bool)

  • build_for_upload (bool)

  • app_name (str)

  • app_version (str)

  • app_type (str)

  • app_config_file_path (KPath)

  • app_config_raw (Dict)

  • app_config_model (KelvinAppConfiguration | None)

  • app_dir_path (KPath)

  • app_build_dir_path (KPath)

  • docker_image_labels (dict)

  • docker_image_name (str)

  • docker_registry (str)

  • build_args (Dict[str, str] | None)

  • archs (List[str])

  • dockerfile_path (KPath)

  • docker_build_context_path (KPath)

  • kelvin_app_builder_image (str)

  • kelvin_app_runner_image (str)

  • reduced_size_kelvin_app_runner_image (bool)

  • docker_image_version (str)

  • app_datatype_dir_path (KPath | None)

  • build_for_datatype_compilation (bool)

  • upload_datatypes (bool)

get_dockerfile_run_command()[source]
Return type:

Tuple[Optional[str], Optional[str]]

class kelvin.sdk.lib.models.apps.ksdk_app_setup.DockerAppBuildingObject(**data)[source]

Bases: ProjectBuildingObject

Parameters:
class kelvin.sdk.lib.models.apps.ksdk_app_setup.ProjectEmulationObject(**data)[source]

Bases: KSDKModel

Parameters:
app_name: str | None
app_config_path: str | None
app_config_model: KelvinAppConfiguration | None
net_alias: str | None
attach: bool
show_logs: bool
is_external_app: bool
detach: bool
auto_remove: bool
publish_all_ports: bool
privileged: bool
entrypoint: str | None
ports: List[int | Tuple[int, str]] | None
port_mapping: Dict | None
volumes: List[str] | None
file_volumes: List[KSDKDockerVolume] | None
arguments: Sequence[str] | None
environment_variables: Dict | None
memory: str | None
cpu: str | None
stream: bool
follow: bool
should_print: bool
tail: int | None
property emulation_app_name: str
classmethod from_app_model(app_config_model=None, app_config_file_path=None)[source]

From either an app configuration model or file path, generate the corresponding ProjectEmulationObject.

Return type:

ProjectEmulationObject

Parameters:

Parameters

app_config_model : an application configuration model to retrieve configurations from. app_config_file_path : the alternative path to the application configuration file path.

Returns

A new instance of an ProjectEmulationObject with the necessary variables ready for a complete emulation.

static process_environment_variables(environment_variables)[source]

From the provided environment variables list, yield a docker-readable dictionary.

Return type:

dict

Parameters:

environment_variables (List[EnvironmentVar] | None)

Parameters

environment_variables : The Kelvin EnvironmentVar list.

Returns

A docker-readable compliant dict.

static process_ports(ports)[source]

From the provided Port configuration list, yield a docker compliant configuration

Return type:

Tuple[List, Dict]

Parameters:

ports (List[PortMapping] | None)

Parameters

ports : The Kelvin PortMapping list.

Returns

A tuple with both the list of ports to be open in the container and a port mapping dictionary.

static process_volumes(volumes)[source]

From the provided Volume configuration list, yield a docker compliant configuration

Return type:

Tuple[List[str], List[KSDKDockerVolume]]

Parameters:

volumes (List[Volume] | None)

Parameters

volumes : The Kelvin Volume list.

Returns

The pair of volume and volume files to be passed on to docker.

static process_resources(resources)[source]

From the provided Resources, yield a docker compliant configuration

Return type:

Tuple[Optional[str], Optional[str]]

Parameters:

resources (Resources | None)

Parameters

resources : The Resources.

Returns

The pair of, respectively, memory and cpu resources.

Workload Models

Models for workload deployment and management.

KSDK Workload Deployment

Models for workload deployment configurations.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.models.workloads.ksdk_workload_deployment.WorkloadDeploymentRequest(**data)[source]

Bases: KSDKModel

Parameters:
  • cluster_name (str | None)

  • workload_name (ConstrainedStrValue | None)

  • workload_title (ConstrainedStrValue | None)

  • app_config (str | None)

  • runtime (str | None)

  • quiet (bool)

cluster_name: str | None
workload_name: str | None
workload_title: str | None
app_config: str | None
runtime: str | None
quiet: bool
class kelvin.sdk.lib.models.workloads.ksdk_workload_deployment.WorkloadUpdateRequest(**data)[source]

Bases: KSDKModel

Parameters:
  • workload_name (ConstrainedStrValue)

  • workload_title (ConstrainedStrValue | None)

  • app_config (str)

  • runtime (str | None)

  • quiet (bool)

workload_name: str
workload_title: str | None
app_config: str
runtime: str | None
quiet: bool
class kelvin.sdk.lib.models.workloads.ksdk_workload_deployment.WorkloadTemplateData(**data)[source]

Bases: KSDKModel

Parameters:
  • status (str | None)

  • result (Literal['success', 'failed', 'skip'] | None)

  • node_name (str)

  • app_name (str)

  • app_version (str)

  • workload_name (str)

  • workload_title (str)

  • app_config (KPath)

  • extra_data (Any)

class Config[source]

Bases: object

extra = 'allow'
classmethod validate_app_config(value)[source]
Return type:

KPath

Parameters:

value (str)

classmethod validate_empty_fields(value)[source]
Return type:

Optional[str]

Parameters:

value (str | None)

status: str | None
result: Literal['success', 'failed', 'skip'] | None
node_name: str
app_name: str
app_version: str
workload_name: str
workload_title: str
app_config: KPath
dict(*args, **kwargs)[source]

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Return type:

Dict[str, Any]

Parameters:

Factories

Factory classes for creating model instances.

App Setup Configuration Factory

Factory for creating application setup configurations.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

kelvin.sdk.lib.models.factories.app_setup_configuration_objects_factory.get_project_building_object(app_config_obj, app_dir, fresh_build=False)[source]

Create a ProjectBuildingObject from the provided app directory.

This object will encapsulate all the necessary variables for the building of a base application, thus resulting in reduced, cleaner and more testable code.

Return type:

ProjectBuildingObject

Parameters:
  • app_config_obj (AppConfigObj)

  • app_dir (str)

  • fresh_build (bool)

Parameters

app_dirstr

the path to the application’s dir.

fresh_buildbool

If specified will remove any cache and rebuild the application from scratch.

Returns

ProjectBuildingObject

a ProjectBuildingObject containing all the necessary variables for the building of a base app.

kelvin.sdk.lib.models.factories.app_setup_configuration_objects_factory.get_kelvin_app_building_object(base_build_object)[source]

Creates a KelvinAppBuildingObject from the specified parameters.

This object will encapsulate all the necessary variables for the building of a kelvin application, thus resulting in reduced, cleaner and more testable code.

Return type:

KelvinAppBuildingObject

Parameters:

base_build_object (ProjectBuildingObject)

Parameters

app_dirstr

the path to the application’s dir.

app_config_rawOptional[Dict]

the raw app configuration dictionary.

fresh_buildbool

If specified will remove any cache and rebuild the application from scratch.

build_for_uploadbool

indicates whether or the package object aims for an upload.

upload_datatypesbool

If specified, will upload locally defined datatypes.

Returns

KelvinAppBuildingObject

a KelvinAppBuildingObject containing all the necessary variables for the building of a kelvin application.

kelvin.sdk.lib.models.factories.app_setup_configuration_objects_factory.get_bridge_app_building_object(base_build_object)[source]

Creates a BridgeAppBuildingObject from the specified parameters.

This object will encapsulate all the necessary variables for the building of a kelvin application, thus resulting in reduced, cleaner and more testable code.

Return type:

BridgeAppBuildingObject

Parameters:

base_build_object (ProjectBuildingObject)

Parameters

app_dir: str

the path to the application’s dir.

app_config_raw: Optional[Dict]

the raw app configuration dictionary.

fresh_build: bool

If specified will remove any cache and rebuild the application from scratch.

build_for_upload: bool

indicates whether or the package object aims for an upload.

upload_datatypes: bool

If specified, will upload locally defined datatypes.

Returns

BridgeAppBuildingObject

a BridgeAppBuildingObject containing all the necessary variables for the building of a kelvin application.

kelvin.sdk.lib.models.factories.app_setup_configuration_objects_factory.get_default_app_configuration(app_dir_path=None, app_config_file_path=None)[source]

Retrieve the application’s configuration from either the provided app directory of app configuration.

Return type:

KelvinAppConfiguration

Parameters:
  • app_dir_path (KPath | None)

  • app_config_file_path (KPath | None)

Parameters

app_dir_pathOptional[KPath]

the path to the application’s directory.

app_config_file_pathOptional[KPath]

the path to the application’s configuration.

Returns

KelvinAppConfiguration

a KelvinAppConfiguration object matching the app configuration of the app.

kelvin.sdk.lib.models.factories.app_setup_configuration_objects_factory.get_default_app_name(app_dir_path=None)[source]

Retrieve the app name from the default configuration file (usually, app.yaml)

Return type:

str

Parameters:

app_dir_path (KPath | None)

Parameters

app_dir_pathOptional[KPath]

the path to the application’s directory.

Returns

str

a string containing the default app name.

Project Factory

Factory for creating project instances.

class kelvin.sdk.lib.models.factories.project.factory.ProjectFactory[source]

Bases: object

The factory class for creating projects

registry: Dict[ProjectType, Any] = {ProjectType.app: <class 'kelvin.sdk.lib.models.factories.project.kelvin.KelvinProject'>, ProjectType.docker: <class 'kelvin.sdk.lib.models.factories.project.kelvin.KelvinProject'>, ProjectType.exporter: <class 'kelvin.sdk.lib.models.factories.project.kelvin.KelvinProject'>, ProjectType.importer: <class 'kelvin.sdk.lib.models.factories.project.kelvin.KelvinProject'>}
classmethod create_project(project_creation_parameters, **kwargs)[source]

Factory command to create the project instance

Return type:

ProjectBase

Parameters:

Project

Base project model.

class kelvin.sdk.lib.models.factories.project.project.ProjectFileTree(**data)[source]

Bases: KSDKModel, ABC

Parameters:

root (Directory)

root: Directory
classmethod from_tree(app_root, project_type, kelvin_app_flavour, template_parameters, kelvin_app_lang=None, **kwargs)[source]

Class method that must fill the Tree directories and respective files

Return type:

ProjectFileTree

Parameters:

Parameters

app_root: KPath

Application path root directory path

template_parameters:

Dictionary to fill the templates

project_type: ProjectType

The type of project to create.

kelvin_app_flavour: ApplicationFlavour

The application flavour.

kelvin_app_lang: ApplicationLanguage, optional

The application language.

Returns

ProjectFileTree

A ProjectFileTree instance with the populated tree structure.

abstractmethod static get_tree_dict(app_root, **kwargs)[source]

Returns a dictionary with the file tree associated with the class attributes

Return type:

Dict

Parameters:
abstractmethod fundamental_dirs()[source]

A list of project’s main directories

Return type:

List[Directory]

Returns

List[Directory]

abstractmethod optional_dirs()[source]

A list of project’s optional directories

Return type:

List[Directory]

Returns

List[Directory]

static get_extra_template_parameters()[source]
Return type:

Dict

class kelvin.sdk.lib.models.factories.project.project.ProjectMixin(creation_parameters)[source]

Bases: object

Workaround due to mypy and dataclasses issue https://github.com/python/mypy/issues/5374

Parameters:

creation_parameters (ProjectCreationParametersObject)

creation_parameters: ProjectCreationParametersObject
class kelvin.sdk.lib.models.factories.project.project.ProjectBase(creation_parameters)[source]

Bases: ProjectMixin, ABC

Project representation Contains the structure to create the app file tree and templates based on the AppType and AppFlavour

Parameters:

creation_parameters (ProjectCreationParametersObject)

creation_parameters: ProjectCreationParametersObject
file_tree: ProjectFileTree | None = None
flavour_registry: Dict = {}
get_flavour()[source]
Return type:

ApplicationFlavour

get_flavour_class()[source]
Return type:

Type[ProjectFileTree]

create_dirs_and_files()[source]

Creates the directory tree and the files for each one

Return type:

None

abstractmethod get_template_parameters()[source]

Dict used to fill the templates

Return type:

Dict

Returns

Dict

A dictionary containing the required parameters to fill the project templates

Kelvin Project

Kelvin-specific project model.

class kelvin.sdk.lib.models.factories.project.kelvin.ProjectDockerDefaultFileTree(**data)[source]

Bases: ProjectFileTree

Parameters:
schemas: Directory
github: Directory
static get_tree_dict(app_root, **kwargs)[source]

Returns a dictionary with the file tree associated with the class attributes

Return type:

Dict

Parameters:
fundamental_dirs()[source]

A list of project’s main directories

Return type:

List[Directory]

Returns

List[Directory]

optional_dirs()[source]

A list of project’s optional directories

Return type:

List[Directory]

Returns

List[Directory]

class kelvin.sdk.lib.models.factories.project.kelvin.KelvinProject(creation_parameters)[source]

Bases: ProjectBase

Parameters:

creation_parameters (ProjectCreationParametersObject)

flavour_registry: Dict = {ApplicationFlavour.default: <class 'kelvin.sdk.lib.models.factories.project.kelvin.ProjectDockerDefaultFileTree'>, ApplicationFlavour.mlflow: <class 'kelvin.sdk.lib.models.factories.project.kelvin.ProjectDockerDefaultFileTree'>}
get_template_parameters()[source]

Dict used to fill the templates

Return type:

Dict

Returns

Dict

A dictionary containing the required parameters to fill the project templates