ni.datamonikers.v1.client 0.1.0.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.3
2
+ Name: ni.datamonikers.v1.client
3
+ Version: 0.1.0.dev0
4
+ Summary: gRPC Client for NI Data Moniker Service
5
+ License: MIT
6
+ Keywords: data-moniker,client
7
+ Author: NI
8
+ Author-email: opensource@ni.com
9
+ Maintainer: Joe Friedrichsen
10
+ Maintainer-email: joe.friedrichsen@emerson.com
11
+ Requires-Python: >=3.9,<4.0
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Manufacturing
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: Implementation :: CPython
25
+ Requires-Dist: ni-datamonikers-v1-proto (>=0.1.0.dev0)
26
+ Requires-Dist: ni-grpc-extensions (>=0.1.0.dev0)
27
+ Project-URL: Repository, https://github.com/ni/ni-apis-python
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Table of Contents
31
+
32
+ - [Table of Contents](#table-of-contents)
33
+ - [About](#about)
34
+ - [Operating System Support](#operating-system-support)
35
+ - [Python Version Support](#python-version-support)
36
+
37
+ # About
38
+
39
+ `ni.datamonikers.v1.client` is a Python package that provides a gRPC client for the
40
+ NI Data Moniker Service, version 1. The corresponding service is defined in the
41
+ [ni.datamonikers.v1 package](https://github.com/ni/ni-apis/tree/main/ni/datamonikers/v1).
42
+
43
+ NI created and supports this package.
44
+
45
+ ## Operating System Support
46
+
47
+ `ni.datamonikers.v1.client` supports Windows operating systems.
48
+
49
+ ## Python Version Support
50
+
51
+ `ni.datamonikers.v1.client` supports CPython 3.9+.
52
+
53
+ ## Installation
54
+
55
+ You can directly install the `ni.datamonikers.v1.client` package using `pip` or by listing it as a
56
+ dependency in your project's `pyproject.toml` file.
@@ -0,0 +1,27 @@
1
+ # Table of Contents
2
+
3
+ - [Table of Contents](#table-of-contents)
4
+ - [About](#about)
5
+ - [Operating System Support](#operating-system-support)
6
+ - [Python Version Support](#python-version-support)
7
+
8
+ # About
9
+
10
+ `ni.datamonikers.v1.client` is a Python package that provides a gRPC client for the
11
+ NI Data Moniker Service, version 1. The corresponding service is defined in the
12
+ [ni.datamonikers.v1 package](https://github.com/ni/ni-apis/tree/main/ni/datamonikers/v1).
13
+
14
+ NI created and supports this package.
15
+
16
+ ## Operating System Support
17
+
18
+ `ni.datamonikers.v1.client` supports Windows operating systems.
19
+
20
+ ## Python Version Support
21
+
22
+ `ni.datamonikers.v1.client` supports CPython 3.9+.
23
+
24
+ ## Installation
25
+
26
+ You can directly install the `ni.datamonikers.v1.client` package using `pip` or by listing it as a
27
+ dependency in your project's `pyproject.toml` file.
@@ -0,0 +1,106 @@
1
+ [project]
2
+ name = "ni.datamonikers.v1.client"
3
+ version = "0.1.0-dev0"
4
+ license = "MIT"
5
+ description = "gRPC Client for NI Data Moniker Service"
6
+ authors = [{name = "NI", email = "opensource@ni.com"}]
7
+ maintainers = [
8
+ {name = "Joe Friedrichsen", email = "joe.friedrichsen@emerson.com"},
9
+ {name = "Brad Keryan", email = "brad.keryan@emerson.com"}
10
+ ]
11
+ readme = "README.md"
12
+ keywords = ["data-moniker", "client"]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Intended Audience :: Developers",
16
+ "Intended Audience :: Manufacturing",
17
+ "Intended Audience :: Science/Research",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: Microsoft :: Windows",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: Implementation :: CPython",
27
+ ]
28
+ dynamic = ["dependencies"]
29
+ requires-python = '>=3.9,<4.0'
30
+
31
+ [project.urls]
32
+ repository = "https://github.com/ni/ni-apis-python"
33
+
34
+ [tool.poetry]
35
+ packages = [{include = "ni", from = "src"}]
36
+ requires-poetry = '>=2.1,<3.0'
37
+
38
+ [tool.poetry.dependencies]
39
+ ni-grpc-extensions = { version = ">=0.1.0.dev0", allow-prereleases = true }
40
+ ni-datamonikers-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true }
41
+
42
+ [tool.poetry.group.dev.dependencies]
43
+ types-grpcio = ">=1.0"
44
+ types-protobuf = ">=4.21"
45
+ ni-grpc-extensions = { path = "../ni-grpc-extensions", develop = true }
46
+ ni-datamonikers-v1-proto = { path = "../ni.datamonikers.v1.proto", develop = true }
47
+
48
+ [tool.poetry.group.lint.dependencies]
49
+ bandit = { version = ">=1.7", extras = ["toml"] }
50
+ ni-python-styleguide = ">=0.4.1"
51
+ mypy = ">=1.0"
52
+ pyright = { version = ">=1.1.400", extras = ["nodejs"] }
53
+
54
+ [tool.poetry.group.test.dependencies]
55
+ pytest = ">=7.2"
56
+ pytest-cov = ">=4.0"
57
+ pytest-doctestplus = ">=1.4"
58
+ pytest-mock = ">=3.0"
59
+
60
+ [tool.poetry.group.docs]
61
+ optional = true
62
+
63
+ [tool.poetry.group.docs.dependencies]
64
+ # The latest Sphinx requires a recent Python version.
65
+ Sphinx = [
66
+ { version = ">=7.4", python = ">=3.9,<3.10" },
67
+ { version = ">=8.1", python = ">=3.10,<3.11" },
68
+ { version = ">=8.2", python = "^3.11" },
69
+ ]
70
+ sphinx-rtd-theme = ">=1.0.0"
71
+ sphinx-autoapi = ">=1.8.4"
72
+ m2r2 = ">=0.3.2"
73
+ toml = ">=0.10.2"
74
+
75
+ [build-system]
76
+ requires = ["poetry-core>=2.1.0,<3.0"]
77
+ build-backend = "poetry.core.masonry.api"
78
+
79
+
80
+ [tool.bandit]
81
+ skips = [
82
+ "B101", # assert_used
83
+ ]
84
+
85
+ [tool.ni-python-styleguide]
86
+ extend_exclude = "docs"
87
+ application-import-names = "ni.datamonikers.v1.client"
88
+
89
+ [tool.black]
90
+ extend-exclude = 'docs/'
91
+ line-length = 100
92
+
93
+ [tool.mypy]
94
+ mypy_path = "src"
95
+ files = "."
96
+ namespace_packages = true
97
+ strict = true
98
+ explicit_package_bases = true
99
+ exclude = ["docs"]
100
+
101
+ [tool.pyright]
102
+ include = ["src/", "tests/"]
103
+
104
+ [tool.pytest.ini_options]
105
+ addopts = "--doctest-modules --doctest-plus --strict-markers"
106
+ testpaths = ["tests"]
@@ -0,0 +1,5 @@
1
+ """Public API for accessing the NI Data Moniker Service."""
2
+
3
+ from ni.datamonikers.v1.client._client import MonikerClient
4
+
5
+ __all__ = ["MonikerClient"]
@@ -0,0 +1,110 @@
1
+ """Client for accessing the NI Data Moniker Service."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ import threading
7
+ from typing import Iterator
8
+
9
+ import grpc
10
+ import ni.datamonikers.v1.data_moniker_pb2 as data_moniker_pb2
11
+ import ni.datamonikers.v1.data_moniker_pb2_grpc as data_moniker_pb2_grpc
12
+ from ni_grpc_extensions.channelpool import GrpcChannelPool
13
+
14
+ _logger = logging.getLogger(__name__)
15
+
16
+
17
+ class MonikerClient:
18
+ """Client for accessing the NI Data Moniker Service."""
19
+
20
+ __slots__ = (
21
+ "_initialization_lock",
22
+ "_service_location",
23
+ "_grpc_channel_pool",
24
+ "_stub",
25
+ )
26
+
27
+ _initialization_lock: threading.Lock
28
+ _service_location: str | None
29
+ _grpc_channel_pool: GrpcChannelPool | None
30
+ _stub: data_moniker_pb2_grpc.MonikerServiceStub | None
31
+
32
+ def __init__(
33
+ self,
34
+ *,
35
+ service_location: str | None = None,
36
+ grpc_channel: grpc.Channel | None = None,
37
+ grpc_channel_pool: GrpcChannelPool | None = None,
38
+ ) -> None:
39
+ """Initialize the Moniker Client.
40
+
41
+ Args:
42
+ service_location: The address of the data moniker service location (recommended).
43
+
44
+ grpc_channel: A data moniker gRPC channel (optional).
45
+
46
+ grpc_channel_pool: A gRPC channel pool (recommended).
47
+
48
+ Either `service_location` or `grpc_channel` must be provided. If both are provided,
49
+ `grpc_channel` takes precedence.
50
+ """
51
+ if service_location is None and grpc_channel is None:
52
+ raise ValueError("Either 'service_location' or 'grpc_channel' must be provided.")
53
+
54
+ self._initialization_lock = threading.Lock()
55
+ self._service_location = service_location
56
+ self._grpc_channel_pool = grpc_channel_pool
57
+ self._stub = (
58
+ data_moniker_pb2_grpc.MonikerServiceStub(grpc_channel)
59
+ if grpc_channel is not None
60
+ else None
61
+ )
62
+
63
+ def _get_stub(self) -> data_moniker_pb2_grpc.MonikerServiceStub:
64
+ if self._stub is None:
65
+ with self._initialization_lock:
66
+ if self._grpc_channel_pool is None:
67
+ _logger.debug("Creating unshared GrpcChannelPool.")
68
+ self._grpc_channel_pool = GrpcChannelPool()
69
+
70
+ if self._stub is None:
71
+ channel = self._grpc_channel_pool.get_channel(self._service_location) # type: ignore
72
+ self._stub = data_moniker_pb2_grpc.MonikerServiceStub(channel)
73
+
74
+ return self._stub
75
+
76
+ def begin_sideband_stream(
77
+ self, request: data_moniker_pb2.BeginMonikerSidebandStreamRequest
78
+ ) -> data_moniker_pb2.BeginMonikerSidebandStreamResponse:
79
+ """Begin a sideband stream."""
80
+ return self._get_stub().BeginSidebandStream(request)
81
+
82
+ def stream_read(
83
+ self, moniker_list: data_moniker_pb2.MonikerList
84
+ ) -> Iterator[data_moniker_pb2.MonikerReadResult]:
85
+ """Stream read data from monikers."""
86
+ return self._get_stub().StreamRead(moniker_list)
87
+
88
+ def stream_write(
89
+ self, requests: Iterator[data_moniker_pb2.MonikerWriteRequest]
90
+ ) -> Iterator[data_moniker_pb2.StreamWriteResponse]:
91
+ """Stream write data to monikers."""
92
+ return self._get_stub().StreamWrite(requests)
93
+
94
+ def stream_read_write(
95
+ self, requests: Iterator[data_moniker_pb2.MonikerWriteRequest]
96
+ ) -> Iterator[data_moniker_pb2.MonikerReadResult]:
97
+ """Stream read and write data with monikers."""
98
+ return self._get_stub().StreamReadWrite(requests)
99
+
100
+ def read_from_moniker(
101
+ self, moniker: data_moniker_pb2.Moniker
102
+ ) -> data_moniker_pb2.ReadFromMonikerResult:
103
+ """Read data from a moniker."""
104
+ return self._get_stub().ReadFromMoniker(moniker)
105
+
106
+ def write_to_moniker(
107
+ self, request: data_moniker_pb2.WriteToMonikerRequest
108
+ ) -> data_moniker_pb2.WriteToMonikerResponse:
109
+ """Write data to a moniker."""
110
+ return self._get_stub().WriteToMoniker(request)