diff --git a/config/package.json b/config/package.json index f56d203..ae7a7f9 100644 --- a/config/package.json +++ b/config/package.json @@ -1,4 +1,4 @@ { "name": "kitops", - "version": "1.0.1" + "version": "1.0.2" } \ No newline at end of file diff --git a/docs/explanation.md b/docs/explanation.md new file mode 100644 index 0000000..1a74ec0 --- /dev/null +++ b/docs/explanation.md @@ -0,0 +1,15 @@ +This part of the project documentation focuses on an +**understanding-oriented** approach. You'll get a +chance to read about the background of the project, +as well as reasoning about how it was implemented. + +> **Note:** Expand this section by considering the +> following points: + +- Give context and background on your library +- Explain why you created it +- Provide multiple examples and approaches of how + to work with it +- Help the reader make connections +- Avoid writing instructions or technical descriptions + here \ No newline at end of file diff --git a/docs/how-to-guides.md b/docs/how-to-guides.md new file mode 100644 index 0000000..f460f09 --- /dev/null +++ b/docs/how-to-guides.md @@ -0,0 +1,66 @@ +This part of the project documentation focuses on a +**problem-oriented** approach. You'll tackle common +tasks that you might have, with the help of the code +provided in this project. + +## How To Create A Kitfile Object? + +Whether you're working with an existing ModelKit's Kitfile, +or starting from nothing, the `kitops` package can help you +get this done. + +Install the `kitops` package from PYPI into your project's environment +with the following command +``` +pip install kitops +``` + +Inside of your code you can now import the `Kitfile` +class from the `kitops.modelkit.kitfile` module: + + # your code + from kitops.modelkit.kitfile import Kitfile + +After you've imported the class, you can use it +to create a Kitfile object from an existing ModelKit's Kitfile: + + # your code + from kitops.modelkit.kitfile import Kitfile + + my_kitfile = Kitfile(path='/path/to/Kitfile') + print(my_kitfile.to_yaml()) + + # The output should match the contents of the Kitfile + # located at: /path/to/Kitfile + +You can also create an empty Kitfile from scratch: + + # your code + from kitops.modelkit.kitfile import Kitfile + + my_kitfile = Kitfile() + print(my_kitfile.to_yaml()) + + # OUTPUT: {} + +Regardless of how you created the Kitfile, you can update its contents +like you would do with any other python dictionary: + + # your code + my_kitfile.manifestVersion = "3.0" + my_kitfile.package = { + "name": "Another-Package", + "version": "3.0.0", + "description": "Another description", + "authors": ["Someone"] + } + print(my_kitfile.to_yaml()) + + # OUTPUT: + # manifestVersion: '3.0' + # package: + # name: Another-Package + # version: 3.0.0 + # description: Another description + # authors: + # - Someone \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..db001b6 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,19 @@ +This site contains the project documentation for the +`KitOps Manager` project. Its aim is to provide a python library for +easily working with [KitOps' ModelKits](https://kitops.ml). + +## Table Of Contents + +The documentation follows the best practice for +project documentation as described by Daniele Procida +in the [Diátaxis documentation framework](https://diataxis.fr/) +and consists of four separate parts: + +1. [Tutorials](tutorials.md) +2. [How-To Guides](how-to-guides.md) +3. [Reference](reference.md) +4. [Explanation](explanation.md) + +Quickly find what you're looking for depending on +your use case by looking at the different pages. + diff --git a/docs/reference.md b/docs/reference.md new file mode 100644 index 0000000..ad3b111 --- /dev/null +++ b/docs/reference.md @@ -0,0 +1,6 @@ +This part of the project documentation focuses on +an **information-oriented** approach. Use it as a +reference for the technical implementation of the +`kitops` project code. + +::: src.kitops.modelkit.kitfile.Kitfile \ No newline at end of file diff --git a/docs/tutorials.md b/docs/tutorials.md new file mode 100644 index 0000000..384f1d6 --- /dev/null +++ b/docs/tutorials.md @@ -0,0 +1,16 @@ +This part of the project documentation focuses on a +**learning-oriented** approach. You'll learn how to +get started with the code in this project. + +> **Note:** Expand this section by considering the +> following points: + +- Help newcomers with getting started +- Teach readers about your library by making them + write code +- Inspire confidence through examples that work for + everyone, repeatably +- Give readers an immediate sense of achievement +- Show concrete examples, no abstractions +- Provide the minimum necessary explanation +- Avoid any distractions \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..8bcbb71 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,14 @@ +site_name: KitOps Manager Documentation + +theme: + name: "material" + +plugins: + - mkdocstrings + +nav: + - KitOps Manager Docs: index.md + - tutorials.md + - How-To Guides: how-to-guides.md + - reference.md + - explanation.md \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index b206eea..e3c3a5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "kitops" -version = "1.0.1" +version = "1.0.2" authors = [ { name="Brett Hodges", email="brett@jozu.com" }, ] diff --git a/requirements/ci.in b/requirements/ci.in index 6f02f18..039e883 100644 --- a/requirements/ci.in +++ b/requirements/ci.in @@ -1,2 +1,5 @@ tox tox-conda +mkdocs +"mkdocstrings[python]" +mkdocs-material diff --git a/src/kitops/__init__.py b/src/kitops/__init__.py index d3023d1..c30d308 100644 --- a/src/kitops/__init__.py +++ b/src/kitops/__init__.py @@ -1,4 +1,25 @@ -__version__ = '1.0.1' +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + +""" +Manage KitOps' ModelKits +""" +__version__ = '1.0.2' __all__ = [ 'kitfile' ] diff --git a/src/kitops/modelkit/__init__.py b/src/kitops/modelkit/__init__.py index 37355e3..a386504 100644 --- a/src/kitops/modelkit/__init__.py +++ b/src/kitops/modelkit/__init__.py @@ -1,2 +1,20 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from .kitfile import Kitfile diff --git a/src/kitops/modelkit/kitfile.py b/src/kitops/modelkit/kitfile.py index 553dbd9..eca5124 100644 --- a/src/kitops/modelkit/kitfile.py +++ b/src/kitops/modelkit/kitfile.py @@ -1,7 +1,30 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + +""" +Define the Kitfile class to manage KitOps ModelKits and Kitfiles. +""" +import copy import yaml from pathlib import Path from typing import Any, Dict, List, Set +from .util import clean_empty_items, validate_dict from .validators.code_validator import CodeValidator from .validators.datasets_validator import DatasetsValidator from .validators.docs_validator import DocsValidator @@ -20,10 +43,38 @@ class Kitfile: def __init__(self, path=None): """ - Initialize the Kitfile. + Initialize the Kitfile from a path to an existing Kitfile, or + create an empty Kitfile. + + Examples: + >>> kitfile = Kitfile(path="path/to/Kitfile") + >>> kitfile.to_yaml() + + >>> kitfile = Kitfile() + >>> kitfile.manifestVersion = "1.0" + >>> kitfile.package = {"name": "my_package", "version": "0.1.0", + ... "description": "My package description", + ... "authors": ["Author 1", "Author 2"]} + >>> kitfile.code = [{"path": "code/", "description": "Code description", + ... "license": "Apache-2.0"}] + >>> kitfile.datasets = [{"name": "my_dataset", "path": "datasets/", + ... "description": "Dataset description", + ... "license": "Apache-2.0"}] + >>> kitfile.docs = [{"path": "docs/", "description": "Docs description"}] + >>> kitfile.model = {"name": "my_model", "path": "model/", + ... "framework": "tensorflow", "version": "2.0.0", + ... "description": "Model description", + ... "license": "Apache-2.0", "parts": [], + ... "parameters": ""} + >>> kitfile.to_yaml() + 'manifestVersion: 1.0\npackage:\n name: my_package\n version: 0.1.0\n description: My package description\n authors:\n - Author 1\n - Author 2\ncode:\n- path: code/\n description: Code description\n license: Apache-2.0\ndatasets:\n- name: my_dataset\n path: datasets/\n description: Dataset description\n license: Apache-2.0\ndocs:\n- path: docs/\n description: Docs description\nmodel:\n name: my_model\n path: model/\n framework: tensorflow\n version: 2.0.0\n description: Model description\n license: Apache-2.0\n parts: []\n parameters: ''\n' + Args: - path (str, optional): Path to the Kitfile. Defaults to None. + path (str, optional): Path to existing Kitfile to load. Defaults to None. + + Returns: + Kitfile: Kitfile object. """ self._data = {} self._kitfile_allowed_keys = {'manifestVersion', 'package', @@ -77,7 +128,7 @@ def initialize_kitfile_section_validators(self): def load_from_file(self, path): """ - Load Kitfile data from a file. + Load Kitfile data from a yaml-formatted file. Args: path (str): Path to the Kitfile. @@ -102,8 +153,8 @@ def load_from_file(self, path): raise try: - self.validate_dict(value=data, - allowed_keys=self._kitfile_allowed_keys) + validate_dict(value=data, + allowed_keys=self._kitfile_allowed_keys) except ValueError as e: raise ValueError( "Kitfile must be a dictionary with allowed " + @@ -122,23 +173,6 @@ def validate_and_set_attributes(self, data: Dict[str, Any]): for key, value in data.items(): self.__setattr__(key, value) - def validate_dict(self, value: Any, allowed_keys: Set[str]): - """ - Validate a dictionary against allowed keys. - - Args: - value (Any): Value to validate. - allowed_keys (Set[str]): Set of allowed keys. - """ - if not isinstance(value, dict): - raise ValueError( - f"Expected a dictionary but got {type(value).__name__}") - value_keys = set(value.keys()) - unallowed_keys = value_keys.difference(allowed_keys) - if len(unallowed_keys) > 0: - raise ValueError("Found unallowed key(s): " + - f"{', '.join(unallowed_keys)}") - @property def manifestVersion(self) -> str: """ @@ -264,13 +298,21 @@ def model(self, value: Dict[str, Any]): """ self._model_validator.validate(data=value) self._data["model"] = value - - def to_yaml(self) -> str: + + def to_yaml(self, suppress_empty_values: bool = True) -> str: """ - Serialize the Kitfile to YAML format. + Serialize the Kitfile to YAML format. + Args: + suppress_empty_values (bool, optional): Whether to suppress + empty values. Defaults to True. Returns: str: YAML representation of the Kitfile. """ - return yaml.dump(data = self._data, sort_keys=False, + dict_to_print = self._data + if suppress_empty_values: + dict_to_print = copy.deepcopy(self._data) + dict_to_print = clean_empty_items(dict_to_print) + + return yaml.dump(data = dict_to_print, sort_keys=False, default_flow_style=False) diff --git a/src/kitops/modelkit/manager.py b/src/kitops/modelkit/manager.py new file mode 100644 index 0000000..e69de29 diff --git a/src/kitops/modelkit/util.py b/src/kitops/modelkit/util.py new file mode 100644 index 0000000..cddbdea --- /dev/null +++ b/src/kitops/modelkit/util.py @@ -0,0 +1,93 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + +from typing import Any, Dict, Set + +def validate_dict(value: Dict[str, Any], allowed_keys: Set[str]): + """ + Validate a dictionary against allowed keys. + + Examples: + >>> validate_dict({"a": 1, "b": 2}, {"a", "b"}) + None + + >>> validate_dict({"a": 1, "b": 2}, {"a"}) + ValueError: Found unallowed key(s): b + + >>> validate_dict({"a": 1, "d": 2}, {"a", "b", "c"}) + ValueError: Found unallowed key(s): d + + Args: + value (Dict[str, Any]): Value to validate. + allowed_keys (Set[str]): Set of allowed keys. + """ + if not isinstance(value, dict): + raise ValueError( + f"Expected a dictionary but got {type(value).__name__}") + value_keys = set(value.keys()) + unallowed_keys = value_keys.difference(allowed_keys) + if len(unallowed_keys) > 0: + raise ValueError("Found unallowed key(s): " + + f"{', '.join(unallowed_keys)}") + +def clean_empty_items(d: Any) -> Any: + """ + Remove empty items from a dictionary or list. + + Examples: + >>> clean_empty_items({"a": "", "b": "c", "d": None}) + {'b': 'c'} + + >>> clean_empty_items(["", "a", None]) + ['a'] + + Args: + d (Any): Dictionary or list to clean. + + Returns: + Any: Cleaned dictionary or list. + """ + if isinstance(d, dict): + cleaned_dict = {} + for k, v in d.items(): + if k.strip() and v is not None: + if isinstance(v, (dict, list)): + cleaned_v = clean_empty_items(v) + if cleaned_v: # Only add non-empty items + cleaned_dict[k] = cleaned_v + elif isinstance(v, str) and v.strip() != "": + cleaned_dict[k] = v + elif not isinstance(v, str): + cleaned_dict[k] = v + return cleaned_dict + + elif isinstance(d, list): + cleaned_list = [] + for item in d: + if item is not None: + if isinstance(item, (dict, list)): + cleaned_item = clean_empty_items(item) + if cleaned_item: # Only add non-empty items + cleaned_list.append(cleaned_item) + elif isinstance(item, str) and item.strip() != "": + cleaned_list.append(item) + elif not isinstance(item, str): + cleaned_list.append(item) + return cleaned_list + + return d \ No newline at end of file diff --git a/src/kitops/modelkit/validators/__init__.py b/src/kitops/modelkit/validators/__init__.py index 0119bb1..fbc533a 100644 --- a/src/kitops/modelkit/validators/__init__.py +++ b/src/kitops/modelkit/validators/__init__.py @@ -1,16 +1,20 @@ -# __version__ = '1.0.0' +''' +Copyright 2024 The KitOps Authors. -# __all__ = [ -# 'string_validator', -# 'dict_validator', -# 'dict_list_validator', -# 'manifest_version_validator', -# 'package_validator', -# 'code_validator', -# 'datasets_validator', -# 'docs_validator', -# 'model_validator' -# ] +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' from . import string_validator from . import dict_validator diff --git a/src/kitops/modelkit/validators/code_validator.py b/src/kitops/modelkit/validators/code_validator.py index 164ac5c..c23bdeb 100644 --- a/src/kitops/modelkit/validators/code_validator.py +++ b/src/kitops/modelkit/validators/code_validator.py @@ -1,3 +1,21 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from typing import Any, Set from .dict_list_validator import DictListValidator diff --git a/src/kitops/modelkit/validators/datasets_validator.py b/src/kitops/modelkit/validators/datasets_validator.py index e62c983..6487963 100644 --- a/src/kitops/modelkit/validators/datasets_validator.py +++ b/src/kitops/modelkit/validators/datasets_validator.py @@ -1,3 +1,21 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from typing import Any, Set from .dict_list_validator import DictListValidator diff --git a/src/kitops/modelkit/validators/dict_list_validator.py b/src/kitops/modelkit/validators/dict_list_validator.py index 7ef88f9..4d5e6e6 100644 --- a/src/kitops/modelkit/validators/dict_list_validator.py +++ b/src/kitops/modelkit/validators/dict_list_validator.py @@ -1,3 +1,21 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from typing import Any, Set from .dict_validator import DictValidator diff --git a/src/kitops/modelkit/validators/dict_validator.py b/src/kitops/modelkit/validators/dict_validator.py index 64835e4..66d8255 100644 --- a/src/kitops/modelkit/validators/dict_validator.py +++ b/src/kitops/modelkit/validators/dict_validator.py @@ -1,3 +1,21 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from typing import Any, Set from .string_validator import StringValidator diff --git a/src/kitops/modelkit/validators/docs_validator.py b/src/kitops/modelkit/validators/docs_validator.py index c1e1dde..5c55adb 100644 --- a/src/kitops/modelkit/validators/docs_validator.py +++ b/src/kitops/modelkit/validators/docs_validator.py @@ -1,3 +1,21 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from typing import Any, Set from .dict_list_validator import DictListValidator diff --git a/src/kitops/modelkit/validators/manifest_version_validator.py b/src/kitops/modelkit/validators/manifest_version_validator.py index 32c16a1..30b26f8 100644 --- a/src/kitops/modelkit/validators/manifest_version_validator.py +++ b/src/kitops/modelkit/validators/manifest_version_validator.py @@ -1,3 +1,21 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from typing import Any, Set from .string_validator import StringValidator diff --git a/src/kitops/modelkit/validators/model_validator.py b/src/kitops/modelkit/validators/model_validator.py index 95956dd..71df9d4 100644 --- a/src/kitops/modelkit/validators/model_validator.py +++ b/src/kitops/modelkit/validators/model_validator.py @@ -1,3 +1,21 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from typing import Any, Dict, List, Set from .dict_list_validator import DictListValidator from .dict_validator import DictValidator diff --git a/src/kitops/modelkit/validators/package_validator.py b/src/kitops/modelkit/validators/package_validator.py index 8fe08d2..e0309c5 100644 --- a/src/kitops/modelkit/validators/package_validator.py +++ b/src/kitops/modelkit/validators/package_validator.py @@ -1,3 +1,21 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from typing import Any, List, Set from .dict_validator import DictValidator from .string_validator import StringValidator diff --git a/src/kitops/modelkit/validators/string_validator.py b/src/kitops/modelkit/validators/string_validator.py index 8687489..5637dd8 100644 --- a/src/kitops/modelkit/validators/string_validator.py +++ b/src/kitops/modelkit/validators/string_validator.py @@ -1,3 +1,21 @@ +''' +Copyright 2024 The KitOps Authors. + +Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +''' + from typing import Any, Dict, List, Set class StringValidator: diff --git a/test.py b/test.py index 2acffea..83c931e 100644 --- a/test.py +++ b/test.py @@ -38,6 +38,13 @@ # Create an empty Kitfile and update attributes kitfile = Kitfile() + +print("=======================================================") +# Serialize to YAML +yaml_data = kitfile.to_yaml() +print(yaml_data) +print("=======================================================") + kitfile.manifestVersion = "3.0" kitfile.package = { "name": "Another-Package", @@ -45,12 +52,9 @@ "description": "Another description", "authors": ["Someone"] } -# Deserialize from YAML -# new_kitfile = Kitfile.from_yaml(yaml_data) -# print("new_kitfile.manifestVersion: " + new_kitfile.manifestVersion) -# print("new_kitfile.package: ") -# print(new_kitfile.package) - -# def custom_dict_representer(dumper, data): -# return dumper.represent_dict(data.items()) \ No newline at end of file +print("=======================================================") +# Serialize to YAML +yaml_data = kitfile.to_yaml() +print(yaml_data) +print("=======================================================") diff --git a/tests/test_kitfile.py b/tests/test_kitfile.py index 1b18160..f77b188 100644 --- a/tests/test_kitfile.py +++ b/tests/test_kitfile.py @@ -1,7 +1,7 @@ from _pytest.compat import LEGACY_PATH import py import pytest -from src.kitops.modelkit.kitfile.kitfile import Kitfile +from src.kitops.modelkit.kitfile import Kitfile class TestKitfileCreation: