From eb181c5df4d3ac1d9ca7b36de88052a6897e9797 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 13:59:46 -0500 Subject: [PATCH 01/15] First pass at minimal Python API for publish / read --- docs/conf.py | 10 +- poetry.lock | 239 +++++++++++++++++++++++++- pyproject.toml | 1 + src/ni/datastore/__init__.py | 4 + src/ni/datastore/client.py | 44 +++++ src/ni/datastore/placeholder_types.py | 8 + src/ni/datastore/types.py | 25 +++ tests/placeholder.py | 1 + 8 files changed, 330 insertions(+), 2 deletions(-) create mode 100644 src/ni/datastore/client.py create mode 100644 src/ni/datastore/placeholder_types.py create mode 100644 src/ni/datastore/types.py create mode 100644 tests/placeholder.py diff --git a/docs/conf.py b/docs/conf.py index 6ac0610..df1e0c6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -68,7 +68,15 @@ def setup(sphinx): # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "design/*"] +exclude_patterns = [ + "_build", + "Thumbs.db", + ".DS_Store", +] + +suppress_warnings = [ + "docutils", +] intersphinx_mapping = { "python": ("https://docs.python.org/3", None), diff --git a/poetry.lock b/poetry.lock index 571c77a..f67383e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -481,6 +481,17 @@ files = [ pycodestyle = "*" setuptools = "*" +[[package]] +name = "hightime" +version = "0.2.2" +description = "Hightime Python API" +optional = false +python-versions = "*" +groups = ["main"] +files = [ + {file = "hightime-0.2.2-py3-none-any.whl", hash = "sha256:5109a449bb3a75dbf305147777de71634c91b943d47cfbee18ed2f34a8307e0b"}, +] + [[package]] name = "idna" version = "3.10" @@ -861,6 +872,25 @@ pycodestyle = [ ] toml = ">=0.10.1" +[[package]] +name = "nitypes" +version = "0.1.0.dev10" +description = "Data types for NI Python APIs" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "nitypes-0.1.0.dev10-py3-none-any.whl", hash = "sha256:c4f097ffdeaf05697a7752a1e2b712760b28e84a4f6f446b4b7b76b349927490"}, + {file = "nitypes-0.1.0.dev10.tar.gz", hash = "sha256:e319ebbdefca63db8e879b9f119cc4f76a086c550931dea2be0e33e9c10e9d9f"}, +] + +[package.dependencies] +hightime = ">=0.2.2" +numpy = [ + {version = ">=1.22", markers = "python_version >= \"3.9\" and python_version < \"3.13\""}, + {version = ">=2.1", markers = "python_version >= \"3.13\" and python_version < \"4.0\""}, +] + [[package]] name = "nodeenv" version = "1.9.1" @@ -890,6 +920,213 @@ files = [ {file = "nodejs_wheel_binaries-22.18.0-py2.py3-none-win_amd64.whl", hash = "sha256:0f55e72733f1df2f542dce07f35145ac2e125408b5e2051cac08e5320e41b4d1"}, ] +[[package]] +name = "numpy" +version = "2.0.2" +description = "Fundamental package for array computing in Python" +optional = false +python-versions = ">=3.9" +groups = ["main"] +markers = "python_version == \"3.9\"" +files = [ + {file = "numpy-2.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:51129a29dbe56f9ca83438b706e2e69a39892b5eda6cedcb6b0c9fdc9b0d3ece"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f15975dfec0cf2239224d80e32c3170b1d168335eaedee69da84fbe9f1f9cd04"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:8c5713284ce4e282544c68d1c3b2c7161d38c256d2eefc93c1d683cf47683e66"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:becfae3ddd30736fe1889a37f1f580e245ba79a5855bff5f2a29cb3ccc22dd7b"}, + {file = "numpy-2.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2da5960c3cf0df7eafefd806d4e612c5e19358de82cb3c343631188991566ccd"}, + {file = "numpy-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:496f71341824ed9f3d2fd36cf3ac57ae2e0165c143b55c3a035ee219413f3318"}, + {file = "numpy-2.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a61ec659f68ae254e4d237816e33171497e978140353c0c2038d46e63282d0c8"}, + {file = "numpy-2.0.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:d731a1c6116ba289c1e9ee714b08a8ff882944d4ad631fd411106a30f083c326"}, + {file = "numpy-2.0.2-cp310-cp310-win32.whl", hash = "sha256:984d96121c9f9616cd33fbd0618b7f08e0cfc9600a7ee1d6fd9b239186d19d97"}, + {file = "numpy-2.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:c7b0be4ef08607dd04da4092faee0b86607f111d5ae68036f16cc787e250a131"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:49ca4decb342d66018b01932139c0961a8f9ddc7589611158cb3c27cbcf76448"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:11a76c372d1d37437857280aa142086476136a8c0f373b2e648ab2c8f18fb195"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:807ec44583fd708a21d4a11d94aedf2f4f3c3719035c76a2bbe1fe8e217bdc57"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:8cafab480740e22f8d833acefed5cc87ce276f4ece12fdaa2e8903db2f82897a"}, + {file = "numpy-2.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a15f476a45e6e5a3a79d8a14e62161d27ad897381fecfa4a09ed5322f2085669"}, + {file = "numpy-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13e689d772146140a252c3a28501da66dfecd77490b498b168b501835041f951"}, + {file = "numpy-2.0.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9ea91dfb7c3d1c56a0e55657c0afb38cf1eeae4544c208dc465c3c9f3a7c09f9"}, + {file = "numpy-2.0.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:c1c9307701fec8f3f7a1e6711f9089c06e6284b3afbbcd259f7791282d660a15"}, + {file = "numpy-2.0.2-cp311-cp311-win32.whl", hash = "sha256:a392a68bd329eafac5817e5aefeb39038c48b671afd242710b451e76090e81f4"}, + {file = "numpy-2.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:286cd40ce2b7d652a6f22efdfc6d1edf879440e53e76a75955bc0c826c7e64dc"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:df55d490dea7934f330006d0f81e8551ba6010a5bf035a249ef61a94f21c500b"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8df823f570d9adf0978347d1f926b2a867d5608f434a7cff7f7908c6570dcf5e"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:9a92ae5c14811e390f3767053ff54eaee3bf84576d99a2456391401323f4ec2c"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:a842d573724391493a97a62ebbb8e731f8a5dcc5d285dfc99141ca15a3302d0c"}, + {file = "numpy-2.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c05e238064fc0610c840d1cf6a13bf63d7e391717d247f1bf0318172e759e692"}, + {file = "numpy-2.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a"}, + {file = "numpy-2.0.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:96a55f64139912d61de9137f11bf39a55ec8faec288c75a54f93dfd39f7eb40c"}, + {file = "numpy-2.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:ec9852fb39354b5a45a80bdab5ac02dd02b15f44b3804e9f00c556bf24b4bded"}, + {file = "numpy-2.0.2-cp312-cp312-win32.whl", hash = "sha256:671bec6496f83202ed2d3c8fdc486a8fc86942f2e69ff0e986140339a63bcbe5"}, + {file = "numpy-2.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:cfd41e13fdc257aa5778496b8caa5e856dc4896d4ccf01841daee1d96465467a"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9059e10581ce4093f735ed23f3b9d283b9d517ff46009ddd485f1747eb22653c"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:423e89b23490805d2a5a96fe40ec507407b8ee786d66f7328be214f9679df6dd"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_14_0_arm64.whl", hash = "sha256:2b2955fa6f11907cf7a70dab0d0755159bca87755e831e47932367fc8f2f2d0b"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:97032a27bd9d8988b9a97a8c4d2c9f2c15a81f61e2f21404d7e8ef00cb5be729"}, + {file = "numpy-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1e795a8be3ddbac43274f18588329c72939870a16cae810c2b73461c40718ab1"}, + {file = "numpy-2.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f26b258c385842546006213344c50655ff1555a9338e2e5e02a0756dc3e803dd"}, + {file = "numpy-2.0.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fec9451a7789926bcf7c2b8d187292c9f93ea30284802a0ab3f5be8ab36865d"}, + {file = "numpy-2.0.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:9189427407d88ff25ecf8f12469d4d39d35bee1db5d39fc5c168c6f088a6956d"}, + {file = "numpy-2.0.2-cp39-cp39-win32.whl", hash = "sha256:905d16e0c60200656500c95b6b8dca5d109e23cb24abc701d41c02d74c6b3afa"}, + {file = "numpy-2.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:a3f4ab0caa7f053f6797fcd4e1e25caee367db3112ef2b6ef82d749530768c73"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:7f0a0c6f12e07fa94133c8a67404322845220c06a9e80e85999afe727f7438b8"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-macosx_14_0_x86_64.whl", hash = "sha256:312950fdd060354350ed123c0e25a71327d3711584beaef30cdaa93320c392d4"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26df23238872200f63518dd2aa984cfca675d82469535dc7162dc2ee52d9dd5c"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a46288ec55ebbd58947d31d72be2c63cbf839f0a63b49cb755022310792a3385"}, + {file = "numpy-2.0.2.tar.gz", hash = "sha256:883c987dee1880e2a864ab0dc9892292582510604156762362d9326444636e78"}, +] + +[[package]] +name = "numpy" +version = "2.2.6" +description = "Fundamental package for array computing in Python" +optional = false +python-versions = ">=3.10" +groups = ["main"] +markers = "python_version == \"3.10\"" +files = [ + {file = "numpy-2.2.6-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b412caa66f72040e6d268491a59f2c43bf03eb6c96dd8f0307829feb7fa2b6fb"}, + {file = "numpy-2.2.6-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8e41fd67c52b86603a91c1a505ebaef50b3314de0213461c7a6e99c9a3beff90"}, + {file = "numpy-2.2.6-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:37e990a01ae6ec7fe7fa1c26c55ecb672dd98b19c3d0e1d1f326fa13cb38d163"}, + {file = "numpy-2.2.6-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:5a6429d4be8ca66d889b7cf70f536a397dc45ba6faeb5f8c5427935d9592e9cf"}, + {file = "numpy-2.2.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:efd28d4e9cd7d7a8d39074a4d44c63eda73401580c5c76acda2ce969e0a38e83"}, + {file = "numpy-2.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fc7b73d02efb0e18c000e9ad8b83480dfcd5dfd11065997ed4c6747470ae8915"}, + {file = "numpy-2.2.6-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:74d4531beb257d2c3f4b261bfb0fc09e0f9ebb8842d82a7b4209415896adc680"}, + {file = "numpy-2.2.6-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:8fc377d995680230e83241d8a96def29f204b5782f371c532579b4f20607a289"}, + {file = "numpy-2.2.6-cp310-cp310-win32.whl", hash = "sha256:b093dd74e50a8cba3e873868d9e93a85b78e0daf2e98c6797566ad8044e8363d"}, + {file = "numpy-2.2.6-cp310-cp310-win_amd64.whl", hash = "sha256:f0fd6321b839904e15c46e0d257fdd101dd7f530fe03fd6359c1ea63738703f3"}, + {file = "numpy-2.2.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f9f1adb22318e121c5c69a09142811a201ef17ab257a1e66ca3025065b7f53ae"}, + {file = "numpy-2.2.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c820a93b0255bc360f53eca31a0e676fd1101f673dda8da93454a12e23fc5f7a"}, + {file = "numpy-2.2.6-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:3d70692235e759f260c3d837193090014aebdf026dfd167834bcba43e30c2a42"}, + {file = "numpy-2.2.6-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:481b49095335f8eed42e39e8041327c05b0f6f4780488f61286ed3c01368d491"}, + {file = "numpy-2.2.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b64d8d4d17135e00c8e346e0a738deb17e754230d7e0810ac5012750bbd85a5a"}, + {file = "numpy-2.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba10f8411898fc418a521833e014a77d3ca01c15b0c6cdcce6a0d2897e6dbbdf"}, + {file = "numpy-2.2.6-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:bd48227a919f1bafbdda0583705e547892342c26fb127219d60a5c36882609d1"}, + {file = "numpy-2.2.6-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9551a499bf125c1d4f9e250377c1ee2eddd02e01eac6644c080162c0c51778ab"}, + {file = "numpy-2.2.6-cp311-cp311-win32.whl", hash = "sha256:0678000bb9ac1475cd454c6b8c799206af8107e310843532b04d49649c717a47"}, + {file = "numpy-2.2.6-cp311-cp311-win_amd64.whl", hash = "sha256:e8213002e427c69c45a52bbd94163084025f533a55a59d6f9c5b820774ef3303"}, + {file = "numpy-2.2.6-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:41c5a21f4a04fa86436124d388f6ed60a9343a6f767fced1a8a71c3fbca038ff"}, + {file = "numpy-2.2.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:de749064336d37e340f640b05f24e9e3dd678c57318c7289d222a8a2f543e90c"}, + {file = "numpy-2.2.6-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:894b3a42502226a1cac872f840030665f33326fc3dac8e57c607905773cdcde3"}, + {file = "numpy-2.2.6-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:71594f7c51a18e728451bb50cc60a3ce4e6538822731b2933209a1f3614e9282"}, + {file = "numpy-2.2.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f2618db89be1b4e05f7a1a847a9c1c0abd63e63a1607d892dd54668dd92faf87"}, + {file = "numpy-2.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fd83c01228a688733f1ded5201c678f0c53ecc1006ffbc404db9f7a899ac6249"}, + {file = "numpy-2.2.6-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:37c0ca431f82cd5fa716eca9506aefcabc247fb27ba69c5062a6d3ade8cf8f49"}, + {file = "numpy-2.2.6-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fe27749d33bb772c80dcd84ae7e8df2adc920ae8297400dabec45f0dedb3f6de"}, + {file = "numpy-2.2.6-cp312-cp312-win32.whl", hash = "sha256:4eeaae00d789f66c7a25ac5f34b71a7035bb474e679f410e5e1a94deb24cf2d4"}, + {file = "numpy-2.2.6-cp312-cp312-win_amd64.whl", hash = "sha256:c1f9540be57940698ed329904db803cf7a402f3fc200bfe599334c9bd84a40b2"}, + {file = "numpy-2.2.6-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:0811bb762109d9708cca4d0b13c4f67146e3c3b7cf8d34018c722adb2d957c84"}, + {file = "numpy-2.2.6-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:287cc3162b6f01463ccd86be154f284d0893d2b3ed7292439ea97eafa8170e0b"}, + {file = "numpy-2.2.6-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:f1372f041402e37e5e633e586f62aa53de2eac8d98cbfb822806ce4bbefcb74d"}, + {file = "numpy-2.2.6-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:55a4d33fa519660d69614a9fad433be87e5252f4b03850642f88993f7b2ca566"}, + {file = "numpy-2.2.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f92729c95468a2f4f15e9bb94c432a9229d0d50de67304399627a943201baa2f"}, + {file = "numpy-2.2.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1bc23a79bfabc5d056d106f9befb8d50c31ced2fbc70eedb8155aec74a45798f"}, + {file = "numpy-2.2.6-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:e3143e4451880bed956e706a3220b4e5cf6172ef05fcc397f6f36a550b1dd868"}, + {file = "numpy-2.2.6-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:b4f13750ce79751586ae2eb824ba7e1e8dba64784086c98cdbbcc6a42112ce0d"}, + {file = "numpy-2.2.6-cp313-cp313-win32.whl", hash = "sha256:5beb72339d9d4fa36522fc63802f469b13cdbe4fdab4a288f0c441b74272ebfd"}, + {file = "numpy-2.2.6-cp313-cp313-win_amd64.whl", hash = "sha256:b0544343a702fa80c95ad5d3d608ea3599dd54d4632df855e4c8d24eb6ecfa1c"}, + {file = "numpy-2.2.6-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:0bca768cd85ae743b2affdc762d617eddf3bcf8724435498a1e80132d04879e6"}, + {file = "numpy-2.2.6-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:fc0c5673685c508a142ca65209b4e79ed6740a4ed6b2267dbba90f34b0b3cfda"}, + {file = "numpy-2.2.6-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:5bd4fc3ac8926b3819797a7c0e2631eb889b4118a9898c84f585a54d475b7e40"}, + {file = "numpy-2.2.6-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:fee4236c876c4e8369388054d02d0e9bb84821feb1a64dd59e137e6511a551f8"}, + {file = "numpy-2.2.6-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e1dda9c7e08dc141e0247a5b8f49cf05984955246a327d4c48bda16821947b2f"}, + {file = "numpy-2.2.6-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f447e6acb680fd307f40d3da4852208af94afdfab89cf850986c3ca00562f4fa"}, + {file = "numpy-2.2.6-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:389d771b1623ec92636b0786bc4ae56abafad4a4c513d36a55dce14bd9ce8571"}, + {file = "numpy-2.2.6-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:8e9ace4a37db23421249ed236fdcdd457d671e25146786dfc96835cd951aa7c1"}, + {file = "numpy-2.2.6-cp313-cp313t-win32.whl", hash = "sha256:038613e9fb8c72b0a41f025a7e4c3f0b7a1b5d768ece4796b674c8f3fe13efff"}, + {file = "numpy-2.2.6-cp313-cp313t-win_amd64.whl", hash = "sha256:6031dd6dfecc0cf9f668681a37648373bddd6421fff6c66ec1624eed0180ee06"}, + {file = "numpy-2.2.6-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:0b605b275d7bd0c640cad4e5d30fa701a8d59302e127e5f79138ad62762c3e3d"}, + {file = "numpy-2.2.6-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:7befc596a7dc9da8a337f79802ee8adb30a552a94f792b9c9d18c840055907db"}, + {file = "numpy-2.2.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ce47521a4754c8f4593837384bd3424880629f718d87c5d44f8ed763edd63543"}, + {file = "numpy-2.2.6-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:d042d24c90c41b54fd506da306759e06e568864df8ec17ccc17e9e884634fd00"}, + {file = "numpy-2.2.6.tar.gz", hash = "sha256:e29554e2bef54a90aa5cc07da6ce955accb83f21ab5de01a62c8478897b264fd"}, +] + +[[package]] +name = "numpy" +version = "2.3.3" +description = "Fundamental package for array computing in Python" +optional = false +python-versions = ">=3.11" +groups = ["main"] +markers = "python_version >= \"3.11\"" +files = [ + {file = "numpy-2.3.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0ffc4f5caba7dfcbe944ed674b7eef683c7e94874046454bb79ed7ee0236f59d"}, + {file = "numpy-2.3.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e7e946c7170858a0295f79a60214424caac2ffdb0063d4d79cb681f9aa0aa569"}, + {file = "numpy-2.3.3-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:cd4260f64bc794c3390a63bf0728220dd1a68170c169088a1e0dfa2fde1be12f"}, + {file = "numpy-2.3.3-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:f0ddb4b96a87b6728df9362135e764eac3cfa674499943ebc44ce96c478ab125"}, + {file = "numpy-2.3.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:afd07d377f478344ec6ca2b8d4ca08ae8bd44706763d1efb56397de606393f48"}, + {file = "numpy-2.3.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bc92a5dedcc53857249ca51ef29f5e5f2f8c513e22cfb90faeb20343b8c6f7a6"}, + {file = "numpy-2.3.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7af05ed4dc19f308e1d9fc759f36f21921eb7bbfc82843eeec6b2a2863a0aefa"}, + {file = "numpy-2.3.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:433bf137e338677cebdd5beac0199ac84712ad9d630b74eceeb759eaa45ddf30"}, + {file = "numpy-2.3.3-cp311-cp311-win32.whl", hash = "sha256:eb63d443d7b4ffd1e873f8155260d7f58e7e4b095961b01c91062935c2491e57"}, + {file = "numpy-2.3.3-cp311-cp311-win_amd64.whl", hash = "sha256:ec9d249840f6a565f58d8f913bccac2444235025bbb13e9a4681783572ee3caa"}, + {file = "numpy-2.3.3-cp311-cp311-win_arm64.whl", hash = "sha256:74c2a948d02f88c11a3c075d9733f1ae67d97c6bdb97f2bb542f980458b257e7"}, + {file = "numpy-2.3.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:cfdd09f9c84a1a934cde1eec2267f0a43a7cd44b2cca4ff95b7c0d14d144b0bf"}, + {file = "numpy-2.3.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cb32e3cf0f762aee47ad1ddc6672988f7f27045b0783c887190545baba73aa25"}, + {file = "numpy-2.3.3-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:396b254daeb0a57b1fe0ecb5e3cff6fa79a380fa97c8f7781a6d08cd429418fe"}, + {file = "numpy-2.3.3-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:067e3d7159a5d8f8a0b46ee11148fc35ca9b21f61e3c49fbd0a027450e65a33b"}, + {file = "numpy-2.3.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1c02d0629d25d426585fb2e45a66154081b9fa677bc92a881ff1d216bc9919a8"}, + {file = "numpy-2.3.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d9192da52b9745f7f0766531dcfa978b7763916f158bb63bdb8a1eca0068ab20"}, + {file = "numpy-2.3.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:cd7de500a5b66319db419dc3c345244404a164beae0d0937283b907d8152e6ea"}, + {file = "numpy-2.3.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:93d4962d8f82af58f0b2eb85daaf1b3ca23fe0a85d0be8f1f2b7bb46034e56d7"}, + {file = "numpy-2.3.3-cp312-cp312-win32.whl", hash = "sha256:5534ed6b92f9b7dca6c0a19d6df12d41c68b991cef051d108f6dbff3babc4ebf"}, + {file = "numpy-2.3.3-cp312-cp312-win_amd64.whl", hash = "sha256:497d7cad08e7092dba36e3d296fe4c97708c93daf26643a1ae4b03f6294d30eb"}, + {file = "numpy-2.3.3-cp312-cp312-win_arm64.whl", hash = "sha256:ca0309a18d4dfea6fc6262a66d06c26cfe4640c3926ceec90e57791a82b6eee5"}, + {file = "numpy-2.3.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f5415fb78995644253370985342cd03572ef8620b934da27d77377a2285955bf"}, + {file = "numpy-2.3.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:d00de139a3324e26ed5b95870ce63be7ec7352171bc69a4cf1f157a48e3eb6b7"}, + {file = "numpy-2.3.3-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:9dc13c6a5829610cc07422bc74d3ac083bd8323f14e2827d992f9e52e22cd6a6"}, + {file = "numpy-2.3.3-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:d79715d95f1894771eb4e60fb23f065663b2298f7d22945d66877aadf33d00c7"}, + {file = "numpy-2.3.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:952cfd0748514ea7c3afc729a0fc639e61655ce4c55ab9acfab14bda4f402b4c"}, + {file = "numpy-2.3.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5b83648633d46f77039c29078751f80da65aa64d5622a3cd62aaef9d835b6c93"}, + {file = "numpy-2.3.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b001bae8cea1c7dfdb2ae2b017ed0a6f2102d7a70059df1e338e307a4c78a8ae"}, + {file = "numpy-2.3.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8e9aced64054739037d42fb84c54dd38b81ee238816c948c8f3ed134665dcd86"}, + {file = "numpy-2.3.3-cp313-cp313-win32.whl", hash = "sha256:9591e1221db3f37751e6442850429b3aabf7026d3b05542d102944ca7f00c8a8"}, + {file = "numpy-2.3.3-cp313-cp313-win_amd64.whl", hash = "sha256:f0dadeb302887f07431910f67a14d57209ed91130be0adea2f9793f1a4f817cf"}, + {file = "numpy-2.3.3-cp313-cp313-win_arm64.whl", hash = "sha256:3c7cf302ac6e0b76a64c4aecf1a09e51abd9b01fc7feee80f6c43e3ab1b1dbc5"}, + {file = "numpy-2.3.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:eda59e44957d272846bb407aad19f89dc6f58fecf3504bd144f4c5cf81a7eacc"}, + {file = "numpy-2.3.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:823d04112bc85ef5c4fda73ba24e6096c8f869931405a80aa8b0e604510a26bc"}, + {file = "numpy-2.3.3-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:40051003e03db4041aa325da2a0971ba41cf65714e65d296397cc0e32de6018b"}, + {file = "numpy-2.3.3-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:6ee9086235dd6ab7ae75aba5662f582a81ced49f0f1c6de4260a78d8f2d91a19"}, + {file = "numpy-2.3.3-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:94fcaa68757c3e2e668ddadeaa86ab05499a70725811e582b6a9858dd472fb30"}, + {file = "numpy-2.3.3-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:da1a74b90e7483d6ce5244053399a614b1d6b7bc30a60d2f570e5071f8959d3e"}, + {file = "numpy-2.3.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:2990adf06d1ecee3b3dcbb4977dfab6e9f09807598d647f04d385d29e7a3c3d3"}, + {file = "numpy-2.3.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:ed635ff692483b8e3f0fcaa8e7eb8a75ee71aa6d975388224f70821421800cea"}, + {file = "numpy-2.3.3-cp313-cp313t-win32.whl", hash = "sha256:a333b4ed33d8dc2b373cc955ca57babc00cd6f9009991d9edc5ddbc1bac36bcd"}, + {file = "numpy-2.3.3-cp313-cp313t-win_amd64.whl", hash = "sha256:4384a169c4d8f97195980815d6fcad04933a7e1ab3b530921c3fef7a1c63426d"}, + {file = "numpy-2.3.3-cp313-cp313t-win_arm64.whl", hash = "sha256:75370986cc0bc66f4ce5110ad35aae6d182cc4ce6433c40ad151f53690130bf1"}, + {file = "numpy-2.3.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:cd052f1fa6a78dee696b58a914b7229ecfa41f0a6d96dc663c1220a55e137593"}, + {file = "numpy-2.3.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:414a97499480067d305fcac9716c29cf4d0d76db6ebf0bf3cbce666677f12652"}, + {file = "numpy-2.3.3-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:50a5fe69f135f88a2be9b6ca0481a68a136f6febe1916e4920e12f1a34e708a7"}, + {file = "numpy-2.3.3-cp314-cp314-macosx_14_0_x86_64.whl", hash = "sha256:b912f2ed2b67a129e6a601e9d93d4fa37bef67e54cac442a2f588a54afe5c67a"}, + {file = "numpy-2.3.3-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9e318ee0596d76d4cb3d78535dc005fa60e5ea348cd131a51e99d0bdbe0b54fe"}, + {file = "numpy-2.3.3-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ce020080e4a52426202bdb6f7691c65bb55e49f261f31a8f506c9f6bc7450421"}, + {file = "numpy-2.3.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e6687dc183aa55dae4a705b35f9c0f8cb178bcaa2f029b241ac5356221d5c021"}, + {file = "numpy-2.3.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:d8f3b1080782469fdc1718c4ed1d22549b5fb12af0d57d35e992158a772a37cf"}, + {file = "numpy-2.3.3-cp314-cp314-win32.whl", hash = "sha256:cb248499b0bc3be66ebd6578b83e5acacf1d6cb2a77f2248ce0e40fbec5a76d0"}, + {file = "numpy-2.3.3-cp314-cp314-win_amd64.whl", hash = "sha256:691808c2b26b0f002a032c73255d0bd89751425f379f7bcd22d140db593a96e8"}, + {file = "numpy-2.3.3-cp314-cp314-win_arm64.whl", hash = "sha256:9ad12e976ca7b10f1774b03615a2a4bab8addce37ecc77394d8e986927dc0dfe"}, + {file = "numpy-2.3.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:9cc48e09feb11e1db00b320e9d30a4151f7369afb96bd0e48d942d09da3a0d00"}, + {file = "numpy-2.3.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:901bf6123879b7f251d3631967fd574690734236075082078e0571977c6a8e6a"}, + {file = "numpy-2.3.3-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:7f025652034199c301049296b59fa7d52c7e625017cae4c75d8662e377bf487d"}, + {file = "numpy-2.3.3-cp314-cp314t-macosx_14_0_x86_64.whl", hash = "sha256:533ca5f6d325c80b6007d4d7fb1984c303553534191024ec6a524a4c92a5935a"}, + {file = "numpy-2.3.3-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0edd58682a399824633b66885d699d7de982800053acf20be1eaa46d92009c54"}, + {file = "numpy-2.3.3-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:367ad5d8fbec5d9296d18478804a530f1191e24ab4d75ab408346ae88045d25e"}, + {file = "numpy-2.3.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8f6ac61a217437946a1fa48d24c47c91a0c4f725237871117dea264982128097"}, + {file = "numpy-2.3.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:179a42101b845a816d464b6fe9a845dfaf308fdfc7925387195570789bb2c970"}, + {file = "numpy-2.3.3-cp314-cp314t-win32.whl", hash = "sha256:1250c5d3d2562ec4174bce2e3a1523041595f9b651065e4a4473f5f48a6bc8a5"}, + {file = "numpy-2.3.3-cp314-cp314t-win_amd64.whl", hash = "sha256:b37a0b2e5935409daebe82c1e42274d30d9dd355852529eab91dab8dcca7419f"}, + {file = "numpy-2.3.3-cp314-cp314t-win_arm64.whl", hash = "sha256:78c9f6560dc7e6b3990e32df7ea1a50bbd0e2a111e05209963f5ddcab7073b0b"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:1e02c7159791cd481e1e6d5ddd766b62a4d5acf8df4d4d1afe35ee9c5c33a41e"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:dca2d0fc80b3893ae72197b39f69d55a3cd8b17ea1b50aa4c62de82419936150"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_14_0_arm64.whl", hash = "sha256:99683cbe0658f8271b333a1b1b4bb3173750ad59c0c61f5bbdc5b318918fffe3"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_14_0_x86_64.whl", hash = "sha256:d9d537a39cc9de668e5cd0e25affb17aec17b577c6b3ae8a3d866b479fbe88d0"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8596ba2f8af5f93b01d97563832686d20206d303024777f6dfc2e7c7c3f1850e"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e1ec5615b05369925bd1125f27df33f3b6c8bc10d788d5999ecd8769a1fa04db"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:2e267c7da5bf7309670523896df97f93f6e469fb931161f483cd6882b3b1a5dc"}, + {file = "numpy-2.3.3.tar.gz", hash = "sha256:ddc7c39727ba62b80dfdbedf400d1c10ddfa8eefbd7ec8dcb118be8b56d31029"}, +] + [[package]] name = "packaging" version = "25.0" @@ -1758,4 +1995,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "68b5146bae689d5d4e143b2c04347fcbcde3525de68ea971ceea91d2168ca393" +content-hash = "ed170f929f693faf373205b1fc8441ffc2f434413b44610188dedbd03e19ed70" diff --git a/pyproject.toml b/pyproject.toml index da446bc..aaab548 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ python = "^3.9" protobuf = {version=">=4.21"} ni-datamonikers-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-metadata-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } +nitypes = {version=">=0.1.0dev3", allow-prereleases=true} [tool.poetry.group.dev.dependencies] types-grpcio = ">=1.0" diff --git a/src/ni/datastore/__init__.py b/src/ni/datastore/__init__.py index e26528b..ee3ff99 100644 --- a/src/ni/datastore/__init__.py +++ b/src/ni/datastore/__init__.py @@ -1 +1,5 @@ """Public API for accessing the NI Data Store Service.""" + +from ni.datastore.client import Client + +__all__ = ["Client"] \ No newline at end of file diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py new file mode 100644 index 0000000..1a74695 --- /dev/null +++ b/src/ni/datastore/client.py @@ -0,0 +1,44 @@ +from typing import Union + +from nitypes.waveform import AnalogWaveform, DigitalWaveform +from ni.datastore.placeholder_types import MetadataStoreClient, DataStoreClient, MonikerClient +from ni.datastore.types import ( + StoredDataValue, Measurement, PassFailStatus, Moniker +) + + +class Client: + """Datastore client for publishing and reading data.""" + + __slots__ = ("_data_store_client", "_metadata_store_client", "_moniker_client") + + _data_store_client: DataStoreClient + _metadata_store_client: MetadataStoreClient + _moniker_client: MonikerClient + + def __init__(self): + pass + + def publish_data( + self, + name: str, + value: Union[str, bool, int, float, AnalogWaveform, DigitalWaveform], + description: str, + passFailStatus: PassFailStatus, + measurement: Measurement, + ) -> StoredDataValue: + """Publish a polymorphic data value to the datastore. + + * Open Question: Should this be a general 'publish_data'? + * Where do we put the data, metadata, etc client stubs? + """ + if isinstance(value, (AnalogWaveform)): + pass + return StoredDataValue() + + def read_data( + self, + moniker: Moniker, + ) -> Union[str, bool, int, float]: + """Read a scalar value from the datastore.""" + return True \ No newline at end of file diff --git a/src/ni/datastore/placeholder_types.py b/src/ni/datastore/placeholder_types.py new file mode 100644 index 0000000..e5799c0 --- /dev/null +++ b/src/ni/datastore/placeholder_types.py @@ -0,0 +1,8 @@ +class DataStoreClient: + pass + +class MetadataStoreClient: + pass + +class MonikerClient: + pass \ No newline at end of file diff --git a/src/ni/datastore/types.py b/src/ni/datastore/types.py new file mode 100644 index 0000000..879bbaa --- /dev/null +++ b/src/ni/datastore/types.py @@ -0,0 +1,25 @@ +from enum import Enum + +class Measurement: + """Minimal Measurement class.""" + + def __init__(self): + pass + +class StoredDataValue: + """Minimal StoredDataValue class.""" + + def __init__(self): + pass + +class PassFailStatus(Enum): + PASS_FAIL_STATUS_UNSPECIFIED = 0 + PASS_FAIL_STATUS_PASSED = 1 + PASS_FAIL_STATUS_FAILED = 2 + PASS_FAIL_STATUS_INDETERMINATE = 3 + +class Moniker: + """Minimal Moniker class.""" + + def __init__(self): + pass \ No newline at end of file diff --git a/tests/placeholder.py b/tests/placeholder.py new file mode 100644 index 0000000..ffa8b69 --- /dev/null +++ b/tests/placeholder.py @@ -0,0 +1 @@ +"""Temporary placeholder test.""" \ No newline at end of file From f17963d071fe55f56275c38edde8b6a48ddf4be8 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Fri, 12 Sep 2025 13:59:48 -0500 Subject: [PATCH 02/15] Add publish_and_read example as a first pass at using the data store --- examples/placeholder.py | 1 - examples/publish_and_read/poetry.lock | 7 ++++ examples/publish_and_read/poetry.toml | 2 ++ examples/publish_and_read/pyproject.toml | 14 ++++++++ examples/publish_and_read/scalar.py | 6 ++++ poetry.lock | 36 ++++++++++++++++++++- pyproject.toml | 1 + src/ni/datastore/client.py | 41 ++++++++++++++++++++++-- src/ni/datastore/placeholder_types.py | 3 -- 9 files changed, 104 insertions(+), 7 deletions(-) delete mode 100644 examples/placeholder.py create mode 100644 examples/publish_and_read/poetry.lock create mode 100644 examples/publish_and_read/poetry.toml create mode 100644 examples/publish_and_read/pyproject.toml create mode 100644 examples/publish_and_read/scalar.py diff --git a/examples/placeholder.py b/examples/placeholder.py deleted file mode 100644 index 31f1667..0000000 --- a/examples/placeholder.py +++ /dev/null @@ -1 +0,0 @@ -"""Temporary placeholder example.""" diff --git a/examples/publish_and_read/poetry.lock b/examples/publish_and_read/poetry.lock new file mode 100644 index 0000000..bc5b625 --- /dev/null +++ b/examples/publish_and_read/poetry.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. +package = [] + +[metadata] +lock-version = "2.1" +python-versions = ">=3.9" +content-hash = "ff9c4d90a413e5b513f92a443c2607225973bebea8f831996abbafecd3ad8446" diff --git a/examples/publish_and_read/poetry.toml b/examples/publish_and_read/poetry.toml new file mode 100644 index 0000000..ab1033b --- /dev/null +++ b/examples/publish_and_read/poetry.toml @@ -0,0 +1,2 @@ +[virtualenvs] +in-project = true diff --git a/examples/publish_and_read/pyproject.toml b/examples/publish_and_read/pyproject.toml new file mode 100644 index 0000000..eb6f235 --- /dev/null +++ b/examples/publish_and_read/pyproject.toml @@ -0,0 +1,14 @@ +[project] +name = "publish_and_read" +version = "0.1.0" +description = "Showcases publishing various kinds of data and reading it back" +authors = [ + {name = "Johann Scholtz", email = "johann.scholtz@emerson.com"}, + {name = "Joel Dixon", email = "joel.dixon@emerson.com"} +] +requires-python = ">=3.9" +dependencies = [] + +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/examples/publish_and_read/scalar.py b/examples/publish_and_read/scalar.py new file mode 100644 index 0000000..576e907 --- /dev/null +++ b/examples/publish_and_read/scalar.py @@ -0,0 +1,6 @@ +from ni.datastore.client import Client +from ni.datastore.types import Measurement, PassFailStatus, Moniker + +if __name__ == "__main__": + client = Client() + client.publish_bool() diff --git a/poetry.lock b/poetry.lock index f67383e..a6907bc 100644 --- a/poetry.lock +++ b/poetry.lock @@ -826,6 +826,24 @@ files = [ [package.dependencies] protobuf = ">=4.21" +[[package]] +name = "ni-measurements-data-v1-proto" +version = "0.1.0.dev0" +description = "Protobuf data types and service stubs for NI data store gRPC APIs" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "ni_measurements_data_v1_proto-0.1.0.dev0-py3-none-any.whl", hash = "sha256:7f650bde80e276195ec155d1925f06a12e60a96828c9ed8712ab85e999b6109e"}, + {file = "ni_measurements_data_v1_proto-0.1.0.dev0.tar.gz", hash = "sha256:206430bd5f2cafd21e69296027159dd03c11e6f9750ced2ee7ee3e71ea10f2b3"}, +] + +[package.dependencies] +ni-datamonikers-v1-proto = ">=0.1.0.dev0" +ni-measurements-metadata-v1-proto = ">=0.1.0.dev0" +ni-protobuf-types = ">=0.1.0.dev3" +protobuf = ">=4.21" + [[package]] name = "ni-measurements-metadata-v1-proto" version = "0.1.0.dev0" @@ -841,6 +859,22 @@ files = [ [package.dependencies] protobuf = ">=4.21" +[[package]] +name = "ni-protobuf-types" +version = "0.1.0.dev4" +description = "Protobuf data types for NI gRPC APIs" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "ni_protobuf_types-0.1.0.dev4-py3-none-any.whl", hash = "sha256:dceac83ca05c286e99b44898340f58b45eac91e9609444e252d89c17a7d7c1ff"}, + {file = "ni_protobuf_types-0.1.0.dev4.tar.gz", hash = "sha256:11c6a486bcb3984078e100efac93b96d5a84d70f0d8035a2303eb5cf9c0b1532"}, +] + +[package.dependencies] +nitypes = ">=0.1.0dev8" +protobuf = ">=4.21" + [[package]] name = "ni-python-styleguide" version = "0.4.7" @@ -1995,4 +2029,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "ed170f929f693faf373205b1fc8441ffc2f434413b44610188dedbd03e19ed70" +content-hash = "dfdc7ff5ae86a7835b392c11bd7377be58719b4b074ebf18bcad07340bc5051e" diff --git a/pyproject.toml b/pyproject.toml index aaab548..9b1d072 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ requires-poetry = '>=2.1,<3.0' python = "^3.9" protobuf = {version=">=4.21"} ni-datamonikers-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } +ni-measurements-data-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-metadata-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } nitypes = {version=">=0.1.0dev3", allow-prereleases=true} diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 1a74695..ea2a396 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -1,10 +1,15 @@ +from datetime import datetime, timezone from typing import Union +from google.protobuf.timestamp_pb2 import Timestamp from nitypes.waveform import AnalogWaveform, DigitalWaveform -from ni.datastore.placeholder_types import MetadataStoreClient, DataStoreClient, MonikerClient +from ni.datastore.placeholder_types import MetadataStoreClient, MonikerClient from ni.datastore.types import ( StoredDataValue, Measurement, PassFailStatus, Moniker ) +from ni.measurements.data.v1.data_store_pb2 import PublishableData, PassFailStatus, ErrorState +from ni.measurements.data.v1.data_store_service_pb2 import PublishDataRequest, PublishDataResponse +from ni.measurements.data.v1.client import DataStoreClient class Client: @@ -17,6 +22,16 @@ class Client: _moniker_client: MonikerClient def __init__(self): + self._data_store_client = DataStoreClient() + + def publish_bool(self): + publishable_data = PublishableData() + publishable_data.scalar.bool_value = True + self._publish_data( + publishable_data, + "Simple Boolean", + measurement_id="" + ) pass def publish_data( @@ -41,4 +56,26 @@ def read_data( moniker: Moniker, ) -> Union[str, bool, int, float]: """Read a scalar value from the datastore.""" - return True \ No newline at end of file + return True + + + def _publish_data( + self, + data: PublishableData, + description: str, + measurement_id: str + ) -> PublishDataResponse: + timestamp = datetime.now(timezone.utc) + request_timestamp = Timestamp() + request_timestamp.FromDatetime(timestamp) + publish_request = PublishDataRequest( + notes=description, + data=data, + timestamp=request_timestamp, + pass_fail_status=PassFailStatus.PASS_FAIL_STATUS_FAILED, + error_state=ErrorState.ERROR_STATE_NO_ERROR, + measurement_id=measurement_id + ) + + publish_response = self._data_store_client.publish_data(publish_request) + return publish_response diff --git a/src/ni/datastore/placeholder_types.py b/src/ni/datastore/placeholder_types.py index e5799c0..1281e2d 100644 --- a/src/ni/datastore/placeholder_types.py +++ b/src/ni/datastore/placeholder_types.py @@ -1,6 +1,3 @@ -class DataStoreClient: - pass - class MetadataStoreClient: pass From 952b11c8786eb41e7f23a9c8571dd1e341f4de06 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Fri, 12 Sep 2025 15:43:42 -0500 Subject: [PATCH 03/15] Make publish_and_read of a boolean scalar work --- .gitignore | 3 + examples/publish_and_read/poetry.lock | 292 ++++++++++++++++++++++- examples/publish_and_read/pyproject.toml | 10 +- examples/publish_and_read/scalar.py | 14 +- poetry.lock | 2 +- pyproject.toml | 1 + src/ni/datastore/client.py | 68 +++--- src/ni/datastore/placeholder_types.py | 5 - 8 files changed, 344 insertions(+), 51 deletions(-) delete mode 100644 src/ni/datastore/placeholder_types.py diff --git a/.gitignore b/.gitignore index 49c675d..21e70a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +#VS Code +.vscode/ + # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/examples/publish_and_read/poetry.lock b/examples/publish_and_read/poetry.lock index bc5b625..290cf55 100644 --- a/examples/publish_and_read/poetry.lock +++ b/examples/publish_and_read/poetry.lock @@ -1,7 +1,293 @@ # This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. -package = [] + +[[package]] +name = "hightime" +version = "0.2.2" +description = "Hightime Python API" +optional = false +python-versions = "*" +groups = ["dev"] +files = [ + {file = "hightime-0.2.2-py3-none-any.whl", hash = "sha256:5109a449bb3a75dbf305147777de71634c91b943d47cfbee18ed2f34a8307e0b"}, +] + +[[package]] +name = "ni-datamonikers-v1-proto" +version = "0.1.0.dev0" +description = "Protobuf data types and service stub for NI data moniker gRPC APIs" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["dev"] +files = [ + {file = "ni_datamonikers_v1_proto-0.1.0.dev0-py3-none-any.whl", hash = "sha256:5ae96df50a010de68b40527e75696eeca2fc1522ab9d8a169a5993f031eb2185"}, + {file = "ni_datamonikers_v1_proto-0.1.0.dev0.tar.gz", hash = "sha256:cdcf9b4d1fc463f4b2664949f6037bdcc0a6556679eddb3350b5630873da4147"}, +] + +[package.dependencies] +protobuf = ">=4.21" + +[[package]] +name = "ni-datastore" +version = "0.1.0-dev0" +description = "APIs for publishing and retrieving data from the NI Measurement Data Store" +optional = false +python-versions = "^3.9" +groups = ["dev"] +files = [] +develop = true + +[package.dependencies] +ni-datamonikers-v1-proto = ">=0.1.0.dev0" +ni-measurements-data-v1-proto = ">=0.1.0.dev0" +ni-measurements-metadata-v1-proto = ">=0.1.0.dev0" +nitypes = ">=0.1.0dev3" +protobuf = ">=4.21" + +[package.source] +type = "directory" +url = "../.." + +[[package]] +name = "ni-measurements-data-v1-proto" +version = "0.1.0.dev0" +description = "Protobuf data types and service stubs for NI data store gRPC APIs" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["dev"] +files = [ + {file = "ni_measurements_data_v1_proto-0.1.0.dev0-py3-none-any.whl", hash = "sha256:7f650bde80e276195ec155d1925f06a12e60a96828c9ed8712ab85e999b6109e"}, + {file = "ni_measurements_data_v1_proto-0.1.0.dev0.tar.gz", hash = "sha256:206430bd5f2cafd21e69296027159dd03c11e6f9750ced2ee7ee3e71ea10f2b3"}, +] + +[package.dependencies] +ni-datamonikers-v1-proto = ">=0.1.0.dev0" +ni-measurements-metadata-v1-proto = ">=0.1.0.dev0" +ni-protobuf-types = ">=0.1.0.dev3" +protobuf = ">=4.21" + +[[package]] +name = "ni-measurements-metadata-v1-proto" +version = "0.1.0.dev0" +description = "Protobuf data types and service stub for NI metadata store gRPC APIs" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["dev"] +files = [ + {file = "ni_measurements_metadata_v1_proto-0.1.0.dev0-py3-none-any.whl", hash = "sha256:cab8ae264cd33ea16758f37b72efa5d1dc4ee06d635be7c5225de54c420b5641"}, + {file = "ni_measurements_metadata_v1_proto-0.1.0.dev0.tar.gz", hash = "sha256:37768f4187d76f508ebbbcd178b8754ea587e6eddff5bcc15f1685732c008854"}, +] + +[package.dependencies] +protobuf = ">=4.21" + +[[package]] +name = "ni-protobuf-types" +version = "0.1.0.dev4" +description = "Protobuf data types for NI gRPC APIs" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["dev"] +files = [ + {file = "ni_protobuf_types-0.1.0.dev4-py3-none-any.whl", hash = "sha256:dceac83ca05c286e99b44898340f58b45eac91e9609444e252d89c17a7d7c1ff"}, + {file = "ni_protobuf_types-0.1.0.dev4.tar.gz", hash = "sha256:11c6a486bcb3984078e100efac93b96d5a84d70f0d8035a2303eb5cf9c0b1532"}, +] + +[package.dependencies] +nitypes = ">=0.1.0dev8" +protobuf = ">=4.21" + +[[package]] +name = "nitypes" +version = "0.1.0.dev10" +description = "Data types for NI Python APIs" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["dev"] +files = [ + {file = "nitypes-0.1.0.dev10-py3-none-any.whl", hash = "sha256:c4f097ffdeaf05697a7752a1e2b712760b28e84a4f6f446b4b7b76b349927490"}, + {file = "nitypes-0.1.0.dev10.tar.gz", hash = "sha256:e319ebbdefca63db8e879b9f119cc4f76a086c550931dea2be0e33e9c10e9d9f"}, +] + +[package.dependencies] +hightime = ">=0.2.2" +numpy = [ + {version = ">=1.22", markers = "python_version >= \"3.9\" and python_version < \"3.13\""}, + {version = ">=2.1", markers = "python_version >= \"3.13\" and python_version < \"4.0\""}, +] + +[[package]] +name = "numpy" +version = "2.0.2" +description = "Fundamental package for array computing in Python" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +markers = "python_version < \"3.13\"" +files = [ + {file = "numpy-2.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:51129a29dbe56f9ca83438b706e2e69a39892b5eda6cedcb6b0c9fdc9b0d3ece"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f15975dfec0cf2239224d80e32c3170b1d168335eaedee69da84fbe9f1f9cd04"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:8c5713284ce4e282544c68d1c3b2c7161d38c256d2eefc93c1d683cf47683e66"}, + {file = "numpy-2.0.2-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:becfae3ddd30736fe1889a37f1f580e245ba79a5855bff5f2a29cb3ccc22dd7b"}, + {file = "numpy-2.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2da5960c3cf0df7eafefd806d4e612c5e19358de82cb3c343631188991566ccd"}, + {file = "numpy-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:496f71341824ed9f3d2fd36cf3ac57ae2e0165c143b55c3a035ee219413f3318"}, + {file = "numpy-2.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a61ec659f68ae254e4d237816e33171497e978140353c0c2038d46e63282d0c8"}, + {file = "numpy-2.0.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:d731a1c6116ba289c1e9ee714b08a8ff882944d4ad631fd411106a30f083c326"}, + {file = "numpy-2.0.2-cp310-cp310-win32.whl", hash = "sha256:984d96121c9f9616cd33fbd0618b7f08e0cfc9600a7ee1d6fd9b239186d19d97"}, + {file = "numpy-2.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:c7b0be4ef08607dd04da4092faee0b86607f111d5ae68036f16cc787e250a131"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:49ca4decb342d66018b01932139c0961a8f9ddc7589611158cb3c27cbcf76448"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:11a76c372d1d37437857280aa142086476136a8c0f373b2e648ab2c8f18fb195"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:807ec44583fd708a21d4a11d94aedf2f4f3c3719035c76a2bbe1fe8e217bdc57"}, + {file = "numpy-2.0.2-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:8cafab480740e22f8d833acefed5cc87ce276f4ece12fdaa2e8903db2f82897a"}, + {file = "numpy-2.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a15f476a45e6e5a3a79d8a14e62161d27ad897381fecfa4a09ed5322f2085669"}, + {file = "numpy-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13e689d772146140a252c3a28501da66dfecd77490b498b168b501835041f951"}, + {file = "numpy-2.0.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9ea91dfb7c3d1c56a0e55657c0afb38cf1eeae4544c208dc465c3c9f3a7c09f9"}, + {file = "numpy-2.0.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:c1c9307701fec8f3f7a1e6711f9089c06e6284b3afbbcd259f7791282d660a15"}, + {file = "numpy-2.0.2-cp311-cp311-win32.whl", hash = "sha256:a392a68bd329eafac5817e5aefeb39038c48b671afd242710b451e76090e81f4"}, + {file = "numpy-2.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:286cd40ce2b7d652a6f22efdfc6d1edf879440e53e76a75955bc0c826c7e64dc"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:df55d490dea7934f330006d0f81e8551ba6010a5bf035a249ef61a94f21c500b"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8df823f570d9adf0978347d1f926b2a867d5608f434a7cff7f7908c6570dcf5e"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:9a92ae5c14811e390f3767053ff54eaee3bf84576d99a2456391401323f4ec2c"}, + {file = "numpy-2.0.2-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:a842d573724391493a97a62ebbb8e731f8a5dcc5d285dfc99141ca15a3302d0c"}, + {file = "numpy-2.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c05e238064fc0610c840d1cf6a13bf63d7e391717d247f1bf0318172e759e692"}, + {file = "numpy-2.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a"}, + {file = "numpy-2.0.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:96a55f64139912d61de9137f11bf39a55ec8faec288c75a54f93dfd39f7eb40c"}, + {file = "numpy-2.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:ec9852fb39354b5a45a80bdab5ac02dd02b15f44b3804e9f00c556bf24b4bded"}, + {file = "numpy-2.0.2-cp312-cp312-win32.whl", hash = "sha256:671bec6496f83202ed2d3c8fdc486a8fc86942f2e69ff0e986140339a63bcbe5"}, + {file = "numpy-2.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:cfd41e13fdc257aa5778496b8caa5e856dc4896d4ccf01841daee1d96465467a"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9059e10581ce4093f735ed23f3b9d283b9d517ff46009ddd485f1747eb22653c"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:423e89b23490805d2a5a96fe40ec507407b8ee786d66f7328be214f9679df6dd"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_14_0_arm64.whl", hash = "sha256:2b2955fa6f11907cf7a70dab0d0755159bca87755e831e47932367fc8f2f2d0b"}, + {file = "numpy-2.0.2-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:97032a27bd9d8988b9a97a8c4d2c9f2c15a81f61e2f21404d7e8ef00cb5be729"}, + {file = "numpy-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1e795a8be3ddbac43274f18588329c72939870a16cae810c2b73461c40718ab1"}, + {file = "numpy-2.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f26b258c385842546006213344c50655ff1555a9338e2e5e02a0756dc3e803dd"}, + {file = "numpy-2.0.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fec9451a7789926bcf7c2b8d187292c9f93ea30284802a0ab3f5be8ab36865d"}, + {file = "numpy-2.0.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:9189427407d88ff25ecf8f12469d4d39d35bee1db5d39fc5c168c6f088a6956d"}, + {file = "numpy-2.0.2-cp39-cp39-win32.whl", hash = "sha256:905d16e0c60200656500c95b6b8dca5d109e23cb24abc701d41c02d74c6b3afa"}, + {file = "numpy-2.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:a3f4ab0caa7f053f6797fcd4e1e25caee367db3112ef2b6ef82d749530768c73"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:7f0a0c6f12e07fa94133c8a67404322845220c06a9e80e85999afe727f7438b8"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-macosx_14_0_x86_64.whl", hash = "sha256:312950fdd060354350ed123c0e25a71327d3711584beaef30cdaa93320c392d4"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26df23238872200f63518dd2aa984cfca675d82469535dc7162dc2ee52d9dd5c"}, + {file = "numpy-2.0.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a46288ec55ebbd58947d31d72be2c63cbf839f0a63b49cb755022310792a3385"}, + {file = "numpy-2.0.2.tar.gz", hash = "sha256:883c987dee1880e2a864ab0dc9892292582510604156762362d9326444636e78"}, +] + +[[package]] +name = "numpy" +version = "2.3.3" +description = "Fundamental package for array computing in Python" +optional = false +python-versions = ">=3.11" +groups = ["dev"] +markers = "python_version >= \"3.13\"" +files = [ + {file = "numpy-2.3.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0ffc4f5caba7dfcbe944ed674b7eef683c7e94874046454bb79ed7ee0236f59d"}, + {file = "numpy-2.3.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e7e946c7170858a0295f79a60214424caac2ffdb0063d4d79cb681f9aa0aa569"}, + {file = "numpy-2.3.3-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:cd4260f64bc794c3390a63bf0728220dd1a68170c169088a1e0dfa2fde1be12f"}, + {file = "numpy-2.3.3-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:f0ddb4b96a87b6728df9362135e764eac3cfa674499943ebc44ce96c478ab125"}, + {file = "numpy-2.3.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:afd07d377f478344ec6ca2b8d4ca08ae8bd44706763d1efb56397de606393f48"}, + {file = "numpy-2.3.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bc92a5dedcc53857249ca51ef29f5e5f2f8c513e22cfb90faeb20343b8c6f7a6"}, + {file = "numpy-2.3.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7af05ed4dc19f308e1d9fc759f36f21921eb7bbfc82843eeec6b2a2863a0aefa"}, + {file = "numpy-2.3.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:433bf137e338677cebdd5beac0199ac84712ad9d630b74eceeb759eaa45ddf30"}, + {file = "numpy-2.3.3-cp311-cp311-win32.whl", hash = "sha256:eb63d443d7b4ffd1e873f8155260d7f58e7e4b095961b01c91062935c2491e57"}, + {file = "numpy-2.3.3-cp311-cp311-win_amd64.whl", hash = "sha256:ec9d249840f6a565f58d8f913bccac2444235025bbb13e9a4681783572ee3caa"}, + {file = "numpy-2.3.3-cp311-cp311-win_arm64.whl", hash = "sha256:74c2a948d02f88c11a3c075d9733f1ae67d97c6bdb97f2bb542f980458b257e7"}, + {file = "numpy-2.3.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:cfdd09f9c84a1a934cde1eec2267f0a43a7cd44b2cca4ff95b7c0d14d144b0bf"}, + {file = "numpy-2.3.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cb32e3cf0f762aee47ad1ddc6672988f7f27045b0783c887190545baba73aa25"}, + {file = "numpy-2.3.3-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:396b254daeb0a57b1fe0ecb5e3cff6fa79a380fa97c8f7781a6d08cd429418fe"}, + {file = "numpy-2.3.3-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:067e3d7159a5d8f8a0b46ee11148fc35ca9b21f61e3c49fbd0a027450e65a33b"}, + {file = "numpy-2.3.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1c02d0629d25d426585fb2e45a66154081b9fa677bc92a881ff1d216bc9919a8"}, + {file = "numpy-2.3.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d9192da52b9745f7f0766531dcfa978b7763916f158bb63bdb8a1eca0068ab20"}, + {file = "numpy-2.3.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:cd7de500a5b66319db419dc3c345244404a164beae0d0937283b907d8152e6ea"}, + {file = "numpy-2.3.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:93d4962d8f82af58f0b2eb85daaf1b3ca23fe0a85d0be8f1f2b7bb46034e56d7"}, + {file = "numpy-2.3.3-cp312-cp312-win32.whl", hash = "sha256:5534ed6b92f9b7dca6c0a19d6df12d41c68b991cef051d108f6dbff3babc4ebf"}, + {file = "numpy-2.3.3-cp312-cp312-win_amd64.whl", hash = "sha256:497d7cad08e7092dba36e3d296fe4c97708c93daf26643a1ae4b03f6294d30eb"}, + {file = "numpy-2.3.3-cp312-cp312-win_arm64.whl", hash = "sha256:ca0309a18d4dfea6fc6262a66d06c26cfe4640c3926ceec90e57791a82b6eee5"}, + {file = "numpy-2.3.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f5415fb78995644253370985342cd03572ef8620b934da27d77377a2285955bf"}, + {file = "numpy-2.3.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:d00de139a3324e26ed5b95870ce63be7ec7352171bc69a4cf1f157a48e3eb6b7"}, + {file = "numpy-2.3.3-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:9dc13c6a5829610cc07422bc74d3ac083bd8323f14e2827d992f9e52e22cd6a6"}, + {file = "numpy-2.3.3-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:d79715d95f1894771eb4e60fb23f065663b2298f7d22945d66877aadf33d00c7"}, + {file = "numpy-2.3.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:952cfd0748514ea7c3afc729a0fc639e61655ce4c55ab9acfab14bda4f402b4c"}, + {file = "numpy-2.3.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5b83648633d46f77039c29078751f80da65aa64d5622a3cd62aaef9d835b6c93"}, + {file = "numpy-2.3.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b001bae8cea1c7dfdb2ae2b017ed0a6f2102d7a70059df1e338e307a4c78a8ae"}, + {file = "numpy-2.3.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8e9aced64054739037d42fb84c54dd38b81ee238816c948c8f3ed134665dcd86"}, + {file = "numpy-2.3.3-cp313-cp313-win32.whl", hash = "sha256:9591e1221db3f37751e6442850429b3aabf7026d3b05542d102944ca7f00c8a8"}, + {file = "numpy-2.3.3-cp313-cp313-win_amd64.whl", hash = "sha256:f0dadeb302887f07431910f67a14d57209ed91130be0adea2f9793f1a4f817cf"}, + {file = "numpy-2.3.3-cp313-cp313-win_arm64.whl", hash = "sha256:3c7cf302ac6e0b76a64c4aecf1a09e51abd9b01fc7feee80f6c43e3ab1b1dbc5"}, + {file = "numpy-2.3.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:eda59e44957d272846bb407aad19f89dc6f58fecf3504bd144f4c5cf81a7eacc"}, + {file = "numpy-2.3.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:823d04112bc85ef5c4fda73ba24e6096c8f869931405a80aa8b0e604510a26bc"}, + {file = "numpy-2.3.3-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:40051003e03db4041aa325da2a0971ba41cf65714e65d296397cc0e32de6018b"}, + {file = "numpy-2.3.3-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:6ee9086235dd6ab7ae75aba5662f582a81ced49f0f1c6de4260a78d8f2d91a19"}, + {file = "numpy-2.3.3-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:94fcaa68757c3e2e668ddadeaa86ab05499a70725811e582b6a9858dd472fb30"}, + {file = "numpy-2.3.3-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:da1a74b90e7483d6ce5244053399a614b1d6b7bc30a60d2f570e5071f8959d3e"}, + {file = "numpy-2.3.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:2990adf06d1ecee3b3dcbb4977dfab6e9f09807598d647f04d385d29e7a3c3d3"}, + {file = "numpy-2.3.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:ed635ff692483b8e3f0fcaa8e7eb8a75ee71aa6d975388224f70821421800cea"}, + {file = "numpy-2.3.3-cp313-cp313t-win32.whl", hash = "sha256:a333b4ed33d8dc2b373cc955ca57babc00cd6f9009991d9edc5ddbc1bac36bcd"}, + {file = "numpy-2.3.3-cp313-cp313t-win_amd64.whl", hash = "sha256:4384a169c4d8f97195980815d6fcad04933a7e1ab3b530921c3fef7a1c63426d"}, + {file = "numpy-2.3.3-cp313-cp313t-win_arm64.whl", hash = "sha256:75370986cc0bc66f4ce5110ad35aae6d182cc4ce6433c40ad151f53690130bf1"}, + {file = "numpy-2.3.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:cd052f1fa6a78dee696b58a914b7229ecfa41f0a6d96dc663c1220a55e137593"}, + {file = "numpy-2.3.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:414a97499480067d305fcac9716c29cf4d0d76db6ebf0bf3cbce666677f12652"}, + {file = "numpy-2.3.3-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:50a5fe69f135f88a2be9b6ca0481a68a136f6febe1916e4920e12f1a34e708a7"}, + {file = "numpy-2.3.3-cp314-cp314-macosx_14_0_x86_64.whl", hash = "sha256:b912f2ed2b67a129e6a601e9d93d4fa37bef67e54cac442a2f588a54afe5c67a"}, + {file = "numpy-2.3.3-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9e318ee0596d76d4cb3d78535dc005fa60e5ea348cd131a51e99d0bdbe0b54fe"}, + {file = "numpy-2.3.3-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ce020080e4a52426202bdb6f7691c65bb55e49f261f31a8f506c9f6bc7450421"}, + {file = "numpy-2.3.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e6687dc183aa55dae4a705b35f9c0f8cb178bcaa2f029b241ac5356221d5c021"}, + {file = "numpy-2.3.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:d8f3b1080782469fdc1718c4ed1d22549b5fb12af0d57d35e992158a772a37cf"}, + {file = "numpy-2.3.3-cp314-cp314-win32.whl", hash = "sha256:cb248499b0bc3be66ebd6578b83e5acacf1d6cb2a77f2248ce0e40fbec5a76d0"}, + {file = "numpy-2.3.3-cp314-cp314-win_amd64.whl", hash = "sha256:691808c2b26b0f002a032c73255d0bd89751425f379f7bcd22d140db593a96e8"}, + {file = "numpy-2.3.3-cp314-cp314-win_arm64.whl", hash = "sha256:9ad12e976ca7b10f1774b03615a2a4bab8addce37ecc77394d8e986927dc0dfe"}, + {file = "numpy-2.3.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:9cc48e09feb11e1db00b320e9d30a4151f7369afb96bd0e48d942d09da3a0d00"}, + {file = "numpy-2.3.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:901bf6123879b7f251d3631967fd574690734236075082078e0571977c6a8e6a"}, + {file = "numpy-2.3.3-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:7f025652034199c301049296b59fa7d52c7e625017cae4c75d8662e377bf487d"}, + {file = "numpy-2.3.3-cp314-cp314t-macosx_14_0_x86_64.whl", hash = "sha256:533ca5f6d325c80b6007d4d7fb1984c303553534191024ec6a524a4c92a5935a"}, + {file = "numpy-2.3.3-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0edd58682a399824633b66885d699d7de982800053acf20be1eaa46d92009c54"}, + {file = "numpy-2.3.3-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:367ad5d8fbec5d9296d18478804a530f1191e24ab4d75ab408346ae88045d25e"}, + {file = "numpy-2.3.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8f6ac61a217437946a1fa48d24c47c91a0c4f725237871117dea264982128097"}, + {file = "numpy-2.3.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:179a42101b845a816d464b6fe9a845dfaf308fdfc7925387195570789bb2c970"}, + {file = "numpy-2.3.3-cp314-cp314t-win32.whl", hash = "sha256:1250c5d3d2562ec4174bce2e3a1523041595f9b651065e4a4473f5f48a6bc8a5"}, + {file = "numpy-2.3.3-cp314-cp314t-win_amd64.whl", hash = "sha256:b37a0b2e5935409daebe82c1e42274d30d9dd355852529eab91dab8dcca7419f"}, + {file = "numpy-2.3.3-cp314-cp314t-win_arm64.whl", hash = "sha256:78c9f6560dc7e6b3990e32df7ea1a50bbd0e2a111e05209963f5ddcab7073b0b"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:1e02c7159791cd481e1e6d5ddd766b62a4d5acf8df4d4d1afe35ee9c5c33a41e"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:dca2d0fc80b3893ae72197b39f69d55a3cd8b17ea1b50aa4c62de82419936150"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_14_0_arm64.whl", hash = "sha256:99683cbe0658f8271b333a1b1b4bb3173750ad59c0c61f5bbdc5b318918fffe3"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_14_0_x86_64.whl", hash = "sha256:d9d537a39cc9de668e5cd0e25affb17aec17b577c6b3ae8a3d866b479fbe88d0"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8596ba2f8af5f93b01d97563832686d20206d303024777f6dfc2e7c7c3f1850e"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e1ec5615b05369925bd1125f27df33f3b6c8bc10d788d5999ecd8769a1fa04db"}, + {file = "numpy-2.3.3-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:2e267c7da5bf7309670523896df97f93f6e469fb931161f483cd6882b3b1a5dc"}, + {file = "numpy-2.3.3.tar.gz", hash = "sha256:ddc7c39727ba62b80dfdbedf400d1c10ddfa8eefbd7ec8dcb118be8b56d31029"}, +] + +[[package]] +name = "protobuf" +version = "6.32.1" +description = "" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "protobuf-6.32.1-cp310-abi3-win32.whl", hash = "sha256:a8a32a84bc9f2aad712041b8b366190f71dde248926da517bde9e832e4412085"}, + {file = "protobuf-6.32.1-cp310-abi3-win_amd64.whl", hash = "sha256:b00a7d8c25fa471f16bc8153d0e53d6c9e827f0953f3c09aaa4331c718cae5e1"}, + {file = "protobuf-6.32.1-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:d8c7e6eb619ffdf105ee4ab76af5a68b60a9d0f66da3ea12d1640e6d8dab7281"}, + {file = "protobuf-6.32.1-cp39-abi3-manylinux2014_aarch64.whl", hash = "sha256:2f5b80a49e1eb7b86d85fcd23fe92df154b9730a725c3b38c4e43b9d77018bf4"}, + {file = "protobuf-6.32.1-cp39-abi3-manylinux2014_x86_64.whl", hash = "sha256:b1864818300c297265c83a4982fd3169f97122c299f56a56e2445c3698d34710"}, + {file = "protobuf-6.32.1-cp39-cp39-win32.whl", hash = "sha256:68ff170bac18c8178f130d1ccb94700cf72852298e016a2443bdb9502279e5f1"}, + {file = "protobuf-6.32.1-cp39-cp39-win_amd64.whl", hash = "sha256:d0975d0b2f3e6957111aa3935d08a0eb7e006b1505d825f862a1fffc8348e122"}, + {file = "protobuf-6.32.1-py3-none-any.whl", hash = "sha256:2601b779fc7d32a866c6b4404f9d42a3f67c5b9f3f15b4db3cccabe06b95c346"}, + {file = "protobuf-6.32.1.tar.gz", hash = "sha256:ee2469e4a021474ab9baafea6cd070e5bf27c7d29433504ddea1a4ee5850f68d"}, +] + +[[package]] +name = "typing-extensions" +version = "4.15.0" +description = "Backported and Experimental Type Hints for Python 3.9+" +optional = false +python-versions = ">=3.9" +groups = ["main"] +files = [ + {file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"}, + {file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"}, +] [metadata] lock-version = "2.1" -python-versions = ">=3.9" -content-hash = "ff9c4d90a413e5b513f92a443c2607225973bebea8f831996abbafecd3ad8446" +python-versions = "^3.9" +content-hash = "2e8303576822eb32d3751db31f80fd492ac2be114104311bfd77cac1147f9067" diff --git a/examples/publish_and_read/pyproject.toml b/examples/publish_and_read/pyproject.toml index eb6f235..a8c8b8d 100644 --- a/examples/publish_and_read/pyproject.toml +++ b/examples/publish_and_read/pyproject.toml @@ -6,9 +6,15 @@ authors = [ {name = "Johann Scholtz", email = "johann.scholtz@emerson.com"}, {name = "Joel Dixon", email = "joel.dixon@emerson.com"} ] -requires-python = ">=3.9" -dependencies = [] +requires-python = "^3.9" +dependencies = [ + "typing-extensions (>=4.15.0,<5.0.0)" +] [build-system] requires = ["setuptools>=61.0", "wheel"] build-backend = "setuptools.build_meta" + +[tool.poetry.group.dev.dependencies] +ni-datastore = {path = "../..", develop = true} +ni-protobuf-types = "*" \ No newline at end of file diff --git a/examples/publish_and_read/scalar.py b/examples/publish_and_read/scalar.py index 576e907..c5ed491 100644 --- a/examples/publish_and_read/scalar.py +++ b/examples/publish_and_read/scalar.py @@ -1,6 +1,14 @@ + from ni.datastore.client import Client -from ni.datastore.types import Measurement, PassFailStatus, Moniker -if __name__ == "__main__": +def test_publish_and_read_bool(value: bool): client = Client() - client.publish_bool() + stored_data_value = client.publish_bool(value) + print(f"Published boolean value {value}, stored data value: {stored_data_value}") + read_value = client.read_bool(stored_data_value) + print(f"Read boolean value: {read_value}") + assert read_value == value, f"Expected {value}, got {read_value}" + +if __name__ == "__main__": + test_publish_and_read_bool(True) + test_publish_and_read_bool(False) \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index a6907bc..1912147 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2029,4 +2029,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "dfdc7ff5ae86a7835b392c11bd7377be58719b4b074ebf18bcad07340bc5051e" +content-hash = "ea4c9357b2eb06f4429fe68a17dc9a6dfe7e426deacb37704f079f5eeec4017f" diff --git a/pyproject.toml b/pyproject.toml index 9b1d072..dfc3c33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ protobuf = {version=">=4.21"} ni-datamonikers-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-data-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-metadata-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } +ni-protobuf-types = "*" nitypes = {version=">=0.1.0dev3", allow-prereleases=true} [tool.poetry.group.dev.dependencies] diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index ea2a396..1e2423b 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -3,14 +3,24 @@ from google.protobuf.timestamp_pb2 import Timestamp from nitypes.waveform import AnalogWaveform, DigitalWaveform -from ni.datastore.placeholder_types import MetadataStoreClient, MonikerClient +from ni.datamonikers.v1.client import MonikerClient from ni.datastore.types import ( - StoredDataValue, Measurement, PassFailStatus, Moniker + StoredDataValue, + Measurement, + PassFailStatus, + Moniker ) -from ni.measurements.data.v1.data_store_pb2 import PublishableData, PassFailStatus, ErrorState -from ni.measurements.data.v1.data_store_service_pb2 import PublishDataRequest, PublishDataResponse +from ni.measurements.data.v1.data_store_pb2 import ( + ErrorState, + MeasurementMetadata, + PassFailStatus, + PublishableData, + StoredDataValue, +) +from ni.measurements.data.v1.data_store_service_pb2 import PublishDataRequest, PublishDataResponse, CreateMeasurementRequest from ni.measurements.data.v1.client import DataStoreClient - +from ni.measurements.metadata.v1.client import MetadataStoreClient +from ni.protobuf.types.vector_pb2 import Vector class Client: """Datastore client for publishing and reading data.""" @@ -19,52 +29,36 @@ class Client: _data_store_client: DataStoreClient _metadata_store_client: MetadataStoreClient - _moniker_client: MonikerClient def __init__(self): self._data_store_client = DataStoreClient() + self._metadata_store_client = MetadataStoreClient() - def publish_bool(self): + def publish_bool(self, value: bool) -> StoredDataValue: publishable_data = PublishableData() - publishable_data.scalar.bool_value = True - self._publish_data( + publishable_data.scalar.bool_value = value + create_measurement_request = CreateMeasurementRequest(measurement=MeasurementMetadata(name="Boolean Measurement")) + measurement_id = self._data_store_client.create_measurement(create_measurement_request).id + return self._publish_data( publishable_data, "Simple Boolean", - measurement_id="" + measurement_id=measurement_id ) - pass - - def publish_data( - self, - name: str, - value: Union[str, bool, int, float, AnalogWaveform, DigitalWaveform], - description: str, - passFailStatus: PassFailStatus, - measurement: Measurement, - ) -> StoredDataValue: - """Publish a polymorphic data value to the datastore. - - * Open Question: Should this be a general 'publish_data'? - * Where do we put the data, metadata, etc client stubs? - """ - if isinstance(value, (AnalogWaveform)): - pass - return StoredDataValue() - - def read_data( - self, - moniker: Moniker, - ) -> Union[str, bool, int, float]: - """Read a scalar value from the datastore.""" - return True + def read_bool(self, stored_data_value: StoredDataValue) -> bool: + moniker = stored_data_value.moniker + moniker_client = MonikerClient(service_location='localhost:53361') + result = moniker_client.read_from_moniker(moniker) + vector = Vector() + result.value.Unpack(vector) + return vector.bool_array.values[0] def _publish_data( self, data: PublishableData, description: str, measurement_id: str - ) -> PublishDataResponse: + ) -> StoredDataValue: timestamp = datetime.now(timezone.utc) request_timestamp = Timestamp() request_timestamp.FromDatetime(timestamp) @@ -78,4 +72,4 @@ def _publish_data( ) publish_response = self._data_store_client.publish_data(publish_request) - return publish_response + return publish_response.stored_data_value diff --git a/src/ni/datastore/placeholder_types.py b/src/ni/datastore/placeholder_types.py deleted file mode 100644 index 1281e2d..0000000 --- a/src/ni/datastore/placeholder_types.py +++ /dev/null @@ -1,5 +0,0 @@ -class MetadataStoreClient: - pass - -class MonikerClient: - pass \ No newline at end of file From 51c10dadf224dbbdfe20ab5e67f92365945aad6f Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Mon, 15 Sep 2025 16:09:45 -0500 Subject: [PATCH 04/15] Add commented out unit test for publish and read of booleans --- examples/placeholder.py | 1 + examples/publish_and_read/poetry.lock | 293 ----------------------- examples/publish_and_read/poetry.toml | 2 - examples/publish_and_read/pyproject.toml | 20 -- examples/publish_and_read/scalar.py | 14 -- poetry.lock | 221 ++++++++++++++++- pyproject.toml | 3 + src/ni/datastore/client.py | 112 ++++----- src/ni/datastore/types.py | 6 +- tests/placeholder.py | 1 - tests/unit/test_ni_datastore_client.py | 34 ++- 11 files changed, 295 insertions(+), 412 deletions(-) create mode 100644 examples/placeholder.py delete mode 100644 examples/publish_and_read/poetry.lock delete mode 100644 examples/publish_and_read/poetry.toml delete mode 100644 examples/publish_and_read/pyproject.toml delete mode 100644 examples/publish_and_read/scalar.py delete mode 100644 tests/placeholder.py diff --git a/examples/placeholder.py b/examples/placeholder.py new file mode 100644 index 0000000..da732a9 --- /dev/null +++ b/examples/placeholder.py @@ -0,0 +1 @@ +"""Temporary placeholder example.""" \ No newline at end of file diff --git a/examples/publish_and_read/poetry.lock b/examples/publish_and_read/poetry.lock deleted file mode 100644 index 290cf55..0000000 --- a/examples/publish_and_read/poetry.lock +++ /dev/null @@ -1,293 +0,0 @@ -# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. - -[[package]] -name = "hightime" -version = "0.2.2" -description = "Hightime Python API" -optional = false -python-versions = "*" -groups = ["dev"] -files = [ - {file = "hightime-0.2.2-py3-none-any.whl", hash = "sha256:5109a449bb3a75dbf305147777de71634c91b943d47cfbee18ed2f34a8307e0b"}, -] - -[[package]] -name = "ni-datamonikers-v1-proto" -version = "0.1.0.dev0" -description = "Protobuf data types and service stub for NI data moniker gRPC APIs" -optional = false -python-versions = "<4.0,>=3.9" -groups = ["dev"] -files = [ - {file = "ni_datamonikers_v1_proto-0.1.0.dev0-py3-none-any.whl", hash = "sha256:5ae96df50a010de68b40527e75696eeca2fc1522ab9d8a169a5993f031eb2185"}, - {file = "ni_datamonikers_v1_proto-0.1.0.dev0.tar.gz", hash = "sha256:cdcf9b4d1fc463f4b2664949f6037bdcc0a6556679eddb3350b5630873da4147"}, -] - -[package.dependencies] -protobuf = ">=4.21" - -[[package]] -name = "ni-datastore" -version = "0.1.0-dev0" -description = "APIs for publishing and retrieving data from the NI Measurement Data Store" -optional = false -python-versions = "^3.9" -groups = ["dev"] -files = [] -develop = true - -[package.dependencies] -ni-datamonikers-v1-proto = ">=0.1.0.dev0" -ni-measurements-data-v1-proto = ">=0.1.0.dev0" -ni-measurements-metadata-v1-proto = ">=0.1.0.dev0" -nitypes = ">=0.1.0dev3" -protobuf = ">=4.21" - -[package.source] -type = "directory" -url = "../.." - -[[package]] -name = "ni-measurements-data-v1-proto" -version = "0.1.0.dev0" -description = "Protobuf data types and service stubs for NI data store gRPC APIs" -optional = false -python-versions = "<4.0,>=3.9" -groups = ["dev"] -files = [ - {file = "ni_measurements_data_v1_proto-0.1.0.dev0-py3-none-any.whl", hash = "sha256:7f650bde80e276195ec155d1925f06a12e60a96828c9ed8712ab85e999b6109e"}, - {file = "ni_measurements_data_v1_proto-0.1.0.dev0.tar.gz", hash = "sha256:206430bd5f2cafd21e69296027159dd03c11e6f9750ced2ee7ee3e71ea10f2b3"}, -] - -[package.dependencies] -ni-datamonikers-v1-proto = ">=0.1.0.dev0" -ni-measurements-metadata-v1-proto = ">=0.1.0.dev0" -ni-protobuf-types = ">=0.1.0.dev3" -protobuf = ">=4.21" - -[[package]] -name = "ni-measurements-metadata-v1-proto" -version = "0.1.0.dev0" -description = "Protobuf data types and service stub for NI metadata store gRPC APIs" -optional = false -python-versions = "<4.0,>=3.9" -groups = ["dev"] -files = [ - {file = "ni_measurements_metadata_v1_proto-0.1.0.dev0-py3-none-any.whl", hash = "sha256:cab8ae264cd33ea16758f37b72efa5d1dc4ee06d635be7c5225de54c420b5641"}, - {file = "ni_measurements_metadata_v1_proto-0.1.0.dev0.tar.gz", hash = "sha256:37768f4187d76f508ebbbcd178b8754ea587e6eddff5bcc15f1685732c008854"}, -] - -[package.dependencies] -protobuf = ">=4.21" - -[[package]] -name = "ni-protobuf-types" -version = "0.1.0.dev4" -description = "Protobuf data types for NI gRPC APIs" -optional = false -python-versions = "<4.0,>=3.9" -groups = ["dev"] -files = [ - {file = "ni_protobuf_types-0.1.0.dev4-py3-none-any.whl", hash = "sha256:dceac83ca05c286e99b44898340f58b45eac91e9609444e252d89c17a7d7c1ff"}, - {file = "ni_protobuf_types-0.1.0.dev4.tar.gz", hash = "sha256:11c6a486bcb3984078e100efac93b96d5a84d70f0d8035a2303eb5cf9c0b1532"}, -] - -[package.dependencies] -nitypes = ">=0.1.0dev8" -protobuf = ">=4.21" - -[[package]] -name = "nitypes" -version = "0.1.0.dev10" -description = "Data types for NI Python APIs" -optional = false -python-versions = "<4.0,>=3.9" -groups = ["dev"] -files = [ - {file = "nitypes-0.1.0.dev10-py3-none-any.whl", hash = "sha256:c4f097ffdeaf05697a7752a1e2b712760b28e84a4f6f446b4b7b76b349927490"}, - {file = "nitypes-0.1.0.dev10.tar.gz", hash = "sha256:e319ebbdefca63db8e879b9f119cc4f76a086c550931dea2be0e33e9c10e9d9f"}, -] - -[package.dependencies] -hightime = ">=0.2.2" -numpy = [ - {version = ">=1.22", markers = "python_version >= \"3.9\" and python_version < \"3.13\""}, - {version = ">=2.1", markers = "python_version >= \"3.13\" and python_version < \"4.0\""}, -] - -[[package]] -name = "numpy" -version = "2.0.2" -description = "Fundamental package for array computing in Python" -optional = false -python-versions = ">=3.9" -groups = ["dev"] -markers = "python_version < \"3.13\"" -files = [ - {file = "numpy-2.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:51129a29dbe56f9ca83438b706e2e69a39892b5eda6cedcb6b0c9fdc9b0d3ece"}, - {file = "numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f15975dfec0cf2239224d80e32c3170b1d168335eaedee69da84fbe9f1f9cd04"}, - {file = "numpy-2.0.2-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:8c5713284ce4e282544c68d1c3b2c7161d38c256d2eefc93c1d683cf47683e66"}, - {file = "numpy-2.0.2-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:becfae3ddd30736fe1889a37f1f580e245ba79a5855bff5f2a29cb3ccc22dd7b"}, - {file = "numpy-2.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2da5960c3cf0df7eafefd806d4e612c5e19358de82cb3c343631188991566ccd"}, - {file = "numpy-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:496f71341824ed9f3d2fd36cf3ac57ae2e0165c143b55c3a035ee219413f3318"}, - {file = "numpy-2.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a61ec659f68ae254e4d237816e33171497e978140353c0c2038d46e63282d0c8"}, - {file = "numpy-2.0.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:d731a1c6116ba289c1e9ee714b08a8ff882944d4ad631fd411106a30f083c326"}, - {file = "numpy-2.0.2-cp310-cp310-win32.whl", hash = "sha256:984d96121c9f9616cd33fbd0618b7f08e0cfc9600a7ee1d6fd9b239186d19d97"}, - {file = "numpy-2.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:c7b0be4ef08607dd04da4092faee0b86607f111d5ae68036f16cc787e250a131"}, - {file = "numpy-2.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:49ca4decb342d66018b01932139c0961a8f9ddc7589611158cb3c27cbcf76448"}, - {file = "numpy-2.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:11a76c372d1d37437857280aa142086476136a8c0f373b2e648ab2c8f18fb195"}, - {file = "numpy-2.0.2-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:807ec44583fd708a21d4a11d94aedf2f4f3c3719035c76a2bbe1fe8e217bdc57"}, - {file = "numpy-2.0.2-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:8cafab480740e22f8d833acefed5cc87ce276f4ece12fdaa2e8903db2f82897a"}, - {file = "numpy-2.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a15f476a45e6e5a3a79d8a14e62161d27ad897381fecfa4a09ed5322f2085669"}, - {file = "numpy-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13e689d772146140a252c3a28501da66dfecd77490b498b168b501835041f951"}, - {file = "numpy-2.0.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9ea91dfb7c3d1c56a0e55657c0afb38cf1eeae4544c208dc465c3c9f3a7c09f9"}, - {file = "numpy-2.0.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:c1c9307701fec8f3f7a1e6711f9089c06e6284b3afbbcd259f7791282d660a15"}, - {file = "numpy-2.0.2-cp311-cp311-win32.whl", hash = "sha256:a392a68bd329eafac5817e5aefeb39038c48b671afd242710b451e76090e81f4"}, - {file = "numpy-2.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:286cd40ce2b7d652a6f22efdfc6d1edf879440e53e76a75955bc0c826c7e64dc"}, - {file = "numpy-2.0.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:df55d490dea7934f330006d0f81e8551ba6010a5bf035a249ef61a94f21c500b"}, - {file = "numpy-2.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8df823f570d9adf0978347d1f926b2a867d5608f434a7cff7f7908c6570dcf5e"}, - {file = "numpy-2.0.2-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:9a92ae5c14811e390f3767053ff54eaee3bf84576d99a2456391401323f4ec2c"}, - {file = "numpy-2.0.2-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:a842d573724391493a97a62ebbb8e731f8a5dcc5d285dfc99141ca15a3302d0c"}, - {file = "numpy-2.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c05e238064fc0610c840d1cf6a13bf63d7e391717d247f1bf0318172e759e692"}, - {file = "numpy-2.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a"}, - {file = "numpy-2.0.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:96a55f64139912d61de9137f11bf39a55ec8faec288c75a54f93dfd39f7eb40c"}, - {file = "numpy-2.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:ec9852fb39354b5a45a80bdab5ac02dd02b15f44b3804e9f00c556bf24b4bded"}, - {file = "numpy-2.0.2-cp312-cp312-win32.whl", hash = "sha256:671bec6496f83202ed2d3c8fdc486a8fc86942f2e69ff0e986140339a63bcbe5"}, - {file = "numpy-2.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:cfd41e13fdc257aa5778496b8caa5e856dc4896d4ccf01841daee1d96465467a"}, - {file = "numpy-2.0.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9059e10581ce4093f735ed23f3b9d283b9d517ff46009ddd485f1747eb22653c"}, - {file = "numpy-2.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:423e89b23490805d2a5a96fe40ec507407b8ee786d66f7328be214f9679df6dd"}, - {file = "numpy-2.0.2-cp39-cp39-macosx_14_0_arm64.whl", hash = "sha256:2b2955fa6f11907cf7a70dab0d0755159bca87755e831e47932367fc8f2f2d0b"}, - {file = "numpy-2.0.2-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:97032a27bd9d8988b9a97a8c4d2c9f2c15a81f61e2f21404d7e8ef00cb5be729"}, - {file = "numpy-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1e795a8be3ddbac43274f18588329c72939870a16cae810c2b73461c40718ab1"}, - {file = "numpy-2.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f26b258c385842546006213344c50655ff1555a9338e2e5e02a0756dc3e803dd"}, - {file = "numpy-2.0.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fec9451a7789926bcf7c2b8d187292c9f93ea30284802a0ab3f5be8ab36865d"}, - {file = "numpy-2.0.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:9189427407d88ff25ecf8f12469d4d39d35bee1db5d39fc5c168c6f088a6956d"}, - {file = "numpy-2.0.2-cp39-cp39-win32.whl", hash = "sha256:905d16e0c60200656500c95b6b8dca5d109e23cb24abc701d41c02d74c6b3afa"}, - {file = "numpy-2.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:a3f4ab0caa7f053f6797fcd4e1e25caee367db3112ef2b6ef82d749530768c73"}, - {file = "numpy-2.0.2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:7f0a0c6f12e07fa94133c8a67404322845220c06a9e80e85999afe727f7438b8"}, - {file = "numpy-2.0.2-pp39-pypy39_pp73-macosx_14_0_x86_64.whl", hash = "sha256:312950fdd060354350ed123c0e25a71327d3711584beaef30cdaa93320c392d4"}, - {file = "numpy-2.0.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26df23238872200f63518dd2aa984cfca675d82469535dc7162dc2ee52d9dd5c"}, - {file = "numpy-2.0.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a46288ec55ebbd58947d31d72be2c63cbf839f0a63b49cb755022310792a3385"}, - {file = "numpy-2.0.2.tar.gz", hash = "sha256:883c987dee1880e2a864ab0dc9892292582510604156762362d9326444636e78"}, -] - -[[package]] -name = "numpy" -version = "2.3.3" -description = "Fundamental package for array computing in Python" -optional = false -python-versions = ">=3.11" -groups = ["dev"] -markers = "python_version >= \"3.13\"" -files = [ - {file = "numpy-2.3.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0ffc4f5caba7dfcbe944ed674b7eef683c7e94874046454bb79ed7ee0236f59d"}, - {file = "numpy-2.3.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e7e946c7170858a0295f79a60214424caac2ffdb0063d4d79cb681f9aa0aa569"}, - {file = "numpy-2.3.3-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:cd4260f64bc794c3390a63bf0728220dd1a68170c169088a1e0dfa2fde1be12f"}, - {file = "numpy-2.3.3-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:f0ddb4b96a87b6728df9362135e764eac3cfa674499943ebc44ce96c478ab125"}, - {file = "numpy-2.3.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:afd07d377f478344ec6ca2b8d4ca08ae8bd44706763d1efb56397de606393f48"}, - {file = "numpy-2.3.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bc92a5dedcc53857249ca51ef29f5e5f2f8c513e22cfb90faeb20343b8c6f7a6"}, - {file = "numpy-2.3.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7af05ed4dc19f308e1d9fc759f36f21921eb7bbfc82843eeec6b2a2863a0aefa"}, - {file = "numpy-2.3.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:433bf137e338677cebdd5beac0199ac84712ad9d630b74eceeb759eaa45ddf30"}, - {file = "numpy-2.3.3-cp311-cp311-win32.whl", hash = "sha256:eb63d443d7b4ffd1e873f8155260d7f58e7e4b095961b01c91062935c2491e57"}, - {file = "numpy-2.3.3-cp311-cp311-win_amd64.whl", hash = "sha256:ec9d249840f6a565f58d8f913bccac2444235025bbb13e9a4681783572ee3caa"}, - {file = "numpy-2.3.3-cp311-cp311-win_arm64.whl", hash = "sha256:74c2a948d02f88c11a3c075d9733f1ae67d97c6bdb97f2bb542f980458b257e7"}, - {file = "numpy-2.3.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:cfdd09f9c84a1a934cde1eec2267f0a43a7cd44b2cca4ff95b7c0d14d144b0bf"}, - {file = "numpy-2.3.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cb32e3cf0f762aee47ad1ddc6672988f7f27045b0783c887190545baba73aa25"}, - {file = "numpy-2.3.3-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:396b254daeb0a57b1fe0ecb5e3cff6fa79a380fa97c8f7781a6d08cd429418fe"}, - {file = "numpy-2.3.3-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:067e3d7159a5d8f8a0b46ee11148fc35ca9b21f61e3c49fbd0a027450e65a33b"}, - {file = "numpy-2.3.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1c02d0629d25d426585fb2e45a66154081b9fa677bc92a881ff1d216bc9919a8"}, - {file = "numpy-2.3.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d9192da52b9745f7f0766531dcfa978b7763916f158bb63bdb8a1eca0068ab20"}, - {file = "numpy-2.3.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:cd7de500a5b66319db419dc3c345244404a164beae0d0937283b907d8152e6ea"}, - {file = "numpy-2.3.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:93d4962d8f82af58f0b2eb85daaf1b3ca23fe0a85d0be8f1f2b7bb46034e56d7"}, - {file = "numpy-2.3.3-cp312-cp312-win32.whl", hash = "sha256:5534ed6b92f9b7dca6c0a19d6df12d41c68b991cef051d108f6dbff3babc4ebf"}, - {file = "numpy-2.3.3-cp312-cp312-win_amd64.whl", hash = "sha256:497d7cad08e7092dba36e3d296fe4c97708c93daf26643a1ae4b03f6294d30eb"}, - {file = "numpy-2.3.3-cp312-cp312-win_arm64.whl", hash = "sha256:ca0309a18d4dfea6fc6262a66d06c26cfe4640c3926ceec90e57791a82b6eee5"}, - {file = "numpy-2.3.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f5415fb78995644253370985342cd03572ef8620b934da27d77377a2285955bf"}, - {file = "numpy-2.3.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:d00de139a3324e26ed5b95870ce63be7ec7352171bc69a4cf1f157a48e3eb6b7"}, - {file = "numpy-2.3.3-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:9dc13c6a5829610cc07422bc74d3ac083bd8323f14e2827d992f9e52e22cd6a6"}, - {file = "numpy-2.3.3-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:d79715d95f1894771eb4e60fb23f065663b2298f7d22945d66877aadf33d00c7"}, - {file = "numpy-2.3.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:952cfd0748514ea7c3afc729a0fc639e61655ce4c55ab9acfab14bda4f402b4c"}, - {file = "numpy-2.3.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5b83648633d46f77039c29078751f80da65aa64d5622a3cd62aaef9d835b6c93"}, - {file = "numpy-2.3.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b001bae8cea1c7dfdb2ae2b017ed0a6f2102d7a70059df1e338e307a4c78a8ae"}, - {file = "numpy-2.3.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8e9aced64054739037d42fb84c54dd38b81ee238816c948c8f3ed134665dcd86"}, - {file = "numpy-2.3.3-cp313-cp313-win32.whl", hash = "sha256:9591e1221db3f37751e6442850429b3aabf7026d3b05542d102944ca7f00c8a8"}, - {file = "numpy-2.3.3-cp313-cp313-win_amd64.whl", hash = "sha256:f0dadeb302887f07431910f67a14d57209ed91130be0adea2f9793f1a4f817cf"}, - {file = "numpy-2.3.3-cp313-cp313-win_arm64.whl", hash = "sha256:3c7cf302ac6e0b76a64c4aecf1a09e51abd9b01fc7feee80f6c43e3ab1b1dbc5"}, - {file = "numpy-2.3.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:eda59e44957d272846bb407aad19f89dc6f58fecf3504bd144f4c5cf81a7eacc"}, - {file = "numpy-2.3.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:823d04112bc85ef5c4fda73ba24e6096c8f869931405a80aa8b0e604510a26bc"}, - {file = "numpy-2.3.3-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:40051003e03db4041aa325da2a0971ba41cf65714e65d296397cc0e32de6018b"}, - {file = "numpy-2.3.3-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:6ee9086235dd6ab7ae75aba5662f582a81ced49f0f1c6de4260a78d8f2d91a19"}, - {file = "numpy-2.3.3-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:94fcaa68757c3e2e668ddadeaa86ab05499a70725811e582b6a9858dd472fb30"}, - {file = "numpy-2.3.3-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:da1a74b90e7483d6ce5244053399a614b1d6b7bc30a60d2f570e5071f8959d3e"}, - {file = "numpy-2.3.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:2990adf06d1ecee3b3dcbb4977dfab6e9f09807598d647f04d385d29e7a3c3d3"}, - {file = "numpy-2.3.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:ed635ff692483b8e3f0fcaa8e7eb8a75ee71aa6d975388224f70821421800cea"}, - {file = "numpy-2.3.3-cp313-cp313t-win32.whl", hash = "sha256:a333b4ed33d8dc2b373cc955ca57babc00cd6f9009991d9edc5ddbc1bac36bcd"}, - {file = "numpy-2.3.3-cp313-cp313t-win_amd64.whl", hash = "sha256:4384a169c4d8f97195980815d6fcad04933a7e1ab3b530921c3fef7a1c63426d"}, - {file = "numpy-2.3.3-cp313-cp313t-win_arm64.whl", hash = "sha256:75370986cc0bc66f4ce5110ad35aae6d182cc4ce6433c40ad151f53690130bf1"}, - {file = "numpy-2.3.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:cd052f1fa6a78dee696b58a914b7229ecfa41f0a6d96dc663c1220a55e137593"}, - {file = "numpy-2.3.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:414a97499480067d305fcac9716c29cf4d0d76db6ebf0bf3cbce666677f12652"}, - {file = "numpy-2.3.3-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:50a5fe69f135f88a2be9b6ca0481a68a136f6febe1916e4920e12f1a34e708a7"}, - {file = "numpy-2.3.3-cp314-cp314-macosx_14_0_x86_64.whl", hash = "sha256:b912f2ed2b67a129e6a601e9d93d4fa37bef67e54cac442a2f588a54afe5c67a"}, - {file = "numpy-2.3.3-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9e318ee0596d76d4cb3d78535dc005fa60e5ea348cd131a51e99d0bdbe0b54fe"}, - {file = "numpy-2.3.3-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ce020080e4a52426202bdb6f7691c65bb55e49f261f31a8f506c9f6bc7450421"}, - {file = "numpy-2.3.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e6687dc183aa55dae4a705b35f9c0f8cb178bcaa2f029b241ac5356221d5c021"}, - {file = "numpy-2.3.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:d8f3b1080782469fdc1718c4ed1d22549b5fb12af0d57d35e992158a772a37cf"}, - {file = "numpy-2.3.3-cp314-cp314-win32.whl", hash = "sha256:cb248499b0bc3be66ebd6578b83e5acacf1d6cb2a77f2248ce0e40fbec5a76d0"}, - {file = "numpy-2.3.3-cp314-cp314-win_amd64.whl", hash = "sha256:691808c2b26b0f002a032c73255d0bd89751425f379f7bcd22d140db593a96e8"}, - {file = "numpy-2.3.3-cp314-cp314-win_arm64.whl", hash = "sha256:9ad12e976ca7b10f1774b03615a2a4bab8addce37ecc77394d8e986927dc0dfe"}, - {file = "numpy-2.3.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:9cc48e09feb11e1db00b320e9d30a4151f7369afb96bd0e48d942d09da3a0d00"}, - {file = "numpy-2.3.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:901bf6123879b7f251d3631967fd574690734236075082078e0571977c6a8e6a"}, - {file = "numpy-2.3.3-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:7f025652034199c301049296b59fa7d52c7e625017cae4c75d8662e377bf487d"}, - {file = "numpy-2.3.3-cp314-cp314t-macosx_14_0_x86_64.whl", hash = "sha256:533ca5f6d325c80b6007d4d7fb1984c303553534191024ec6a524a4c92a5935a"}, - {file = "numpy-2.3.3-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0edd58682a399824633b66885d699d7de982800053acf20be1eaa46d92009c54"}, - {file = "numpy-2.3.3-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:367ad5d8fbec5d9296d18478804a530f1191e24ab4d75ab408346ae88045d25e"}, - {file = "numpy-2.3.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8f6ac61a217437946a1fa48d24c47c91a0c4f725237871117dea264982128097"}, - {file = "numpy-2.3.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:179a42101b845a816d464b6fe9a845dfaf308fdfc7925387195570789bb2c970"}, - {file = "numpy-2.3.3-cp314-cp314t-win32.whl", hash = "sha256:1250c5d3d2562ec4174bce2e3a1523041595f9b651065e4a4473f5f48a6bc8a5"}, - {file = "numpy-2.3.3-cp314-cp314t-win_amd64.whl", hash = "sha256:b37a0b2e5935409daebe82c1e42274d30d9dd355852529eab91dab8dcca7419f"}, - {file = "numpy-2.3.3-cp314-cp314t-win_arm64.whl", hash = "sha256:78c9f6560dc7e6b3990e32df7ea1a50bbd0e2a111e05209963f5ddcab7073b0b"}, - {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:1e02c7159791cd481e1e6d5ddd766b62a4d5acf8df4d4d1afe35ee9c5c33a41e"}, - {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:dca2d0fc80b3893ae72197b39f69d55a3cd8b17ea1b50aa4c62de82419936150"}, - {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_14_0_arm64.whl", hash = "sha256:99683cbe0658f8271b333a1b1b4bb3173750ad59c0c61f5bbdc5b318918fffe3"}, - {file = "numpy-2.3.3-pp311-pypy311_pp73-macosx_14_0_x86_64.whl", hash = "sha256:d9d537a39cc9de668e5cd0e25affb17aec17b577c6b3ae8a3d866b479fbe88d0"}, - {file = "numpy-2.3.3-pp311-pypy311_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8596ba2f8af5f93b01d97563832686d20206d303024777f6dfc2e7c7c3f1850e"}, - {file = "numpy-2.3.3-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e1ec5615b05369925bd1125f27df33f3b6c8bc10d788d5999ecd8769a1fa04db"}, - {file = "numpy-2.3.3-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:2e267c7da5bf7309670523896df97f93f6e469fb931161f483cd6882b3b1a5dc"}, - {file = "numpy-2.3.3.tar.gz", hash = "sha256:ddc7c39727ba62b80dfdbedf400d1c10ddfa8eefbd7ec8dcb118be8b56d31029"}, -] - -[[package]] -name = "protobuf" -version = "6.32.1" -description = "" -optional = false -python-versions = ">=3.9" -groups = ["dev"] -files = [ - {file = "protobuf-6.32.1-cp310-abi3-win32.whl", hash = "sha256:a8a32a84bc9f2aad712041b8b366190f71dde248926da517bde9e832e4412085"}, - {file = "protobuf-6.32.1-cp310-abi3-win_amd64.whl", hash = "sha256:b00a7d8c25fa471f16bc8153d0e53d6c9e827f0953f3c09aaa4331c718cae5e1"}, - {file = "protobuf-6.32.1-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:d8c7e6eb619ffdf105ee4ab76af5a68b60a9d0f66da3ea12d1640e6d8dab7281"}, - {file = "protobuf-6.32.1-cp39-abi3-manylinux2014_aarch64.whl", hash = "sha256:2f5b80a49e1eb7b86d85fcd23fe92df154b9730a725c3b38c4e43b9d77018bf4"}, - {file = "protobuf-6.32.1-cp39-abi3-manylinux2014_x86_64.whl", hash = "sha256:b1864818300c297265c83a4982fd3169f97122c299f56a56e2445c3698d34710"}, - {file = "protobuf-6.32.1-cp39-cp39-win32.whl", hash = "sha256:68ff170bac18c8178f130d1ccb94700cf72852298e016a2443bdb9502279e5f1"}, - {file = "protobuf-6.32.1-cp39-cp39-win_amd64.whl", hash = "sha256:d0975d0b2f3e6957111aa3935d08a0eb7e006b1505d825f862a1fffc8348e122"}, - {file = "protobuf-6.32.1-py3-none-any.whl", hash = "sha256:2601b779fc7d32a866c6b4404f9d42a3f67c5b9f3f15b4db3cccabe06b95c346"}, - {file = "protobuf-6.32.1.tar.gz", hash = "sha256:ee2469e4a021474ab9baafea6cd070e5bf27c7d29433504ddea1a4ee5850f68d"}, -] - -[[package]] -name = "typing-extensions" -version = "4.15.0" -description = "Backported and Experimental Type Hints for Python 3.9+" -optional = false -python-versions = ">=3.9" -groups = ["main"] -files = [ - {file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"}, - {file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"}, -] - -[metadata] -lock-version = "2.1" -python-versions = "^3.9" -content-hash = "2e8303576822eb32d3751db31f80fd492ac2be114104311bfd77cac1147f9067" diff --git a/examples/publish_and_read/poetry.toml b/examples/publish_and_read/poetry.toml deleted file mode 100644 index ab1033b..0000000 --- a/examples/publish_and_read/poetry.toml +++ /dev/null @@ -1,2 +0,0 @@ -[virtualenvs] -in-project = true diff --git a/examples/publish_and_read/pyproject.toml b/examples/publish_and_read/pyproject.toml deleted file mode 100644 index a8c8b8d..0000000 --- a/examples/publish_and_read/pyproject.toml +++ /dev/null @@ -1,20 +0,0 @@ -[project] -name = "publish_and_read" -version = "0.1.0" -description = "Showcases publishing various kinds of data and reading it back" -authors = [ - {name = "Johann Scholtz", email = "johann.scholtz@emerson.com"}, - {name = "Joel Dixon", email = "joel.dixon@emerson.com"} -] -requires-python = "^3.9" -dependencies = [ - "typing-extensions (>=4.15.0,<5.0.0)" -] - -[build-system] -requires = ["setuptools>=61.0", "wheel"] -build-backend = "setuptools.build_meta" - -[tool.poetry.group.dev.dependencies] -ni-datastore = {path = "../..", develop = true} -ni-protobuf-types = "*" \ No newline at end of file diff --git a/examples/publish_and_read/scalar.py b/examples/publish_and_read/scalar.py deleted file mode 100644 index c5ed491..0000000 --- a/examples/publish_and_read/scalar.py +++ /dev/null @@ -1,14 +0,0 @@ - -from ni.datastore.client import Client - -def test_publish_and_read_bool(value: bool): - client = Client() - stored_data_value = client.publish_bool(value) - print(f"Published boolean value {value}, stored data value: {stored_data_value}") - read_value = client.read_bool(stored_data_value) - print(f"Read boolean value: {read_value}") - assert read_value == value, f"Expected {value}, got {read_value}" - -if __name__ == "__main__": - test_publish_and_read_bool(True) - test_publish_and_read_bool(False) \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 1912147..fc4b510 100644 --- a/poetry.lock +++ b/poetry.lock @@ -481,6 +481,70 @@ files = [ pycodestyle = "*" setuptools = "*" +[[package]] +name = "grpcio" +version = "1.74.0" +description = "HTTP/2-based RPC framework" +optional = false +python-versions = ">=3.9" +groups = ["main"] +files = [ + {file = "grpcio-1.74.0-cp310-cp310-linux_armv7l.whl", hash = "sha256:85bd5cdf4ed7b2d6438871adf6afff9af7096486fcf51818a81b77ef4dd30907"}, + {file = "grpcio-1.74.0-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:68c8ebcca945efff9d86d8d6d7bfb0841cf0071024417e2d7f45c5e46b5b08eb"}, + {file = "grpcio-1.74.0-cp310-cp310-manylinux_2_17_aarch64.whl", hash = "sha256:e154d230dc1bbbd78ad2fdc3039fa50ad7ffcf438e4eb2fa30bce223a70c7486"}, + {file = "grpcio-1.74.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e8978003816c7b9eabe217f88c78bc26adc8f9304bf6a594b02e5a49b2ef9c11"}, + {file = "grpcio-1.74.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c3d7bd6e3929fd2ea7fbc3f562e4987229ead70c9ae5f01501a46701e08f1ad9"}, + {file = "grpcio-1.74.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:136b53c91ac1d02c8c24201bfdeb56f8b3ac3278668cbb8e0ba49c88069e1bdc"}, + {file = "grpcio-1.74.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:fe0f540750a13fd8e5da4b3eaba91a785eea8dca5ccd2bc2ffe978caa403090e"}, + {file = "grpcio-1.74.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4e4181bfc24413d1e3a37a0b7889bea68d973d4b45dd2bc68bb766c140718f82"}, + {file = "grpcio-1.74.0-cp310-cp310-win32.whl", hash = "sha256:1733969040989f7acc3d94c22f55b4a9501a30f6aaacdbccfaba0a3ffb255ab7"}, + {file = "grpcio-1.74.0-cp310-cp310-win_amd64.whl", hash = "sha256:9e912d3c993a29df6c627459af58975b2e5c897d93287939b9d5065f000249b5"}, + {file = "grpcio-1.74.0-cp311-cp311-linux_armv7l.whl", hash = "sha256:69e1a8180868a2576f02356565f16635b99088da7df3d45aaa7e24e73a054e31"}, + {file = "grpcio-1.74.0-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:8efe72fde5500f47aca1ef59495cb59c885afe04ac89dd11d810f2de87d935d4"}, + {file = "grpcio-1.74.0-cp311-cp311-manylinux_2_17_aarch64.whl", hash = "sha256:a8f0302f9ac4e9923f98d8e243939a6fb627cd048f5cd38595c97e38020dffce"}, + {file = "grpcio-1.74.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2f609a39f62a6f6f05c7512746798282546358a37ea93c1fcbadf8b2fed162e3"}, + {file = "grpcio-1.74.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c98e0b7434a7fa4e3e63f250456eaef52499fba5ae661c58cc5b5477d11e7182"}, + {file = "grpcio-1.74.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:662456c4513e298db6d7bd9c3b8df6f75f8752f0ba01fb653e252ed4a59b5a5d"}, + {file = "grpcio-1.74.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:3d14e3c4d65e19d8430a4e28ceb71ace4728776fd6c3ce34016947474479683f"}, + {file = "grpcio-1.74.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1bf949792cee20d2078323a9b02bacbbae002b9e3b9e2433f2741c15bdeba1c4"}, + {file = "grpcio-1.74.0-cp311-cp311-win32.whl", hash = "sha256:55b453812fa7c7ce2f5c88be3018fb4a490519b6ce80788d5913f3f9d7da8c7b"}, + {file = "grpcio-1.74.0-cp311-cp311-win_amd64.whl", hash = "sha256:86ad489db097141a907c559988c29718719aa3e13370d40e20506f11b4de0d11"}, + {file = "grpcio-1.74.0-cp312-cp312-linux_armv7l.whl", hash = "sha256:8533e6e9c5bd630ca98062e3a1326249e6ada07d05acf191a77bc33f8948f3d8"}, + {file = "grpcio-1.74.0-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:2918948864fec2a11721d91568effffbe0a02b23ecd57f281391d986847982f6"}, + {file = "grpcio-1.74.0-cp312-cp312-manylinux_2_17_aarch64.whl", hash = "sha256:60d2d48b0580e70d2e1954d0d19fa3c2e60dd7cbed826aca104fff518310d1c5"}, + {file = "grpcio-1.74.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3601274bc0523f6dc07666c0e01682c94472402ac2fd1226fd96e079863bfa49"}, + {file = "grpcio-1.74.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:176d60a5168d7948539def20b2a3adcce67d72454d9ae05969a2e73f3a0feee7"}, + {file = "grpcio-1.74.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:e759f9e8bc908aaae0412642afe5416c9f983a80499448fcc7fab8692ae044c3"}, + {file = "grpcio-1.74.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:9e7c4389771855a92934b2846bd807fc25a3dfa820fd912fe6bd8136026b2707"}, + {file = "grpcio-1.74.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:cce634b10aeab37010449124814b05a62fb5f18928ca878f1bf4750d1f0c815b"}, + {file = "grpcio-1.74.0-cp312-cp312-win32.whl", hash = "sha256:885912559974df35d92219e2dc98f51a16a48395f37b92865ad45186f294096c"}, + {file = "grpcio-1.74.0-cp312-cp312-win_amd64.whl", hash = "sha256:42f8fee287427b94be63d916c90399ed310ed10aadbf9e2e5538b3e497d269bc"}, + {file = "grpcio-1.74.0-cp313-cp313-linux_armv7l.whl", hash = "sha256:2bc2d7d8d184e2362b53905cb1708c84cb16354771c04b490485fa07ce3a1d89"}, + {file = "grpcio-1.74.0-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:c14e803037e572c177ba54a3e090d6eb12efd795d49327c5ee2b3bddb836bf01"}, + {file = "grpcio-1.74.0-cp313-cp313-manylinux_2_17_aarch64.whl", hash = "sha256:f6ec94f0e50eb8fa1744a731088b966427575e40c2944a980049798b127a687e"}, + {file = "grpcio-1.74.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:566b9395b90cc3d0d0c6404bc8572c7c18786ede549cdb540ae27b58afe0fb91"}, + {file = "grpcio-1.74.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e1ea6176d7dfd5b941ea01c2ec34de9531ba494d541fe2057c904e601879f249"}, + {file = "grpcio-1.74.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:64229c1e9cea079420527fa8ac45d80fc1e8d3f94deaa35643c381fa8d98f362"}, + {file = "grpcio-1.74.0-cp313-cp313-musllinux_1_1_i686.whl", hash = "sha256:0f87bddd6e27fc776aacf7ebfec367b6d49cad0455123951e4488ea99d9b9b8f"}, + {file = "grpcio-1.74.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:3b03d8f2a07f0fea8c8f74deb59f8352b770e3900d143b3d1475effcb08eec20"}, + {file = "grpcio-1.74.0-cp313-cp313-win32.whl", hash = "sha256:b6a73b2ba83e663b2480a90b82fdae6a7aa6427f62bf43b29912c0cfd1aa2bfa"}, + {file = "grpcio-1.74.0-cp313-cp313-win_amd64.whl", hash = "sha256:fd3c71aeee838299c5887230b8a1822795325ddfea635edd82954c1eaa831e24"}, + {file = "grpcio-1.74.0-cp39-cp39-linux_armv7l.whl", hash = "sha256:4bc5fca10aaf74779081e16c2bcc3d5ec643ffd528d9e7b1c9039000ead73bae"}, + {file = "grpcio-1.74.0-cp39-cp39-macosx_11_0_universal2.whl", hash = "sha256:6bab67d15ad617aff094c382c882e0177637da73cbc5532d52c07b4ee887a87b"}, + {file = "grpcio-1.74.0-cp39-cp39-manylinux_2_17_aarch64.whl", hash = "sha256:655726919b75ab3c34cdad39da5c530ac6fa32696fb23119e36b64adcfca174a"}, + {file = "grpcio-1.74.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1a2b06afe2e50ebfd46247ac3ba60cac523f54ec7792ae9ba6073c12daf26f0a"}, + {file = "grpcio-1.74.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f251c355167b2360537cf17bea2cf0197995e551ab9da6a0a59b3da5e8704f9"}, + {file = "grpcio-1.74.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:8f7b5882fb50632ab1e48cb3122d6df55b9afabc265582808036b6e51b9fd6b7"}, + {file = "grpcio-1.74.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:834988b6c34515545b3edd13e902c1acdd9f2465d386ea5143fb558f153a7176"}, + {file = "grpcio-1.74.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:22b834cef33429ca6cc28303c9c327ba9a3fafecbf62fae17e9a7b7163cc43ac"}, + {file = "grpcio-1.74.0-cp39-cp39-win32.whl", hash = "sha256:7d95d71ff35291bab3f1c52f52f474c632db26ea12700c2ff0ea0532cb0b5854"}, + {file = "grpcio-1.74.0-cp39-cp39-win_amd64.whl", hash = "sha256:ecde9ab49f58433abe02f9ed076c7b5be839cf0153883a6d23995937a82392fa"}, + {file = "grpcio-1.74.0.tar.gz", hash = "sha256:80d1f4fbb35b0742d3e3d3bb654b7381cd5f015f8497279a1e9c21ba623e01b1"}, +] + +[package.extras] +protobuf = ["grpcio-tools (>=1.74.0)"] + [[package]] name = "hightime" version = "0.2.2" @@ -811,6 +875,22 @@ files = [ {file = "mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558"}, ] +[[package]] +name = "ni-datamonikers-v1-client" +version = "0.1.0.dev0" +description = "gRPC Client for NI Data Moniker Service" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "ni_datamonikers_v1_client-0.1.0.dev0-py3-none-any.whl", hash = "sha256:1491badadb77782169e86e51f35cc4a216ed1b1272ff59bc8893b31904f98a58"}, + {file = "ni_datamonikers_v1_client-0.1.0.dev0.tar.gz", hash = "sha256:757f452b0357ca9e17af8de9fc54cc552e2283f9a21ddcff59a031b977dbb904"}, +] + +[package.dependencies] +ni-datamonikers-v1-proto = ">=0.1.0.dev0" +ni-grpc-extensions = ">=0.1.0.dev0" + [[package]] name = "ni-datamonikers-v1-proto" version = "0.1.0.dev0" @@ -827,33 +907,114 @@ files = [ protobuf = ">=4.21" [[package]] -name = "ni-measurements-data-v1-proto" +name = "ni-grpc-extensions" +version = "0.1.0.dev1" +description = "gRPC Extensions" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "ni_grpc_extensions-0.1.0.dev1-py3-none-any.whl", hash = "sha256:171a16303a2cfcbd2f29ad5df448bf6b89b399be3ba52fc0c2e755c2e7075075"}, + {file = "ni_grpc_extensions-0.1.0.dev1.tar.gz", hash = "sha256:99af79ab9054b15b8682c9540ea4e474236bfaab0b271b42731ba9fd2c5bb4c7"}, +] + +[package.dependencies] +grpcio = ">=1.49.0,<2.0" +traceloggingdynamic = {version = ">=1.0", markers = "sys_platform == \"win32\""} + +[[package]] +name = "ni-measurementlink-discovery-v1-client" version = "0.1.0.dev0" +description = "gRPC Client for NI Discovery Service" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "ni_measurementlink_discovery_v1_client-0.1.0.dev0-py3-none-any.whl", hash = "sha256:b27abeddb3465e2be3a8142f0884eaeabff82d89040a76d026501d8527064167"}, + {file = "ni_measurementlink_discovery_v1_client-0.1.0.dev0.tar.gz", hash = "sha256:b964d48bc7942fc1eb6bcc5b03ce1a3fb031e9fa19d7d1a92c3c85b92fc44c17"}, +] + +[package.dependencies] +grpcio = ">=1.49.0,<2.0" +ni-grpc-extensions = ">=0.1.0.dev0" +ni-measurementlink-discovery-v1-proto = ">=0.1.0.dev0" +pywin32 = {version = ">=303", markers = "sys_platform == \"win32\""} + +[[package]] +name = "ni-measurementlink-discovery-v1-proto" +version = "0.1.0.dev1" +description = "Protobuf data types for NI discovery gRPC APIs" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "ni_measurementlink_discovery_v1_proto-0.1.0.dev1-py3-none-any.whl", hash = "sha256:2525e5c2975b6c3b5d0127a55c974a077a56d35e42ae1203c6063770b87e3062"}, + {file = "ni_measurementlink_discovery_v1_proto-0.1.0.dev1.tar.gz", hash = "sha256:75ebca4560d1e58d8ba585d6b1b8ea9923327d3ed5cc2cb6b9d8cc8d8931aa4e"}, +] + +[package.dependencies] +protobuf = ">=4.21" + +[[package]] +name = "ni-measurements-data-v1-client" +version = "0.1.0.dev0" +description = "gRPC Client for NI Data Store Service" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "ni_measurements_data_v1_client-0.1.0.dev0-py3-none-any.whl", hash = "sha256:5ce6933fc60d33ebb7d8b9abd205137323bfa4b0df2f5a578321632dd4edc0ff"}, + {file = "ni_measurements_data_v1_client-0.1.0.dev0.tar.gz", hash = "sha256:88d2ac07f303d9a11e0db91af02aab961951b7684065ec7c586ce141c066e4a6"}, +] + +[package.dependencies] +ni-measurementlink-discovery-v1-client = ">=0.1.0.dev0" +ni-measurements-data-v1-proto = ">=0.1.0.dev1" + +[[package]] +name = "ni-measurements-data-v1-proto" +version = "0.1.0.dev1" description = "Protobuf data types and service stubs for NI data store gRPC APIs" optional = false python-versions = "<4.0,>=3.9" groups = ["main"] files = [ - {file = "ni_measurements_data_v1_proto-0.1.0.dev0-py3-none-any.whl", hash = "sha256:7f650bde80e276195ec155d1925f06a12e60a96828c9ed8712ab85e999b6109e"}, - {file = "ni_measurements_data_v1_proto-0.1.0.dev0.tar.gz", hash = "sha256:206430bd5f2cafd21e69296027159dd03c11e6f9750ced2ee7ee3e71ea10f2b3"}, + {file = "ni_measurements_data_v1_proto-0.1.0.dev1-py3-none-any.whl", hash = "sha256:7a6d3b2e94ef7ced6ba29d6203498da96e226840cacfe8a5a5ea24040b08ec75"}, + {file = "ni_measurements_data_v1_proto-0.1.0.dev1.tar.gz", hash = "sha256:b78440a8cee40c09dcf8805e613c4866a7d4397422903a8edca9c7df98e34d9a"}, ] [package.dependencies] ni-datamonikers-v1-proto = ">=0.1.0.dev0" -ni-measurements-metadata-v1-proto = ">=0.1.0.dev0" +ni-measurements-metadata-v1-proto = ">=0.1.0.dev1" ni-protobuf-types = ">=0.1.0.dev3" protobuf = ">=4.21" [[package]] -name = "ni-measurements-metadata-v1-proto" +name = "ni-measurements-metadata-v1-client" version = "0.1.0.dev0" +description = "gRPC Client for NI Metadata Store Service" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "ni_measurements_metadata_v1_client-0.1.0.dev0-py3-none-any.whl", hash = "sha256:42d4c11d6ac717b2dfca5e57d2136024202f689716f230eae2664b7ac670c424"}, + {file = "ni_measurements_metadata_v1_client-0.1.0.dev0.tar.gz", hash = "sha256:4b5c3aa2d59d437e7f9d2577d79d9430cfd00955f88e855b1d1a9c75ea8a0228"}, +] + +[package.dependencies] +ni-measurementlink-discovery-v1-client = ">=0.1.0.dev0" +ni-measurements-metadata-v1-proto = ">=0.1.0.dev1" + +[[package]] +name = "ni-measurements-metadata-v1-proto" +version = "0.1.0.dev1" description = "Protobuf data types and service stub for NI metadata store gRPC APIs" optional = false python-versions = "<4.0,>=3.9" groups = ["main"] files = [ - {file = "ni_measurements_metadata_v1_proto-0.1.0.dev0-py3-none-any.whl", hash = "sha256:cab8ae264cd33ea16758f37b72efa5d1dc4ee06d635be7c5225de54c420b5641"}, - {file = "ni_measurements_metadata_v1_proto-0.1.0.dev0.tar.gz", hash = "sha256:37768f4187d76f508ebbbcd178b8754ea587e6eddff5bcc15f1685732c008854"}, + {file = "ni_measurements_metadata_v1_proto-0.1.0.dev1-py3-none-any.whl", hash = "sha256:1300d9dd6ba335355692d013342dce516405578519c7548c03a57442c8be2ce6"}, + {file = "ni_measurements_metadata_v1_proto-0.1.0.dev1.tar.gz", hash = "sha256:8c05c2715dc34e21cfae3bf95ea1a07dd1c35f1203ddfdede488e385009df1dc"}, ] [package.dependencies] @@ -1440,6 +1601,37 @@ pytest = ">=6.2.5" [package.extras] dev = ["pre-commit", "pytest-asyncio", "tox"] +[[package]] +name = "pywin32" +version = "311" +description = "Python for Window Extensions" +optional = false +python-versions = "*" +groups = ["main"] +markers = "sys_platform == \"win32\"" +files = [ + {file = "pywin32-311-cp310-cp310-win32.whl", hash = "sha256:d03ff496d2a0cd4a5893504789d4a15399133fe82517455e78bad62efbb7f0a3"}, + {file = "pywin32-311-cp310-cp310-win_amd64.whl", hash = "sha256:797c2772017851984b97180b0bebe4b620bb86328e8a884bb626156295a63b3b"}, + {file = "pywin32-311-cp310-cp310-win_arm64.whl", hash = "sha256:0502d1facf1fed4839a9a51ccbcc63d952cf318f78ffc00a7e78528ac27d7a2b"}, + {file = "pywin32-311-cp311-cp311-win32.whl", hash = "sha256:184eb5e436dea364dcd3d2316d577d625c0351bf237c4e9a5fabbcfa5a58b151"}, + {file = "pywin32-311-cp311-cp311-win_amd64.whl", hash = "sha256:3ce80b34b22b17ccbd937a6e78e7225d80c52f5ab9940fe0506a1a16f3dab503"}, + {file = "pywin32-311-cp311-cp311-win_arm64.whl", hash = "sha256:a733f1388e1a842abb67ffa8e7aad0e70ac519e09b0f6a784e65a136ec7cefd2"}, + {file = "pywin32-311-cp312-cp312-win32.whl", hash = "sha256:750ec6e621af2b948540032557b10a2d43b0cee2ae9758c54154d711cc852d31"}, + {file = "pywin32-311-cp312-cp312-win_amd64.whl", hash = "sha256:b8c095edad5c211ff31c05223658e71bf7116daa0ecf3ad85f3201ea3190d067"}, + {file = "pywin32-311-cp312-cp312-win_arm64.whl", hash = "sha256:e286f46a9a39c4a18b319c28f59b61de793654af2f395c102b4f819e584b5852"}, + {file = "pywin32-311-cp313-cp313-win32.whl", hash = "sha256:f95ba5a847cba10dd8c4d8fefa9f2a6cf283b8b88ed6178fa8a6c1ab16054d0d"}, + {file = "pywin32-311-cp313-cp313-win_amd64.whl", hash = "sha256:718a38f7e5b058e76aee1c56ddd06908116d35147e133427e59a3983f703a20d"}, + {file = "pywin32-311-cp313-cp313-win_arm64.whl", hash = "sha256:7b4075d959648406202d92a2310cb990fea19b535c7f4a78d3f5e10b926eeb8a"}, + {file = "pywin32-311-cp314-cp314-win32.whl", hash = "sha256:b7a2c10b93f8986666d0c803ee19b5990885872a7de910fc460f9b0c2fbf92ee"}, + {file = "pywin32-311-cp314-cp314-win_amd64.whl", hash = "sha256:3aca44c046bd2ed8c90de9cb8427f581c479e594e99b5c0bb19b29c10fd6cb87"}, + {file = "pywin32-311-cp314-cp314-win_arm64.whl", hash = "sha256:a508e2d9025764a8270f93111a970e1d0fbfc33f4153b388bb649b7eec4f9b42"}, + {file = "pywin32-311-cp38-cp38-win32.whl", hash = "sha256:6c6f2969607b5023b0d9ce2541f8d2cbb01c4f46bc87456017cf63b73f1e2d8c"}, + {file = "pywin32-311-cp38-cp38-win_amd64.whl", hash = "sha256:c8015b09fb9a5e188f83b7b04de91ddca4658cee2ae6f3bc483f0b21a77ef6cd"}, + {file = "pywin32-311-cp39-cp39-win32.whl", hash = "sha256:aba8f82d551a942cb20d4a83413ccbac30790b50efb89a75e4f586ac0bb8056b"}, + {file = "pywin32-311-cp39-cp39-win_amd64.whl", hash = "sha256:e0c4cfb0621281fe40387df582097fd796e80430597cb9944f0ae70447bacd91"}, + {file = "pywin32-311-cp39-cp39-win_arm64.whl", hash = "sha256:62ea666235135fee79bb154e695f3ff67370afefd71bd7fea7512fc70ef31e3d"}, +] + [[package]] name = "pyyaml" version = "6.0.2" @@ -1950,6 +2142,19 @@ files = [ {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, ] +[[package]] +name = "traceloggingdynamic" +version = "1.0.1" +description = "Generates Event Tracing for Windows events using TraceLogging" +optional = false +python-versions = ">=3.6" +groups = ["main"] +markers = "sys_platform == \"win32\"" +files = [ + {file = "traceloggingdynamic-1.0.1-py3-none-any.whl", hash = "sha256:0e19da491a8960725b3622366487ae35f49d8f595bb2e4e5ce1795eb5928db7c"}, + {file = "traceloggingdynamic-1.0.1.tar.gz", hash = "sha256:d9dd4b291dd04c15e34181eed06f73fdf4ffa7b1f895b78217163def48ab1a52"}, +] + [[package]] name = "types-grpcio" version = "1.0.0.20250703" @@ -2029,4 +2234,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "ea4c9357b2eb06f4429fe68a17dc9a6dfe7e426deacb37704f079f5eeec4017f" +content-hash = "1904e27f5181893a7471255562cc5c5f5f858b12f9097b2060b7725036d63122" diff --git a/pyproject.toml b/pyproject.toml index dfc3c33..23e5fff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,8 +37,11 @@ requires-poetry = '>=2.1,<3.0' [tool.poetry.dependencies] python = "^3.9" protobuf = {version=">=4.21"} +ni-datamonikers-v1-client = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-datamonikers-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } +ni-measurements-data-v1-client = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-data-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } +ni-measurements-metadata-v1-client = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-metadata-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-protobuf-types = "*" nitypes = {version=">=0.1.0dev3", allow-prereleases=true} diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 1e2423b..2965ff4 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -1,75 +1,51 @@ -from datetime import datetime, timezone -from typing import Union - -from google.protobuf.timestamp_pb2 import Timestamp -from nitypes.waveform import AnalogWaveform, DigitalWaveform -from ni.datamonikers.v1.client import MonikerClient -from ni.datastore.types import ( - StoredDataValue, - Measurement, - PassFailStatus, - Moniker -) -from ni.measurements.data.v1.data_store_pb2 import ( - ErrorState, - MeasurementMetadata, - PassFailStatus, - PublishableData, - StoredDataValue, -) -from ni.measurements.data.v1.data_store_service_pb2 import PublishDataRequest, PublishDataResponse, CreateMeasurementRequest -from ni.measurements.data.v1.client import DataStoreClient -from ni.measurements.metadata.v1.client import MetadataStoreClient -from ni.protobuf.types.vector_pb2 import Vector +from nitypes.bintime import DateTime +from ni.datamonikers.v1.data_moniker_pb2 import Moniker +from ni.measurements.data.v1.data_store_pb2 import PublishedMeasurement, Outcome, ErrorInformation class Client: """Datastore client for publishing and reading data.""" - __slots__ = ("_data_store_client", "_metadata_store_client", "_moniker_client") - - _data_store_client: DataStoreClient - _metadata_store_client: MetadataStoreClient - def __init__(self): - self._data_store_client = DataStoreClient() - self._metadata_store_client = MetadataStoreClient() - - def publish_bool(self, value: bool) -> StoredDataValue: - publishable_data = PublishableData() - publishable_data.scalar.bool_value = value - create_measurement_request = CreateMeasurementRequest(measurement=MeasurementMetadata(name="Boolean Measurement")) - measurement_id = self._data_store_client.create_measurement(create_measurement_request).id - return self._publish_data( - publishable_data, - "Simple Boolean", - measurement_id=measurement_id - ) + pass - def read_bool(self, stored_data_value: StoredDataValue) -> bool: - moniker = stored_data_value.moniker - moniker_client = MonikerClient(service_location='localhost:53361') - result = moniker_client.read_from_moniker(moniker) - vector = Vector() - result.value.Unpack(vector) - return vector.bool_array.values[0] - - def _publish_data( + def publish_measurement_data( self, - data: PublishableData, - description: str, - measurement_id: str - ) -> StoredDataValue: - timestamp = datetime.now(timezone.utc) - request_timestamp = Timestamp() - request_timestamp.FromDatetime(timestamp) - publish_request = PublishDataRequest( - notes=description, - data=data, - timestamp=request_timestamp, - pass_fail_status=PassFailStatus.PASS_FAIL_STATUS_FAILED, - error_state=ErrorState.ERROR_STATE_NO_ERROR, - measurement_id=measurement_id - ) - - publish_response = self._data_store_client.publish_data(publish_request) - return publish_response.stored_data_value + step_id: str, + name: str, + notes: str, + timestamp: DateTime, + data: object, # More strongly typed Union[bool, AnalogWaveform] can be used if needed + outcome: Outcome, + error_info: ErrorInformation, + hardware_item_ids: list[str], + software_item_ids: list[str], + test_adapter_ids: list[str] + ) -> PublishedMeasurement: + return PublishedMeasurement() + + def read_measurement_data(self, moniker: Moniker) -> object: # What type is this object? + return True + + def create_step( + self, + step_name: str, + step_type: str, + notes: str, + start_time: DateTime, + end_time: DateTime, + test_result_id: str = "", + ) -> str: + return "step_id" + + def create_test_result( + self, + test_name: str, + uut_instance_id: str = "", + operator_id: str = "", + test_station_id: str = "", + test_description_id: str = "", + software_item_ids: list[str] = [], + hardware_item_ids: list[str] = [], + test_adapter_ids: list[str] = [], + ) -> str: + return "test_result_id" \ No newline at end of file diff --git a/src/ni/datastore/types.py b/src/ni/datastore/types.py index 879bbaa..e6946c6 100644 --- a/src/ni/datastore/types.py +++ b/src/ni/datastore/types.py @@ -6,11 +6,6 @@ class Measurement: def __init__(self): pass -class StoredDataValue: - """Minimal StoredDataValue class.""" - - def __init__(self): - pass class PassFailStatus(Enum): PASS_FAIL_STATUS_UNSPECIFIED = 0 @@ -18,6 +13,7 @@ class PassFailStatus(Enum): PASS_FAIL_STATUS_FAILED = 2 PASS_FAIL_STATUS_INDETERMINATE = 3 + class Moniker: """Minimal Moniker class.""" diff --git a/tests/placeholder.py b/tests/placeholder.py deleted file mode 100644 index ffa8b69..0000000 --- a/tests/placeholder.py +++ /dev/null @@ -1 +0,0 @@ -"""Temporary placeholder test.""" \ No newline at end of file diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index 974038b..052e171 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -1,7 +1,39 @@ """Contains tests to validate the datastore client functionality.""" - from __future__ import annotations +import pytest + +from nitypes.bintime import DateTime +from ni.datastore.client import Client +from ni.measurements.data.v1.data_store_pb2 import Outcome, ErrorInformation + def test__datastore_client() -> None: assert True + +# Not Implemented in client.py +# @pytest.mark.parametrize("value", [True, False]) +# def test_publish_and_read_bool(value: bool): +# client = Client() +# step_id = client.create_step( +# "Test Step", +# "Type A", +# "This is a test step.", +# start_time=DateTime.now(), +# end_time=DateTime.now(), +# ) +# published_measurement = client.publish_measurement_data( +# step_id, +# "test_bool_publish", +# "Notes on measurement", +# DateTime.now(), +# value, +# Outcome(), +# ErrorInformation(), +# [], +# [], +# []) +# print(f"Published boolean value {value}, stored data value: {published_measurement}") +# read_value = client.read_measurement_data(published_measurement.moniker) +# print(f"Read boolean value: {read_value}") +# assert read_value == value, f"Expected {value}, got {read_value}" From 10671e0071a34d83c60e560bd2d8d1931ad86fd4 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Mon, 15 Sep 2025 16:26:54 -0500 Subject: [PATCH 05/15] Fix linter errors --- examples/placeholder.py | 2 +- src/ni/datastore/__init__.py | 2 +- src/ni/datastore/client.py | 28 ++++++++++++++++++-------- src/ni/datastore/types.py | 21 ------------------- tests/unit/test_ni_datastore_client.py | 8 ++------ 5 files changed, 24 insertions(+), 37 deletions(-) delete mode 100644 src/ni/datastore/types.py diff --git a/examples/placeholder.py b/examples/placeholder.py index da732a9..31f1667 100644 --- a/examples/placeholder.py +++ b/examples/placeholder.py @@ -1 +1 @@ -"""Temporary placeholder example.""" \ No newline at end of file +"""Temporary placeholder example.""" diff --git a/src/ni/datastore/__init__.py b/src/ni/datastore/__init__.py index ee3ff99..36fc2fe 100644 --- a/src/ni/datastore/__init__.py +++ b/src/ni/datastore/__init__.py @@ -2,4 +2,4 @@ from ni.datastore.client import Client -__all__ = ["Client"] \ No newline at end of file +__all__ = ["Client"] diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 2965ff4..81c677e 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -1,11 +1,19 @@ -from nitypes.bintime import DateTime +"""Datastore client for publishing and reading data.""" + from ni.datamonikers.v1.data_moniker_pb2 import Moniker -from ni.measurements.data.v1.data_store_pb2 import PublishedMeasurement, Outcome, ErrorInformation +from ni.measurements.data.v1.data_store_pb2 import ( + ErrorInformation, + Outcome, + PublishedMeasurement, +) +from nitypes.bintime import DateTime + class Client: """Datastore client for publishing and reading data.""" - def __init__(self): + def __init__(self) -> None: + """Initialize the Client.""" pass def publish_measurement_data( @@ -14,16 +22,18 @@ def publish_measurement_data( name: str, notes: str, timestamp: DateTime, - data: object, # More strongly typed Union[bool, AnalogWaveform] can be used if needed + data: object, # More strongly typed Union[bool, AnalogWaveform] can be used if needed outcome: Outcome, error_info: ErrorInformation, hardware_item_ids: list[str], software_item_ids: list[str], - test_adapter_ids: list[str] + test_adapter_ids: list[str], ) -> PublishedMeasurement: + """Publish measurement data to the datastore.""" return PublishedMeasurement() - def read_measurement_data(self, moniker: Moniker) -> object: # What type is this object? + def read_measurement_data(self, moniker: Moniker) -> object: + """Read measurement data from the datastore.""" return True def create_step( @@ -35,8 +45,9 @@ def create_step( end_time: DateTime, test_result_id: str = "", ) -> str: + """Create a test step in the datastore.""" return "step_id" - + def create_test_result( self, test_name: str, @@ -48,4 +59,5 @@ def create_test_result( hardware_item_ids: list[str] = [], test_adapter_ids: list[str] = [], ) -> str: - return "test_result_id" \ No newline at end of file + """Create a test result in the datastore.""" + return "test_result_id" diff --git a/src/ni/datastore/types.py b/src/ni/datastore/types.py deleted file mode 100644 index e6946c6..0000000 --- a/src/ni/datastore/types.py +++ /dev/null @@ -1,21 +0,0 @@ -from enum import Enum - -class Measurement: - """Minimal Measurement class.""" - - def __init__(self): - pass - - -class PassFailStatus(Enum): - PASS_FAIL_STATUS_UNSPECIFIED = 0 - PASS_FAIL_STATUS_PASSED = 1 - PASS_FAIL_STATUS_FAILED = 2 - PASS_FAIL_STATUS_INDETERMINATE = 3 - - -class Moniker: - """Minimal Moniker class.""" - - def __init__(self): - pass \ No newline at end of file diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index 052e171..c20b670 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -1,16 +1,12 @@ """Contains tests to validate the datastore client functionality.""" -from __future__ import annotations - -import pytest -from nitypes.bintime import DateTime -from ni.datastore.client import Client -from ni.measurements.data.v1.data_store_pb2 import Outcome, ErrorInformation +from __future__ import annotations def test__datastore_client() -> None: assert True + # Not Implemented in client.py # @pytest.mark.parametrize("value", [True, False]) # def test_publish_and_read_bool(value: bool): From 43a93d0d5411c4117d4e67d761deec64ecea3a35 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Mon, 15 Sep 2025 16:32:01 -0500 Subject: [PATCH 06/15] Suppress sphinx import warnings --- docs/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index df1e0c6..15318d5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -53,6 +53,11 @@ autodoc_typehints = "description" autoapi_file_patterns = ["*.pyi", "*.py"] +# Optional: suppress warnings globally +suppress_warnings = [ + "autoapi.python_import_resolution" +] + def process_docstring(app, what, name, obj, options, lines): """Make edits to docstrings as necessary""" From 80aef2321c9299c2b2f90f6e97c8d0f8293baa36 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Mon, 15 Sep 2025 17:00:34 -0500 Subject: [PATCH 07/15] Suppress sphinx import warnings --- docs/conf.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 15318d5..7cb70e8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -79,10 +79,6 @@ def setup(sphinx): ".DS_Store", ] -suppress_warnings = [ - "docutils", -] - intersphinx_mapping = { "python": ("https://docs.python.org/3", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), From 47272b25e2892d4884efa7d6a8e7dda23423326e Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Tue, 16 Sep 2025 13:55:40 -0500 Subject: [PATCH 08/15] Add a boolean test --- poetry.lock | 2 +- pyproject.toml | 2 +- src/ni/datastore/client.py | 40 +++++++++-- tests/unit/test_ni_datastore_client.py | 94 ++++++++++++++++++-------- 4 files changed, 102 insertions(+), 36 deletions(-) diff --git a/poetry.lock b/poetry.lock index fc4b510..e2d64f1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2234,4 +2234,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "1904e27f5181893a7471255562cc5c5f5f858b12f9097b2060b7725036d63122" +content-hash = "4b1007fc7a07dd20daab247c08dc812d3e7bb898ceef54857ce5b49182fff9b1" diff --git a/pyproject.toml b/pyproject.toml index 23e5fff..608994c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ ni-measurements-data-v1-client = { version = ">=0.1.0.dev0", allow-prereleases = ni-measurements-data-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-metadata-v1-client = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-metadata-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } -ni-protobuf-types = "*" +ni-protobuf-types = { version = ">=0.1.0.dev3", allow-prereleases = true } nitypes = {version=">=0.1.0dev3", allow-prereleases=true} [tool.poetry.group.dev.dependencies] diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 81c677e..8bd4a7c 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -1,20 +1,36 @@ """Datastore client for publishing and reading data.""" from ni.datamonikers.v1.data_moniker_pb2 import Moniker +from ni.measurements.data.v1.client import DataStoreClient from ni.measurements.data.v1.data_store_pb2 import ( ErrorInformation, Outcome, PublishedMeasurement, ) +from ni.measurements.data.v1.data_store_service_pb2 import PublishMeasurementRequest +from ni.measurements.metadata.v1.client import MetadataStoreClient +from ni.protobuf.types.precision_timestamp_conversion import ( + bintime_datetime_to_protobuf, +) from nitypes.bintime import DateTime class Client: """Datastore client for publishing and reading data.""" - def __init__(self) -> None: + __slots__ = ("_data_store_client", "_metadata_store_client", "_moniker_client") + + _data_store_client: DataStoreClient + _metadata_store_client: MetadataStoreClient + + def __init__( + self, + data_store_client: DataStoreClient | None = None, + metadata_store_client: MetadataStoreClient | None = None, + ) -> None: """Initialize the Client.""" - pass + self._data_store_client = data_store_client or DataStoreClient() + self._metadata_store_client = metadata_store_client or MetadataStoreClient() def publish_measurement_data( self, @@ -23,14 +39,30 @@ def publish_measurement_data( notes: str, timestamp: DateTime, data: object, # More strongly typed Union[bool, AnalogWaveform] can be used if needed - outcome: Outcome, + outcome: Outcome.ValueType, error_info: ErrorInformation, hardware_item_ids: list[str], software_item_ids: list[str], test_adapter_ids: list[str], ) -> PublishedMeasurement: """Publish measurement data to the datastore.""" - return PublishedMeasurement() + publish_request = PublishMeasurementRequest( + step_id=step_id, + measurement_name=name, + notes=notes, + timestamp=bintime_datetime_to_protobuf(timestamp), + outcome=outcome, + error_information=error_info, + hardware_item_ids=hardware_item_ids, + software_item_ids=software_item_ids, + test_adapter_ids=test_adapter_ids, + ) + + if isinstance(data, bool): + publish_request.scalar.bool_value = data + + publish_response = self._data_store_client.publish_measurement(publish_request) + return publish_response.published_measurement def read_measurement_data(self, moniker: Moniker) -> object: """Read measurement data from the datastore.""" diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index c20b670..02fdd2b 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -2,34 +2,68 @@ from __future__ import annotations +import datetime as dt +import unittest.mock +from typing import Any +from unittest.mock import Mock -def test__datastore_client() -> None: - assert True - - -# Not Implemented in client.py -# @pytest.mark.parametrize("value", [True, False]) -# def test_publish_and_read_bool(value: bool): -# client = Client() -# step_id = client.create_step( -# "Test Step", -# "Type A", -# "This is a test step.", -# start_time=DateTime.now(), -# end_time=DateTime.now(), -# ) -# published_measurement = client.publish_measurement_data( -# step_id, -# "test_bool_publish", -# "Notes on measurement", -# DateTime.now(), -# value, -# Outcome(), -# ErrorInformation(), -# [], -# [], -# []) -# print(f"Published boolean value {value}, stored data value: {published_measurement}") -# read_value = client.read_measurement_data(published_measurement.moniker) -# print(f"Read boolean value: {read_value}") -# assert read_value == value, f"Expected {value}, got {read_value}" +import pytest +from ni.datastore.client import Client +from ni.measurements.data.v1.data_store_pb2 import ( + ErrorInformation, + Outcome, + PublishedMeasurement, +) +from ni.measurements.data.v1.data_store_service_pb2 import PublishMeasurementResponse +from nitypes.bintime import DateTime +from pytest_mock import MockerFixture + + +@pytest.mark.parametrize("value", [True, False]) +def test__publish_measurement_data__calls_datastoreclient( + mocked_datastore_client: Mock, value: bool +) -> None: + timestamp = DateTime.now(tz=dt.timezone.utc) + published_measurement = PublishedMeasurement() + publish_measurement_response = PublishMeasurementResponse( + published_measurement=published_measurement + ) + mocked_datastore_client.publish_measurement.return_value = publish_measurement_response + client = Client(data_store_client=mocked_datastore_client) + # Now, when client.publish_measurement_data calls foo.MyClass().publish(), it will use the mock + client.publish_measurement_data( + "step_id", + "name", + "notes", + timestamp, + value, + Outcome.OUTCOME_PASSED, + ErrorInformation(), + [], + [], + [], + ) + args, __ = mocked_datastore_client.publish_measurement.call_args + request = args[0] # The PublishMeasurementRequest object + + # Now assert on its fields + assert request.step_id == "step_id" + assert request.measurement_name == "name" + assert request.notes == "notes" + assert request.timestamp == unittest.mock.ANY + assert request.scalar.bool_value == value + assert request.outcome == Outcome.OUTCOME_PASSED + assert request.error_information == ErrorInformation() + assert request.hardware_item_ids == [] + assert request.software_item_ids == [] + assert request.test_adapter_ids == [] + + +@pytest.fixture +def mocked_datastore_client(mocker: MockerFixture) -> Any: + mock_datastore_client = mocker.patch( + "ni.measurements.data.v1.client.DataStoreClient", autospec=True + ) + # Set up the mock's publish method + mock_datastore_instance = mock_datastore_client.return_value + return mock_datastore_instance From 4f9af731a3b5f985456694468e92b1fd8f197211 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Tue, 16 Sep 2025 14:16:47 -0500 Subject: [PATCH 09/15] Fix unit tests - Python 3.9 doesn't like DataStoreClient | None as a type hint --- poetry.lock | 2 +- pyproject.toml | 4 ---- src/ni/datastore/client.py | 6 ++++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/poetry.lock b/poetry.lock index e2d64f1..fde2a80 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2234,4 +2234,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "4b1007fc7a07dd20daab247c08dc812d3e7bb898ceef54857ce5b49182fff9b1" +content-hash = "9c5f6acfde6ed440b06801732ccf6258c8eab872f5f5dcd6cc78682603b10b56" diff --git a/pyproject.toml b/pyproject.toml index 608994c..e865706 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,13 +38,9 @@ requires-poetry = '>=2.1,<3.0' python = "^3.9" protobuf = {version=">=4.21"} ni-datamonikers-v1-client = { version = ">=0.1.0.dev0", allow-prereleases = true } -ni-datamonikers-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-data-v1-client = { version = ">=0.1.0.dev0", allow-prereleases = true } -ni-measurements-data-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-measurements-metadata-v1-client = { version = ">=0.1.0.dev0", allow-prereleases = true } -ni-measurements-metadata-v1-proto = { version = ">=0.1.0.dev0", allow-prereleases = true } ni-protobuf-types = { version = ">=0.1.0.dev3", allow-prereleases = true } -nitypes = {version=">=0.1.0dev3", allow-prereleases=true} [tool.poetry.group.dev.dependencies] types-grpcio = ">=1.0" diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 8bd4a7c..7f03751 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -1,5 +1,7 @@ """Datastore client for publishing and reading data.""" +from typing import Optional + from ni.datamonikers.v1.data_moniker_pb2 import Moniker from ni.measurements.data.v1.client import DataStoreClient from ni.measurements.data.v1.data_store_pb2 import ( @@ -25,8 +27,8 @@ class Client: def __init__( self, - data_store_client: DataStoreClient | None = None, - metadata_store_client: MetadataStoreClient | None = None, + data_store_client: Optional[DataStoreClient] = None, + metadata_store_client: Optional[MetadataStoreClient] = None, ) -> None: """Initialize the Client.""" self._data_store_client = data_store_client or DataStoreClient() From c8c73f1fc57974e5e2cbf41feb8d399e2e0f3cc1 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Tue, 16 Sep 2025 14:50:12 -0500 Subject: [PATCH 10/15] Change read signature to use a TypeVar. --- src/ni/datastore/client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 7f03751..598e818 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -1,6 +1,6 @@ """Datastore client for publishing and reading data.""" -from typing import Optional +from typing import Optional, Type, TypeVar, cast from ni.datamonikers.v1.data_moniker_pb2 import Moniker from ni.measurements.data.v1.client import DataStoreClient @@ -16,6 +16,8 @@ ) from nitypes.bintime import DateTime +TRead = TypeVar("TRead") +TWrite = TypeVar("TWrite") class Client: """Datastore client for publishing and reading data.""" @@ -40,7 +42,7 @@ def publish_measurement_data( name: str, notes: str, timestamp: DateTime, - data: object, # More strongly typed Union[bool, AnalogWaveform] can be used if needed + data: object, # More strongly typed Union[bool, AnalogWaveform] can be used if needed outcome: Outcome.ValueType, error_info: ErrorInformation, hardware_item_ids: list[str], @@ -66,9 +68,9 @@ def publish_measurement_data( publish_response = self._data_store_client.publish_measurement(publish_request) return publish_response.published_measurement - def read_measurement_data(self, moniker: Moniker) -> object: + def read_measurement_data(self, moniker: Moniker, expected_type: Type[TRead]) -> TRead: """Read measurement data from the datastore.""" - return True + return cast(TRead, True) def create_step( self, From 96b149c416cd5a60651916c5134b70d82e702067 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Tue, 16 Sep 2025 16:15:26 -0500 Subject: [PATCH 11/15] Add test to read a boolean --- src/ni/datastore/client.py | 30 ++++++--- tests/unit/test_ni_datastore_client.py | 86 +++++++++++++++++++++++++- 2 files changed, 105 insertions(+), 11 deletions(-) diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 598e818..2807abf 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -1,7 +1,10 @@ """Datastore client for publishing and reading data.""" +from __future__ import annotations -from typing import Optional, Type, TypeVar, cast - +from collections.abc import Iterable +from typing import Type, TypeVar, cast +import numpy as np +from ni.datamonikers.v1.client import MonikerClient from ni.datamonikers.v1.data_moniker_pb2 import Moniker from ni.measurements.data.v1.client import DataStoreClient from ni.measurements.data.v1.data_store_pb2 import ( @@ -14,7 +17,9 @@ from ni.protobuf.types.precision_timestamp_conversion import ( bintime_datetime_to_protobuf, ) +from ni.protobuf.types.waveform_conversion import float64_analog_waveform_to_protobuf from nitypes.bintime import DateTime +from nitypes.waveform import AnalogWaveform TRead = TypeVar("TRead") TWrite = TypeVar("TWrite") @@ -26,15 +31,18 @@ class Client: _data_store_client: DataStoreClient _metadata_store_client: MetadataStoreClient + _moniker_client: MonikerClient def __init__( self, - data_store_client: Optional[DataStoreClient] = None, - metadata_store_client: Optional[MetadataStoreClient] = None, + data_store_client: DataStoreClient | None = None, + metadata_store_client: MetadataStoreClient | None = None, + moniker_client: MonikerClient | None = None, ) -> None: """Initialize the Client.""" self._data_store_client = data_store_client or DataStoreClient() self._metadata_store_client = metadata_store_client or MetadataStoreClient() + self._moniker_client = moniker_client or MonikerClient(service_location="dummy") def publish_measurement_data( self, @@ -45,9 +53,9 @@ def publish_measurement_data( data: object, # More strongly typed Union[bool, AnalogWaveform] can be used if needed outcome: Outcome.ValueType, error_info: ErrorInformation, - hardware_item_ids: list[str], - software_item_ids: list[str], - test_adapter_ids: list[str], + hardware_item_ids: Iterable[str] = tuple(), + software_item_ids: Iterable[str] = tuple(), + test_adapter_ids: Iterable[str] = tuple(), ) -> PublishedMeasurement: """Publish measurement data to the datastore.""" publish_request = PublishMeasurementRequest( @@ -64,13 +72,19 @@ def publish_measurement_data( if isinstance(data, bool): publish_request.scalar.bool_value = data + elif isinstance(data, AnalogWaveform): + # Assuming data is of type AnalogWaveform + analog_waveform = cast(AnalogWaveform[np.float64], data) + publish_request.double_analog_waveform.CopyFrom(float64_analog_waveform_to_protobuf(analog_waveform)) publish_response = self._data_store_client.publish_measurement(publish_request) return publish_response.published_measurement def read_measurement_data(self, moniker: Moniker, expected_type: Type[TRead]) -> TRead: """Read measurement data from the datastore.""" - return cast(TRead, True) + self._moniker_client._service_location = moniker.service_location + result = self._moniker_client.read_from_moniker(moniker) + return cast(TRead, result.value) def create_step( self, diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index 02fdd2b..62e7856 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -4,23 +4,31 @@ import datetime as dt import unittest.mock -from typing import Any +from typing import Any, cast from unittest.mock import Mock import pytest +from ni.datamonikers.v1.data_moniker_pb2 import Moniker, ReadFromMonikerResult from ni.datastore.client import Client from ni.measurements.data.v1.data_store_pb2 import ( ErrorInformation, Outcome, PublishedMeasurement, ) -from ni.measurements.data.v1.data_store_service_pb2 import PublishMeasurementResponse +from ni.measurements.data.v1.data_store_service_pb2 import ( + PublishMeasurementRequest, + PublishMeasurementResponse +) +from ni.protobuf.types.waveform_conversion import float64_analog_waveform_to_protobuf +from ni.protobuf.types.waveform_pb2 import DoubleAnalogWaveform +from ni.protobuf.types.vector_pb2 import Vector +from nitypes.waveform import AnalogWaveform from nitypes.bintime import DateTime from pytest_mock import MockerFixture @pytest.mark.parametrize("value", [True, False]) -def test__publish_measurement_data__calls_datastoreclient( +def test__publish_boolean_data__calls_datastoreclient( mocked_datastore_client: Mock, value: bool ) -> None: timestamp = DateTime.now(tz=dt.timezone.utc) @@ -59,6 +67,68 @@ def test__publish_measurement_data__calls_datastoreclient( assert request.test_adapter_ids == [] +def test__publish_analog_waveform_data__calls_datastoreclient( + mocked_datastore_client: Mock +) -> None: + timestamp = DateTime.now(tz=dt.timezone.utc) + published_measurement = PublishedMeasurement() + publish_measurement_response = PublishMeasurementResponse( + published_measurement=published_measurement + ) + mocked_datastore_client.publish_measurement.return_value = publish_measurement_response + waveform_values = [1.0, 2.0, 3.0] + analog_waveform = AnalogWaveform.from_array_1d(waveform_values, dtype=float) + expected_protobuf_waveform = DoubleAnalogWaveform() + expected_protobuf_waveform.CopyFrom(float64_analog_waveform_to_protobuf(analog_waveform)) + client = Client(data_store_client=mocked_datastore_client) + # Now, when client.publish_measurement_data calls foo.MyClass().publish(), it will use the mock + client.publish_measurement_data( + "step_id", + "name", + "notes", + timestamp, + analog_waveform, + Outcome.OUTCOME_PASSED, + ErrorInformation(), + [], + [], + [], + ) + args, __ = mocked_datastore_client.publish_measurement.call_args + request = cast(PublishMeasurementRequest, args[0]) # The PublishMeasurementRequest object + + # Now assert on its fields + assert request.step_id == "step_id" + assert request.measurement_name == "name" + assert request.notes == "notes" + assert request.timestamp == unittest.mock.ANY + assert request.double_analog_waveform == expected_protobuf_waveform + assert request.outcome == Outcome.OUTCOME_PASSED + assert request.error_information == ErrorInformation() + assert request.hardware_item_ids == [] + assert request.software_item_ids == [] + assert request.test_adapter_ids == [] + + +def test__read_boolean_data__calls_monikerclient( + mocked_moniker_client: Mock +) -> None: + client = Client(moniker_client=mocked_moniker_client) + moniker = Moniker() + moniker.data_instance = 12 + moniker.data_source = "ABCD123" + moniker.service_location = "localhost:50051" + client.read_measurement_data(moniker, type[Vector]) + mocked_moniker_client.read_from_moniker.return_value = ReadFromMonikerResult() + + args, __ = mocked_moniker_client.read_from_moniker.call_args + requested_moniker = cast(Moniker, args[0]) + + assert requested_moniker.service_location == moniker.service_location + assert requested_moniker.data_instance == moniker.data_instance + assert requested_moniker.data_source == moniker.data_source + + @pytest.fixture def mocked_datastore_client(mocker: MockerFixture) -> Any: mock_datastore_client = mocker.patch( @@ -67,3 +137,13 @@ def mocked_datastore_client(mocker: MockerFixture) -> Any: # Set up the mock's publish method mock_datastore_instance = mock_datastore_client.return_value return mock_datastore_instance + + +@pytest.fixture +def mocked_moniker_client(mocker: MockerFixture) -> Any: + mock_moniker_client = mocker.patch( + "ni.datamonikers.v1.client.MonikerClient", autospec=True + ) + # Set up the mock's publish method + mock_moniker_instance = mock_moniker_client.return_value + return mock_moniker_instance From 50dc25c3839e2969918cc30a8efc85f3b372b6ec Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Tue, 16 Sep 2025 16:18:23 -0500 Subject: [PATCH 12/15] Fix linter errors --- src/ni/datastore/client.py | 9 +++++++-- tests/unit/test_ni_datastore_client.py | 18 +++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 2807abf..2d4a08e 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -1,8 +1,10 @@ """Datastore client for publishing and reading data.""" + from __future__ import annotations from collections.abc import Iterable from typing import Type, TypeVar, cast + import numpy as np from ni.datamonikers.v1.client import MonikerClient from ni.datamonikers.v1.data_moniker_pb2 import Moniker @@ -24,6 +26,7 @@ TRead = TypeVar("TRead") TWrite = TypeVar("TWrite") + class Client: """Datastore client for publishing and reading data.""" @@ -50,7 +53,7 @@ def publish_measurement_data( name: str, notes: str, timestamp: DateTime, - data: object, # More strongly typed Union[bool, AnalogWaveform] can be used if needed + data: object, # More strongly typed Union[bool, AnalogWaveform] can be used if needed outcome: Outcome.ValueType, error_info: ErrorInformation, hardware_item_ids: Iterable[str] = tuple(), @@ -75,7 +78,9 @@ def publish_measurement_data( elif isinstance(data, AnalogWaveform): # Assuming data is of type AnalogWaveform analog_waveform = cast(AnalogWaveform[np.float64], data) - publish_request.double_analog_waveform.CopyFrom(float64_analog_waveform_to_protobuf(analog_waveform)) + publish_request.double_analog_waveform.CopyFrom( + float64_analog_waveform_to_protobuf(analog_waveform) + ) publish_response = self._data_store_client.publish_measurement(publish_request) return publish_response.published_measurement diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index 62e7856..b1b6743 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -17,13 +17,13 @@ ) from ni.measurements.data.v1.data_store_service_pb2 import ( PublishMeasurementRequest, - PublishMeasurementResponse + PublishMeasurementResponse, ) +from ni.protobuf.types.vector_pb2 import Vector from ni.protobuf.types.waveform_conversion import float64_analog_waveform_to_protobuf from ni.protobuf.types.waveform_pb2 import DoubleAnalogWaveform -from ni.protobuf.types.vector_pb2 import Vector -from nitypes.waveform import AnalogWaveform from nitypes.bintime import DateTime +from nitypes.waveform import AnalogWaveform from pytest_mock import MockerFixture @@ -68,7 +68,7 @@ def test__publish_boolean_data__calls_datastoreclient( def test__publish_analog_waveform_data__calls_datastoreclient( - mocked_datastore_client: Mock + mocked_datastore_client: Mock, ) -> None: timestamp = DateTime.now(tz=dt.timezone.utc) published_measurement = PublishedMeasurement() @@ -110,15 +110,13 @@ def test__publish_analog_waveform_data__calls_datastoreclient( assert request.test_adapter_ids == [] -def test__read_boolean_data__calls_monikerclient( - mocked_moniker_client: Mock -) -> None: +def test__read_boolean_data__calls_monikerclient(mocked_moniker_client: Mock) -> None: client = Client(moniker_client=mocked_moniker_client) moniker = Moniker() moniker.data_instance = 12 moniker.data_source = "ABCD123" moniker.service_location = "localhost:50051" - client.read_measurement_data(moniker, type[Vector]) + client.read_measurement_data(moniker, Vector) mocked_moniker_client.read_from_moniker.return_value = ReadFromMonikerResult() args, __ = mocked_moniker_client.read_from_moniker.call_args @@ -141,9 +139,7 @@ def mocked_datastore_client(mocker: MockerFixture) -> Any: @pytest.fixture def mocked_moniker_client(mocker: MockerFixture) -> Any: - mock_moniker_client = mocker.patch( - "ni.datamonikers.v1.client.MonikerClient", autospec=True - ) + mock_moniker_client = mocker.patch("ni.datamonikers.v1.client.MonikerClient", autospec=True) # Set up the mock's publish method mock_moniker_instance = mock_moniker_client.return_value return mock_moniker_instance From c8304d5534f34fcdce5d445cdadc543bca5fc3de Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Tue, 16 Sep 2025 16:21:46 -0500 Subject: [PATCH 13/15] Fix test name --- tests/unit/test_ni_datastore_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index b1b6743..f5be834 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -110,7 +110,7 @@ def test__publish_analog_waveform_data__calls_datastoreclient( assert request.test_adapter_ids == [] -def test__read_boolean_data__calls_monikerclient(mocked_moniker_client: Mock) -> None: +def test__read_measurement_data__calls_monikerclient(mocked_moniker_client: Mock) -> None: client = Client(moniker_client=mocked_moniker_client) moniker = Moniker() moniker.data_instance = 12 From 66bc48b36471139d1d0af1a0b6cb5fc6b0da4375 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Wed, 17 Sep 2025 09:41:21 -0500 Subject: [PATCH 14/15] Check type at runtime with isinstance instead of cast --- src/ni/datastore/client.py | 10 ++++++++-- tests/unit/test_ni_datastore_client.py | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 2d4a08e..98f1ceb 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -85,11 +85,17 @@ def publish_measurement_data( publish_response = self._data_store_client.publish_measurement(publish_request) return publish_response.published_measurement - def read_measurement_data(self, moniker: Moniker, expected_type: Type[TRead]) -> TRead: + def read_measurement_data(self, moniker_source: Moniker | PublishedMeasurement, expected_type: Type[TRead]) -> TRead: """Read measurement data from the datastore.""" + if isinstance(moniker_source, Moniker): + moniker = moniker_source + else: + moniker = moniker_source.moniker self._moniker_client._service_location = moniker.service_location result = self._moniker_client.read_from_moniker(moniker) - return cast(TRead, result.value) + if not isinstance(result.value, expected_type): + raise TypeError(f"Expected type {expected_type}, got {type(result.value)}") + return result.value def create_step( self, diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index f5be834..2c369c9 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -4,9 +4,9 @@ import datetime as dt import unittest.mock -from typing import Any, cast +from typing import cast from unittest.mock import Mock - +from google.protobuf.any_pb2 import Any import pytest from ni.datamonikers.v1.data_moniker_pb2 import Moniker, ReadFromMonikerResult from ni.datastore.client import Client @@ -116,8 +116,8 @@ def test__read_measurement_data__calls_monikerclient(mocked_moniker_client: Mock moniker.data_instance = 12 moniker.data_source = "ABCD123" moniker.service_location = "localhost:50051" - client.read_measurement_data(moniker, Vector) mocked_moniker_client.read_from_moniker.return_value = ReadFromMonikerResult() + client.read_measurement_data(moniker, Any) args, __ = mocked_moniker_client.read_from_moniker.call_args requested_moniker = cast(Moniker, args[0]) From b8e01aeeb13acd4b75e107400a202b3f6771c067 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Wed, 17 Sep 2025 09:48:35 -0500 Subject: [PATCH 15/15] Remove unneeded mock setup. --- src/ni/datastore/client.py | 4 +++- tests/unit/test_ni_datastore_client.py | 21 ++++----------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/ni/datastore/client.py b/src/ni/datastore/client.py index 98f1ceb..bebab18 100644 --- a/src/ni/datastore/client.py +++ b/src/ni/datastore/client.py @@ -85,7 +85,9 @@ def publish_measurement_data( publish_response = self._data_store_client.publish_measurement(publish_request) return publish_response.published_measurement - def read_measurement_data(self, moniker_source: Moniker | PublishedMeasurement, expected_type: Type[TRead]) -> TRead: + def read_measurement_data( + self, moniker_source: Moniker | PublishedMeasurement, expected_type: Type[TRead] + ) -> TRead: """Read measurement data from the datastore.""" if isinstance(moniker_source, Moniker): moniker = moniker_source diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index 2c369c9..69f35cd 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -4,22 +4,20 @@ import datetime as dt import unittest.mock -from typing import cast +from typing import Any, cast from unittest.mock import Mock -from google.protobuf.any_pb2 import Any + import pytest +from google.protobuf.any_pb2 import Any as gpAny from ni.datamonikers.v1.data_moniker_pb2 import Moniker, ReadFromMonikerResult from ni.datastore.client import Client from ni.measurements.data.v1.data_store_pb2 import ( ErrorInformation, Outcome, - PublishedMeasurement, ) from ni.measurements.data.v1.data_store_service_pb2 import ( PublishMeasurementRequest, - PublishMeasurementResponse, ) -from ni.protobuf.types.vector_pb2 import Vector from ni.protobuf.types.waveform_conversion import float64_analog_waveform_to_protobuf from ni.protobuf.types.waveform_pb2 import DoubleAnalogWaveform from nitypes.bintime import DateTime @@ -32,13 +30,7 @@ def test__publish_boolean_data__calls_datastoreclient( mocked_datastore_client: Mock, value: bool ) -> None: timestamp = DateTime.now(tz=dt.timezone.utc) - published_measurement = PublishedMeasurement() - publish_measurement_response = PublishMeasurementResponse( - published_measurement=published_measurement - ) - mocked_datastore_client.publish_measurement.return_value = publish_measurement_response client = Client(data_store_client=mocked_datastore_client) - # Now, when client.publish_measurement_data calls foo.MyClass().publish(), it will use the mock client.publish_measurement_data( "step_id", "name", @@ -71,11 +63,6 @@ def test__publish_analog_waveform_data__calls_datastoreclient( mocked_datastore_client: Mock, ) -> None: timestamp = DateTime.now(tz=dt.timezone.utc) - published_measurement = PublishedMeasurement() - publish_measurement_response = PublishMeasurementResponse( - published_measurement=published_measurement - ) - mocked_datastore_client.publish_measurement.return_value = publish_measurement_response waveform_values = [1.0, 2.0, 3.0] analog_waveform = AnalogWaveform.from_array_1d(waveform_values, dtype=float) expected_protobuf_waveform = DoubleAnalogWaveform() @@ -117,7 +104,7 @@ def test__read_measurement_data__calls_monikerclient(mocked_moniker_client: Mock moniker.data_source = "ABCD123" moniker.service_location = "localhost:50051" mocked_moniker_client.read_from_moniker.return_value = ReadFromMonikerResult() - client.read_measurement_data(moniker, Any) + client.read_measurement_data(moniker, gpAny) args, __ = mocked_moniker_client.read_from_moniker.call_args requested_moniker = cast(Moniker, args[0])