diff --git a/.gitignore b/.gitignore index 2f69e1d..4b8c176 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,15 @@ __pycache__/ +.venv/ *.py[cod] *$py.class .ipynb_checkpoints -keysight_chakra/tests/*.html -keysight_chakra/tests/*.yml +tests/*.html +tests/*.yml .yml build dist .pytest_cache *.egg-info -keysight_chakra/generated -keysight_chakra/tests/generated_artifacts \ No newline at end of file +keysight_chakra/infra/*pb2* +keysight_chakra/mlcommons/*pb2* +tests/generated_artifacts diff --git a/MANIFEST.in b/MANIFEST.in index e857479..cf11b51 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ -include ./keysight_chakra/protos/*.proto -include ./keysight_chakra/generated/*.pyi +include ./keysight_chakra/infra/* +include ./keysight_chakra/mlcommons/* diff --git a/Makefile b/Makefile index def0c72..9930c4c 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +MLCOMMONS_PACKAGE_DIR := ./keysight_chakra/mlcommons +INFRA_PACKAGE_DIR := ./keysight_chakra/infra + help: @awk -F ':|##' '/^[^\t].+:.*##/ { printf "\033[36mmake %-28s\033[0m -%s\n", $$1, $$NF }' $(MAKEFILE_LIST) | sort @@ -5,24 +8,34 @@ env: ## install env requirements echo "installing python packages..." && \ pip install -r requirements.txt +.PHONY: clean +clean: + rm -rf build/* || true + rm -rf dist/* || true + rm -rf $(MLCOMMONS_PACKAGE_DIR)/*pb2* || true + rm -rf $(INFRA_PACKAGE_DIR)/*pb2* || true + .PHONY: build -GENERATED_DIR := ./keysight_chakra/generated build: ## compile all .proto files and generate artifacts - curl -L -o ./keysight_chakra/protos/et_def.proto https://raw.githubusercontent.com/mlcommons/chakra/main/schema/protobuf/et_def.proto - rm -rf $(GENERATED_DIR) || true - mkdir -p $(GENERATED_DIR) + curl -L -o $(MLCOMMONS_PACKAGE_DIR)/et_def.proto https://raw.githubusercontent.com/mlcommons/chakra/main/schema/protobuf/et_def.proto + sed -i 's/ChakraProtoMsg/keysight_chakra.mlcommons/g' $(MLCOMMONS_PACKAGE_DIR)/et_def.proto + rm -rf $(MLCOMMONS_PACKAGE_DIR)/*pb2* || true + rm -rf $(INFRA_PACKAGE_DIR)/*pb2* || true python3 -m grpc_tools.protoc \ - --proto_path=./keysight_chakra/protos \ - --python_out=$(GENERATED_DIR) \ - --pyi_out=$(GENERATED_DIR) \ - --grpc_python_out=$(GENERATED_DIR) \ - et_def.proto infra.proto annotate.proto service.proto + --proto_path=./ \ + --python_out=./ \ + --pyi_out=./ \ + --grpc_python_out=./ \ + $(INFRA_PACKAGE_DIR)/infra.proto \ + $(INFRA_PACKAGE_DIR)/annotate.proto \ + $(INFRA_PACKAGE_DIR)/service.proto \ + $(MLCOMMONS_PACKAGE_DIR)/et_def.proto python3 -m pip uninstall -y keysight-chakra python3 setup.py bdist_wheel python3 -m pip install --no-cache . .PHONY: test test: build ## run sanity tests on the distribution - python3 -m pytest -s keysight_chakra/tests + python3 -m pytest -s tests diff --git a/VERSION b/VERSION index 9084fa2..26aaba0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.2.0 diff --git a/keysight_chakra/infra/__init__.py b/keysight_chakra/infra/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/keysight_chakra/protos/annotate.proto b/keysight_chakra/infra/annotate.proto similarity index 99% rename from keysight_chakra/protos/annotate.proto rename to keysight_chakra/infra/annotate.proto index b7cafac..a91ddac 100644 --- a/keysight_chakra/protos/annotate.proto +++ b/keysight_chakra/infra/annotate.proto @@ -26,7 +26,7 @@ syntax = "proto3"; -package annotate; +package keysight_chakra.infra; import "google/protobuf/any.proto"; diff --git a/keysight_chakra/protos/infra.proto b/keysight_chakra/infra/infra.proto similarity index 99% rename from keysight_chakra/protos/infra.proto rename to keysight_chakra/infra/infra.proto index 62be9b8..2df01a1 100644 --- a/keysight_chakra/protos/infra.proto +++ b/keysight_chakra/infra/infra.proto @@ -10,7 +10,7 @@ syntax = "proto3"; -package infra; +package keysight_chakra.infra; import "google/protobuf/any.proto"; diff --git a/keysight_chakra/protos/service.proto b/keysight_chakra/infra/service.proto similarity index 85% rename from keysight_chakra/protos/service.proto rename to keysight_chakra/infra/service.proto index 3ab0c8c..2cda1e6 100644 --- a/keysight_chakra/protos/service.proto +++ b/keysight_chakra/infra/service.proto @@ -4,14 +4,14 @@ syntax = "proto3"; -package service; +package keysight_chakra.infra; -import "infra.proto"; -import "annotate.proto"; +import "keysight_chakra/infra/infra.proto"; +import "keysight_chakra/infra/annotate.proto"; message ValidationRequest { - infra.Infrastructure infrastructure = 1; - repeated annotate.Annotation annotations = 2; + Infrastructure infrastructure = 1; + repeated Annotation annotations = 2; } message ValidationError { @@ -48,4 +48,4 @@ message ValidationResponse { service InfraService { // Validate rpc validates both infra and annotation messages rpc Validate(ValidationRequest) returns (ValidationResponse); -} \ No newline at end of file +} diff --git a/keysight_chakra/mlcommons/__init__.py b/keysight_chakra/mlcommons/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/keysight_chakra/protos/et_def.proto b/keysight_chakra/mlcommons/et_def.proto similarity index 98% rename from keysight_chakra/protos/et_def.proto rename to keysight_chakra/mlcommons/et_def.proto index 965cec8..9d4f455 100644 --- a/keysight_chakra/protos/et_def.proto +++ b/keysight_chakra/mlcommons/et_def.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package ChakraProtoMsg; +package keysight_chakra.mlcommons; message AttributeProto { string name = 1; diff --git a/keysight_chakra/validation.py b/keysight_chakra/validation.py index 60d9f0b..cfdc38c 100644 --- a/keysight_chakra/validation.py +++ b/keysight_chakra/validation.py @@ -5,9 +5,9 @@ from typing import Annotated from google.protobuf.message import Message -from generated.service_pb2 import ValidationRequest, ValidationError, ValidationResponse -from generated.infra_pb2 import Device -from generated.annotate_pb2 import Annotation +from keysight_chakra.infra.service_pb2 import ValidationRequest, ValidationError, ValidationResponse +from keysight_chakra.infra.infra_pb2 import Device +from keysight_chakra.infra.annotate_pb2 import Annotation class Validation: diff --git a/setup.py b/setup.py index 6692294..f16fa95 100644 --- a/setup.py +++ b/setup.py @@ -16,8 +16,8 @@ # "install_destination_package_path": "source_dir_path" package_dir_map = { f"{package_base}": "./keysight_chakra", - f"{package_base}/generated": "./keysight_chakra/generated", - f"{package_base}/tests": "./keysight_chakra/tests", + f"{package_base}/infra": "./keysight_chakra/infra", + f"{package_base}/mlcommons": "./keysight_chakra/mlcommons", } requires = [ diff --git a/keysight_chakra/tests/conftest.py b/tests/conftest.py similarity index 68% rename from keysight_chakra/tests/conftest.py rename to tests/conftest.py index bc80452..29a4ab8 100644 --- a/keysight_chakra/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,5 @@ -import sys -import os - -for directory_piece in ["..", "generated", "tests"]: - sys.path.append(os.path.join(os.path.dirname(__file__), directory_piece)) - import pytest -from keysight_chakra.generated.infra_pb2 import Device, Component, Link, Bandwidth, Npu, Nic +from keysight_chakra.infra.infra_pb2 import Device, Component, Link, Bandwidth, Npu, Nic from keysight_chakra.validation import Validation diff --git a/keysight_chakra/tests/test_serialization.py b/tests/test_serialization.py similarity index 96% rename from keysight_chakra/tests/test_serialization.py rename to tests/test_serialization.py index 1aad5b5..43ffb76 100644 --- a/keysight_chakra/tests/test_serialization.py +++ b/tests/test_serialization.py @@ -2,7 +2,7 @@ from google.protobuf.json_format import MessageToJson, Parse from google.protobuf.any_pb2 import Any from google.protobuf.wrappers_pb2 import StringValue -from keysight_chakra.generated.annotate_pb2 import Annotation, Target, Data +from keysight_chakra.infra.annotate_pb2 import Annotation, Target, Data class AnyString: diff --git a/keysight_chakra/tests/test_validation.py b/tests/test_validation.py similarity index 95% rename from keysight_chakra/tests/test_validation.py rename to tests/test_validation.py index e377d73..0b9209d 100644 --- a/keysight_chakra/tests/test_validation.py +++ b/tests/test_validation.py @@ -1,7 +1,7 @@ import pytest -from keysight_chakra.generated.service_pb2 import ValidationRequest -from keysight_chakra.generated.infra_pb2 import ( +from keysight_chakra.infra.service_pb2 import ValidationRequest +from keysight_chakra.infra.infra_pb2 import ( Infrastructure, Inventory, Device,