Skip to content

Commit

Permalink
Change package structure. Move tests out of package dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricefrog committed Jan 30, 2025
1 parent 344cce1 commit 23862ab
Show file tree
Hide file tree
Showing 25 changed files with 991 additions and 33 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include ./keysight_chakra/protobuf/*
include ./keysight_chakra/infra/*
include ./keysight_chakra/mlcommons/*
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -9,28 +12,30 @@ env: ## install env requirements
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
PROTO_PACKAGE_DIR := ./keysight_chakra/protobuf
build: ## compile all .proto files and generate artifacts
curl -L -o ./keysight_chakra/protobuf/et_def.proto https://raw.githubusercontent.com/mlcommons/chakra/main/schema/protobuf/et_def.proto
sed -i 's/ChakraProtoMsg/keysight_chakra.protobuf/g' ./keysight_chakra/protobuf/et_def.proto
rm -rf $(PROTO_PACKAGE_DIR)/*pb2* || true
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=./ \
--python_out=./ \
--pyi_out=./ \
--grpc_python_out=./ \
$(PROTO_PACKAGE_DIR)/infra.proto \
$(PROTO_PACKAGE_DIR)/annotate.proto \
$(PROTO_PACKAGE_DIR)/service.proto \
$(PROTO_PACKAGE_DIR)/et_def.proto
$(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


Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

syntax = "proto3";

package keysight_chakra.protobuf;
package keysight_chakra.infra;

import "google/protobuf/any.proto";

Expand Down
41 changes: 41 additions & 0 deletions keysight_chakra/infra/annotate_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions keysight_chakra/infra/annotate_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from google.protobuf import any_pb2 as _any_pb2
from google.protobuf.internal import containers as _containers
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union

DESCRIPTOR: _descriptor.FileDescriptor

class Data(_message.Message):
__slots__ = ("name", "value")
NAME_FIELD_NUMBER: _ClassVar[int]
VALUE_FIELD_NUMBER: _ClassVar[int]
name: str
value: _any_pb2.Any
def __init__(self, name: _Optional[str] = ..., value: _Optional[_Union[_any_pb2.Any, _Mapping]] = ...) -> None: ...

class Target(_message.Message):
__slots__ = ("infrastructure", "device", "device_component", "device_component_index", "device_instance", "device_instance_index", "device_instance_index_component", "device_instance_index_component_index")
INFRASTRUCTURE_FIELD_NUMBER: _ClassVar[int]
DEVICE_FIELD_NUMBER: _ClassVar[int]
DEVICE_COMPONENT_FIELD_NUMBER: _ClassVar[int]
DEVICE_COMPONENT_INDEX_FIELD_NUMBER: _ClassVar[int]
DEVICE_INSTANCE_FIELD_NUMBER: _ClassVar[int]
DEVICE_INSTANCE_INDEX_FIELD_NUMBER: _ClassVar[int]
DEVICE_INSTANCE_INDEX_COMPONENT_FIELD_NUMBER: _ClassVar[int]
DEVICE_INSTANCE_INDEX_COMPONENT_INDEX_FIELD_NUMBER: _ClassVar[int]
infrastructure: str
device: str
device_component: str
device_component_index: str
device_instance: str
device_instance_index: str
device_instance_index_component: str
device_instance_index_component_index: str
def __init__(self, infrastructure: _Optional[str] = ..., device: _Optional[str] = ..., device_component: _Optional[str] = ..., device_component_index: _Optional[str] = ..., device_instance: _Optional[str] = ..., device_instance_index: _Optional[str] = ..., device_instance_index_component: _Optional[str] = ..., device_instance_index_component_index: _Optional[str] = ...) -> None: ...

class Annotation(_message.Message):
__slots__ = ("targets", "data")
TARGETS_FIELD_NUMBER: _ClassVar[int]
DATA_FIELD_NUMBER: _ClassVar[int]
targets: _containers.RepeatedCompositeFieldContainer[Target]
data: Data
def __init__(self, targets: _Optional[_Iterable[_Union[Target, _Mapping]]] = ..., data: _Optional[_Union[Data, _Mapping]] = ...) -> None: ...
24 changes: 24 additions & 0 deletions keysight_chakra/infra/annotate_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings


GRPC_GENERATED_VERSION = '1.67.1'
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
from grpc._utilities import first_version_is_lower
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
_version_not_supported = True

if _version_not_supported:
raise RuntimeError(
f'The grpc package installed is at version {GRPC_VERSION},'
+ f' but the generated code in keysight_chakra/infra/annotate_pb2_grpc.py depends on'
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

syntax = "proto3";

package keysight_chakra.protobuf;
package keysight_chakra.infra;

import "google/protobuf/any.proto";

Expand Down
91 changes: 91 additions & 0 deletions keysight_chakra/infra/infra_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 23862ab

Please sign in to comment.