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])
- class kelvin.sdk.lib.models.generic.Dependency(dependency)[source]¶
Bases:
object- Parameters:
dependency (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
- read_yaml_all(verbose=True)[source]¶
Load the content of the specified yaml_file into a dictionary.
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:
- Parameters:
delimiter_style (DelimiterStyle)
verbose (bool)
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)
- 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:
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.
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)
- class kelvin.sdk.lib.models.generic.KSDKModel(**data)[source]¶
Bases:
BaseModelExtends 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
- 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
- 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 kelvin.sdk.lib.models.generic.GenericObject(data)[source]¶
Bases:
objectA simple generic object used to wrap-up dictionaries into a class. Uses reflection to set data dynamically.
- Parameters:
data (Mapping)
- kelvin.sdk.lib.models.generic.render_template(content, context, delimiter_style)[source]¶
Render content with context.
- Return type:
- Parameters:
content (str)
delimiter_style (DelimiterStyle)
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
- 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'¶
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.
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.DockerContainer(**data)[source]¶
Bases:
KSDKModel- Parameters:
- mounts: List[DockerMount] | None¶
- ports: List[DockerPort]¶
- 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:
- 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:
- 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:
- 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:
KSDKModelDocker 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:
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:
- class kelvin.sdk.lib.models.ksdk_global_configuration.DockerMetadataEntry(**data)[source]¶
Bases:
GenericMetadataEntry- Parameters:
- class kelvin.sdk.lib.models.ksdk_global_configuration.SchemaMetadataEntry(**data)[source]¶
Bases:
GenericMetadataEntry- Parameters:
- class kelvin.sdk.lib.models.ksdk_global_configuration.ComponentsMetadataEntry(**data)[source]¶
Bases:
GenericMetadataEntry- Parameters:
- get_runner_docker_image_for_lang(reduced_size=True, app_lang=None)[source]¶
- Return type:
- Parameters:
reduced_size (bool)
app_lang (ApplicationLanguage | None)
- get_builder_docker_image_for_lang(app_lang=None)[source]¶
- Return type:
- Parameters:
app_lang (ApplicationLanguage | None)
- class kelvin.sdk.lib.models.ksdk_global_configuration.SDKMetadataEntry(**data)[source]¶
Bases:
GenericMetadataEntry- Parameters:
- components: ComponentsMetadataEntry¶
- class kelvin.sdk.lib.models.ksdk_global_configuration.CompanyMetadata(**data)[source]¶
Bases:
KSDKModel- Parameters:
authentication (GenericMetadataEntry)
docker (DockerMetadataEntry)
documentation (GenericMetadataEntry)
sdk (SDKMetadataEntry)
schema (SchemaMetadataEntry)
- authentication: GenericMetadataEntry¶
- docker: DockerMetadataEntry¶
- documentation: GenericMetadataEntry¶
- sdk: SDKMetadataEntry¶
- kelvin_schema: SchemaMetadataEntry¶
- 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:
- 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'}}¶
- 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:
_env_file (str | PathLike | List[str | PathLike] | Tuple[str | PathLike, ...] | None)
_env_file_encoding (str | None)
_env_nested_delimiter (str | None)
last_metadata_refresh (float)
current_url (str)
current_user (str)
ksdk_current_version (str)
ksdk_minimum_version (str)
ksdk_latest_version (str)
configurations (KelvinSDKEnvironmentVariables)
- configurations: KelvinSDKEnvironmentVariables¶
- class kelvin.sdk.lib.models.ksdk_global_configuration.KelvinSDKGlobalConfiguration(**data)[source]¶
Bases:
KSDKSettings- Parameters:
ksdk_config_dir_path (KPath)
kelvin_sdk (KelvinSDKConfiguration)
- 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.
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.Version[source]¶
Bases:
StrictStr
- class kelvin.sdk.lib.models.apps.common.Authentication(**data)[source]¶
Bases:
KSDKModel- Parameters:
type (str)
credentials (Credentials)
- credentials: Credentials¶
- class kelvin.sdk.lib.models.apps.common.Mqtt(**data)[source]¶
Bases:
KSDKModel- Parameters:
ip (str)
port (Port)
authentication (Authentication | None)
- authentication: Authentication | None¶
- class kelvin.sdk.lib.models.apps.common.DataType(**data)[source]¶
Bases:
KSDKModel- Parameters:
name (DottedIdentifier)
version (Version)
path (str | None)
- name: DottedIdentifier¶
- class kelvin.sdk.lib.models.apps.common.EnvironmentVar(**data)[source]¶
Bases:
KSDKModel- Parameters:
name (Identifier)
value (str | None)
- name: Identifier¶
- class kelvin.sdk.lib.models.apps.common.ApplicationLanguage(*values)[source]¶
Bases:
BaseEnum- python = 'python'¶
- class kelvin.sdk.lib.models.apps.common.PythonLanguageType(**data)[source]¶
Bases:
KSDKModel- Parameters:
entry_point (PythonEntryPoint)
requirements (str | None)
flavour (str | None)
extra_data (Any)
- entry_point: PythonEntryPoint¶
- requirements_file_path(app_dir_path)[source]¶
When provided with an application dir, yield the complete requirements.txt absolute file path
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
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)
- 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)
- name: NonEmptyString | None¶
- class kelvin.sdk.lib.models.apps.kelvin_app.MetricInfo(**data)[source]¶
Bases:
KSDKModel- Parameters:
- class kelvin.sdk.lib.models.apps.kelvin_app.MetricInput(**data)[source]¶
Bases:
Metric- Parameters:
name (Name)
data_type (str)
sources (List[MetricInfo] | None)
- sources: List[MetricInfo] | None¶
- class kelvin.sdk.lib.models.apps.kelvin_app.MetricOutput(**data)[source]¶
Bases:
Metric- Parameters:
- targets: List[MetricInfo] | 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)
mqtt (Mqtt | None)
language (Language)
inputs (List[MetricInput] | None)
outputs (List[MetricOutput] | None)
configuration (Any | None)
extra_data (Any)
- logging_level: LoggingLevel | None¶
- assets: List[AssetsEntry] | None¶
- global_: MetricInfo | None¶
- inputs: List[MetricInput] | None¶
- outputs: List[MetricOutput] | 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:
- asset_name: NonEmptyString¶
- class kelvin.sdk.lib.models.apps.bridge_app.BridgeAppType(**data)[source]¶
Bases:
KSDKModel- Parameters:
- logging_level: LoggingLevel | 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.
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.ProjectType(*values)[source]¶
-
- app = 'app'¶
- importer = 'importer'¶
- exporter = 'exporter'¶
- docker = 'docker'¶
- kelvin = 'kelvin'¶
- legacy_docker = 'legacy_docker'¶
- bridge = 'bridge'¶
- kelvin_legacy = 'kelvin_legacy'¶
- 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)
- 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.SystemResources(**data)[source]¶
Bases:
KSDKModel
- class kelvin.sdk.lib.models.apps.ksdk_app_configuration.Resources(**data)[source]¶
Bases:
KSDKModel- Parameters:
limits (SystemResources | None)
requests (SystemResources | None)
- 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.PortMappingService(**data)[source]¶
Bases:
KSDKModel- Parameters:
container_port (Port | None)
port (Port)
exposed (bool | None)
exposed_port (ExternalPort | None)
- exposed_port: ExternalPort | None¶
- class kelvin.sdk.lib.models.apps.ksdk_app_configuration.PortMappingHostPort(**data)[source]¶
Bases:
KSDKModel- Parameters:
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)
- 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
- class kelvin.sdk.lib.models.apps.ksdk_app_configuration.VolumeHost(**data)[source]¶
Bases:
KSDKModel- Parameters:
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)
- type: VolumeType¶
- text: VolumeText | None¶
- host: VolumeHost | 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)
- environment_vars: List[EnvironmentVar] | None¶
- ports: List[PortMapping] | None¶
- class kelvin.sdk.lib.models.apps.ksdk_app_configuration.Environment(**data)[source]¶
Bases:
KSDKModel
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- content: Template¶
- 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)
- app_type: ProjectType¶
- app_flavour: ApplicationFlavour¶
- kelvin_app_lang: ApplicationLanguage¶
- class kelvin.sdk.lib.models.apps.ksdk_app_setup.MLFlowProjectCreationParametersObject(**data)[source]¶
Bases:
ProjectCreationParametersObject- Parameters:
app_dir (str)
app_name (str)
app_version (str)
app_description (str)
app_type (ProjectType)
app_flavour (ApplicationFlavour)
kelvin_app_lang (ApplicationLanguage)
- 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)
- app_config_raw: Dict¶
- app_config_model: KelvinAppConfiguration | None¶
- 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)
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)
- 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)
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)
- class kelvin.sdk.lib.models.apps.ksdk_app_setup.DockerAppBuildingObject(**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)
- 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)
port_mapping (Dict | None)
file_volumes (List[KSDKDockerVolume] | None)
environment_variables (Dict | None)
memory (str | None)
cpu (str | None)
stream (bool)
follow (bool)
should_print (bool)
tail (int | None)
- app_config_model: KelvinAppConfiguration | None¶
- file_volumes: List[KSDKDockerVolume] | None¶
- 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:
- Parameters:
app_config_model (KelvinAppConfiguration | None)
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:
- 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:
- 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
Parameters¶
volumes : The Kelvin Volume list.
Returns¶
The pair of volume and volume files to be passed on to docker.
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:
- class kelvin.sdk.lib.models.workloads.ksdk_workload_deployment.WorkloadUpdateRequest(**data)[source]¶
Bases:
KSDKModel- 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:
- Parameters:
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:
- 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:
- 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:
- Parameters:
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)
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:
objectThe 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:
- Parameters:
project_creation_parameters (ProjectCreationParametersObject)
kwargs (Any)
Project¶
Base project model.
- class kelvin.sdk.lib.models.factories.project.project.ProjectFileTree(**data)[source]¶
-
- Parameters:
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:
- Parameters:
app_root (KPath)
project_type (ProjectType)
kelvin_app_flavour (ApplicationFlavour)
template_parameters (Dict)
kelvin_app_lang (ApplicationLanguage | None)
kwargs (Dict)
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
- abstractmethod fundamental_dirs()[source]¶
A list of project’s main directories
Returns¶
List[Directory]
- class kelvin.sdk.lib.models.factories.project.project.ProjectMixin(creation_parameters)[source]¶
Bases:
objectWorkaround 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,ABCProject 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¶
Kelvin Project¶
Kelvin-specific project model.
- class kelvin.sdk.lib.models.factories.project.kelvin.ProjectDockerDefaultFileTree(**data)[source]¶
Bases:
ProjectFileTree- static get_tree_dict(app_root, **kwargs)[source]¶
Returns a dictionary with the file tree associated with the class attributes
- class kelvin.sdk.lib.models.factories.project.kelvin.KelvinProject(creation_parameters)[source]¶
Bases:
ProjectBase- Parameters:
creation_parameters (ProjectCreationParametersObject)