aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony DiGirolamo <tonymd@google.com>2022-12-07 02:28:49 +0000
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-12-07 02:28:49 +0000
commitbb8f5f26a702d583bf4badaeb1453f81c9c62fac (patch)
tree9c6e9381ec944b196ef49a316da87487dc6ce588
parenta0882f8e6c118055d9e0f559b80a4270224f8d35 (diff)
downloadpigweed-bb8f5f26a702d583bf4badaeb1453f81c9c62fac.tar.gz
pw_system: Missing pw_metric & pw_unit_test deps
Bug: b/242110560 Change-Id: I1d1901fd0dc88156bf5c12d2900b3eaf8f8db0c4 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/122950 Commit-Queue: Anthony DiGirolamo <tonymd@google.com> Reviewed-by: Ted Pudlik <tpudlik@google.com> Pigweed-Auto-Submit: Anthony DiGirolamo <tonymd@google.com>
-rw-r--r--pw_metric/BUILD.bazel8
-rw-r--r--pw_system/py/BUILD.bazel16
-rw-r--r--pw_system/py/pw_system/console.py18
-rw-r--r--pw_system/py/pw_system/device.py8
-rw-r--r--pw_unit_test/py/BUILD.bazel31
-rw-r--r--pw_unit_test/py/pw_unit_test/rpc.py4
6 files changed, 64 insertions, 21 deletions
diff --git a/pw_metric/BUILD.bazel b/pw_metric/BUILD.bazel
index 604846fd7..2eae45c18 100644
--- a/pw_metric/BUILD.bazel
+++ b/pw_metric/BUILD.bazel
@@ -18,6 +18,7 @@ load(
"pw_cc_test",
)
load("//pw_protobuf_compiler:proto.bzl", "pw_proto_library")
+load("//pw_build/bazel_internal:py_proto_library.bzl", "py_proto_library")
package(default_visibility = ["//visibility:public"])
@@ -109,6 +110,13 @@ proto_library(
],
)
+# TODO(b/241456982): Not expected to build yet.
+py_proto_library(
+ name = "metric_proto_py_pb2",
+ tags = ["manual"],
+ deps = [":metric_proto"],
+)
+
pw_proto_library(
name = "metric_proto_cc",
deps = [":metric_proto"],
diff --git a/pw_system/py/BUILD.bazel b/pw_system/py/BUILD.bazel
index 9a6e4ebd9..0feba3139 100644
--- a/pw_system/py/BUILD.bazel
+++ b/pw_system/py/BUILD.bazel
@@ -16,6 +16,17 @@ load("@rules_python//python:defs.bzl", "py_binary", "py_library")
package(default_visibility = ["//visibility:public"])
+# TODO(b/241456982): The following deps are required to build :pw_system_lib
+# deps = [
+# "//pw_thread/py:pw_thread",
+# "//pw_log:log_proto_py_pb2",
+# "//pw_metric:metric_proto_py_pb2",
+# "//pw_thread:thread_proto_py_pb2",
+# "//pw_thread:thread_snapshot_service_py_pb2",
+# "//pw_tokenizer:tokenizer_proto_py_pb2",
+# "//pw_unit_test:unit_test_py_pb2",
+# "//pw_unit_test/py:pw_unit_test_lib",
+# ],
py_library(
name = "pw_system_lib",
srcs = [
@@ -32,15 +43,10 @@ py_library(
"//pw_metric/py:pw_metric",
"//pw_rpc/py:pw_rpc",
"//pw_status/py:pw_status",
- "//pw_thread/py:pw_thread",
"//pw_tokenizer/py:pw_tokenizer",
],
)
-# TODO(b/241456982): This won't run due to missing proto_py_pb2 imports:
-# "//pw_log:log_proto_py_pb2",
-# "//pw_thread:thread_proto_py_pb2",
-# "//pw_tokenizer:tokenizer_proto_py_pb2",
py_binary(
name = "pw_system_console",
srcs = [
diff --git a/pw_system/py/pw_system/console.py b/pw_system/py/pw_system/console.py
index f48e832ec..80fd2c3f3 100644
--- a/pw_system/py/pw_system/console.py
+++ b/pw_system/py/pw_system/console.py
@@ -54,12 +54,12 @@ import socket
import serial # type: ignore
import IPython # type: ignore
-import pw_cli.log
+from pw_cli import log as pw_cli_log
from pw_console.embed import PwConsoleEmbed
from pw_console.log_store import LogStore
from pw_console.plugins.bandwidth_toolbar import BandwidthToolbar
from pw_console.pyserial_wrapper import SerialWithLogging
-import pw_console.python_logging
+from pw_console.python_logging import create_temp_log_file, JsonLogFormatter
from pw_rpc.console_tools.console import flattened_rpc_completions
from pw_system.device import Device
from pw_tokenizer.detokenize import AutoUpdatingDetokenizer
@@ -370,16 +370,16 @@ def console(
if not logfile:
# Create a temp logfile to prevent logs from appearing over stdout. This
# would corrupt the prompt toolkit UI.
- logfile = pw_console.python_logging.create_temp_log_file()
+ logfile = create_temp_log_file()
log_level = logging.DEBUG if verbose else logging.INFO
- pw_cli.log.install(
+ pw_cli_log.install(
level=log_level, use_color=False, hide_timestamp=False, log_file=logfile
)
if device_logfile:
- pw_cli.log.install(
+ pw_cli_log.install(
level=log_level,
use_color=False,
hide_timestamp=False,
@@ -387,7 +387,7 @@ def console(
logger=_DEVICE_LOG,
)
if host_logfile:
- pw_cli.log.install(
+ pw_cli_log.install(
level=log_level,
use_color=False,
hide_timestamp=False,
@@ -397,7 +397,7 @@ def console(
if merge_device_and_host_logs:
# Add device logs to the default logfile.
- pw_cli.log.install(
+ pw_cli_log.install(
level=log_level,
use_color=False,
hide_timestamp=False,
@@ -413,9 +413,7 @@ def console(
if json_logfile:
json_filehandler = logging.FileHandler(json_logfile, encoding='utf-8')
json_filehandler.setLevel(log_level)
- json_filehandler.setFormatter(
- pw_console.python_logging.JsonLogFormatter()
- )
+ json_filehandler.setFormatter(JsonLogFormatter())
_DEVICE_LOG.addHandler(json_filehandler)
detokenizer = None
diff --git a/pw_system/py/pw_system/device.py b/pw_system/py/pw_system/device.py
index 9d4e5adc1..3ec387f99 100644
--- a/pw_system/py/pw_system/device.py
+++ b/pw_system/py/pw_system/device.py
@@ -20,7 +20,7 @@ from types import ModuleType
from typing import Any, Callable, List, Union, Optional
from pw_hdlc.rpc import HdlcRpcClient, default_channels
-import pw_log_tokenized
+from pw_log_tokenized import FormatStringWithMetadata
from pw_log.proto import log_pb2
from pw_metric import metric_parser
from pw_rpc import callback_client, console_tools
@@ -29,7 +29,7 @@ from pw_thread.thread_analyzer import ThreadSnapshotAnalyzer
from pw_thread_protos import thread_pb2
from pw_tokenizer import detokenize
from pw_tokenizer.proto import decode_optionally_tokenized
-import pw_unit_test.rpc
+from pw_unit_test.rpc import run_tests as pw_unit_test_run_tests
# Internal log for troubleshooting this tool (the console).
_LOG = logging.getLogger('tools')
@@ -104,7 +104,7 @@ class Device:
def run_tests(self, timeout_s: Optional[float] = 5) -> bool:
"""Runs the unit tests on this device."""
- return pw_unit_test.rpc.run_tests(self.rpcs, timeout_s=timeout_s)
+ return pw_unit_test_run_tests(self.rpcs, timeout_s=timeout_s)
def listen_to_log_stream(self):
"""Opens a log RPC for the device's unrequested log stream.
@@ -167,7 +167,7 @@ class Device:
)
else:
message = log_proto.message.decode('utf-8')
- log = pw_log_tokenized.FormatStringWithMetadata(message)
+ log = FormatStringWithMetadata(message)
# Handle dropped count.
if log_proto.dropped:
diff --git a/pw_unit_test/py/BUILD.bazel b/pw_unit_test/py/BUILD.bazel
new file mode 100644
index 000000000..8915b04e4
--- /dev/null
+++ b/pw_unit_test/py/BUILD.bazel
@@ -0,0 +1,31 @@
+# Copyright 2022 The Pigweed 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
+#
+# https://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.
+
+load("@rules_python//python:defs.bzl", "py_library")
+
+package(default_visibility = ["//visibility:public"])
+
+py_library(
+ name = "pw_unit_test_lib",
+ srcs = [
+ "pw_unit_test/__init__.py",
+ "pw_unit_test/rpc.py",
+ "pw_unit_test/test_runner.py",
+ ],
+ deps = [
+ "//pw_cli/py:pw_cli",
+ "//pw_rpc/py:pw_rpc",
+ "//pw_unit_test:unit_test_py_pb2",
+ ],
+)
diff --git a/pw_unit_test/py/pw_unit_test/rpc.py b/pw_unit_test/py/pw_unit_test/rpc.py
index 3f22bd670..ac1c56a2f 100644
--- a/pw_unit_test/py/pw_unit_test/rpc.py
+++ b/pw_unit_test/py/pw_unit_test/rpc.py
@@ -19,7 +19,7 @@ from dataclasses import dataclass
import logging
from typing import Iterable
-import pw_rpc.client
+from pw_rpc.client import Services
from pw_rpc.callback_client import OptionalTimeout, UseDefault
from pw_unit_test_proto import unit_test_pb2
@@ -134,7 +134,7 @@ class LoggingEventHandler(EventHandler):
def run_tests(
- rpcs: pw_rpc.client.Services,
+ rpcs: Services,
report_passed_expectations: bool = False,
test_suites: Iterable[str] = (),
event_handlers: Iterable[EventHandler] = (LoggingEventHandler(),),