Enable python nodes and ovms, geti calculators in new python lib#134
Enable python nodes and ovms, geti calculators in new python lib#134rasapala wants to merge 4 commits into
Conversation
…library solution for mediapipe.
| #define KSERVE_H | ||
|
|
||
| #include "mediapipe/calculators/geti/inference/grpc_predict_v2.pb.h" | ||
| #include "src/kfserving_api/grpc_predict_v2.pb.h" |
There was a problem hiding this comment.
Does GETI work with current changes with regards to python binding?
| #include "mediapipe/framework/calculator_framework.h" | ||
| #include "mediapipe/framework/port/canonical_errors.h" | ||
| #pragma GCC diagnostic pop | ||
| #if !defined(OVMS_RUNTIME_DISABLE_TF_TENSORS) |
There was a problem hiding this comment.
rename to OVMS_RUNTIME_DISABLE_TFLITE_TENSORS?
| OVMS_Server* getInheritedServerHandleFromRuntime() { | ||
| using GetterFn = void* (*)(); | ||
| #ifdef _WIN32 | ||
| HMODULE runtimeHandle = GetModuleHandleA("ovms_mediapipe_runtime_shared.dll"); |
There was a problem hiding this comment.
Just filename? No need for path?
There was a problem hiding this comment.
Yes. GetModuleHandleA looks up a already-loaded module by name in the current process's module list — it does not load from disk.
| ) | ||
|
|
||
| cc_library( | ||
| name = "openvinoinferencecalculator_runtime", |
There was a problem hiding this comment.
Maybe we could have some more meaniingful naming convention - what exactly is the meaning of "_runtime"? I see this uses additional define. Theres issue already that header does use this define but the define is in local_defines section. Any target depending on that won't inherit that define.
There was a problem hiding this comment.
Since all the guards are in openvinoinferencecalculator.cc (not the header), local_defines happens to be correct scope-wise here. Renaming to openvinoinferencecalculator_no_tflite.
| // Creates (once per process) and returns a shared OVMS server handle for adapters | ||
| // that are constructed without an explicit server pointer. | ||
| // This path is used by calculators running in-process when they rely on the default | ||
| // OVMS singleton instead of receiving a handle from runtime/shared-library plumbing. | ||
| // Keeping one shared handle avoids repeated OVMS_ServerNew calls and keeps all such | ||
| // adapters bound to the same server instance. |
There was a problem hiding this comment.
Earlier on the fact the only one server instance existed was due to not creating new server instance in C-API of OVMS. So if the same instance was being created depended entirely on OVMS desing. Now you add this logic also here. Why we could not call serverNewFn multiple times as earlier on?
Calling OVMS_ServerNew should still work the same way anyway. So this brings new unnecessary logic and checks here I think.
There was a problem hiding this comment.
You still can use OVMS_ServerNew — and on Linux with RTLD_GLOBAL it works because symbol resolution finds the main process singleton. The setExternalServerHandle mechanism was added specifically for:
Windows — where GetModuleHandleA("ovms_mediapipe_runtime_shared.dll") + GetProcAddress is the only reliable way to pass a pointer across DLL boundaries.
Deterministic cross-boundary handoff — rather than relying on dlsym(RTLD_DEFAULT, ...) lookup ordering, which can resolve to the wrong copy if both the main binary and the runtime shared library export OVMS_ServerNew.
Issue was found in capi stress test on windows.
| } | ||
| ASSERT_CAPI_STATUS_NULL(OVMS_ServerLive(cserver, &isServerLive)); | ||
| // if config is in calc then we start the server | ||
| { |
There was a problem hiding this comment.
Why need for additional {}?
| std::unordered_map<std::string, std::string> outputNameToTag; | ||
| std::vector<std::string> input_order_list; | ||
| std::vector<std::string> output_order_list; | ||
| #if !defined(OVMS_RUNTIME_DISABLE_TF_TENSORS) |
There was a problem hiding this comment.
In what configuration we need this define? We do not add it here in .bazelrc
There was a problem hiding this comment.
When building openvinoinferencecalculator_runtime — the variant used by ovms_calculator_runtime. That target drops the TF/TFLite deps (@org_tensorflow//tensorflow/core:framework and @org_tensorflow//tensorflow/lite/c:c_api) compared to the regular openvinoinferencecalculator.
The use case is when the calculator is compiled as a shared library loaded into another process (OVMS runtime-shared mode) where TensorFlow is not available or not linked. Without the define, the code would try to include and use TF/TFLite headers and types that don't exist in that build environment.
So in short: no TF dependency in the build → define needed to strip the TF/TFLite code paths.
rasapala
left a comment
There was a problem hiding this comment.
Made some fixes.
This PR aligns the MediaPipe fork with OVMS’s new Python runtime-shared architecture so CLIP Python-node graphs can load and run reliably.
Why this was needed:
OVMS moved Python calculators to dynamic/runtime-shared loading, but MediaPipe Geti/OVMS calculator deps still assumed the old in-tree/static wiring.
That caused build mismatches and runtime registration/load issues (including stale targets and duplicated proto ownership).
What was changed:
Switched Geti inference to use OVMS KServe proto (@ovms//src/kfserving_api:kfserving_api_cpp) instead of local grpc_predict_v2_* targets.
Added runtime-focused OVMS calculator targets (ovms_calculator_runtime, openvinoinferencecalculator_runtime) to support one-point calculator registration in the runtime-shared flow.
Updated OpenVINOInferenceCalculator to support runtime mode with TensorFlow/TFLite paths compile-disabled via OVMS_RUNTIME_DISABLE_TF_TENSORS and explicit guards for unsupported TF/TFLite packet tags in that mode.
Follow-up build fix removed stale grpc_predict_v2_* references from //mediapipe:geti_targets after proto ownership moved to OVMS.
Outcome:
Restores successful MediaPipe fork build in the new integration model.
Unblocks CLIP Python nodes in OVMS runtime-shared setup.
Keeps calculator registration and dependency ownership consistent between MediaPipe and OVMS.