ML Service: Implement client library (MachineLearningServiceConnection) |
|||||
Issue descriptionOnce the ML Service Daemon can bootstrap over D-Bus to provide a Mojo ModelProvider implementation, we can create the client library MlBridge on Chromium side that will do this for users of ML Service there.
,
Jun 6 2018
,
Jun 6 2018
Per discussions with rockot@, a suitable interface would be:
// Runs on a single sequence:
class MachineLearningServiceConnection {
public:
ModelProvider* GetModelProvider() {
LazilyBindServicePtrViaDbusIfNecessary();
if (!model_provider_)
service_->GetModelProvider(mojo::MakeRequest(&model_provider_));
return model_provider_.get();
}
// Expanded interface in future ...
private:
void LazilyBindServicePtrViaDbusIfNecessary() {
if (service_)
return;
// Do the bootstrap here.
}
MachineLearningServicePtr service_;
ModelProviderPtr model_provider_;
};
,
Jul 16
,
Jul 16
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/5ced600fb66be67bd35dbe83022662c82daa090f commit 5ced600fb66be67bd35dbe83022662c82daa090f Author: Andrew Moylan <amoylan@chromium.org> Date: Mon Jul 16 01:24:09 2018 ML service: Implement D-Bus->Mojo bootstrap & add a thin client library This CL adds logic for Chromium to bootstrap a Mojo connection to the Chrome OS ML service daemon via D-Bus, and a very simple client library for client code in Chromium to use to access the ML service. 1. Bootstrap To connect to the daemon, Chromium prepares a Unix socket pair and sends a Mojo invitation, including a primordial pipe handle, through the socket. The file descriptor for the other end of the socket pair is passed to the daemon as the argument of its BootstrapMojoConnection D-Bus method. The daemon is expected to bind the primordial pipe to an implementation of the MachineLearningService top-level Mojo interface. The ML service daemon side of the above interaction is added in crrev.com/c/1123663. 2. Thin client library This CL adds chromeos::machine_learning::ServiceConnection which client code in Chromium can use to access the ML service. This singleton class automatically performs D-Bus->Mojo bootstrap as necessary, and exposes a method clients can use to bind a ModelProviderPtr mojo interface and thereby access the ML service. This CL also brings the .mojom files specifying the ML service Mojo interface under public/mojom. Previously we intended to access these via third_party/cros_system_api, but Chromium will instead maintain its own copy of these mojoms, which will be manually eventually-consistent with the Chrome OS copies (under src/platform2/ml). We are switching to this recommended approach for the reasons discussed in the following doc: https://docs.google.com/document/d/1rX3xtR6ZioKZaO-4qBFJFqFypSX1p6gAvQ_MuYn64G8 A separate CL will remove the .mojoms under platform/system_api/mojo. Testing: How to automatically test that Chromium + the daemon successfully perform the D-Bus -> Mojo bootstrap is not clear and is under discussion (comments welcome). It may have to wait until there is a client in Chromium calling the daemon, which could then have an end-to-end autotest. I manually tested this against a Chrome OS ML service built with crrev.com/c/1123663 by adding some test calls to BootstrapMojoConnection initiated from chrome_browser_main_chromeos. Bug: 836091 , 836092 , 836107 Change-Id: I3dbcaeb7a0af0bc09a56a98e68d9420cc1626d91 Reviewed-on: https://chromium-review.googlesource.com/1123964 Reviewed-by: Ben Chan <benchan@chromium.org> Reviewed-by: Ken Rockot <rockot@chromium.org> Reviewed-by: Dan Erat <derat@chromium.org> Commit-Queue: Andrew Moylan <amoylan@chromium.org> Cr-Commit-Position: refs/heads/master@{#575193} [modify] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chrome/common/chrome_features.cc [modify] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chrome/common/chrome_features.h [modify] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/BUILD.gn [modify] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/dbus/dbus_clients_common.cc [modify] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/dbus/dbus_clients_common.h [modify] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/dbus/dbus_thread_manager.cc [modify] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/dbus/dbus_thread_manager.h [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/dbus/fake_machine_learning_client.cc [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/dbus/fake_machine_learning_client.h [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/dbus/machine_learning_client.cc [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/dbus/machine_learning_client.h [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/DEPS [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/public/cpp/BUILD.gn [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/public/cpp/service_connection.cc [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/public/cpp/service_connection.h [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/public/mojom/BUILD.gn [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/public/mojom/OWNERS [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/public/mojom/graph_executor.mojom [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/public/mojom/machine_learning_service.mojom [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/public/mojom/model.mojom [add] https://crrev.com/5ced600fb66be67bd35dbe83022662c82daa090f/chromeos/services/machine_learning/public/mojom/tensor.mojom
,
Jul 16
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by ovanieva@chromium.org
, May 25 2018Components: UI>ML>Service