Repository navigation
Conversation
…on Windows On Windows, the NI Discovery Service now runs one instance per user on OS-assigned ports and publishes its key file under %LOCALAPPDATA%\National Instruments\MeasurementLink\Discovery\v1. The machine-wide %ProgramData% key file and fixed ports 42000/42001 are only a best-effort compatibility endpoint claimed by whichever user's instance starts first. This SDK read only the %ProgramData% key file, so a measurement service launched by one user's Discovery Service could register with another user's instance, and found nothing when compatibility mode was off. Resolve the Discovery Service in this order: 1. DISCOVERY_SERVICE_ADDRESS, which the Discovery Service sets for the services it launches (host:port). 2. The key file for the cluster selected by NIDiscovery_ClusterId or ClusterId, as the Discovery Service and the 3.x client do. 3. The per-user key file under %LOCALAPPDATA%. 4. The %ProgramData% key file. A file without ProcessId was written by an older Discovery Service and is used as before. A file with ProcessId belongs to a compatibility-mode instance that may be another user's, so the SDK starts this user's own instance first and falls back to it only if that instance does not start. Key files may start with a UTF-8 byte order mark and carry ProcessId and StartTime fields; unknown fields are ignored. Other platforms are unchanged when DISCOVERY_SERVICE_ADDRESS is not set. SDK 3.x gets the same change through ni.measurementlink.discovery.v1.client (ni-apis-python). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…on-Windows platforms The legacy key file directory is Windows-only and raises NotImplementedError elsewhere, which broke Discovery resolution on Linux. Treat it as absent there. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
So my understanding here is that new development of the measurement-plugin-python repo is happening on the But this project has a v2.3 stable branch with its own discovery code (this PR), which I guess was outsourced in later releases. I see several v2.X release-candidate tags that looks like we're considering new v2 releases. But none of them seem to have made it to maturity. So do we need to keep this backport to 2.3, because its the latest v2 release branch? Or can we drop it and say that all measurement-plugin clients should use the v3 release (which gets its discovery ode from ni-apis-python)? |
What does this Pull Request accomplish?
Backports per-user Discovery Service resolution to the
releases/2.3line, the last SDK line with its own copy of the Discovery client; SDK 3.x gets it from ni-apis-python. On Windows, Discovery now runs one instance per user, publishes its key file under%LOCALAPPDATA%\National Instruments\MeasurementLink\Discovery\v1, and passesDISCOVERY_SERVICE_ADDRESSto the services it launches. The client looks in this order:DISCOVERY_SERVICE_ADDRESS(host:port).NIDiscovery_ClusterIdorClusterId.%LOCALAPPDATA%.%ProgramData%key file. A file withoutProcessIdcomes from an older single-instance Discovery and is used as before. A file withProcessIdmay belong to another user's compatibility instance, so the client starts this user's own instance first and uses it only as a fallback.Key files may start with a UTF-8 BOM and carry
ProcessIdandStartTime; unknown fields are ignored.Why should this Pull Request be merged?
Without it, a measurement plug-in built with SDK 2.3 and launched by one user's Discovery can register with another user's Discovery instance, or find none when compatibility mode is off. This is part of Nigel local service authentication (ADO user story AB#4168818, task AB#4173545). The same change for SDK 3.x is in ni/ni-apis-python (
users/astewart/per-user-discovery), and the Discovery side is in review in ASW !1508010.Compatibility policy for SDK clients, decided by the feature owner on 2026-11-19: the client keeps working indefinitely against a legacy single-instance Discovery, which step 4 provides.
Draft: awaiting the feature owner's review before it is marked ready.
What testing has been done?
poetry run pytest tests/unit/test_discovery_service_resolution.py tests/unit/test_discovery_client.pyinpackages/service: 41 passed. The new resolution tests cover the order, the BOM,ProcessIdsemantics and the legacy fallback.ni-python-styleguide lintandmypyon the changed files: clean.