Repository: ni/measurement-plugin-python (language: python)

Issue:
Searching API reference documentation for `GrpcChannelPool` returns a private submodule
# Bug Report

`GrpcChannelPool` is aliased into `ni_measurementlink_service.measurement.service`, but searching the https://measurementlink-python.readthedocs.io/ for it returns https://measurementlink-python.readthedocs.io/en/latest/autoapi/ni_measurementlink_service/_channelpool/index.html which is a private submodule.

## Repro or Code Sample

Search https://measurementlink-python.readthedocs.io/ for GrpcChannelPool.

## Expected Behavior

Search returns https://measurementlink-python.readthedocs.io/en/latest/autoapi/ni_measurementlink_service/measurement/service/index.html

## Current Behavior

Search returns https://measurementlink-python.readthedocs.io/en/latest/autoapi/ni_measurementlink_service/_channelpool/index.html

## Possible Solution

Update https://github.com/ni/measurementlink-python/blob/main/_docs_source/conf.py#L58 to hide the definition?


[AB#2575470](https://dev.azure.com/ni/94b22d7b-ad7b-4f5e-88f0-867910f91c94/_workitems/edit/2575470)


Discussion / hints:

Fix patch:
diff --git a/ni_measurementlink_service/_drivers/_grpcdevice.py b/ni_measurementlink_service/_drivers/_grpcdevice.py
index b49f3926d..ead0eb778 100644
--- a/ni_measurementlink_service/_drivers/_grpcdevice.py
+++ b/ni_measurementlink_service/_drivers/_grpcdevice.py
@@ -7,12 +7,12 @@
 
 import grpc
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._configuration import (
     GRPC_DEVICE_SERVER_ADDRESS,
     USE_GRPC_DEVICE_SERVER,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient, ServiceLocation
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 
 _logger = logging.getLogger(__name__)
 
diff --git a/ni_measurementlink_service/_drivers/_nidaqmx.py b/ni_measurementlink_service/_drivers/_nidaqmx.py
index 9cebac704..d0846666f 100644
--- a/ni_measurementlink_service/_drivers/_nidaqmx.py
+++ b/ni_measurementlink_service/_drivers/_nidaqmx.py
@@ -4,11 +4,11 @@
 
 import nidaqmx
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._drivers._grpcdevice import (
     get_insecure_grpc_device_server_channel,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management._types import (
     SessionInformation,
     SessionInitializationBehavior,
diff --git a/ni_measurementlink_service/_drivers/_nidcpower.py b/ni_measurementlink_service/_drivers/_nidcpower.py
index a92d263ec..b46a2e0ed 100644
--- a/ni_measurementlink_service/_drivers/_nidcpower.py
+++ b/ni_measurementlink_service/_drivers/_nidcpower.py
@@ -4,12 +4,12 @@
 
 import nidcpower
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._configuration import NIDCPOWER_OPTIONS
 from ni_measurementlink_service._drivers._grpcdevice import (
     get_insecure_grpc_device_server_channel,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management._types import (
     SessionInformation,
     SessionInitializationBehavior,
diff --git a/ni_measurementlink_service/_drivers/_nidigital.py b/ni_measurementlink_service/_drivers/_nidigital.py
index 5d4ee9b2c..46eaf1559 100644
--- a/ni_measurementlink_service/_drivers/_nidigital.py
+++ b/ni_measurementlink_service/_drivers/_nidigital.py
@@ -4,12 +4,12 @@
 
 import nidigital
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._configuration import NIDIGITAL_OPTIONS
 from ni_measurementlink_service._drivers._grpcdevice import (
     get_insecure_grpc_device_server_channel,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management._types import (
     SessionInformation,
     SessionInitializationBehavior,
diff --git a/ni_measurementlink_service/_drivers/_nidmm.py b/ni_measurementlink_service/_drivers/_nidmm.py
index e5f91d343..41f7b32fd 100644
--- a/ni_measurementlink_service/_drivers/_nidmm.py
+++ b/ni_measurementlink_service/_drivers/_nidmm.py
@@ -4,12 +4,12 @@
 
 import nidmm
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._configuration import NIDMM_OPTIONS
 from ni_measurementlink_service._drivers._grpcdevice import (
     get_insecure_grpc_device_server_channel,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management._types import (
     SessionInformation,
     SessionInitializationBehavior,
diff --git a/ni_measurementlink_service/_drivers/_nifgen.py b/ni_measurementlink_service/_drivers/_nifgen.py
index 4860ee664..96bceb0ba 100644
--- a/ni_measurementlink_service/_drivers/_nifgen.py
+++ b/ni_measurementlink_service/_drivers/_nifgen.py
@@ -4,12 +4,12 @@
 
 import nifgen
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._configuration import NIFGEN_OPTIONS
 from ni_measurementlink_service._drivers._grpcdevice import (
     get_insecure_grpc_device_server_channel,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management._types import (
     SessionInformation,
     SessionInitializationBehavior,
diff --git a/ni_measurementlink_service/_drivers/_niscope.py b/ni_measurementlink_service/_drivers/_niscope.py
index 176089348..b4982b442 100644
--- a/ni_measurementlink_service/_drivers/_niscope.py
+++ b/ni_measurementlink_service/_drivers/_niscope.py
@@ -4,12 +4,12 @@
 
 import niscope
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._configuration import NISCOPE_OPTIONS
 from ni_measurementlink_service._drivers._grpcdevice import (
     get_insecure_grpc_device_server_channel,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management._types import (
     SessionInformation,
     SessionInitializationBehavior,
diff --git a/ni_measurementlink_service/_drivers/_niswitch.py b/ni_measurementlink_service/_drivers/_niswitch.py
index 4dd9aac39..1c1453338 100644
--- a/ni_measurementlink_service/_drivers/_niswitch.py
+++ b/ni_measurementlink_service/_drivers/_niswitch.py
@@ -4,12 +4,12 @@
 
 import niswitch
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._configuration import NISWITCH_OPTIONS
 from ni_measurementlink_service._drivers._grpcdevice import (
     get_insecure_grpc_device_server_channel,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management._types import (
     SessionInformation,
     SessionInitializationBehavior,
diff --git a/ni_measurementlink_service/_internal/service_manager.py b/ni_measurementlink_service/_internal/service_manager.py
index 70c6a1cdc..40245a749 100644
--- a/ni_measurementlink_service/_internal/service_manager.py
+++ b/ni_measurementlink_service/_internal/service_manager.py
@@ -16,8 +16,8 @@
 from ni_measurementlink_service._internal.stubs.ni.measurementlink.measurement.v2 import (
     measurement_service_pb2_grpc as v2_measurement_service_pb2_grpc,
 )
-from ni_measurementlink_service._loggers import ServerLogger
 from ni_measurementlink_service.discovery import DiscoveryClient, ServiceLocation
+from ni_measurementlink_service.grpc.loggers import ServerLogger
 from ni_measurementlink_service.measurement.info import MeasurementInfo, ServiceInfo
 
 _logger = logging.getLogger(__name__)
diff --git a/ni_measurementlink_service/discovery/_client.py b/ni_measurementlink_service/discovery/_client.py
index d2a54f78d..2a13e78a8 100644
--- a/ni_measurementlink_service/discovery/_client.py
+++ b/ni_measurementlink_service/discovery/_client.py
@@ -6,13 +6,13 @@
 import grpc
 from deprecation import deprecated
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._internal.stubs.ni.measurementlink.discovery.v1 import (
     discovery_service_pb2,
     discovery_service_pb2_grpc,
 )
 from ni_measurementlink_service.discovery._support import _get_discovery_service_address
 from ni_measurementlink_service.discovery._types import ServiceLocation
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.measurement.info import MeasurementInfo, ServiceInfo
 
 _logger = logging.getLogger(__name__)
diff --git a/ni_measurementlink_service/grpc/__init__.py b/ni_measurementlink_service/grpc/__init__.py
new file mode 100644
index 000000000..4ac324169
--- /dev/null
+++ b/ni_measurementlink_service/grpc/__init__.py
@@ -0,0 +1,1 @@
+"""gRPC extensions."""
diff --git a/ni_measurementlink_service/_channelpool.py b/ni_measurementlink_service/grpc/channelpool.py
similarity index 95%
rename from ni_measurementlink_service/_channelpool.py
rename to ni_measurementlink_service/grpc/channelpool.py
index c5014f77f..254247a4b 100644
--- a/ni_measurementlink_service/_channelpool.py
+++ b/ni_measurementlink_service/grpc/channelpool.py
@@ -1,3 +1,5 @@
+"""gRPC channel pool."""
+
 from __future__ import annotations
 
 import sys
@@ -13,7 +15,7 @@
 
 import grpc
 
-from ni_measurementlink_service._loggers import ClientLogger
+from ni_measurementlink_service.grpc.loggers import ClientLogger
 
 if TYPE_CHECKING:
     if sys.version_info >= (3, 11):
diff --git a/ni_measurementlink_service/_loggers.py b/ni_measurementlink_service/grpc/loggers.py
similarity index 99%
rename from ni_measurementlink_service/_loggers.py
rename to ni_measurementlink_service/grpc/loggers.py
index f1e1dadcf..eccdd86d8 100644
--- a/ni_measurementlink_service/_loggers.py
+++ b/ni_measurementlink_service/grpc/loggers.py
@@ -1,3 +1,5 @@
+"""gRPC logging interceptors."""
+
 from __future__ import annotations
 
 import abc
diff --git a/ni_measurementlink_service/measurement/service.py b/ni_measurementlink_service/measurement/service.py
index 29dfec88d..3eb24ad01 100644
--- a/ni_measurementlink_service/measurement/service.py
+++ b/ni_measurementlink_service/measurement/service.py
@@ -28,9 +28,6 @@
 from google.protobuf.descriptor import EnumDescriptor
 
 from ni_measurementlink_service import _datatypeinfo
-from ni_measurementlink_service._channelpool import (  # re-export
-    GrpcChannelPool as GrpcChannelPool,
-)
 from ni_measurementlink_service._featuretoggles import (
     SESSION_MANAGEMENT_2024Q1,
     requires_feature,
@@ -41,6 +38,9 @@
 )
 from ni_measurementlink_service._internal.service_manager import GrpcService
 from ni_measurementlink_service.discovery import DiscoveryClient, ServiceLocation
+from ni_measurementlink_service.grpc.channelpool import (  # re-export
+    GrpcChannelPool as GrpcChannelPool,
+)
 from ni_measurementlink_service.measurement.info import (
     DataType,
     MeasurementInfo,
diff --git a/ni_measurementlink_service/session_management/_client.py b/ni_measurementlink_service/session_management/_client.py
index 2e0494dcc..be843e675 100644
--- a/ni_measurementlink_service/session_management/_client.py
+++ b/ni_measurementlink_service/session_management/_client.py
@@ -8,12 +8,12 @@
 
 import grpc
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._internal.stubs.ni.measurementlink.sessionmanagement.v1 import (
     session_management_service_pb2,
     session_management_service_pb2_grpc,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management._constants import (
     GRPC_SERVICE_CLASS,
     GRPC_SERVICE_INTERFACE_NAME,
diff --git a/ni_measurementlink_service/session_management/_reservation.py b/ni_measurementlink_service/session_management/_reservation.py
index 0b80ddc52..250da6c46 100644
--- a/ni_measurementlink_service/session_management/_reservation.py
+++ b/ni_measurementlink_service/session_management/_reservation.py
@@ -29,7 +29,6 @@
     cast,
 )
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._drivers import (
     closing_session,
     closing_session_with_ts_code_module_support,
@@ -42,6 +41,7 @@
     session_management_service_pb2,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management._constants import (
     INSTRUMENT_TYPE_NI_DAQMX,
     INSTRUMENT_TYPE_NI_DCPOWER,


Test patch:
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py
index a9ea69c9f..717e8d4e3 100644
--- a/tests/unit/conftest.py
+++ b/tests/unit/conftest.py
@@ -7,10 +7,10 @@
 import pytest
 from pytest_mock import MockerFixture
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._internal import grpc_servicer
 from ni_measurementlink_service._internal.grpc_servicer import MeasurementServiceContext
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.measurement.service import MeasurementService
 from ni_measurementlink_service.session_management import (
     MultiSessionReservation,
diff --git a/tests/unit/test_discovery_client.py b/tests/unit/test_discovery_client.py
index 0246ccec5..de148eb5b 100644
--- a/tests/unit/test_discovery_client.py
+++ b/tests/unit/test_discovery_client.py
@@ -12,7 +12,6 @@
 import pytest
 from pytest_mock import MockerFixture
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._internal.stubs.ni.measurementlink.discovery.v1.discovery_service_pb2 import (
     RegisterServiceRequest,
     RegisterServiceResponse,
@@ -31,6 +30,7 @@
     _open_key_file,
     _start_service,
 )
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.measurement.info import MeasurementInfo, ServiceInfo
 from tests.utilities.fake_rpc_error import FakeRpcError
 
diff --git a/tests/unit/test_session_management.py b/tests/unit/test_session_management.py
index 6545a0bd5..d32960603 100644
--- a/tests/unit/test_session_management.py
+++ b/tests/unit/test_session_management.py
@@ -5,7 +5,6 @@
 import pytest
 from pytest_mock import MockerFixture
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._internal.stubs import session_pb2
 from ni_measurementlink_service._internal.stubs.ni.measurementlink.sessionmanagement.v1 import (
     session_management_service_pb2,
@@ -14,6 +13,7 @@
     SessionManagementServiceStub,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 from ni_measurementlink_service.session_management import (
     MultiSessionReservation,
     PinMapContext,
diff --git a/tests/utilities/pin_map_client.py b/tests/utilities/pin_map_client.py
index d44c96497..041c05380 100644
--- a/tests/utilities/pin_map_client.py
+++ b/tests/utilities/pin_map_client.py
@@ -6,12 +6,12 @@
 
 import grpc
 
-from ni_measurementlink_service._channelpool import GrpcChannelPool
 from ni_measurementlink_service._internal.stubs.ni.measurementlink.pinmap.v1 import (
     pin_map_service_pb2,
     pin_map_service_pb2_grpc,
 )
 from ni_measurementlink_service.discovery import DiscoveryClient
+from ni_measurementlink_service.grpc.channelpool import GrpcChannelPool
 
 _logger = logging.getLogger(__name__)