From 9caf9de379c56a48ad9571875e41f6e62450e99e Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Wed, 22 Mar 2023 00:17:03 +0100 Subject: [PATCH 1/2] Upload the colmap rrd file to gcloud. --- .github/workflows/python.yml | 51 ++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 8a53ad68335b..6dfc5b9facc5 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -238,9 +238,10 @@ jobs: shell: bash # If you change the line below you should almost definitely change the `key:` line above by giving it a new, unique name run: | + mkdir rrd pip install -r examples/python/colmap/requirements.txt - python3 examples/python/colmap/main.py --dataset colmap_fiat --resize 800x600 --save colmap.rrd - cp colmap.rrd unpack-dist/${{ env.pkg_folder }}/rerun_sdk/rerun_demo/colmap.rrd + python3 examples/python/colmap/main.py --dataset colmap_fiat --resize 800x600 --save rrd/colmap.rrd + cp rrd/colmap.rrd unpack-dist/${{ env.pkg_folder }}/rerun_sdk/rerun_demo/colmap.rrd - name: Repack the wheel shell: bash @@ -254,8 +255,54 @@ jobs: name: wheels path: dist + # All platforms are currently creating the same rrd file, upload one of them + - name: Save RRD artifact + if: matrix.platform == 'linux' + uses: actions/upload-artifact@v3 + with: + name: rrd + path: rrd + # --------------------------------------------------------------------------- + upload_rrd: + name: Upload RRD to GCloud + permissions: + contents: "read" + id-token: "write" + needs: [wheels] + runs-on: "ubuntu-latest" + steps: + - name: Download Artifact + uses: actions/download-artifact@v3 + with: + name: rrd + path: rrd + + - id: "auth" + uses: google-github-actions/auth@v1 + with: + workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} + + - name: Add SHORT_SHA env property with commit short sha + run: echo "SHORT_SHA=`echo ${{github.sha}} | cut -c1-8`" >> $GITHUB_ENV + + - name: "Upload RRD" + uses: google-github-actions/upload-cloud-storage@v1 + with: + path: "rrd" + destination: "rerun-example-rrd/commit/${{env.SHORT_SHA}}" + parent: false + + - name: "Upload RRD (tagged)" + if: startsWith(github.ref, 'refs/tags/v') + uses: google-github-actions/upload-cloud-storage@v1 + with: + path: "rrd" + destination: "rerun-example-rrd/version/${{github.ref_name}}" + parent: false + # See https://github.com/ncipollo/release-action pre-release: name: Pre Release From bfda281d8c2ac8268fc213f5a70abb16701f0393 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Wed, 22 Mar 2023 08:14:31 +0100 Subject: [PATCH 2/2] Serve a different index.html and url for the hosted app.rerun.io (#1665) * Serve a different index.html and url for the hosted app.rerun.io * Add index_bundled.html * Finish comment * consistent naming for colmap_fiat.rrd --- .github/workflows/python.yml | 4 +- crates/re_web_viewer_server/src/lib.rs | 5 +- rerun_py/pyproject.toml | 2 +- rerun_py/rerun_sdk/rerun_demo/__main__.py | 2 +- web_viewer/index.html | 13 +- web_viewer/index_bundled.html | 163 ++++++++++++++++++++++ 6 files changed, 183 insertions(+), 6 deletions(-) create mode 100644 web_viewer/index_bundled.html diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6dfc5b9facc5..6935512efbc8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -240,8 +240,8 @@ jobs: run: | mkdir rrd pip install -r examples/python/colmap/requirements.txt - python3 examples/python/colmap/main.py --dataset colmap_fiat --resize 800x600 --save rrd/colmap.rrd - cp rrd/colmap.rrd unpack-dist/${{ env.pkg_folder }}/rerun_sdk/rerun_demo/colmap.rrd + python3 examples/python/colmap/main.py --dataset colmap_fiat --resize 800x600 --save rrd/colmap_fiat.rrd + cp rrd/colmap_fiat.rrd unpack-dist/${{ env.pkg_folder }}/rerun_sdk/rerun_demo/colmap_fiat.rrd - name: Repack the wheel shell: bash diff --git a/crates/re_web_viewer_server/src/lib.rs b/crates/re_web_viewer_server/src/lib.rs index dc28aaddea1f..40b454ef71c9 100644 --- a/crates/re_web_viewer_server/src/lib.rs +++ b/crates/re_web_viewer_server/src/lib.rs @@ -70,7 +70,10 @@ impl Service> for Svc { let response = Response::builder(); let (mime, bytes) = match req.uri().path() { - "/" | "/index.html" => ("text/html", &include_bytes!("../web_viewer/index.html")[..]), + "/" | "/index.html" => ( + "text/html", + &include_bytes!("../web_viewer/index_bundled.html")[..], + ), "/favicon.ico" => ( "image/vnd.microsoft.icon", &include_bytes!("../web_viewer/favicon.ico")[..], diff --git a/rerun_py/pyproject.toml b/rerun_py/pyproject.toml index 6c95b28399bc..d60ea1b9f109 100644 --- a/rerun_py/pyproject.toml +++ b/rerun_py/pyproject.toml @@ -91,6 +91,6 @@ ban-relative-imports = "all" # with the other `rerun` pypi package. The rerun_sdk.pth adds this to the pythonpath # which then allows `import rerun` to work as expected. # See https://github.com/rerun-io/rerun/pull/1085 for more details -include = ["rerun_sdk.pth", "rerun_sdk/rerun_demo/colmap.rrd"] +include = ["rerun_sdk.pth", "rerun_sdk/rerun_demo/colmap_fiat.rrd"] locked = true python-packages = ["rerun_sdk/rerun", "rerun_sdk/rerun_demo"] diff --git a/rerun_py/rerun_sdk/rerun_demo/__main__.py b/rerun_py/rerun_sdk/rerun_demo/__main__.py index cda3c62cc832..ce5a5b34fdf4 100644 --- a/rerun_py/rerun_sdk/rerun_demo/__main__.py +++ b/rerun_py/rerun_sdk/rerun_demo/__main__.py @@ -28,7 +28,7 @@ def run_colmap(): # We don't need to call shutdown in this case. Rust should be handling everything unregister_shutdown() - rrd_file = pathlib.Path(__file__).parent.joinpath("colmap.rrd").resolve() + rrd_file = pathlib.Path(__file__).parent.joinpath("colmap_fiat.rrd").resolve() if not rrd_file.exists(): print("No demo file found at {}. Package was built without demo support".format(rrd_file), file=sys.stderr) exit(1) diff --git a/web_viewer/index.html b/web_viewer/index.html index dbd3954e1a2c..2d36ec96ba4c 100644 --- a/web_viewer/index.html +++ b/web_viewer/index.html @@ -1,4 +1,5 @@ + @@ -133,8 +134,18 @@ function on_wasm_loaded() { console.debug("wasm loaded. starting app…"); + // The expected data path is the current pathname relocated to inside of "/data" with the + // index.html stripped off if it's present. + // exa: 'https://app.rerun.io/version/v4.0.0/index.html' -> '/data/version/v4.0.0/' + let data_path = "/data" + window.location.pathname.replace(/index\.html$/, ''); + + const url_params = new URLSearchParams(window.location.search); + const rrd_file = url_params.get('file') || 'colmap_fiat.rrd'; + + // By default load an rrd file over http + let url = data_path + rrd_file; // you can use this to point to an .rrd file over http, or a WebSocket Rerun server. + // This call installs a bunch of callbacks and then returns: - let url = null; // you can use this to point to an .rrd file over http, or a WebSocket Rerun server. wasm_bindgen.start("the_canvas_id", url); console.debug("app started."); diff --git a/web_viewer/index_bundled.html b/web_viewer/index_bundled.html new file mode 100644 index 000000000000..bad606b75a3b --- /dev/null +++ b/web_viewer/index_bundled.html @@ -0,0 +1,163 @@ + + + + + + + + + + rerun viewer + + + + + + +
+

+ Loading… +

+
+
+ + + + + + + + + + + +