-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(grpc-asyncio): Prepare for version 0.2
1) Use the proper logging namespace "remotivelabs.broker", so that loggers initialized with logging.getLogger(__name__) works as expected. 2) Load version from pyproject.toml file, so that version string is not duplicated in __about__.py. 3) Add imports of generated files to the root package, so that they are properly encapsulated in the library. Also make sure our higher-level abstractions in sync/ package use that import. 4) Clean up tests and add some new.
- Loading branch information
1 parent
8cb4220
commit 61bddac
Showing
21 changed files
with
146 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# SPDX-FileCopyrightText: 2022-present remotiveLabs <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from importlib.metadata import PackageNotFoundError, version | ||
|
||
__version__ = "0.1.26" | ||
try: | ||
__version__ = version("remotivelabs-broker") | ||
except PackageNotFoundError: | ||
__version__ = "unknown" |
56 changes: 35 additions & 21 deletions
56
python/remotivelabs-broker/remotivelabs/broker/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,51 @@ | ||
""" | ||
remotiveLabs Python API for remotiveBroker. | ||
See `version` below. | ||
RemotiveLabs Python API for RemotiveBroker. | ||
This API uses protobuffer and gRPC stubs directly, available in the submodules: | ||
- `remotivelabs.broker.common_pb2`. | ||
- `remotivelabs.broker.common_pb2_grpc`. | ||
- `remotivelabs.broker.diagnostics_api_pb2`. | ||
- `remotivelabs.broker.diagnostics_api_pb2_grpc`. | ||
- `remotivelabs.broker.functional_api_pb2`. | ||
- `remotivelabs.broker.functional_api_pb2_grpc`. | ||
- `remotivelabs.broker.network_api_pb2`. | ||
- `remotivelabs.broker.network_api_pb2_grpc`. | ||
- `remotivelabs.broker.system_api_pb2`. | ||
- `remotivelabs.broker.system_api_pb2_grpc`. | ||
- `remotivelabs.broker.traffic_api_pb2`. | ||
- `remotivelabs.broker.traffic_api_pb2_grpc`. | ||
In addition to return codes, this package uses logging to convey operational | ||
status. Logging is done to the name space "com.remotivelabs.broker". | ||
status. Logging is done to the namespace "remotivelabs.broker". | ||
As a user, enable basic logging in your application with: | ||
```python | ||
logging.basicConfig() | ||
# Disable logging for this package: | ||
logging.getLogger("remotivelabs.broker").propagate = False | ||
``` | ||
Disable logging for this package: | ||
```python | ||
logging.getLogger("com.remotivelabs.broker").propagate = False | ||
``` | ||
Use sub module: `remotivelabs.broker.sync`. | ||
""" | ||
|
||
# SPDX-FileCopyrightText: 2022-present remotiveLabs <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import logging | ||
|
||
from .__about__ import __version__ | ||
|
||
log: logging.Logger = logging.getLogger("com.remotivelabs.broker") | ||
"""Package logging interface""" | ||
|
||
log.addHandler(logging.NullHandler()) | ||
from ._log import configure_logging | ||
from .generated.sync import ( | ||
common_pb2, # noqa: F401 | ||
common_pb2_grpc, # noqa: F401 | ||
diagnostics_api_pb2, # noqa: F401 | ||
diagnostics_api_pb2_grpc, # noqa: F401 | ||
functional_api_pb2, # noqa: F401 | ||
functional_api_pb2_grpc, # noqa: F401 | ||
network_api_pb2, # noqa: F401 | ||
network_api_pb2_grpc, # noqa: F401 | ||
system_api_pb2, # noqa: F401 | ||
system_api_pb2_grpc, # noqa: F401 | ||
traffic_api_pb2, # noqa: F401 | ||
traffic_api_pb2_grpc, # noqa: F401 | ||
) | ||
|
||
version: str = __version__ | ||
"""Library version""" | ||
|
||
configure_logging() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
Configure logging according to best practicies for libraries | ||
https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library | ||
""" | ||
|
||
import logging | ||
|
||
|
||
def configure_logging() -> None: | ||
logging.getLogger("remotivelabs.broker").addHandler(logging.NullHandler()) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.