Skip to content

Commit 6ddbcd5

Browse files
authored
Update jupyter web_visualizer for ipywidgets 8 (#6239)
Changed some status messages from Info to Debug Update jupyter_packaging to 0.12
1 parent 5676513 commit 6ddbcd5

File tree

14 files changed

+78
-109
lines changed

14 files changed

+78
-109
lines changed

cpp/open3d/visualization/webrtc_server/PeerConnectionManager.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,19 @@ PeerConnectionManager::PeerConnectionManager(
140140
// Register api in http server.
141141
func_["/api/getMediaList"] = [this](const struct mg_request_info *req_info,
142142
const Json::Value &in) -> Json::Value {
143-
utility::LogInfo("[Called HTTP API] /api/getMediaList");
143+
utility::LogDebug("[Called HTTP API] /api/getMediaList");
144144
return this->GetMediaList();
145145
};
146146

147147
func_["/api/getIceServers"] = [this](const struct mg_request_info *req_info,
148148
const Json::Value &in) -> Json::Value {
149-
utility::LogInfo("[Called HTTP API] /api/getIceServers");
149+
utility::LogDebug("[Called HTTP API] /api/getIceServers");
150150
return this->GetIceServers();
151151
};
152152

153153
func_["/api/call"] = [this](const struct mg_request_info *req_info,
154154
const Json::Value &in) -> Json::Value {
155-
utility::LogInfo("[Called HTTP API] /api/call");
155+
utility::LogDebug("[Called HTTP API] /api/call");
156156
std::string peerid;
157157
std::string url; // window_uid.
158158
std::string options;
@@ -167,7 +167,7 @@ PeerConnectionManager::PeerConnectionManager(
167167
func_["/api/getIceCandidate"] =
168168
[this](const struct mg_request_info *req_info,
169169
const Json::Value &in) -> Json::Value {
170-
utility::LogInfo("[Called HTTP API] /api/getIceCandidate");
170+
utility::LogDebug("[Called HTTP API] /api/getIceCandidate");
171171
std::string peerid;
172172
if (req_info->query_string) {
173173
CivetServer::getParam(req_info->query_string, "peerid", peerid);
@@ -178,7 +178,7 @@ PeerConnectionManager::PeerConnectionManager(
178178
func_["/api/addIceCandidate"] =
179179
[this](const struct mg_request_info *req_info,
180180
const Json::Value &in) -> Json::Value {
181-
utility::LogInfo("[Called HTTP API] /api/addIceCandidate");
181+
utility::LogDebug("[Called HTTP API] /api/addIceCandidate");
182182
std::string peerid;
183183
if (req_info->query_string) {
184184
CivetServer::getParam(req_info->query_string, "peerid", peerid);
@@ -188,7 +188,7 @@ PeerConnectionManager::PeerConnectionManager(
188188

189189
func_["/api/hangup"] = [this](const struct mg_request_info *req_info,
190190
const Json::Value &in) -> Json::Value {
191-
utility::LogInfo("[Called HTTP API] /api/hangup");
191+
utility::LogDebug("[Called HTTP API] /api/hangup");
192192
std::string peerid;
193193
if (req_info->query_string) {
194194
CivetServer::getParam(req_info->query_string, "peerid", peerid);
@@ -713,8 +713,8 @@ void PeerConnectionManager::SendInitFramesToPeer(const std::string &peerid) {
713713

714714
void PeerConnectionManager::CloseWindowConnections(
715715
const std::string &window_uid) {
716-
utility::LogInfo("PeerConnectionManager::CloseWindowConnections: {}",
717-
window_uid);
716+
utility::LogDebug("PeerConnectionManager::CloseWindowConnections: {}",
717+
window_uid);
718718
std::set<std::string> peerids;
719719
{
720720
std::lock_guard<std::mutex> mlock(window_uid_to_peerids_mutex_);

cpp/open3d/visualization/webrtc_server/PeerConnectionManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class PeerConnectionManager {
204204
const std::string state =
205205
webrtc::DataChannelInterface::DataStateString(
206206
data_channel_->state());
207-
utility::LogInfo(
207+
utility::LogDebug(
208208
"DataChannelObserver::OnStateChange label: {}, state: {}, "
209209
"peerid: {}",
210210
label, state, peerid_);

cpp/open3d/visualization/webrtc_server/WebRTCWindowSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ void WebRTCWindowSystem::SendInitFrames(const std::string &window_uid) {
419419
std::string WebRTCWindowSystem::CallHttpAPI(const std::string &entry_point,
420420
const std::string &query_string,
421421
const std::string &data) const {
422-
utility::LogInfo("[Called HTTP API (custom handshake)] {}", entry_point);
422+
utility::LogDebug("[Called HTTP API (custom handshake)] {}", entry_point);
423423

424424
std::string query_string_trimmed = "";
425425
if (!query_string.empty() && query_string[0] == '?') {

cpp/pybind/make_install_pip_package.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# Note: Since `make python-package` clears PYTHON_COMPILED_MODULE_DIR every time,
55
# it is guaranteed that there is only one wheel in ${PYTHON_PACKAGE_DST_DIR}/pip_package/*.whl
66
file(GLOB WHEEL_FILE "${PYTHON_PACKAGE_DST_DIR}/pip_package/*.whl")
7-
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip uninstall open3d --yes)
7+
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip uninstall open3d open3d-cpu --yes)
88
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip install ${WHEEL_FILE} -U)

python/js/amd-public-path.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// In an AMD module, we set the public path using the magic requirejs "module" dependency
2+
// See https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#module
3+
// Since "module" is a requirejs magic module, we must include "module" in the webpack externals configuration.
4+
var module = require("module");
5+
var url = new URL(module.uri, document.location);
6+
// Using lastIndexOf("/")+1 gives us the empty string if there is no "/", so pathname becomes "/"
7+
url.pathname = url.pathname.slice(0, url.pathname.lastIndexOf("/") + 1);
8+
__webpack_public_path__ = `${url.origin}${url.pathname}`;

python/js/lib/embed.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

python/js/lib/extension.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
// This file contains the javascript that is run when the notebook is loaded.
22
// It contains some requirejs configuration and the `load_ipython_extension`
33
// which is required for any notebook extension.
4-
//
5-
// Some static assets may be required by the custom widget javascript. The base
6-
// url for the notebook is not known at build time and is therefore computed
7-
// dynamically.
8-
__webpack_public_path__ = document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/open3d';
9-
104

115
// Configure requirejs
126
if (window.require) {
@@ -21,5 +15,5 @@ if (window.require) {
2115

2216
// Export the required load_ipython_extension
2317
module.exports = {
24-
load_ipython_extension: function() {}
18+
load_ipython_extensionn() {}
2519
};

python/js/lib/labplugin.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ var base = require('@jupyter-widgets/base');
44
module.exports = {
55
id: 'open3d:plugin',
66
requires: [base.IJupyterWidgetRegistry],
7-
activate: function(app, widgets) {
8-
widgets.registerWidget({
9-
name: 'open3d',
10-
version: plugin.version,
11-
exports: plugin
12-
});
7+
activate: (app, widgets) => {
8+
widgets.registerWidget({
9+
name: 'open3d',
10+
version: plugin.version,
11+
exports: plugin
12+
});
1313
},
1414
autoStart: true
1515
};
16-

python/js/lib/web_visualizer.js

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
11
// ----------------------------------------------------------------------------
2-
// - Open3D: www.open3d.org -
2+
// - Open3D: www.open3d.org -
33
// ----------------------------------------------------------------------------
4-
// The MIT License (MIT)
5-
//
6-
// Copyright (c) 2018-2023 www.open3d.org
7-
//
8-
// Permission is hereby granted, free of charge, to any person obtaining a copy
9-
// of this software and associated documentation files (the "Software"), to deal
10-
// in the Software without restriction, including without limitation the rights
11-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12-
// copies of the Software, and to permit persons to whom the Software is
13-
// furnished to do so, subject to the following conditions:
14-
//
15-
// The above copyright notice and this permission notice shall be included in
16-
// all copies or substantial portions of the Software.
17-
//
18-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23-
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24-
// IN THE SOFTWARE.
4+
// Copyright(c) 2018-2023 www.open3d.org
5+
// SPDX - License - Identifier: MIT
256
// ----------------------------------------------------------------------------
267

278
// Jupyter widget for Open3D WebRTC visualizer. See web_visualizer.py for the
@@ -44,49 +25,51 @@ let WebRtcStreamer = require("./webrtcstreamer");
4425
//
4526
// When serializing the entire widget state for embedding, only values that
4627
// differ from the defaults will be specified.
47-
let WebVisualizerModel = widgets.DOMWidgetModel.extend({
48-
defaults: _.extend(widgets.DOMWidgetModel.prototype.defaults(), {
49-
_model_name: "WebVisualizerModel",
50-
_view_name: "WebVisualizerView",
51-
_model_module: "open3d",
52-
_view_module: "open3d",
53-
// @...@ is configured by cpp/pybind/make_python_package.cmake.
54-
_model_module_version: "@PROJECT_VERSION_THREE_NUMBER@",
55-
_view_module_version: "@PROJECT_VERSION_THREE_NUMBER@",
56-
}),
57-
});
28+
class WebVisualizerModel extends widgets.DOMWidgetModel {
29+
defaults() {
30+
return _.extend(widgets.DOMWidgetModel.prototype.defaults(), {
31+
_model_name: "WebVisualizerModel",
32+
_view_name: "WebVisualizerView",
33+
_model_module: "open3d",
34+
_view_module: "open3d",
35+
// @...@ is configured by cpp/pybind/make_python_package.cmake.
36+
_model_module_version: "@PROJECT_VERSION_THREE_NUMBER@",
37+
_view_module_version: "@PROJECT_VERSION_THREE_NUMBER@",
38+
});
39+
}
40+
}
5841

5942
// Custom View. Renders the widget model.
60-
let WebVisualizerView = widgets.DOMWidgetView.extend({
61-
sleep: function (time_ms) {
43+
class WebVisualizerView extends widgets.DOMWidgetView {
44+
sleep(time_ms) {
6245
return new Promise((resolve) => setTimeout(resolve, time_ms));
63-
},
46+
}
6447

65-
logAndReturn: function (value) {
48+
logAndReturn(value) {
6649
console.log("logAndReturn: ", value);
6750
return value;
68-
},
51+
}
6952

70-
callResultReady: function (callId) {
53+
callResultReady(callId) {
7154
let pyjs_channel = this.model.get("pyjs_channel");
7255
console.log("Current pyjs_channel:", pyjs_channel);
7356
let callResultMap = JSON.parse(this.model.get("pyjs_channel"));
7457
return callId in callResultMap;
75-
},
58+
}
7659

77-
extractCallResult: function (callId) {
60+
extractCallResult(callId) {
7861
if (!this.callResultReady(callId)) {
7962
throw "extractCallResult not ready yet.";
8063
}
8164
let callResultMap = JSON.parse(this.model.get("pyjs_channel"));
8265
return callResultMap[callId];
83-
},
66+
}
8467

8568
/**
8669
* Hard-coded to call "call_http_api". Args and return value are all
8770
* strings.
8871
*/
89-
callPython: async function (func, args = []) {
72+
async callPython(func, args = []) {
9073
let callId = this.callId.toString();
9174
this.callId++;
9275
let message = {
@@ -116,9 +99,9 @@ let WebVisualizerView = widgets.DOMWidgetView.extend({
11699
json_result
117100
);
118101
return json_result;
119-
},
102+
}
120103

121-
commsCall: function (url, data = {}) {
104+
commsCall(url, data = {}) {
122105
// https://stackoverflow.com/a/736970/1255535
123106
// parseUrl(url).hostname
124107
// parseUrl(url).entryPoint
@@ -180,9 +163,9 @@ let WebVisualizerView = widgets.DOMWidgetView.extend({
180163
} else {
181164
throw "Unsupported entryPoint: " + entryPoint;
182165
}
183-
},
166+
}
184167

185-
render: function () {
168+
render() {
186169
let windowUID = this.model.get("window_uid");
187170
let onClose = function () {
188171
console.log("onClose() called for window_uid:", windowUID);
@@ -214,8 +197,8 @@ let WebVisualizerView = widgets.DOMWidgetView.extend({
214197
this.commsCall.bind(this)
215198
);
216199
this.webRtcClient.connect(windowUID);
217-
},
218-
});
200+
}
201+
}
219202

220203
module.exports = {
221204
WebVisualizerModel: WebVisualizerModel,

python/js/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "open3d",
33
"version": "@PROJECT_VERSION_THREE_NUMBER@",
4-
"description": "Open3D: A Modern Library for 3D Data Processing",
5-
"author": "Open3D.org",
4+
"description": "@PROJECT_DESCRIPTION@",
5+
"author": "@PROJECT_EMAIL@",
66
"main": "lib/index.js",
77
"repository": {
88
"type": "git",
@@ -36,7 +36,7 @@
3636
"rimraf": "^2.6.1"
3737
},
3838
"dependencies": {
39-
"@jupyter-widgets/base": "^1.1 || ^2 || ^3 || ^4",
39+
"@jupyter-widgets/base": "^2 || ^3 || ^4 || ^5 || ^6",
4040
"lodash": "^4.17.4",
4141
"webrtc-adapter": "^4.2.2"
4242
},

0 commit comments

Comments
 (0)